## Project Euler 205: Comparing four-sided and six-sided dice

#### Project Euler 205 Problem Description

Project Euler 205: 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

#### Analysis

Type | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

9 four-sided dice | 0 | 0 | 0 | 1 | 9 | 45 | 165 | 486 | 1206 | 2598 | 4950 | 8451 | 13051 | 18351 | 23607 | 27876 | 30276 |

6 six-sided dice | 1 | 6 | 21 | 56 | 126 | 252 | 456 | 756 | 1161 | 1666 | 2247 | 2856 | 3431 | 3906 | 4221 | 4332 | 4221 |

Type | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

9 four-sided dice | 30276 | 27876 | 23607 | 18351 | 13051 | 8451 | 4950 | 2598 | 1206 | 486 | 165 | 45 | 9 | 1 |

6 six-sided dice | 3906 | 3431 | 2856 | 2247 | 1666 | 1161 | 756 | 456 | 252 | 126 | 56 | 21 | 6 | 1 |

After calculating the table above all that remains is finding the ratio of winning combinations to the total possible combinations. So the denominator will be (4^9)(6^6) and the numerator the total number of ways Pete out sums Colin (Pete’s index one more than Colin’s). Draws are inherently ignored, which was fortuitous.

#### Project Euler 205 Solution

Runs < 0.002 seconds in Python 2.7.Use this link to get the Project Euler 205 Solution Python 2.7 source.

#### Afterthoughts

- Reference: The On-Line Encyclopedia of Integer Sequences (OEIS) A108907: Number of times a point sum n is attained in all 6^6 permutations of throwing 6 dice.

Project Euler 205

*Project Euler 205 Solution last updated*

How did you calculate the table of combinations?