Library · The Fiddler: Solutions · Chapter 2

Can You Maximize the Range?

Revised Report an error

You roll a number of fair six-sided dice all at once and measure the range of the results: the difference between the largest and the smallest roll. With very many dice the range is almost always 55. With fewer dice a range of 55 is no longer a sure thing. What is the smallest number of dice for which a range of 55 is more likely than not?

The Fiddler, Zach Wissner-Gross, November 6, 2026(original post)

The official solution appeared in the post of November 13, 2026 and gives 77 dice for the main puzzle, agreeing with the answer below. The Extra Credit half of that post is paywalled, so the value of NN is my own.

Solution

The range is 55 exactly when the largest roll is 66 and the smallest is 11, that is, when at least one die shows a 11 and at least one shows a 66. It is easier to count the failures. A roll fails when there is no 11 or there is no 66.

With dd dice, the chance of no 11 is (5/6)d(5/6)^d, since each die must avoid one face, and the chance of no 66 is the same. Adding them counts twice the rolls that have neither a 11 nor a 66, in which every die shows 22, 33, 44 or 55, with chance (4/6)d(4/6)^d. Subtracting that overlap once gives the chance of failure, 2(5/6)d−(4/6)d2(5/6)^d - (4/6)^d, so P(d)  =  1−2(56)d+(46)d  =  6d−2⋅5d+4d6d.P(d) \;=\; 1 - 2\Big(\frac56\Big)^d + \Big(\frac46\Big)^d \;=\; \frac{6^d - 2\cdot 5^d + 4^d}{6^d}. Adding a die can only help, since a 11 and a 66 already present stay present, so P(d)P(d) grows with dd and we need the first dd at which it passes 12\tfrac12. Two values settle it: P(6)=46656−31250+409646656=1950246656≈0.418,P(7)=279936−156250+16384279936=140070279936≈0.5004.\begin{align*} P(6) &= \frac{46656 - 31250 + 4096}{46656} = \frac{19502}{46656} \approx 0.418,\\ P(7) &= \frac{279936 - 156250 + 16384}{279936} = \frac{140070}{279936} \approx 0.5004 . \end{align*} Seven dice clear the bar by a whisker:  7 dice \boxed{\ 7 \text{ dice} \ }

The computation

The check does not use inclusion and exclusion. For each number of dice it lists every one of the 6d6^d equally likely rolls, measures the range directly and counts how often it is 55, as an exact fraction.

from fractions import Fraction
from itertools import product

def p_range5(d):
    """Exact chance that d dice show a range of 5, by listing every roll."""
    good = sum(max(r) - min(r) == 5 for r in product(range(1, 7), repeat=d))
    return Fraction(good, 6**d)

for d in range(2, 9):
    p = p_range5(d)
    verdict = ", more likely than not" if p > Fraction(1, 2) else ""
    print(f"{d} dice: {float(p):.4f}{verdict}")

It prints

2 dice: 0.0556
3 dice: 0.1389
4 dice: 0.2330
5 dice: 0.3279
6 dice: 0.4180
7 dice: 0.5004, more likely than not
8 dice: 0.5739, more likely than not

Extra Credit

Now roll 10001000 dice together, record their total, and repeat this NN times. For very large NN the range of the NN totals is almost always 50005000; for smaller NN it is not. Find the smallest NN for which a range of 50005000 is more likely than not. Write it as A×10BA \times 10^B with BB a whole number and 1≤A<101 \le A < 10, and give AA to at least four decimal places, and BB.

Solution

The main puzzle is the miniature of this one. A total of 10001000 dice lies between 10001000 and 60006000, so the range of the totals is 50005000 exactly when at least one total is 10001000 and at least one is 60006000. Each extreme can happen in only one way, every die showing 11 or every die showing 66, so each has chance p=6−1000.p = 6^{-1000} . The repetitions are now the dice, and the extremes are the faces 11 and 66. The same counting as before, with NN repetitions in place of dd dice and 1−p1-p, 1−2p1-2p in place of 5/65/6, 4/64/6, gives P(N)  =  1−2(1−p)N+(1−2p)N.P(N) \;=\; 1 - 2(1-p)^N + (1-2p)^N . Again P(N)P(N) grows with NN, so we want the point where it crosses 12\tfrac12.

Here pp is so small that NN must be enormous, and the natural scale is the expected number of all-ones totals, x=Npx = Np. For tiny pp, (1−p)N=eNln⁡(1−p)(1-p)^N = e^{N\ln(1-p)}, and ln⁡(1−p)=−p−p2/2−⋯\ln(1-p) = -p - p^2/2 - \dotsb differs from −p-p by about p2/2p^2/2. So (1−p)N=e−x(1-p)^N = e^{-x} up to a relative error of about Np2=xpNp^2 = xp, which with xx near 11 is around 10−77810^{-778}. Likewise (1−2p)N=e−2x(1-2p)^N = e^{-2x}, and to any precision we could ever print, P(N)  =  1−2e−x+e−2x  =  (1−e−x)2.P(N) \;=\; 1 - 2e^{-x} + e^{-2x} \;=\; \big(1 - e^{-x}\big)^2 . The square has a meaning: the counts of all-ones and all-sixes totals are, in the limit, independent, and each is non-zero with chance 1−e−x1 - e^{-x}.

Setting (1−e−x)2=12(1 - e^{-x})^2 = \tfrac12 gives e−x=1−1/2e^{-x} = 1 - 1/\sqrt2, so x  =  ln⁡11−1/2  =  ln⁡22−1  =  ln⁡(2+2)  ≈  1.2279.x \;=\; \ln\frac{1}{1 - 1/\sqrt2} \;=\; \ln\frac{\sqrt2}{\sqrt2 - 1} \;=\; \ln\big(2 + \sqrt2\big) \;\approx\; 1.2279 . The smallest NN is the first whole number past x/px/p: N  =  ⌈61000ln⁡(2+2)⌉.N \;=\; \Big\lceil 6^{1000}\ln\big(2+\sqrt2\big) \Big\rceil . To put it in scientific notation, log⁡1061000=1000log⁡106≈778.1512504\log_{10} 6^{1000} = 1000\log_{10}6 \approx 778.1512504, so 61000≈1.416610×107786^{1000} \approx 1.416610 \times 10^{778}, and multiplying by 1.22794721.2279472,  N≈1.7395×10778,A≈1.73952257,B=778 \boxed{\ N \approx 1.7395 \times 10^{778}, \qquad A \approx 1.73952257,\quad B = 778 \ } The rounding up to a whole number and the error of order 10−77810^{-778} in the approximation move NN by a few units at most, far below the 778778th digit, so they cannot touch AA.

The computation

The check repeats the experiment’s logic with nothing taken on trust: not the value of pp, and not the formula for P(N)P(N).

  1. Compute the exact distribution of the total of 10001000 dice by expanding (x+x2+⋯+x6)1000(x + x^2 + \dots + x^6)^{1000}. Python’s big integers do this in one power if each coefficient is packed into its own block of 26002600 binary digits (enough, since no coefficient exceeds 61000<225856^{1000} < 2^{2585}). Read off the number of ways to roll 10001000 and 60006000.

  2. Follow the NN repetitions as a chain with three states: neither extreme seen yet, one seen, both seen. One repetition moves the chain by a 3×33 \times 3 matrix built from the two probabilities in step 1. The chance of a range of 50005000 after NN repetitions is the chance of being in the last state, computed by raising the matrix to the power NN by repeated squaring, in 17001700-digit arithmetic so that 1−p1 - p is not rounded to 11.

  3. Bisect on NN for the point where that chance passes 12\tfrac12.

from mpmath import mp, mpf, matrix, log10, floor

# 1. Exact distribution of the total of 1000 dice
K, BITS = 1000, 2600
packed = sum(1 << (BITS*i) for i in range(1, 7))**K
mask = (1 << BITS) - 1
ways = {s: (packed >> (BITS*s)) & mask for s in range(K, 6*K + 1)}
assert sum(ways.values()) == 6**K
print("ways to roll 1000 / 6000:", ways[K], ways[6*K])

# 2. States: 0 = neither extreme seen, 1 = one seen, 2 = both seen
mp.dps = 1700
p_low = mpf(ways[K]) / 6**K
p_high = mpf(ways[6*K]) / 6**K
step = matrix([[1 - p_low - p_high, p_low + p_high, 0],
               [0, 1 - p_low, p_low],   # the missing extreme is equally
               [0, 0, 1]])              # likely to be either (p_low = p_high)

def chance_full_range(N):
    """Probability that N repetitions reach state 2, by repeated squaring."""
    result, power = matrix([[1, 0, 0]]), step
    while N:
        if N & 1:
            result = result * power
        power, N = power * power, N >> 1
    return result[0, 2]

# 3. The chance only grows with N, so bisect for where it passes 1/2
lo, hi = 1, 6**K * 10                   # chance(lo) < 1/2 < chance(hi)
while hi - lo > 6**K // 10**12:
    mid = (lo + hi) // 2
    if chance_full_range(mid) > 0.5: hi = mid
    else: lo = mid
B = int(floor(log10(hi)))
print("N = %s x 10^%d" % (mp.nstr(mpf(hi) / mpf(10)**B, 10), B))

It prints

ways to roll 1000 / 6000: 1 1
N = 1.739522573 x 10^778

matching the boxed value to ten significant figures.

Report an error on this page

Reports are stored by Netlify. See the privacy note.