Skip to content

Instantly share code, notes, and snippets.

@krokrob
Created July 9, 2019 16:35
Show Gist options
  • Save krokrob/85f5815cde9cb7a378b9a0ec49a34bba to your computer and use it in GitHub Desktop.
Save krokrob/85f5815cde9cb7a378b9a0ec49a34bba to your computer and use it in GitHub Desktop.
# generer un nombre aleatoire entre 1 et 100
price = rand(1..100)
# demander un nombre a l utilisateur
# comparer les 2 nombres
guess = 0
until price == guess
puts "What's your guess?"
guess = gets.chomp.to_i
# si bonne reponse: indiquer que c'est gagné
# si mauvaise reponse
# donner une indication: plus ou moins
if price > guess
puts "You've underestimated the value"
elsif price < guess
puts "You've overestimated the value"
end
end
# retour a l etape 2
puts "You win"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment