Question: It is Important that the code has to be written in Mars or Mips assembly program. MIPS assembly program is to write the code to
It is Important that the code has to be written in Mars or Mips assembly program.
MIPS assembly program is to write the code to guess the player's hidden number in no more than 20 guesses using the Goldilocks approach. Following each guess, the player will respond with an indication of whether the guess was too high, too low, or just right.
The player will be asked to think of a number in the range of 0-1,000,000 exclusive. Your code will then use a binary search to determine the hidden number. For each guess, divide the range of remaining valid guesses in half and ask the number at the midpoint of the range. Depending on the players response to the guess, modify the range accordingly or terminate the program. Continue guessing until either the number has been guessed correctly or the valid range is empty. If the number has not been guessed in 20 attempts, inform the player that you suspect foul play.
Example:
Think of a number in the range of 1-1000000. I will attempt to guess your number.
Respond to my guesses with one of the following: H if the guess is too high L if the guess is too low E if the guess is correct
Guess #1: 500000 ? L Guess #2: 750000 ? H Guess #3: 625000 ? L Guess #18: 666666 ? E I got it in 18 guesses!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
