Skip to content
Vamshi Jandhyala

Books · The Riddler

Chapter 88

When Will The Fall Colors Peak?

Riddler Express

A solar year is about 365.24217365.24217 days. The Gregorian calendar uses 9797 leap years per 400400, giving 365.2425365.2425. Find LL and NN (with N<400N < 400) so that LL leap years every NN years makes the average day-count as close as possible to 365.24217365.24217.

Solution

We want the leap fraction L/NL/N as close as possible to the fractional part 0.242170.24217, since the average year length is 365+L/N365 + L/N. Scanning every denominator NN below 400400 and choosing the best numerator LL, the closest is N=351,L=85,\boxed{N = 351,\quad L = 85}, giving 85351=0.2421652\tfrac{85}{351} = 0.2421652\ldots, off the target by under 2×1052 \times 10^{-5} of a day, a good deal sharper than the Gregorian 0.24250.2425.

The computation

For each N<400N < 400 pick the LL minimising 0.24217NL|0.24217\,N - L| and keep the best pair.

best = (1, None, None)
for n in range(1, 400):
    l = round(0.24217 * n)
    err = abs(0.24217 * n - l)
    if err < best[0]: best = (err, n, l)
print(best[1], best[2])                         # 351 85

Riddler Classic

Each tree starts changing colour at a uniformly random time between the equinox and the solstice, then drops its leaves at a uniformly random later time before the solstice. Across all trees, what is the largest fraction simultaneously in mid-change?

Solution

Scale the season to [0,1][0, 1]. A tree starts at SU[0,1]S \sim \mathcal{U}[0,1] and ends at EU[S,1]E \sim \mathcal{U}[S, 1], and it is mid-change at time tt when S<t<ES < t < E. The fraction of trees changing at tt is exactly Pr(S<t<E)\Pr(S < t < E). Conditioning on the start s<ts < t, the end exceeds tt with probability 1t1s\tfrac{1 - t}{1 - s}, so Pr(S<t<E)=0t1t1sds=(1t)ln(1t).\Pr(S < t < E) = \int_0^t \frac{1 - t}{1 - s}\,ds = -(1 - t)\ln(1 - t). Maximise over tt: with u=1tu = 1 - t, this is ulnu-u\ln u, whose derivative lnu1-\ln u - 1 vanishes at u=1/eu = 1/e. The peak fraction is therefore ulnuu=1/e=1e0.368.-u\ln u\Big|_{u = 1/e} = \frac{1}{e} \approx \boxed{0.368}. The colours peak when a fraction 11/e1 - 1/e of the season has passed, with just over a third of the trees changing at once.

The computation

Evaluate the changing-fraction (1t)ln(1t)-(1 - t)\ln(1 - t) across the season and take its maximum; a direct tree-by-tree simulation lands on the same value.

import numpy as np
t = np.linspace(1e-9, 1 - 1e-9, 1_000_000)
print((-(1 - t) * np.log(1 - t)).max(), 1 / np.e)   # 0.3679, 0.3679