Skip to content

Instantly share code, notes, and snippets.

@mjacobus
Created February 5, 2020 12:47
Show Gist options
  • Select an option

  • Save mjacobus/38b330542b63bf1abf62bcc28fdf9fb6 to your computer and use it in GitHub Desktop.

Select an option

Save mjacobus/38b330542b63bf1abf62bcc28fdf9fb6 to your computer and use it in GitHub Desktop.
number = rand(100)
guess = nil
puts "Adivinhe o número entre zero e 100:"
while true
print "Que número você escolheu? "
guess = Integer(gets.strip)
if guess == number
puts "Parabéns, você acertou! O número é #{number}"
break
end
if guess < number
puts "Errou. O número sorteado é o maior que #{guess}"
else
puts "Errou. O número sorteado é o menor que #{guess}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment