Created
July 9, 2019 16:35
-
-
Save krokrob/85f5815cde9cb7a378b9a0ec49a34bba to your computer and use it in GitHub Desktop.
This file contains 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
# 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