Skip to content

Instantly share code, notes, and snippets.

@volpeo
Created October 13, 2015 17:23
Show Gist options
  • Save volpeo/270fab61ba66605def66 to your computer and use it in GitHub Desktop.
Save volpeo/270fab61ba66605def66 to your computer and use it in GitHub Desktop.
Juste Price
def rand_price
price = (1..100).to_a.sample
return price
end
price = rand_price
puts "How many players ?"
player_numbers = gets.chomp.to_i
n = 1
puts "What's the price of this product ?"
puts "Player #{n}, your turn"
your_price = gets.chomp.to_i
until your_price == price
if your_price > price
puts "It's less"
elsif your_price < price
puts "It's more !"
end
n = n + 1
if n > player_numbers
n = 1
end
puts "Player #{n}, your turn"
your_price = gets.chomp.to_i
end
puts "You won player #{n}!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment