Skip to content

Instantly share code, notes, and snippets.

@chuckwagoncomputing
Created November 23, 2016 19:04
Show Gist options
  • Save chuckwagoncomputing/a2cd35264e629c5a7aa9221c5989726f to your computer and use it in GitHub Desktop.
Save chuckwagoncomputing/a2cd35264e629c5a7aa9221c5989726f to your computer and use it in GitHub Desktop.
How much more likely are you to roll 6 dice uniquely than all the same?
greed = 0
flush = 0
10000000.times do
dice = []
6.times do
dice.push((1..6).to_a.sample)
end
if dice.include?(1) and dice.include?(2) and dice.include?(3) and dice.include?(4) and dice.include?(5) and dice.include?(6)
greed += 1
elsif dice[0] == dice[1] and dice[1] == dice[2] and dice[2] == dice[3] and dice[3] == dice[4] and dice[4] == dice[5]
flush += 1
end
end
puts "$GREED = #{greed}"
puts "Flush = #{flush}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment