# Reverse Number Guessing Game--in 10 tries???

• 11-02-2013, 12:44 AM
ctkim
Reverse Number Guessing Game--in 10 tries???
Hey all!

So the concept is pretty simple. I wrote a program where the user thinks of a number and the computer tries to guess what the number is (between 1~1000). The user then says whether it's too high, too low, or correct.

My program works great with no bugs, but the only part I'm struggling with is that I need to get the number of guesses to below 10.

So far, I don't see how I can do that, since the numbers are being randomly generated from 1 ~ 1000, as I change the min and the max number according to the guesses and user input.

Is there something I'm missing to see? Any ideas?

Thanks so much!
• 11-02-2013, 02:19 AM
jim829
Re: Reverse Number Guessing Game--in 10 tries???
What you want to do is essentially a binary search. So the computer guesses a number. From there you keep splitting the remaining range of numbers in half until the correct number is reached.

Regards,
Jim
• 11-02-2013, 04:08 AM
ctkim
Re: Reverse Number Guessing Game--in 10 tries???
Yes! Perfect.
Thank you!