Last active
August 29, 2015 13:56
-
-
Save ewhitebloom/9085487 to your computer and use it in GitHub Desktop.
Guessing Game
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
| 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