๐ข Number Guessing Game
Guess a number between 1 and 100.
Attempts: 0
A classic Hi-Lo guessing game: the computer picks a secret number between 1 and 100, and you try to find it in as few guesses as possible using higher/lower hints. Good for killing time or practicing logical narrowing-down.
How to use
- Enter a guess between 1 and 100.
- Use the "Higher" or "Lower" hint to narrow down your next guess.
- Repeat until you find the number, and check your attempt count.
How the calculation works
Guess the secret number the computer picked between 1 and 100. After each guess you get a hint, โhigherโ or โlowerโ, so you can close in on it in as few guesses as possible. The most efficient strategy is to always guess the middle of the remaining range (binary search). Each guess halves the candidates, so for 1โ100 you can always win within 7 guesses (2โท = 128 โฅ 100).
Worked example
Binary search when the secret number is 37 50 โ lower (candidates 1โ49) 25 โ higher (candidates 26โ49) 37 โ correct! (3 guesses) Even in the worst case, 7 guesses are enough.
Things to be aware of
- Your guesses are listed as you go, so you can see how far you have narrowed it down.
- Binary search is the same idea used to look words up in a dictionary and to search sorted data in programs.
- Guesses outside the range (such as 0 or 101) still get a hint.
FAQ
What range is the secret number in?
The secret number is always between 1 and 100.
Is there a limit to how many guesses I get?
No โ guess as many times as you like. Your attempt count is tracked so you can try to beat your best score.
Is there a strategy for guessing efficiently?
Guessing near the middle of the remaining range each time, like a binary search, narrows things down in fewer attempts.
Can I see my guess history?
Yes โ your past guesses and whether each was higher or lower are shown as a running history.
Is this good practice for kids learning number sense?
Yes โ narrowing a range using higher/lower hints is a fun way to build number sense and comparison skills.