Library · The Riddler · Chapter 88

When Will The Fall Colors Peak?

Revised Report an error

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×10−52 \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.24217 N−L∣|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 S∼U[0,1]S \sim \mathcal{U}[0,1] and ends at E∼U[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 1−t1−s\tfrac{1 - t}{1 - s}, so Pr⁡(S<t<E)=∫0t1−t1−s ds=−(1−t)ln⁡(1−t).\Pr(S < t < E) = \int_0^t \frac{1 - t}{1 - s}\,ds = -(1 - t)\ln(1 - t). Maximise over tt: with u=1−tu = 1 - t, this is −uln⁡u-u\ln u, whose derivative −ln⁡u−1-\ln u - 1 vanishes at u=1/eu = 1/e. The peak fraction is therefore −uln⁡u∣u=1/e=1e≈0.368.-u\ln u\Big|_{u = 1/e} = \frac{1}{e} \approx \boxed{0.368}. The colours peak when a fraction 1−1/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 −(1−t)ln⁡(1−t)-(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
Report an error on this page

Reports are stored by Netlify. See the privacy note.