Dice Game
Peter has nine four-sided (pyramidal) dice, each with faces numbered 1 to 4. Colin has six six-sided (cubic) dice, each with faces numbered 1 to 6. Peter and Colin roll their dice and compare total...
Problem Statement
This archive keeps the full statement, math, and original media on the page.
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 Peter beats Cubic Colin? Give your answer rounded to seven decimal places in the form 0.abcdefg.
Problem 205: Dice Game
Mathematical Foundation
Theorem (Convolution of Discrete Uniform Distributions). Let be independent random variables, each uniformly distributed on . The probability mass function of is given by the -fold convolution:
where for and otherwise. Equivalently, the number of ways to write with each is the coefficient of in .
Proof. For independent discrete random variables, the PMF of the sum is the convolution of the individual PMFs. This follows from the law of total probability: , which is precisely the convolution formula. The generating function representation follows from the product rule for generating functions of independent variables.
Theorem (Winning Probability). Let denote Peter’s total (sum of 9 dice with ) and denote Colin’s total (sum of 6 dice with ). Then:
where is the number of outcomes giving Peter total , and is the cumulative frequency function for Colin.
Proof. Since and are independent:
Writing and , we obtain the claimed formula.
Lemma (Range Constraints). Peter’s sum ranges over ( total outcomes). Colin’s sum ranges over ( total outcomes).
Proof. The minimum of dice each showing at least 1 is ; the maximum with faces up to is . For Peter: gives . For Colin: gives .
Editorial
Peter has 9 four-sided dice; Colin has 6 six-sided dice. Find P(Peter beats Colin), rounded to 7 decimal places. Compute sum distributions via convolution, then sum over all (p, c) pairs where Peter’s total p > Colin’s total c. We compute f_P[9..36]: frequency distribution for sum of 9 four-sided dice. We then compute f_C[6..36]: frequency distribution for sum of 6 six-sided dice. Finally, compute cumulative F_C[t] = sum of f_C[6..t] for t = 6..36.
Pseudocode
Input: Peter has 9d4, Colin has 6d6
Output: P(Peter > Colin) rounded to 7 decimal places
Compute f_P[9..36]: frequency distribution for sum of 9 four-sided dice
Compute f_C[6..36]: frequency distribution for sum of 6 six-sided dice
Compute cumulative F_C[t] = sum of f_C[6..t] for t = 6..36
winning_count = sum over p = 9..36 of f_P[p] * F_C[p-1]
probability = winning_count / (4^9 * 6^6)
Return round(probability, 7)
Complexity Analysis
- Time: for the convolutions and final summation, where . This is , effectively .
- Space: , effectively .
Answer
Code
Each problem page includes the exact C++ and Python source files from the local archive.
#include <bits/stdc++.h>
using namespace std;
int main(){
// Peter: 9 four-sided dice. Colin: 6 six-sided dice.
// P(Peter > Colin) rounded to 7 decimal places.
// Compute frequency distribution for sum of n dice with faces 1..f
auto dice_dist = [](int n, int f) -> vector<long long> {
int maxsum = n * f;
vector<long long> freq(maxsum + 1, 0);
freq[0] = 1;
for(int die = 0; die < n; die++){
vector<long long> nf(maxsum + 1, 0);
for(int s = 0; s <= maxsum; s++){
if(freq[s] == 0) continue;
for(int face = 1; face <= f && s + face <= maxsum; face++){
nf[s + face] += freq[s];
}
}
freq = nf;
}
return freq;
};
auto peter = dice_dist(9, 4); // indices 0..36, nonzero for 9..36
auto colin = dice_dist(6, 6); // indices 0..36, nonzero for 6..36
// Cumulative sum for Colin
vector<long long> colin_cum(37, 0);
for(int s = 1; s <= 36; s++){
colin_cum[s] = colin_cum[s-1] + colin[s];
}
// P(Peter > Colin) = sum over p of peter[p] * colin_cum[p-1]
long long win = 0;
for(int p = 9; p <= 36; p++){
win += peter[p] * colin_cum[p-1];
}
double total = (double)(1LL << 18) * 46656.0; // 4^9 * 6^6 = 262144 * 46656
double prob = (double)win / (262144.0 * 46656.0);
cout << fixed << setprecision(7) << prob << endl;
return 0;
}
"""
Problem 205: Dice Game
Peter has 9 four-sided dice; Colin has 6 six-sided dice.
Find P(Peter beats Colin), rounded to 7 decimal places.
Compute sum distributions via convolution, then sum over all (p, c) pairs
where Peter's total p > Colin's total c.
"""
def solve():
from itertools import product as iprod
def dice_distribution(n_dice, faces):
"""Compute frequency distribution for sum of n_dice dice with given faces."""
freq = {0: 1}
for _ in range(n_dice):
new_freq = {}
for s, cnt in freq.items():
for f in range(1, faces + 1):
new_freq[s + f] = new_freq.get(s + f, 0) + cnt
freq = new_freq
return freq
peter = dice_distribution(9, 4) # sums 9..36
colin = dice_distribution(6, 6) # sums 6..36
# Cumulative distribution for Colin: P(Colin < p)
colin_cum = {}
running = 0
for s in range(0, 37):
colin_cum[s] = running
running += colin.get(s, 0)
# P(Peter wins) = sum_p peter[p] * colin_cum[p] / (4^9 * 6^6)
win_count = sum(peter[p] * colin_cum[p] for p in peter)
total = (4**9) * (6**6)
prob = win_count / total
print(f"{prob:.7f}")
if __name__ == "__main__":
solve()