Created
November 27, 2011 17:26
-
-
Save devnoo/1397848 to your computer and use it in GitHub Desktop.
Seven languages in seven weeks : Solutions IO Day2 guess number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
numberToGuess := Random value(100) round | |
previousGuessDistance := nil | |
10 repeat( | |
guess := File standardInput readLine("Enter a number between 1 and 100\n" ) asNumber(); | |
if (guess == numberToGuess, ( | |
"Gratz you won" println ; | |
return | |
) | |
) | |
currentGuessDistance := (guess - numberToGuess) abs; | |
if (previousGuessDistance != nil, ( | |
if (currentGuessDistance < previousGuessDistance, "Hotter" println); | |
if (currentGuessDistance > previousGuessDistance, "Colder" println); | |
if (currentGuessDistance == previousGuessDistance, "That's just plain supid!" println) | |
); | |
) | |
previousGuessDistance = (guess - numberToGuess) abs | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment