Skip to content

Instantly share code, notes, and snippets.

@Papillard
Created October 23, 2017 10:54
Show Gist options
  • Save Papillard/c5c67fddd07a8dff1a23d03347a5e468 to your computer and use it in GitHub Desktop.
Save Papillard/c5c67fddd07a8dff1a23d03347a5e468 to your computer and use it in GitHub Desktop.
PMU - Reboot batch #100
puts "Bonjour, bienvenue à Longchamp"
horses = ["Canaçon", "Sonic", "Belle des vents", "Bad boy"]
while true
puts "Voici les chevaux sur lesquels tu peux parier"
horses.each_with_index do |horse, index|
puts "Cheval numéro #{index + 1} - #{horse}"
end
puts "Sur quel cheval veux-tu parier ? donne ton numero ou tape 'exit' pour arrêter"
answer = gets.chomp
if answer == "exit"
break
else
index = answer.to_i
bet = horses[index - 1]
result = horses.shuffle
winner = result.first
result.each_with_index do |horse, index|
horse_number = horses.index(horse)
puts "Position #{index + 1} - #{horse} (cheval N#{horse_number + 1})"
end
if bet == winner
puts "Tu décroches le gros lot"
else
puts "C'est perdu, le vainqueur était #{winner}. Tu veux parier à nouveau ?"
end
end
end
puts "A bientôt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment