Created
November 14, 2013 18:27
-
-
Save justuseapen/7471848 to your computer and use it in GitHub Desktop.
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
MAX = 1000 | |
NUM = rand(1000) | |
puts "Guess a number between 0 and #{MAX}" | |
guess = gets.chomp.to_i | |
def guess_again | |
guess = gets.chomp.to_i | |
if guess == NUM | |
puts "CORRECT!" | |
elsif guess > NUM | |
puts "Your guess was too high!" | |
puts "Guess again!" | |
guess_again | |
elsif guess < NUM | |
puts "Your guess was too low!" | |
puts "Guess again!" | |
guess_again | |
end | |
end | |
if guess == NUM | |
puts "CORRECT!" | |
elsif guess > NUM | |
puts "Your guess was too high!" | |
puts "Guess again!" | |
guess_again | |
elsif guess < NUM | |
puts "Your guess was too low!" | |
puts "Guess again!" | |
guess_again | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment