Final answer:
Your first ARM assembly program is to guess the player's hidden number in no more than 20 guesses using the Goldilocks approach. Use a binary search to determine the hidden number and divide the range of remaining valid guesses in half for each guess.
Step-by-step explanation:
One In A Million
Your first ARM assembly program is to write the code to guess the players 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.
Algorithm
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 player’s 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.