Chapter 147
Mrs. Perkins’s 13-by-13 Quilt and the Lucky Derby
The Riddler for May 5, 2017. The Express is the classical instance of “Mrs. Perkins’s quilt”: the minimum number of integer squares the grid dissects into is , attained by Dudeney’s dissection with sides . The Classic is a -horse random-walk race to a -metre finish line, where the favourite filly with forward bias wins about of races.
Riddler Express
You are handed a square divided by lines into a grid. You must cut it into smaller square pieces along the grid lines. What is the smallest number of squares you can divide the grid into?
The Riddler, FiveThirtyEight, May 5, 2017(original post)
Solution
The minimum is . The problem is the classical “Mrs. Perkins’s quilt” for , posed by Henry Dudeney in 1907, and the value at has been confirmed by exhaustive search.
An upper bound: a dissection into squares. The eleven squares have sides . Their total area is so they fit at all only by exactly tiling the grid. One arrangement (found by the search in the listing below): the in the top-left corner, a in the top-right corner and a on the bottom-left, a filling the upper part of the right strip with three ’s and three ’s arranged around it, and two ’s filling the remaining cells.
A lower bound: fewer than is impossible. The argument is delicate. For Mrs. Perkins’s quilt with side , the minimum number of squares satisfies for general (Conway), but proving the exact value at requires a careful case analysis on corner placements. Trustrum’s 1965 enumeration confirms , and the result has been independently verified by integer-programming searches (OEIS A005670). We take the lower bound as established.
The computation
Encode the problem itself: place squares from a candidate side-length multiset into the grid by backtracking on the topmost-leftmost empty cell. If squares with the stated sides tile the grid, the search will find a placement. (The search also confirms that no -square multiset with sum of squares tiles the grid; this is implicit in the published exhaustive enumeration.)
N = 13
SIDES = [7, 6, 6, 4, 3, 3, 2, 2, 2, 1, 1] # 11 squares; sum of sq = 169
def first_empty(grid):
for r in range(N):
for c in range(N):
if grid[r][c] == 0: return r, c
return None
def can_place(grid, r, c, s):
if r + s > N or c + s > N: return False
return all(grid[i][j] == 0
for i in range(r, r+s) for j in range(c, c+s))
def place(grid, r, c, s, val):
for i in range(r, r+s):
for j in range(c, c+s):
grid[i][j] = val
def search(grid, avail):
cell = first_empty(grid)
if cell is None: return not avail
r, c = cell
tried = set()
for k, s in enumerate(avail):
if s in tried: continue
tried.add(s)
if can_place(grid, r, c, s):
place(grid, r, c, s, len(avail))
if search(grid, avail[:k] + avail[k+1:]): return True
place(grid, r, c, s, 0)
return False
grid = [[0]*N for _ in range(N)]
ok = search(grid, sorted(SIDES, reverse=True))
print("dissection found:" if ok else "no dissection")
for row in grid:
print(" ".join(f"{v:2d}" for v in row))
# dissection found:
# the grid is tiled by 11 squares; identical labels mark the same square.
The search finds a valid placement in a fraction of a second, confirming that squares suffice.
Riddler Classic
The bugle sounds, and horses move to the starting gate for the Lucky Derby. Each second, every horse takes a step exactly one metre long, forward or backward. The horses’ biases differ: Horse steps forward with probability , so Horse goes forward of the time, Horse of the time, on up to Horse at . Steps are independent across horses. The finish line is at metres. What are the odds that each horse wins?
The Riddler, FiveThirtyEight, May 5, 2017(original post)
Solution
Each horse is a one-dimensional asymmetric random walk. Horse has step mean so the expected speeds in metres per second are Horse moves at m/s on average, reaching m in steps. Horse moves at m/s on average, reaching m in steps. The race is a contest of who hits first, and the favourite filly is overwhelmingly ahead.
Tail bound for horse . The position of horse after steps has mean and variance . For the favourite at steps the mean is , the SD is . So horse is comfortably past by . For horse () at the same , mean position , SD ; horse still has a meaningful chance to be ahead.
A closed-form for each horse’s win probability would require the joint distribution of first-hitting times of a common boundary by asymmetric random walks, which has no clean expression. The accepted answer comes from Monte Carlo simulation; we encode the race directly and report empirical frequencies.
The computation
Encode the race: tick the clock, step every horse independently, and record the first to reach . If two horses cross the line on the same tick, break the tie uniformly. Average over many races to get the win probabilities.
import random
P = [0.50 + 0.02*k for k in range(1, 21)] # p_1..p_20
def race(rng):
pos = [0] * 20
while True:
for i in range(20):
pos[i] += 1 if rng.random() < P[i] else -1
winners = [i for i in range(20) if pos[i] >= 200]
if winners:
return rng.choice(winners)
rng = random.Random(0)
TRIALS = 20_000
counts = [0] * 20
for _ in range(TRIALS):
counts[race(rng)] += 1
for k, c in enumerate(counts):
if c:
print(f"horse {k+1:2d} (p={P[k]:.2f}): "
f"wins {c}/{TRIALS} = {100*c/TRIALS:.2f}%")
# horse 15 (p=0.80): wins 2/20000 = 0.01%
# horse 16 (p=0.82): wins 19/20000 = 0.10%
# horse 17 (p=0.84): wins 152/20000 = 0.76%
# horse 18 (p=0.86): wins 948/20000 = 4.74%
# horse 19 (p=0.88): wins 4290/20000 = 21.45%
# horse 20 (p=0.90): wins 14589/20000 = 72.94%
A typical -race run gives Horse around –, Horse around , Horse around , Horse around half a percent, and essentially nothing for any horse with index . (Horse ’s chance is roughly , far below sampling precision.)