The Guessing Game

The most important part of writing any program is to understand what the program needs to do. If you don't understand how the program is going to work, you cannot succeed at telling the computer how the program needs to work. Understanding it means telling somebody -- perhaps yourself, but it's better to tell somebody else -- what the program is going to do.

In English (or Spanish or Chinese, whatever language you think in).

Then after you know what the computer must do, you have a shot at describing -- still in English or whatever -- how it will do that. Write it down. On paper with a pencil is good, but if you think better that way, you can use your computer's note pad. Paper is better, because you can draw pictures and connecting lines if that helps. Whatever helps you to understand what the computer needs to do.

I can't emphasize this too much, programming a computer is all about telling it what it needs to do, and once you have it in English, all the rest is just translating. Those of us who know two languages know how hard that can be, but that is what programming is all about, saying in English what the computer must do, then saying the same thing in the computer language. Then you are done. Really. When you accurately told the computer what you want it to do, then it will do that.

So, let's get started.

This is a game where somebody thinks of a number, then another person (or the computer) tries to guess what number they thought of, by asking only yes/no questions.

Start with how you would play the game, if you had to do the guessing. You just met somebody, and you know that you want to play the Guessing Game, but they have no idea. They just met you. What do you say first?

Write it down, then turn the page.

<<Previous | ToC | Next >>

[2021 May 12]