# You roll together 5 fair, six-sided dices.
# 1. What is the probability that the sum of the five dices is equal to 19 ? 13.9%
# 2. What is the probability that the sum of the five dices is less or equal to 19 ? 69.5%
# 3. What is the probability that the sum of the five dices is more than 19 ? 30.5%
from itertools import product
from math import gcd
dieRolls=list(product(range(1, 7), repeat=5))
dieRolls
n1=sum(sum(rol)==19 for rol in dieRolls)
n2=sum(sum(rol)<=19 for rol in dieRolls)
n3=sum(sum(rol)>19 for rol in dieRolls)
d=len(dieRolls)
g1=gcd(n1, d)
g2=gcd(n2, d)
g3=gcd(n3, d)
n1
n2
n3
g1
g2
g3
d
n1/d
0.09452160493827161
n2/d
0.6948302469135802
n3/d
0.30516975308641975
Resources:
https://docs.python.org/3/library/itertools.html
https://www.examsbook.com/dice-problems-in-probability
https://campus.datacamp.com/courses/statistical-simulation-in-python/basics-of-randomness-simulation?ex=7
https://www.geeksforgeeks.org/probability-of-getting-a-sum-on-throwing-2-dices-n-times/
https://codereview.stackexchange.com/questions/212930/calculate-probability-of-dice-total
https://www2.karlin.mff.cuni.cz/~nagy/NMSA202/dice1.pdf
https://jvmora.wordpress.com/2018/07/19/dice-probabilities-i/
https://rosettacode.org/wiki/Dice_game_probabilities
https://www.quora.com/You-roll-five-fair-six-sided-dice-What-is-the-probability-that-the-sum-of-the-five-dice-is-20-How-would-I-run-this-in-R-or-Python
Comments