How do I implement an higher lower game algorithm?

Posted by lazorde on Stack Overflow See other posts from Stack Overflow or by lazorde
Published on 2012-04-01T23:07:31Z Indexed on 2012/04/01 23:29 UTC
Read the original article Hit count: 142

Filed under:
|

The computer will guess a player’s number between 1 and 100. After each guess the human player should respond “higher”, “lower” or “correct”. Your program should be able to guess the player’s number in no more than 7 tries.

  • Begin by explaining the game to the player, telling him/her to think of a number between 1 and 100.
  • Make the computer do what you would normally do to guess a number in a certain range.
  • Allow the user to respond with “higher”, “lower”, or “correct” after each computer guess.
  • Output the number of tries it took the computer to guess the number. Make the game as user friendly as you can.

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about homework