Library · The Fiddler: Solutions · Chapter 131

Can You Roll the Dungeon Master’s Dice?

Revised Report an error

Two people sit at a table, each with a bag of six “DnD dice”: a d4, d6, d8, d10, d12 and d20, where a dX has faces 11 to XX, all equally likely. Each person picks a die from their own bag at random, and they roll at the same time. What is the probability that both roll the same number, whether or not they picked the same kind of die?

The Fiddler, Zach Wissner-Gross, January 12, 2024(original post)

The official solution appeared in the post of January 19, 2024 and gives 3/32=9.3753/32 = 9.375 percent for the main puzzle, agreeing with the answer below. The Extra Credit half of that post is paywalled, so the expected number of distinct values, 8489153/3110400≈2.7298489153/3110400 \approx 2.729, is my own and has not been checked against it.

Solution

Condition on the dice. Suppose the two people hold a dX and a dY with X≤YX \le Y. Whatever the smaller die shows, it is a number from 11 to XX, and the larger die shows that same number with probability 1/Y1/Y. So the chance of a match is 1max⁡(X,Y).\frac{1}{\max(X, Y)} . Only the larger die matters. (Two d4s match one time in four; a d4 and a d20 match one time in twenty.)

Each of the 6×6=366 \times 6 = 36 ordered pairs of dice is equally likely. List the dice in order, 4,6,8,10,12,204, 6, 8, 10, 12, 20. The pairs whose larger die is the kkth in this list are those with both dice among the first kk but not both among the first k−1k - 1: there are k2−(k−1)2=2k−1k^2 - (k - 1)^2 = 2k - 1 of them. So P(match)  =  136(14+36+58+710+912+1120)  =  136⋅278,P(\text{match}) \;=\; \frac{1}{36}\left(\frac14 + \frac36 + \frac58 + \frac7{10} + \frac9{12} + \frac{11}{20}\right) \;=\; \frac{1}{36}\cdot\frac{27}{8}, which is  P(same number)  =  332  =  9.375%. \boxed{\ P(\text{same number}) \;=\; \frac{3}{32} \;=\; 9.375\%. \ } That is a little more than half the 1/61/6 chance for two ordinary dice. Every die carries the numbers 11 to 44, and that is where most matches happen.

The computation

The program runs through every pair of dice and every pair of faces, weights each outcome by its exact probability, and adds up the matches.

from fractions import Fraction
from itertools import product

dice = [4, 6, 8, 10, 12, 20]
match = Fraction(0)
for X, Y in product(dice, repeat=2):
    w = Fraction(1, 36 * X * Y)          # this pair of faces
    match += w * sum(1 for a in range(1, X + 1)
                       for b in range(1, Y + 1) if a == b)
print("P(match) =", match)

It prints

P(match) = 3/32

Extra Credit

Now three people each pick a die from their own bag at random and roll. On average, how many distinct numbers appear among the three rolls?

Solution

Count the distinct numbers one value at a time. The number of distinct values is the number of values vv from 11 to 2020 that appear at least once. The average of a sum is the sum of the averages, so E[distinct]  =  ∑v=120P(v appears).E[\text{distinct}] \;=\; \sum_{v=1}^{20} P(v \text{ appears}) . The three people act independently, so if qvq_v is the chance that a single person rolls vv, P(v appears)=1−(1−qv)3.P(v \text{ appears}) = 1 - (1 - q_v)^3 . A single person picks each die with chance 1/61/6, and a dX shows vv with chance 1/X1/X if v≤Xv \le X. So qv=16∑X≥v1Xq_v = \tfrac16 \sum_{X \ge v} \tfrac1X, which takes six values:

vv 11–44 55–66 77–88 99–1010 1111–1212 1313–2020
qvq_v 31240\frac{31}{240} 780\frac{7}{80} 43720\frac{43}{720} 7180\frac{7}{180} 145\frac{1}{45} 1120\frac{1}{120}
1−(1−qv)31 - (1 - q_v)^3 .3396.3396 .2402.2402 .1687.1687 .1122.1122 .0652.0652 .0248.0248

Adding each column’s value once for every vv it covers, 4(.3396)+2(.2402)+2(.1687)+2(.1122)+2(.0652)+8(.0248)  ≈  2.729,\begin{align*} &4(.3396) + 2(.2402) + 2(.1687) \\ &\qquad + 2(.1122) + 2(.0652) + 8(.0248) \;\approx\; 2.729 , \end{align*} and the exact sum is  E[distinct]  =  84891533110400  ≈  2.729. \boxed{\ E[\text{distinct}] \;=\; \frac{8489153}{3110400} \;\approx\; 2.729. \ } For comparison, the same method gives three ordinary dice 6(1−(5/6)3)=91/36≈2.536\left(1 - (5/6)^3\right) = 91/36 \approx 2.53 distinct values, so the mixed bag spreads the rolls out a little more.

The computation

The program enumerates every choice of three dice and every combination of faces, 603=216,00060^3 = 216{,}000 outcomes in all, each weighted by its exact probability, and averages the number of distinct faces.

E = Fraction(0)
for ds in product(dice, repeat=3):
    w = Fraction(1, 216 * ds[0] * ds[1] * ds[2])
    for faces in product(*(range(1, d + 1) for d in ds)):
        E += w * len(set(faces))
print("E[distinct] =", E, float(E))

It prints

E[distinct] = 8489153/3110400 2.729280156893004
Report an error on this page

Reports are stored by Netlify. See the privacy note.