Skip to content

Instantly share code, notes, and snippets.

@richarddmorey
Created February 8, 2021 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richarddmorey/3a0de4732a1d4735646a2a9894457fc3 to your computer and use it in GitHub Desktop.
Save richarddmorey/3a0de4732a1d4735646a2a9894457fc3 to your computer and use it in GitHub Desktop.
ask johnny answer
https://www.theguardian.com/science/2021/feb/08/can-you-solve-it-think-of-a-number
The suggested answer using "yes" and "no" amounts to encoding in base 2, which is inefficient because there are
three possible response options ("yes", "no", "I don't know"). We want to find a way of encoding in base 3, which
amounts to assigning 1/3 of the numbers to "yes", 1/3 to "no", and 1/3 to "I don't know". We can do that by telling
Johnny on the first step (and analogously afterward):
"I have two numbers in mind. One of them is 334. The other is less than 667 but greater than 333, but I will not tell you what it is. Is your
number less than both of my numbers?"
If his number is less than 334, he must answer "yes", because his number must be less than both of my numbers.
If his number is greater than 666, he must answer "no", because he knows that his number must be
greater than both of my numbers.
If his number is between 334 and 666 (inclusive), then he does not know whether his number is less than both, so
he must answer "I don't know".
Continuing in this way you can narrow down the possibilities to 1/3 of what they were at each step instead of 1/2,
reducing the number of questions you need.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment