FOSSASIA

### (1) Objective

Write a simple guess game, and teach the program to play it. Please add the game to the FOSSASIA GCI student site in the section "Games" with a) a link to the code and b) if possible a version that runs in the browser.

### (2) Requirement

Write a program which does the following:

1) Program chooses a random number between 1 and 1024 (or any powers of two, 2^n) with approximately equal probability.

2) User guesses it and the program tells if the answer is larger or smaller than the guess.

3) Repeat "2)" until user guesses right. Then print the number of attempts.

4) Repeat 1-3) this 10 times and record number of attempts.

5) Modify the program so that the computer will choose AND guess the number.

6) Run "5)" N>=100 times and record number of attempts.

7) Improve search algorithm, and use recursion. (read up on binary search algorithm for example)

8) Write-up to interpret "4)" and "6)" - this result will depend on the search algorithm. With your algorithm, try to explain how many guess do you need to make to get the correct answer. (Hint: If the random number range is 2^n instead of 1024=2^10, what would be the result? Do you see a pattern?)

### (3) Expected outcome

• Program with guess game, a search algorithm, and recursion.
• Add your project to the GCI student site at http://gci15.fossasia.org in the section "Games" with a) a link to the code and b) if possible a version that runs in the browser.

• After completion, you might like to tackle Fractal Recursed.

• binary search
• recursion
• big o notation
• log
• powers of 2

#### Students who completed this task

Nalin Bhardwaj, Aishwarya, kngoledge, Chong Jing Quan, Rahul Narayanan, Ching Hannie, Amaan, Tyler, Rajat De, Skylar, Dani Pop, Robin Verhoef, Duc Phan Duy, Ronin, Juanvhook, Anish M., Shyamasis Sarangi, notabigthreat, additya1998, shiftsayan