Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Solution: Number Guessing game - level 0

LIMIT = 20

hidden = Random.rand(LIMIT) + 1
puts "For debugging: #{hidden}"
print "Guess a number between 1 and #{LIMIT}: "
guess = gets.not_nil!.to_i

if guess == hidden
  puts "Matched!"
elsif guess < hidden
  puts "Too small"
else
  puts "Too big"
end