Here we go, day 1, Bonus challenge -guess a number.
#!/usr/bin/ruby
guess = 1
while guess > 0
num = rand(10)
guess = gets.to_i
if guess > num
puts "Too high was : " + num.to_s
elsif guess < num
puts "Too Low was : " + num.to_s
else
puts 'Just Right'
end
end
Bonus tip, the ruby interpreter is called irb, and doesn't necessarily come with the ruby package.
No comments:
Post a Comment