Chapter 12Using Assumptions to Get Unstuck

A few years back, my wife asked for help in designing a magic trick. Now, asking me to design a trick isn’t such an odd request, given that I’ve been interested in magic for forty years and have written books on the subject. This request, though, had a catch.

My wife needed the trick, not for entertainment purposes, but for use in a computer course. It seems she was learning an advanced computer language, and her professor gave the class an assignment that sounded a lot like a mind-reading stunt.

The assignment went like this: Design a program that reveals, in ten guesses or less, a number from 1 to 99, secretly chosen by the computer.

I grabbed a pad and pen, and went to work.

“Tell the computer to ...

Get Accidental Genius, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.