Created
November 6, 2013 22:38
-
-
Save g4vroche/7345497 to your computer and use it in GitHub Desktop.
My Day #1 bonus problem implementation from seven languages in seven weeks
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
#!/usr/bin/ruby | |
max = 10 | |
puts "hello world, try guessing a number beteen 0 and #{max}" | |
number = rand(max) | |
puts "Your guess(#{number}): " | |
guess = max + 1 | |
while guess != number | |
guess = gets.to_i | |
if guess == number | |
puts 'Congrats !' | |
else | |
if guess > number | |
puts 'Too high !' | |
else | |
puts 'Too low !' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment