Knight or Knave (Inspired by Pi Han Goh)

Logic Level 3

I am thinking of an integer between 1 and 10000 inclusive, and you know I either always tell the truth or always lie. You are allowed to ask questions in the form "Is the number in the set X X ?" for any set X X of integers. How many questions are needed to determine the number?

16 14 13 None of these 15

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Alex Li
Jul 7, 2015

Your first question can be "Is the number 0 0 ?" This answer will tell you whether I lie or tell the truth. Then, based on that, you can determine the number in 14 14 more questions by asking "Is the number greater than x x ?", because 2 13 < 10000 < 2 14 2^{13}<10000<2^{14} , so it takes 15 15 questions in total. (I am pretty confident but not 100% certain that there is no way to find the number in 14 14 questions. If you find a way, by all means let me know!)

A strategy to guarantee finding the number in 14 questions does not exist:

Each possible situation I could choose (a number and whether I lie or tell truth) can be represented by a pair ( n , t ) (n, t) where 1 n 10000 1 \leq n \leq 10000 and t { T R U E , F A L S E } t \in \{TRUE, FALSE\}

Note that if you find n n after asking some number of questions, you will also figure out t t , based on any one of my answers and the value of n n .

Each question you ask splits the space of possible situations into two disjoint parts (one of them is still allowed if the answer is YES, the other of them if the answer is NO). Hence one of the answers (YES or NO) will still keep at least half of the possible situations consistent with all the previous questions.

As there are 20,000 legal situations to start with, after 14 questions there will be 2 14 = 16384 2^{14} = 16384 possible ordered lists of answers. Some of them will correspond to more than one situation (and see above why they can't correspond to a single value of n n , just different t t s). Hence a strategy guaranteeing the answer in 14 questions cannot exist.

Paul Walter - 5 years, 11 months ago

For a second there I was really confused. "I didn't write this solution, did something in the site glitch?"

Alex Li - 5 years, 11 months ago

For some reason I think it is none of the above. First would be is it in the set of 1-10000 then just halves. Right?

Cameron CHang - 5 years, 7 months ago

Log in to reply

Wait nvm, halved it wrong

Cameron CHang - 5 years, 7 months ago
Patrick Heebels
Jul 7, 2015

Based on the possible answers and the fact the question is posted als a logic problem I figured the desired number is a binary number, so the stated binary upper bound 10000 equals 2 4 = 16 2^4=16 as a decimal number.

Each subsequent question ask: "Is the number x x ?" with x { 1 , 2 , 3 , . . . , 15 } x \in \{1,2,3,...,15\} .

If you are unlucky at guessing and all of 15 questions are answered either all with "yes" or all with "no" then no other question is necessary because the correct number is the final and 16th one.

If you are lucky and quess the correct number with your 1st attempt, you cannot know this yet, and you need two more attempts. A "Yes-No-No" reveals you are a truthteller and a "No-Yes-Yes" reveals you are a liar. In both cases the first stated number is the correct one.

Therefore at least 3 and at most 15 questions are required.

How you know that the real number is 16 , it may be 18 etc.. , Can you please elaborate more how the binary upper bound is helpful in this case

Syed Baqir - 5 years, 11 months ago

Log in to reply

In response to Syed Baqir.

Alex Li states his problem: "I am thinking of an integer between 1 and 10000 inclusive."

First of all we're trying to figure out an integer number, not a real number as you wrote.

Secondly, I figured that Alex meant binary numbers instead of decimal Numbers when he wrote: "... 1 and 10000...".

Now, the stated lower binary bound 1 equals 2 0 = 1 2^0=1 in it's decimal representation.

And the stated upper binary bound 10000 equals 1 2 4 + 0 2 3 + 0 2 2 + 0 2 1 + 0 2 0 = 16 1 \cdot 2^4 + 0 \cdot 2^3 + 0 \cdot 2^2 + 0 \cdot 2^1 + 0 \cdot 2^0=16

So with 16 possible integer numbers to choose from, we need at most 15 questions under the given restrictions.

Hope this helped more!

Patrick Heebels - 5 years, 11 months ago

Log in to reply

Thank you, it helped a lot :D

Syed Baqir - 5 years, 11 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...