Write an application that plays the game of Fermi. Generate three distinct random digits between 0 and 9. These digits are assigned to positions 1, 2, and 3. The goal of the game is for the player to guess the digits in three positions correctly in the least number of tries. For each guess, the player provides three digits for positions 1, 2, and 3. The program replies with a hint consisting of Fermi, Pico, or Nano. If the digit guessed for a given position is correct, then the reply is Fermi. If the digit guessed for a given position is in a different position, the reply is Pico. If the digit guessed for a given position does not match any of the three digits, then the reply is Nano. Here are sample replies for the three secret digits 6, 5, and 8 at positions 1, 2, and 3, respectively: Guess Hint Explanation
2. Write an application that plays the game of Fermi. Generate three distinct
random digits between 0 and 9. These digits are assigned to positions 1, 2,
and 3. The goal of the game is for the player to guess the digits in three
positions correctly in the least number of tries. For each guess, the player
provides three digits for positions 1, 2, and 3. The program replies with a
hint consisting of Fermi, Pico, or Nano. If the digit guessed for a given
position is correct, then the reply is Fermi. If the digit guessed for a given
position is in a different position, the reply is Pico. If the digit guessed for a
given position does not match any of the three digits, then the reply is Nano.
Here are sample replies for the three secret digits 6, 5, and 8 at positions 1,
2, and 3, respectively:
Guess Hint Explanation
1 2 5 Nano Nano Pico The value 5 matches but
at the wrong position.
8 5 3 Pico Fermi Nano The value 5 matches at
the correct position. The
value 8 matches but at
the wrong position.
5 8 6 Pico Pico Pico All match at the wrong
positions.
Notice that if the hints like the above are given, the player can tell which
number did not match. For example, given the hint for the second guess, we
Exercises 435can tell that 3 is not one of the secret numbers. To avoid this, provide hints in
a random order or in alphabetical order (e.g., it will be Fermi Nano Pico
instead of Pico Fermi Nano for the second reply).
Play games repeatedly until the player wants to quit. After each game,
display the number of guesses made.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps