Created
January 24, 2012 17:48
-
-
Save kachick/1671481 to your computer and use it in GitHub Desktop.
Guess number
This file contains hidden or 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
# an approach to | |
# * http://vipprog.net/wiki/exercise.html#d082e883 | |
# tested Ruby 1.9.3 | |
$VERBOSE = true | |
right = rand 100 | |
loop do | |
puts "Can you guess the number that I'm thinking of?" | |
case Integer(gets) | |
when right | |
puts 'Great!' | |
break | |
when ->answer{answer < right} | |
puts 'small' | |
when ->answer{answer > right} | |
puts 'big' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment