Skip to content

Instantly share code, notes, and snippets.

@TonyNguyen87
Created February 22, 2016 21:11
Show Gist options
  • Save TonyNguyen87/7d7cbefd5a6724561537 to your computer and use it in GitHub Desktop.
Save TonyNguyen87/7d7cbefd5a6724561537 to your computer and use it in GitHub Desktop.
Tony Nguyen homework1
## computer randomly picks a number
## user guesses number higher or lower than the random number
## if user guess correct than puts correct
def guessgame
prng = rand(100)
puts "Guess a number between 0-100"
input = gets.chomp.to_i
until input == prng
if input > prng
puts "Guess Lower"
input = gets.chomp.to_i
elsif input < prng
puts "Guess Higher"
input = gets.chomp.to_i
else
puts "Correct"
end
end
end
guessgame
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment