Books · The Fiddler: Solutions
Chapter 17
Can Every Day Be First?
In , every day of the week falls on the first of some month at least once. Is special in this regard? If so, when is the next year in which one of the days of the week is not represented among the firsts of the months?
The Fiddler, Zach Wissner-Gross, February 27, 2026(original post)
Solution
It is not special at all: every year, common or leap, has all seven weekdays among its month-firsts, so the year asked for never arrives.
The weekday of each month’s first is fixed by the cumulative day-count since January , taken modulo . Those offsets do not depend on which weekday January happens to be; that only shifts every first by the same constant. For a common year the twelve offsets are whose set is : all seven residues. A leap year also covers all seven. Since the offsets already cover every residue, adding the constant for January still covers every weekday. So no year ever omits one:
The computation
Two checks. First, the month-first offsets modulo already hit all seven residues, in both a common and a leap year. Second, sweep eleven centuries of real calendars and confirm none omits a weekday among its twelve month-firsts.
import datetime
def residues(leap):
L = [31, 29 if leap else 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
off, s = 0, {0}
for d in L[:-1]:
off = (off + d) % 7; s.add(off)
return sorted(s)
print(residues(False), residues(True)) # both = [0,1,2,3,4,5,6]
miss = [y for y in range(1900, 3001)
if len({datetime.date(y, m, 1).weekday() for m in range(1, 13)}) < 7]
print(miss) # [] -> never
Extra Credit
Imagine instead a hypothetical calendar with twelve months, each of length to days, and a year totalling or days. What is the fewest days of the week that can appear as the first of a month?
Solution
The real calendar manages all seven by accident; choosing month lengths adversarially we can collapse that to three, and no fewer. A month’s length modulo is for days, so consecutive firsts advance by to weekdays. Lengths repeated (advances , summing to each cycle) send the firsts around , touching only three weekdays, while still totalling . An exhaustive search over all twelve-month length assignments confirms three is the minimum for both and :
The computation
Enumerate every assignment of extra days ( to per month, i.e. lengths to ) to the first eleven months, fix December so the year totals or , and track the set of weekday residues the firsts land on. The smallest such set has size three.
import numpy as np, itertools as it
E = np.array(list(it.product(range(4), repeat=11))) # extra days, months 1..11
P = np.cumsum(E, axis=1); R = P % 7; T11 = P[:, -1]
for year in (365, 366):
tgt = year - 12*28
ok = (T11 >= tgt - 3) & (T11 <= tgt) # December's extra in 0..3
mask = np.ones(ok.sum(), int) # residue 0 (January) always present
for c in range(11): mask |= (1 << R[ok][:, c])
print(year, min(bin(m).count("1") for m in mask)) # 365 3 ; 366 3