Last active
December 21, 2015 05:09
-
-
Save radavis/6255009 to your computer and use it in GitHub Desktop.
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
MAX = 10 | |
answer = rand(MAX) | |
while true do | |
print "Guess a number between 0 and #{MAX}: " | |
guess = gets.chomp.to_i | |
if guess > answer | |
puts "\nToo high, try again..." | |
elsif guess < answer | |
puts "\nToo low, try again..." | |
else | |
puts "Congratulations, you've guessed the number" | |
break | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment