#K81207. Guess the Number Game

    ID: 35702 Type: Default 1000ms 256MiB

Guess the Number Game

Guess the Number Game

In this problem, the program plays a guessing game with the user. The user thinks of a number between 1 and 100 (inclusive), and the program attempts to guess it using a binary search strategy. At each step, the program outputs its guess and waits for the user's feedback. The user should respond with one of the following: (\text{too low}), (\text{too high}), or (\text{correct}). If the response is invalid, the program prints an error message and repeats the guess. The game continues until the correct number is guessed.

inputFormat

The input is provided via standard input (stdin). It consists of a series of responses, one per line. Each response corresponds to the program's guess and can be one of the following: "too low", "too high", or "correct".

outputFormat

The program writes output to standard output (stdout). It first outputs an initial prompt. Then for each guess, it prints a line in the form 'Is your number X?'. When a correct guess is made, it prints 'Great! The number was X.'. If the user enters an invalid response, it prints 'Invalid response. Please enter 'too low', 'too high', or 'correct'.'## sample

correct
Think of a number between 1 and 100 (inclusive).

Is your number 50? Great! The number was 50.

</p>