Canadian Computing Competition: 2001 Stage 2, Day 2, Problem 1
You are playing a game with your friends up in a tall tower with
Your friends have made the challenge a bit harder. You are given only two samples of the object. Once these have broken, there are no more objects to drop. There is one more restriction: you are given only a certain number,
To simulate the dropping of the object from a level, your program will use an interactor. The interactor has four operations:
GetD
andGetN
: Each of these should be called once at the beginning of the simulation and return the value of and , respectively.Drop t
: It simulates the dropping of a sample from level . It returns1
if the sample breaks; it returns0
, otherwise.Decide t
: It should be called once at the end of the simulation. It indicates to the library that your program has determined that the breaking level is . This routine also terminates your program.
Sample Interaction
>>>
denotes your output; don't actually print this out.
>>> GetN
5
>>> GetD
3
>>> Drop 3
1
>>> Drop 1
0
>>> Drop 2
1
>>> Decide 2
Comments
ted-ed riddles finally came into use