Demonstration Task 1: Guess

Jill is thinking of a number between 1 and N, and Jack wants to guess it by asking Jill questions of the form "Is it bigger than K?" for K between 1 and N.

You are to implement a procedure play(N) that implements Jack's role in the game. Your implementation should repeatedly call the procedure bigger(K), which is implemented by the grader. bigger(K) will return 1 if Jill's number is greater than K; otherwise it will return 0. Jill's number should be returned by your implementation as the result of play.

Subtask 1 [50 points]

Assume that N=16. Your implementation must use at most 15 calls to bigger and must return the correct result. The implementation files described below contain a correct implementation of this subtask.

Subtask 2 [50 points]

Assume that N=16. Your implementation must use at most 4 calls to bigger and must return the correct result.

Implementation Details