PyPE solution to PE problem 205
PyPE solution to PE problem 205
Blueprint information
- Status:
- Complete
- Approver:
- None
- Priority:
- Undefined
- Drafter:
- None
- Direction:
- Needs approval
- Assignee:
- None
- Definition:
- Approved
- Series goal:
- None
- Implementation:
- Implemented
- Milestone target:
- None
- Started by
- Scott Armitage
- Completed by
- Scott Armitage
Related branches
Related bugs
Sprints
Whiteboard
ProjectEule
===
Peter has nine four-sided (pyramidal) dice, each with faces numbered 1, 2,
3, 4. Colin has six six-sided (cubic) dice, each with faces numbered 1, 2,
3, 4, 5, 6.
Peter and Colin roll their dice and compare totals: the highest total wins.
The result is a draw if the totals are equal.
What is the probability that Pyramidal Pete beats Cubic Colin? Give your
answer rounded to seven decimal places in the form 0.abcdefg
Solution
--------
From Wikipedia, we can calculate the probability of rolling a certain total
k using i dice, each with s sides:
F(s,i,k) =
(1/s**i) * sum_(n=0..(k-i)/s){ (-1)**n * nCr(i,n) * nCr(k-sn-1,i-1) }
For any given total k rolled by Peter, the probability of rolling that k is
given by F(4,9,k). The probability that Colin rolled alower (but not equal)
total j is given by the sum(F(6,6,j)) for j in 6..(k-1). Therefore, the
probability that Peter rolled a k and won is the product of these two
probabilities.
The total probability that Peter will win a roll is obtained by summing over
all possible totals k that he could have rolled.
Answer
------
0.5731441