The challenge is to implement the game "Bagels" as described in David Ahl's collection of "Basic Games". A link to the original article, with BASIC source code is provided, in case that might be helpful.
The game is simplicity itself:
The computer picks a three-digit number. The player's task is to guess the number by submitting three-digit guesses. The computer provides feedback thusly:
- If the guess is entirely correct, the player wins.
- If the guess includes at least one digit that is in the correct place, the computer reports "Fermi".
- If the guess includes at least one digit contained in the target number, but it's in the wrong place, the computer reports "Pico".
- If the guess is entirely wrong, the computer reports "Bagels".
Only one response will be provided for a given guess, so if the target is 123 and the guess is 132, the response will be "Fermi" and not "Fermi, Pico".
You get twenty guesses.
Your first task is to implement the game for a human solver. The computer will pick a number, and the human player will determine what it was.
For extra sport, write a computer that can zero in on a number you provide. How many guesses does your computer player require to find the correct number?
Be careful of how you handle leading zeros in the input. If you convert the input to integer form, be careful not to lose any information, or at least to ensure you recover the information you lose.
This post has been edited by Simown: 05 January 2013 - 05:25 PM