Possible logic flaw with using the same guess for the 2nd time

I tried the following:
min = 1
max = 30
guess = 15?
push down
guess = 8?
push up
guess = 11?
push down
guess = 9?
push up
guess = 10?
push down
guess = 9? - I don’t think the code should allow me to go back down to 9 for the 2nd time when I already answered before that my number was > 9.
To me it’s a logic flaw… how do I prevent this case in the code?

Well, I don’t completely remember the code, but you lied to the computer and it game was assuming you know the number. It is just guessing integers and you said it was lower than 10 and higher than 9 so it was left we no choice. But it should have complained.

You could use an array to store previous guesses and compare or even a min/max based off the guesses you could compare against then error out.

Privacy & Terms