Amplitude Hackathon Summer '24 Practice Problem 1 - Jeffrey's Favorite Integer

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 0.5s
Memory limit: 1G

Problem type

What is Jeffrey's favorite integer?

Constraints

Jeffrey's favorite integer is between 1 and 100.

Subtask 1 [1 point]

You have 100 guesses to figure it out.

Subtask 2 [1 point]

You have 7 guesses to figure it out.

Interaction Protocol

The interaction will take place over multiple rounds. In one round, you must output a line containing a guess of Jeffrey's favorite integer. Then, you must read in a single integer. Remember to flush your output to standard out before trying to read an integer!

If the guess is exactly equal to Jeffrey's favorite integer, then you will read in a value of CORRECT. Your program has correctly guessed the password, and you are considered to have solved this test case. Your program should terminate immediately.

Otherwise, you will read in either LESS or GREATER. If you read in LESS, then Jeffrey's integer is less than your guess. If you read in GREATER, then Jeffrey's integer is greater than your guess.

Sample Interaction

Note that <<< represents values that you should read from stdin, and >>> represents a string that you print to stdout.

>>> 1
GREATER <<<
>>> 100
LESS <<<
>>> 39
CORRECT <<<

Note that in this sample interaction, Jeffrey's favorite integer is 39.


Comments

There are no comments at the moment.