Guess a number up to a million in twenty questions
I am thinking of a whole number between 1 and 1,000,000 inclusive. You may ask yes-or-no questions, and I always answer truthfully.
How many questions do you need to be certain of identifying the number? Prove that fewer questions cannot work, and describe the questions.
Show a hint
Each answer is one of two possibilities. How many different answer sequences can k questions produce?
Your answer
Solving needs a free account
Answers, streaks and solutions unlock when you are signed in. Reading the question and the hint stays free.
Discussion
Sign in to join the discussion · reading is open to everyone
💡 Discussion rules
- No full solutions here. Hints and approaches only.
- Complexity, edge cases and intuition are the point.
- Interview experiences are welcome. Respect your NDAs.
Loading discussion…
Learn the concepts
The theory behind this question.
Related questions
Which of eight switches runs the pump?Guess my number from 1 to 1000 in ten questionsPoison, rats, and two days to find the bottleTwenty-five horses, five lanes, the top twoFind the heavy ball among 27 in three weighings
All questions →