Guess 1A2B
- Traditional exercise of 1A2B game
requires you to write a program, which randomly generates 4 distinct
digits for the user to guess.
- However, it is the era of AI (artificial intelligence) now.
Let's write a program to give the computer some "wisdom".
In this exercise you are required to write a program, which will guess
the 4 digits you chose.
- The algorithm may look like:
- Generate a vector of permutations (0,1,2,3), (0,1,2,4),
(0,1,2,5), ..., (9,8,7,4), (9,8,7,5), (9,8,7,6).
- The computer picks a guess from the above possible choices.
- After each guess, you will tell the computer whether its guess
achieve "1A2B", "4A", or "0A". For convenience, you may also input in
lowercase "1a2b".
- If "4A", the program ends.
- Otherwise, remove impossible choices and go to Step 2.
(9,8,7,6) -- 0a
(5,4,3,2) -- 1A2B
(5,3,4,1) -- 3B
(4,5,3,0) -- 1a1b
(4,1,5,2) -- 3B
(1,2,3,5) -- 3a
(1,2,3,4) -- 4A
Great. I make it with 7 guesses.