ENIGMA-0x00 (2022) - S3 (Guess and Win!) **

View as PDF

Submit solution

Points: 30 (partial)
Time limit: 1.0s
Memory limit: 64M

Authors:
Problem types
Allowed languages
Blockly, C, C#, C++, Fortran, Go, Haskell, Java, Lua, Pascal, Perl, PHP, Python
Guess and WIn!

The world has changed. Gambling is now the only way for people to fill their time and stay entertained.
Children are no exception and playing "Guess and Win!" is the new trend.

"Guess and Win!" is a game of chance, the aim of which is to guess a positive integer M.
Each attempt costs 1 coin unit. There is no limit to the number of attempts you can make until you get the number, but there is a limit to your financial resources :).
Kids always spend their entire allowance on the game, and now, at Christmastime, when they have their gains from the carols available, they can play up to 1000 times!

Totos, in addition to being addicted to the game, is also extremely observant. He observed that every time he loses, having predicted a number K smaller than the lucky number M, a tiny light bulb lights up with an indication of '1'. On the other hand, when he predicts a number K greater than M, a tiny light bulb lights up with an indication of '2'. In case of a victory, none of the tiny light bulbs lights up (indication '0').

We want to thank Totos for the information he has provided us, by writing a script that will always guess M before he runs out off money. This program tries, one by one, K numbers, printing them in the output STDOUT in whichever acceptable representation, followed by a line break character '\n'.
After each try, it will read from STDIN the answer of the game, an integer L that will be a symbol for Totos' observation :).

Example
STDIN STDOUT
1
1
2
1
3
1
9
2
8
0

Comments

There are no comments at the moment.