Chapter 23
Where Will The Seven Dwarfs Sleep Tonight?
Riddler Express
A kite is inscribed in a circle, with sides as shown. What is the kite’s area? And a rectangle is drawn inside a quarter circle, with the base split into and as shown. What is the rectangle’s area?

Solution
The kite. By symmetry the kite’s long diagonal runs from the top vertex to the bottom vertex, and it passes through the centre, so it is a diameter. Each of the two side vertices therefore sees that diameter at a right angle (an angle inscribed in a semicircle is ). The kite splits along the long diagonal into two right triangles, each with legs and , so
The rectangle. The base of the quarter circle is , which is its radius. The rectangle has width , and its far top corner lies on the arc, at distance from the centre. That corner sits above the point along the base, so its height is (a -- triangle). The rectangle is by , so
The computation
Confirm both with the Pythagorean relations they rest on.
from math import isclose, sqrt
print(2 * 0.5 * 5 * 8) # kite: two right triangles -> 40
h = sqrt(13**2 - 5**2) # rectangle height on the arc
print(h, 5 * h) # 12.0, 60.0
Riddler Classic
Each of seven dwarfs sleeps in his own bed in a shared dormitory. They retire one at a time in a fixed order, youngest first and oldest last. Tonight the youngest, feeling jolly, ignores his own bed and picks one at random from the other six. Each later dwarf takes his own bed if it is free, and otherwise picks an unoccupied bed at random. What is the probability the oldest dwarf sleeps in his own bed? And what is the expected number of dwarfs not in their own beds?
Solution
The oldest dwarf. Whenever a dwarf finds his bed taken he picks at random, and the chain of displacements ends as soon as someone takes either the youngest’s vacated bed (after which everyone left is fine) or the oldest’s bed (leaving the oldest stranded). Track the youngest’s opening choice among the six other beds:
with probability he takes the oldest’s bed directly, and the oldest is displaced;
with probability he takes a middle dwarf’s bed, and that dwarf becomes the next random chooser facing the standard version of this problem, in which the youngest’s and oldest’s beds are filled in a random order, so the oldest keeps his bed with probability .
Hence In general, for dwarfs this is .
Displaced dwarfs. The youngest is always in the wrong bed, and the displacement chain pushes a random number of others out of theirs. Carrying the exact probabilities through the seven retirements (a short computation) gives an expected dwarfs not in their own beds.
The computation
Send the dwarfs to bed in order: the youngest picks a random non-own bed, each later dwarf takes his own bed if free and otherwise a random free one. Tally how often the oldest keeps his bed and how many dwarfs end up displaced.
import numpy as np
rng = np.random.default_rng(0)
n, runs = 7, 2_000_000
oldest_own = 0; displaced = 0
for _ in range(runs):
free = set(range(n))
b = rng.integers(1, n); free.discard(b); wrong = 1 # youngest avoids bed 0
for d in range(1, n - 1):
if d in free:
free.discard(d) # own bed free
else:
wrong += 1; b = rng.choice(list(free)); free.discard(b)
if (n - 1) in free:
oldest_own += 1 # oldest's bed survived
else:
wrong += 1
displaced += wrong
print(oldest_own / runs) # ~0.4167 = 5/12
print(displaced / runs) # ~2.858 = 343/120