Discussion:
Special Case in Guess part 2
(too old to reply)
Hui Frederick Lap Yip
2004-01-23 23:13:19 UTC
Permalink
TAs,

I do not know if we need to consider this special case. Let's say
previous guess was 92 and you said it was too low. So the computer
guesses some number higher than 93, say 97. You sa it's too high. So
then the computer guesses 93 and you say it's too high. My program will
then just keep asking the computer for numbers. However, it is obvious
that that case is not possible. Also, if we cheat (ie. lie to the
computer) do we need a cheat check?

Fred
Moayad Fahim Ali
2004-01-24 18:21:31 UTC
Permalink
For this specific case only, it's fine. The user will eventually have to
press CORRECT on 93. However, for all other cases such as the computer
guessing 100 and you saying "TOO LOW", or the computer guessing 1 and
you saying "TOO HIGH", you must take care of that.

If you keep cheating (i.e. lie about your number) two things could happen:

1. You could reach the state you described in your post (Example: 92 being
too low and 93 too high).

2. Your code will reach a state where there is only one possible number
left and, as mentioned earlier, your program should automatically print that number
without having to ask the user again if it is High, Low, or Correct
(Example: 92 being too low and then it guesses 94, not 93, and you
say its too high --> 93 is the only possible guess).

Please refer to Alexander's earlier post "Input from automarker".

Thanks.
Post by Hui Frederick Lap Yip
TAs,
I do not know if we need to consider this special case. Let's say
previous guess was 92 and you said it was too low. So the computer
guesses some number higher than 93, say 97. You sa it's too high. So
then the computer guesses 93 and you say it's too high. My program will
then just keep asking the computer for numbers. However, it is obvious
that that case is not possible. Also, if we cheat (ie. lie to the
computer) do we need a cheat check?
Fred
Continue reading on narkive:
Loading...