in reply to Guess That Number
You keep insisting that your $goal calculation function is perfect, and you say that your testing demonstrates it to be so.
If you are being sincere about that, then your testing protocol is flawed. It will appear to work correctly (that is, the program functions exactly as expected) as long as the randomly generated $goal is indeed >= $low. And this will indeed be the case a large fraction of the time, depending on what you set $low and $high to. But your $goal calculation function is not perfect, and will — some fraction of the time — set $goal to something less than $low, in which case your program fails. Here's the output of a sample run, with $low set to 100, and printing out the value of $goal so we can see what we're up against:
(hint: goal=59) Enter a number between 100 and 1000: 50 Please stay between 100 and 1000. Enter a number between 100 and 1000: 59 Holy cow! You guessed it!
Use a correct $goal calculation function, such as the one I showed you, and you won't have this problem.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Guess That Number
by naildownx (Beadle) on Jul 10, 2009 at 04:14 UTC | |
by naildownx (Beadle) on Jul 10, 2009 at 05:17 UTC |