Guessing a Number by Halving
A friend secretly picks an integer uniformly at random from to . You repeatedly guess integers, and after each guess the friend tells you only whether the true number is higher or lower than your guess (or that you are correct). Find the smallest such that you have a strategy guaranteeing you identify the number within guesses, no matter which number was chosen.
Work it out, then compare with the answer.
SolutionShow the worked solution
Key idea. Each answer leaves either the guessed number (and you have found it) or one of two smaller sets, so guesses can handle at most candidates.
Let be the largest number of candidates for which some strategy is guaranteed to guess the number within guesses. Here “identify” means making the correct guess.
Upper bound. Suppose the current candidate set can be resolved in guesses, and the first guess is . The reply “correct” covers at most one candidate. The candidates below must then be resolved in further guesses, and so must those above . So each of these two sets has at most elements. Hence
Induction gives .
Achievability. We show by induction that any block of consecutive integers can be resolved in guesses. For the block is empty and there is nothing to do. For , guess the middle element of the block. If the reply is “correct” you are done. Otherwise the remaining candidates form a block of consecutive integers, which the induction hypothesis resolves in more guesses. So .
Applying this to numbers.
- Since , no strategy can guarantee success within guesses.
- Since , ten guesses suffice. Run the halving strategy on ; the extra numbers to are simply never the answer. Equivalently, always guess the midpoint of the remaining interval.
The uniform randomness of the choice plays no role, because the guarantee must hold for every number. The tempting count of numbers in guesses is slightly off; the correct count is . Here this does not change the answer.