Last active
September 30, 2021 04:12
-
-
Save aldy505/66d8ec07ec123d8eed35916dbfdb037a to your computer and use it in GitHub Desktop.
Rust's Guessing Game in Ruby
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
randomNumber = rand(100) | |
puts "The random number is: #{randomNumber}" | |
correct = false | |
until correct do | |
print "Guess the number: " | |
input = gets | |
if input.to_i > randomNumber | |
puts "No, it's smaller than that. Try again." | |
next | |
elsif input.to_i < randomNumber | |
puts "No, it's bigger than that" | |
next | |
else | |
correct = true | |
break | |
end | |
end | |
puts "Yeah, you did it!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment