Guess the number

The computer picks a number from 1 to 100: try to guess it in as few tries as possible. Or flip the roles and watch how fast it guesses yours.

I'm thinking of a number from 1 to 100… take your best shot!

0Guesses
Today's best
🔒 Everything runs in your browser: no data is sent or stored anywhere.

What's the best strategy for guessing?

The trick is called binary search: always start with 50, the number right in the middle. With every "higher" or "lower" hint you cut the remaining range in half: 50, then 25 or 75, and so on. Using this strategy, any number from 1 to 100 can be found in at most 7 guesses, because 2 to the power of 7 is 128 — more than the 100 possibilities. If you can do it in 7 or fewer, you're already playing like an algorithm.

Why does the computer guess so quickly?

In reverse mode the computer uses exactly that binary search: it always proposes the number in the middle of the range it has left. It's the same principle you use when flipping a dictionary open near the middle, and the same one databases rely on to find one record among millions of rows in just a handful of steps. Try it with kids: it's a fun way to show them how an algorithm "thinks".