Skip to content
Vamshi Jandhyala

Books · The Riddler

Chapter 23

Where Will The Seven Dwarfs Sleep Tonight?

Riddler Express

A kite is inscribed in a circle, with sides 5,5,8,85,5,8,8 as shown. What is the kite’s area? And a rectangle is drawn inside a quarter circle, with the base split into 55 and 88 as shown. What is the rectangle’s area?

image image

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 9090^\circ). The kite splits along the long diagonal into two right triangles, each with legs 55 and 88, so area=21258=40.\text{area} = 2\cdot\tfrac12\cdot 5 \cdot 8 = \boxed{40}.

The rectangle. The base of the quarter circle is 5+8=135+8 = 13, which is its radius. The rectangle has width 55, and its far top corner lies on the arc, at distance 1313 from the centre. That corner sits above the point 55 along the base, so its height is 13252=144=12\sqrt{13^2 - 5^2} = \sqrt{144} = 12 (a 55-1212-1313 triangle). The rectangle is 55 by 1212, so area=512=60.\text{area} = 5 \cdot 12 = \boxed{60}.

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 16\tfrac16 he takes the oldest’s bed directly, and the oldest is displaced;

  • with probability 56\tfrac{5}{6} 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 12\tfrac12.

Hence Pr(oldest in own bed)=160+5612=5120.417.\Pr(\text{oldest in own bed}) = \tfrac16\cdot 0 + \tfrac56\cdot\tfrac12 = \boxed{\tfrac{5}{12}} \approx 0.417. In general, for nn dwarfs this is (n2)/(2(n1))(n-2)/\big(2(n-1)\big).

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 3431202.86\boxed{\tfrac{343}{120}} \approx 2.86 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