Skip to content

Instantly share code, notes, and snippets.

@ewhitebloom
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save ewhitebloom/9085487 to your computer and use it in GitHub Desktop.

Select an option

Save ewhitebloom/9085487 to your computer and use it in GitHub Desktop.
Guessing Game
NUMBER = 673
message = print "Guess a number between 0 and 1000:"
guess = gets.chomp.to_i
until guess == NUMBER
message = "Guess a number between 0 and 1000:"
difference = NUMBER - guess
if difference >= 0
puts "Too low, try again..."
print message
guess = gets.chomp.to_i
elsif difference <= 0
puts "Too high, try again..."
print message
guess = gets.chomp.to_i
end
end
puts "Congratulations, you've guessed the number"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment