Back
Close

Guess The Number

Statement

 Goal

Tom and Jerry are playing the game Guess The Number, and asks you to be the facilitator.

The game is very simple.
There is a hidden number N, which is between 1 and 100, inclusive of 1 and 100.
Each player takes turn to guess a number within the valid range, and is given one of three responses: Higher, Lower or Correct!.
The valid range is then updated according to the response, and play continues till one player guesses the number correctly.

Tom starts first, then Jerry, and so on.

There is one catch: Tom, being the cheeky cat, wants to win. Hence, he asks you to adjust the number if Jerry guesses correctly, but still within the valid range. You agree reluctantly, and say that you will adjust the number one higher from the actual number if Jerry guesses correctly. If one higher is not possible, then you will do one lower. If you can neither do one higher nor one lower, then Jerry will win.

Tom agrees, and play begins, with you as the facilitator.

Given each line of Tom and Jerry's guesses (alternating with Tom first), output in each line the right responses for each guess, taking in mind the shifting target you agreed with Tom.

Example game:
Target Number: 35
Turn 1-Tom: 55 (Response: Lower. Valid range now 1 to 54)
Turn 2-Jerry: 20 (Response: Higher. Valid range now 21 to 54)
Turn 3-Tom: 36 (Response: Lower. Valid range now 21 to 35)
Turn 4-Jerry: 35 (This is correct, you try to shift up to 36 first but not possible, so you shift down to 34. Response: Lower. Valid range now 21 to 34)
Turn 5-Tom: 34 (Response: Correct!)
Input
Line 1: Target number N
Line 2: Number of turns T
Next T Lines: Guesses
Output
T Lines: Response corresponding to guesses, either Higher, Lower or Correct!.
Constraints
1 <= N, T <= 100
Example
Input
50
5
30
70
45
60
50
Output
Higher
Lower
Higher
Lower
Correct!

Game modes
Fastest

Test cases
Normal Game Test
Input
50 5 30 70 45 60 50
Output
Higher Lower Higher Lower Correct!

Validator 1 Validator
Input
50 5 60 20 57 53 50
Output
Lower Higher Lower Lower Correct!

Shifting Target Up Test
Input
99 7 60 70 80 90 91 99 100
Output
Higher Higher Higher Higher Higher Higher Correct!

Validator 2 Validator
Input
99 11 60 65 70 75 80 85 90 95 96 99 100
Output
Higher Higher Higher Higher Higher Higher Higher Higher Higher Higher Correct!

Shifting Target Down Test
Input
30 9 60 20 31 30 24 29 25 28 27
Output
Lower Higher Lower Lower Higher Lower Higher Lower Correct!

Validator 3 Validator
Input
40 9 60 20 41 40 24 39 25 38 37
Output
Lower Higher Lower Lower Higher Lower Higher Lower Correct!

Jerry Wins! Test
Input
1 10 50 30 20 10 8 1 5 2 4 3
Output
Lower Lower Lower Lower Lower Higher Lower Higher Lower Correct!

Validator 4 Validator
Input
33 10 70 20 50 40 30 33 37 34 36 35
Output
Lower Higher Lower Lower Higher Higher Lower Higher Lower Correct!

Solution language

Solution

Stub generator input