# Thread: Game question. help me

1. ## Game question. help me

an integer number between 0 and 99. With just 6 question. to guess correctly!!!
6 Question of me. ( numbers is 13 )
Computer: Is your number bigger than 50?
User: No
Computer: Is your number bigger than 25?
User: No
Computer: Is your number bigger than 12?
User: Yes
Computer: Is your number bigger than 18?
User: No
Computer: Is your number bigger than 15?
User: No
Computer: Is your number bigger than 13?
User: No
Computer: your number is 13, right?
User: Absolutely right. Exactly right. You are genius computer.
Error: numbers 14??
Who can do other algorithms??? Help me!!!

2. where is it you are having trouble with this? maybe you could try a flow scheme to start with then try and put it into code

3. put it in the code but then fails when put six questions

4. do you mean this is your sample output? or this is your algorithm or what you want to happen? have you any of your code to post?

Computer: Is your number bigger than 50?
User: No
Computer: Is your number bigger than 25?
User: No
Computer: Is your number bigger than 12?
User: Yes
Computer: Is your number bigger than 18?
User: No
Computer: Is your number bigger than 15?
User: No
Computer: Is your number bigger than 13?
User: No
Computer: your number is 13, right?
User: Absolutely right. Exactly right. You are genius computer.

5. Okie. thanks you! I want to just six questions to guess the number between 0-99 you think. I think this is a very interesting problem. I asked six questions above so, but guess not

6. so.....
have you any of your code to post?

7. can you code help me?? because algorithm of me fail, thanks you very much.

8. if you are capable of stepping through your algorithm on paper (as you say you have no code)
can you code help me?? because algorithm of me fail
and find that something is wrong with it, then surely you are also able to say what your error is, what you guess it is, or at least show us what your working out is

9. The program needs to keep a lower limit a and an upper limit b for the number x, so that a <= x <= b. From the beginning a = 0 and b = 99. The program then makes up a number c between a and b (it has to be lower than b), maybe c = (a+b)/2, and asks the user if x is bigger or not. If it is bigger, it sets a = c+1, else it sets b=c. You repeat the process untill a and b are equal.

10. The number of questions that need to be asked is floor(log2(N)) where N is the range of possibilities. The algorithm the program is using is bisection. It keeps track of the low and high points, and asks you about the middle. If the middle is too low, it sets that as its new low point. Vice versa, if the middle is too high, it sets that as its new high point.

Imagine how you would look up somebody's name in a phone book. You flip back and forth based on your knowledge of the order of the alphabet -- you don't search randomly, or by flipping each page one by one.

Popular pages Recent additions