Halving Search

Guess a number from 1 to 100 with only "higher" and "lower" as clues. Then watch how a computer does it.

Guess number 1

1100

Still possible: 100 1 – 100

The computer has picked a number. Enter a guess.

A simplified teaching model.

How to play

In "You guess", the computer picks a number and you guess it. The only answers are "higher" or "lower". The dark part of the bar shows the numbers still possible. In "Computer guesses", you think of a number, and answer each guess with "higher", "lower" or "correct". Press "Show it automatically" to watch the computer do it alone. Choose a range of 1 to 100 or 1 to 1,000,000.

Learn more

Each time you guess the middle number, the possibilities are cut exactly in half. For 100 numbers: 100, 50, 25, 12 and so on, and 7 guesses always suffice. Six guesses can tell apart at most 63 numbers, which is not enough for 100. Even for a million numbers, 20 guesses always suffice. Making the range 10,000 times bigger only raises the count from 7 to 20. This is binary search, a basic way computers find things in big data (the data must be in order). The numbers on this page were checked by this site's tests for every number from 1 to 100 and from 1 to 1,000,000. A simplified teaching model.