Wednesday, April 4, 2007

Binary thinking






Do you remember the guessing game you may have played as a kid, where one person thinks of a number between 1 and 100, and the other person has to guess the number in as few guesses as possible? It's a great game to play with kids because after a while they begin to figure out, all by themselves, how to do what compter programmers call a binary search. It's an elegant piece of thinking that a kid can invent as soon as she understands how numbers are built.


If the kid guesses 67, and the number is 14, you say, "Too high." She may say 66 next guess, then 65, but after a while she'll figure out that counting down one at a time is boring and she'll get more adventurous.


If you play it in a way that keeps them interested, for example by having two kids compete to see who can accomplish the task in the smallest number of guesses, the loser being fed to the sharks or something, after a while they'll figure out that there is a "trick" beckoning them and they'll begin to hone in on it. The trick is to do a binary search, that is keep dividing things in half. Guess 50 first. Higher? Guess 75. Too High? Guess 62. And so on. If you do this you will always be able to get the right answer within 7 guesses.


Increase the upper limit of the game to 1000, which would be stunningly boring without a binary search. With 1000 you can nail the number within 9 guesses, every time. 10,000 can be cracked in 14 guesses. A million, not that I recommend it, can be cracked in 21 guesses max.


Segue from 21. Another great game, although not binary in nature, is the 21 game. One persons starts and can say 1, 2 or 3. The second person can add either 1, 2 or 3 to the number the first person said.


So I said 2, and you could say either 3,4 or 5. Suppose you said 5.


I can say 6, 7 or 8. I say 8. You say 11. I say 13. You say 14. I say 17, You say 19. I say 21.


Because I said 21, I win. You get fed to the sharks. Play the game a few times and a light will go on in the child's head - you can see it happen. She'll figure out that whoever says 17 will win. Keep playing, another light will go on. 13 is the magic number, because she who says 13 can say 17... And so on.


It's better to do this with a group of kids, otherwise you're just whupping some kid's ass over and over again and after a while she'll begin to resist. But if there's a bunch of them playing they have fun and whoever finally beats you feels like a champ.


I start every game with the question, "Would you like to start, or would you like me to start?"


When a kid says, "I want to start," and then chooses the number 1 in a strong voice, I know I'm shark bait.

No comments: