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 .
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 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 smaller than the lucky number , a tiny light bulb lights up with an indication of '1'
.
On the other hand, when he predicts a number greater than , 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 before he runs out off money.
This program tries, one by one, 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 that will be a symbol for Totos' observation :).
Example
STDIN | STDOUT |
1 | |
1 | |
2 | |
1 | |
3 | |
1 | |
9 | |
2 | |
8 | |
0 |
Comments