# Where Will The Seven Dwarfs Sleep Tonight?

A FiveThirtyEight Riddler puzzle.
mathematics
Riddler
Published

January 5, 2018

## Riddler Express

A kite shape is inscribed in a circle, as shown below.

What is the kite’s area?

A rectangle is drawn inside a quarter circle, as shown below.

What is the rectangle’s area?

## Solution

The longer diagonal of the kite is the diameter of the circle because of symmetry. Therefore, one half of a kite is a right angled triangle. The area of the kite is $$40$$}.

The diagonal of the rectangle is equal to the radius of the quadrant = $$13$$. The length of the rectangle is $$12$$ by Pythagoras theorem. Therefor the area of the rectangle is $$60$$.

## Riddler Classic

Each of the seven dwarfs sleeps in his own bed in a shared dormitory. Every night, they retire to bed one at a time, always in the same sequential order, with the youngest dwarf retiring first and the oldest retiring last. On a particular evening, the youngest dwarf is in a jolly mood. He decides not to go to his own bed but rather to choose one at random from among the other six beds. As each of the other dwarfs retires, he chooses his own bed if it is not occupied, and otherwise chooses another unoccupied bed at random.

What is the probability that the oldest dwarf sleeps in his own bed? What is the expected number of dwarfs who do not sleep in their own beds?

## Solution

from random import sample

runs = 100000
num_dwarfs = 7
cnt_last_wrong_bed = 0
cnt_wrong_beds = 0
for _ in range(runs):
num_wrong_beds = 1
remaining_beds = set(range(num_dwarfs))
b = sample(range(1, num_dwarfs), 1)[0]
for i in range(1, num_dwarfs-1):
if i in remaining_beds:
else:
num_wrong_beds += 1
b = sample(remaining_beds, 1)[0]
print("Chance of oldest in own bed: ", 1 - cnt_last_wrong_bed/runs)
Expected number of wrong beds: $$2.86$$. Chance of oldest in own bed: $$0.4168$$.