FA-77671 / Legal deadline computation / Open access
Court holiday calendar with observed dates: next new year · case 01
When next New Year falls on Saturday, December 31 is missing from the calendar.
ROOT CAUSE
The December 31 observance is tied to a Sunday New Year.
VERIFIED REPAIR
At the next new year decision use `nxt.weekday() == 5`, leaving the other decision sites of the model unchanged.
Unsuccessful approach: The partial repair `nxt.weekday() >= 5` also adds December 31 for a Sunday New Year, which is observed on January 2.
Case contract
Stipulated court holidays for a year: new-year (Jan 1), mlk (3rd Monday Jan), memorial (last Monday May), juneteenth (Jun 19), independence (Jul 4), labor (1st Monday Sep), thanksgiving (4th Thursday Nov), day-after-thanksgiving, christmas (Dec 25). Fixed-date holidays on Saturday are observed the Friday before and on Sunday the Monday after. When next year's January 1 is a Saturday, a new-year-observed entry falls on December 31 of this year; an observed date that falls in another year is not part of this year's calendar. Return [[name, date]] sorted by date.
Why this case matters
Docketing systems compute filing and response deadlines from trigger events; a wrong date can forfeit a right.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(year):
def nth(month, wd, n):
first = dt.date(year, month, 1)
return first + dt.timedelta(days=(wd - first.weekday()) % 7 + 7 * (n - 1))
def last(month, wd):
lastd = dt.date(year, month, calendar.monthrange(year, month)[1])
return lastd - dt.timedelta(days=(lastd.weekday() - wd) % 7)
def observed(d):
return d - dt.timedelta(days=1) if d.weekday() == 5 else d + dt.timedelta(days=1) if d.weekday() == 6 else d
thanks = nth(11, 3, 4)
rows = [['new-year', observed(dt.date(year, 1, 1))], ['mlk', nth(1, 0, 3)], ['memorial', last(5, 0)],
['juneteenth', observed(dt.date(year, 6, 19))], ['independence', observed(dt.date(year, 7, 4))],
['labor', nth(9, 0, 1)], ['thanksgiving', thanks], ['day-after-thanksgiving', thanks + dt.timedelta(days=1)],
['christmas', observed(dt.date(year, 12, 25))]]
nxt = dt.date(year + 1, 1, 1)
if nxt.weekday() == 6:
rows.append(['new-year-observed', nxt - dt.timedelta(days=1)])
rows = [r for r in rows if r[1].year == year]
return [[name, d.isoformat()] for name, d in sorted(rows, key=lambda r: r[1])]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: 2022 new year on saturday',
[2022],
[['mlk', '2022-01-17'],
['memorial', '2022-05-30'],
['juneteenth', '2022-06-20'],
['independence', '2022-07-04'],
['labor', '2022-09-05'],
['thanksgiving', '2022-11-24'],
['day-after-thanksgiving', '2022-11-25'],
['christmas', '2022-12-26']]),
('2021 next new year saturday',
[2021],
[['new-year', '2021-01-01'],
['mlk', '2021-01-18'],
['memorial', '2021-05-31'],
['juneteenth', '2021-06-18'],
['independence', '2021-07-05'],
['labor', '2021-09-06'],
['thanksgiving', '2021-11-25'],
['day-after-thanksgiving', '2021-11-26'],
['christmas', '2021-12-24'],
['new-year-observed', '2021-12-31']]),
('2024 leap',
[2024],
[['new-year', '2024-01-01'],
['mlk', '2024-01-15'],
['memorial', '2024-05-27'],
['juneteenth', '2024-06-19'],
['independence', '2024-07-04'],
['labor', '2024-09-02'],
['thanksgiving', '2024-11-28'],
['day-after-thanksgiving', '2024-11-29'],
['christmas', '2024-12-25']]),
('2019 november starts friday',
[2019],
[['new-year', '2019-01-01'],
['mlk', '2019-01-21'],
['memorial', '2019-05-27'],
['juneteenth', '2019-06-19'],
['independence', '2019-07-04'],
['labor', '2019-09-02'],
['thanksgiving', '2019-11-28'],
['day-after-thanksgiving', '2019-11-29'],
['christmas', '2019-12-25']]),
('2020 july 4 saturday',
[2020],
[['new-year', '2020-01-01'],
['mlk', '2020-01-20'],
['memorial', '2020-05-25'],
['juneteenth', '2020-06-19'],
['independence', '2020-07-03'],
['labor', '2020-09-07'],
['thanksgiving', '2020-11-26'],
['day-after-thanksgiving', '2020-11-27'],
['christmas', '2020-12-25']]),
('2016 next new year sunday',
[2016],
[['new-year', '2016-01-01'],
['mlk', '2016-01-18'],
['memorial', '2016-05-30'],
['juneteenth', '2016-06-20'],
['independence', '2016-07-04'],
['labor', '2016-09-05'],
['thanksgiving', '2016-11-24'],
['day-after-thanksgiving', '2016-11-25'],
['christmas', '2016-12-26']]),
('2027 five mondays may',
[2027],
[['new-year', '2027-01-01'],
['mlk', '2027-01-18'],
['memorial', '2027-05-31'],
['juneteenth', '2027-06-18'],
['independence', '2027-07-05'],
['labor', '2027-09-06'],
['thanksgiving', '2027-11-25'],
['day-after-thanksgiving', '2027-11-26'],
['christmas', '2027-12-24'],
['new-year-observed', '2027-12-31']])],
[('2024 leap',
[2024],
[['new-year', '2024-01-01'],
['mlk', '2024-01-15'],
['memorial', '2024-05-27'],
['juneteenth', '2024-06-19'],
['independence', '2024-07-04'],
['labor', '2024-09-02'],
['thanksgiving', '2024-11-28'],
['day-after-thanksgiving', '2024-11-29'],
['christmas', '2024-12-25']]),
('2019 november starts friday',
[2019],
[['new-year', '2019-01-01'],
['mlk', '2019-01-21'],
['memorial', '2019-05-27'],
['juneteenth', '2019-06-19'],
['independence', '2019-07-04'],
['labor', '2019-09-02'],
['thanksgiving', '2019-11-28'],
['day-after-thanksgiving', '2019-11-29'],
['christmas', '2019-12-25']]),
('2020 july 4 saturday',
[2020],
[['new-year', '2020-01-01'],
['mlk', '2020-01-20'],
['memorial', '2020-05-25'],
['juneteenth', '2020-06-19'],
['independence', '2020-07-03'],
['labor', '2020-09-07'],
['thanksgiving', '2020-11-26'],
['day-after-thanksgiving', '2020-11-27'],
['christmas', '2020-12-25']]),
('2016 next new year sunday',
[2016],
[['new-year', '2016-01-01'],
['mlk', '2016-01-18'],
['memorial', '2016-05-30'],
['juneteenth', '2016-06-20'],
['independence', '2016-07-04'],
['labor', '2016-09-05'],
['thanksgiving', '2016-11-24'],
['day-after-thanksgiving', '2016-11-25'],
['christmas', '2016-12-26']]),
('2027 five mondays may',
[2027],
[['new-year', '2027-01-01'],
['mlk', '2027-01-18'],
['memorial', '2027-05-31'],
['juneteenth', '2027-06-18'],
['independence', '2027-07-05'],
['labor', '2027-09-06'],
['thanksgiving', '2027-11-25'],
['day-after-thanksgiving', '2027-11-26'],
['christmas', '2027-12-24'],
['new-year-observed', '2027-12-31']]),
('2023',
[2023],
[['new-year', '2023-01-02'],
['mlk', '2023-01-16'],
['memorial', '2023-05-29'],
['juneteenth', '2023-06-19'],
['independence', '2023-07-04'],
['labor', '2023-09-04'],
['thanksgiving', '2023-11-23'],
['day-after-thanksgiving', '2023-11-24'],
['christmas', '2023-12-25']]),
('2030',
[2030],
[['new-year', '2030-01-01'],
['mlk', '2030-01-21'],
['memorial', '2030-05-27'],
['juneteenth', '2030-06-19'],
['independence', '2030-07-04'],
['labor', '2030-09-02'],
['thanksgiving', '2030-11-28'],
['day-after-thanksgiving', '2030-11-29'],
['christmas', '2030-12-25']])],
[('2020 july 4 saturday',
[2020],
[['new-year', '2020-01-01'],
['mlk', '2020-01-20'],
['memorial', '2020-05-25'],
['juneteenth', '2020-06-19'],
['independence', '2020-07-03'],
['labor', '2020-09-07'],
['thanksgiving', '2020-11-26'],
['day-after-thanksgiving', '2020-11-27'],
['christmas', '2020-12-25']]),
('2016 next new year sunday',
[2016],
[['new-year', '2016-01-01'],
['mlk', '2016-01-18'],
['memorial', '2016-05-30'],
['juneteenth', '2016-06-20'],
['independence', '2016-07-04'],
['labor', '2016-09-05'],
['thanksgiving', '2016-11-24'],
['day-after-thanksgiving', '2016-11-25'],
['christmas', '2016-12-26']]),
('2027 five mondays may',
[2027],
[['new-year', '2027-01-01'],
['mlk', '2027-01-18'],
['memorial', '2027-05-31'],
['juneteenth', '2027-06-18'],
['independence', '2027-07-05'],
['labor', '2027-09-06'],
['thanksgiving', '2027-11-25'],
['day-after-thanksgiving', '2027-11-26'],
['christmas', '2027-12-24'],
['new-year-observed', '2027-12-31']]),
('2023',
[2023],
[['new-year', '2023-01-02'],
['mlk', '2023-01-16'],
['memorial', '2023-05-29'],
['juneteenth', '2023-06-19'],
['independence', '2023-07-04'],
['labor', '2023-09-04'],
['thanksgiving', '2023-11-23'],
['day-after-thanksgiving', '2023-11-24'],
['christmas', '2023-12-25']]),
('2030',
[2030],
[['new-year', '2030-01-01'],
['mlk', '2030-01-21'],
['memorial', '2030-05-27'],
['juneteenth', '2030-06-19'],
['independence', '2030-07-04'],
['labor', '2030-09-02'],
['thanksgiving', '2030-11-28'],
['day-after-thanksgiving', '2030-11-29'],
['christmas', '2030-12-25']]),
('2032 leap',
[2032],
[['new-year', '2032-01-01'],
['mlk', '2032-01-19'],
['memorial', '2032-05-31'],
['juneteenth', '2032-06-18'],
['independence', '2032-07-05'],
['labor', '2032-09-06'],
['thanksgiving', '2032-11-25'],
['day-after-thanksgiving', '2032-11-26'],
['christmas', '2032-12-24'],
['new-year-observed', '2032-12-31']]),
('2033 new year saturday',
[2033],
[['mlk', '2033-01-17'],
['memorial', '2033-05-30'],
['juneteenth', '2033-06-20'],
['independence', '2033-07-04'],
['labor', '2033-09-05'],
['thanksgiving', '2033-11-24'],
['day-after-thanksgiving', '2033-11-25'],
['christmas', '2033-12-26']])],
[('2027 five mondays may',
[2027],
[['new-year', '2027-01-01'],
['mlk', '2027-01-18'],
['memorial', '2027-05-31'],
['juneteenth', '2027-06-18'],
['independence', '2027-07-05'],
['labor', '2027-09-06'],
['thanksgiving', '2027-11-25'],
['day-after-thanksgiving', '2027-11-26'],
['christmas', '2027-12-24'],
['new-year-observed', '2027-12-31']]),
('2023',
[2023],
[['new-year', '2023-01-02'],
['mlk', '2023-01-16'],
['memorial', '2023-05-29'],
['juneteenth', '2023-06-19'],
['independence', '2023-07-04'],
['labor', '2023-09-04'],
['thanksgiving', '2023-11-23'],
['day-after-thanksgiving', '2023-11-24'],
['christmas', '2023-12-25']]),
('2030',
[2030],
[['new-year', '2030-01-01'],
['mlk', '2030-01-21'],
['memorial', '2030-05-27'],
['juneteenth', '2030-06-19'],
['independence', '2030-07-04'],
['labor', '2030-09-02'],
['thanksgiving', '2030-11-28'],
['day-after-thanksgiving', '2030-11-29'],
['christmas', '2030-12-25']]),
('2032 leap',
[2032],
[['new-year', '2032-01-01'],
['mlk', '2032-01-19'],
['memorial', '2032-05-31'],
['juneteenth', '2032-06-18'],
['independence', '2032-07-05'],
['labor', '2032-09-06'],
['thanksgiving', '2032-11-25'],
['day-after-thanksgiving', '2032-11-26'],
['christmas', '2032-12-24'],
['new-year-observed', '2032-12-31']]),
('2033 new year saturday',
[2033],
[['mlk', '2033-01-17'],
['memorial', '2033-05-30'],
['juneteenth', '2033-06-20'],
['independence', '2033-07-04'],
['labor', '2033-09-05'],
['thanksgiving', '2033-11-24'],
['day-after-thanksgiving', '2033-11-25'],
['christmas', '2033-12-26']]),
('regression: 2022 new year on saturday',
[2022],
[['mlk', '2022-01-17'],
['memorial', '2022-05-30'],
['juneteenth', '2022-06-20'],
['independence', '2022-07-04'],
['labor', '2022-09-05'],
['thanksgiving', '2022-11-24'],
['day-after-thanksgiving', '2022-11-25'],
['christmas', '2022-12-26']]),
('2021 next new year saturday',
[2021],
[['new-year', '2021-01-01'],
['mlk', '2021-01-18'],
['memorial', '2021-05-31'],
['juneteenth', '2021-06-18'],
['independence', '2021-07-05'],
['labor', '2021-09-06'],
['thanksgiving', '2021-11-25'],
['day-after-thanksgiving', '2021-11-26'],
['christmas', '2021-12-24'],
['new-year-observed', '2021-12-31']])],
[('2030',
[2030],
[['new-year', '2030-01-01'],
['mlk', '2030-01-21'],
['memorial', '2030-05-27'],
['juneteenth', '2030-06-19'],
['independence', '2030-07-04'],
['labor', '2030-09-02'],
['thanksgiving', '2030-11-28'],
['day-after-thanksgiving', '2030-11-29'],
['christmas', '2030-12-25']]),
('2032 leap',
[2032],
[['new-year', '2032-01-01'],
['mlk', '2032-01-19'],
['memorial', '2032-05-31'],
['juneteenth', '2032-06-18'],
['independence', '2032-07-05'],
['labor', '2032-09-06'],
['thanksgiving', '2032-11-25'],
['day-after-thanksgiving', '2032-11-26'],
['christmas', '2032-12-24'],
['new-year-observed', '2032-12-31']]),
('2033 new year saturday',
[2033],
[['mlk', '2033-01-17'],
['memorial', '2033-05-30'],
['juneteenth', '2033-06-20'],
['independence', '2033-07-04'],
['labor', '2033-09-05'],
['thanksgiving', '2033-11-24'],
['day-after-thanksgiving', '2033-11-25'],
['christmas', '2033-12-26']]),
('regression: 2022 new year on saturday',
[2022],
[['mlk', '2022-01-17'],
['memorial', '2022-05-30'],
['juneteenth', '2022-06-20'],
['independence', '2022-07-04'],
['labor', '2022-09-05'],
['thanksgiving', '2022-11-24'],
['day-after-thanksgiving', '2022-11-25'],
['christmas', '2022-12-26']]),
('2021 next new year saturday',
[2021],
[['new-year', '2021-01-01'],
['mlk', '2021-01-18'],
['memorial', '2021-05-31'],
['juneteenth', '2021-06-18'],
['independence', '2021-07-05'],
['labor', '2021-09-06'],
['thanksgiving', '2021-11-25'],
['day-after-thanksgiving', '2021-11-26'],
['christmas', '2021-12-24'],
['new-year-observed', '2021-12-31']]),
('2024 leap',
[2024],
[['new-year', '2024-01-01'],
['mlk', '2024-01-15'],
['memorial', '2024-05-27'],
['juneteenth', '2024-06-19'],
['independence', '2024-07-04'],
['labor', '2024-09-02'],
['thanksgiving', '2024-11-28'],
['day-after-thanksgiving', '2024-11-29'],
['christmas', '2024-12-25']]),
('2019 november starts friday',
[2019],
[['new-year', '2019-01-01'],
['mlk', '2019-01-21'],
['memorial', '2019-05-27'],
['juneteenth', '2019-06-19'],
['independence', '2019-07-04'],
['labor', '2019-09-02'],
['thanksgiving', '2019-11-28'],
['day-after-thanksgiving', '2019-11-29'],
['christmas', '2019-12-25']])]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: 2022 new year on saturday | [['mlk', '2022-01-17'], ['memorial', '2022-05-30'], ['juneteenth', '2022-06-20'], ['independence', '2022-07-04'], ['labor', '2022-09-05'], ['thanksgiving', '2022-11-24'], ['day-after-thanksgiving', '2022-11-25'], ['christmas', '2022-12-26'], ['new-year-observed', '2022-12-31']] | [['mlk', '2022-01-17'], ['memorial', '2022-05-30'], ['juneteenth', '2022-06-20'], ['independence', '2022-07-04'], ['labor', '2022-09-05'], ['thanksgiving', '2022-11-24'], ['day-after-thanksgiving', '2022-11-25'], ['christmas', '2022-12-26']] | Failed |
| 2021 next new year saturday | [['new-year', '2021-01-01'], ['mlk', '2021-01-18'], ['memorial', '2021-05-31'], ['juneteenth', '2021-06-18'], ['independence', '2021-07-05'], ['labor', '2021-09-06'], ['thanksgiving', '2021-11-25'], ['day-after-thanksgiving', '2021-11-26'], ['christmas', '2021-12-24']] | [['new-year', '2021-01-01'], ['mlk', '2021-01-18'], ['memorial', '2021-05-31'], ['juneteenth', '2021-06-18'], ['independence', '2021-07-05'], ['labor', '2021-09-06'], ['thanksgiving', '2021-11-25'], ['day-after-thanksgiving', '2021-11-26'], ['christmas', '2021-12-24'], ['new-year-observed', '2021-12-31']] | Failed |
| 2024 leap | [['new-year', '2024-01-01'], ['mlk', '2024-01-15'], ['memorial', '2024-05-27'], ['juneteenth', '2024-06-19'], ['independence', '2024-07-04'], ['labor', '2024-09-02'], ['thanksgiving', '2024-11-28'], ['day-after-thanksgiving', '2024-11-29'], ['christmas', '2024-12-25']] | [['new-year', '2024-01-01'], ['mlk', '2024-01-15'], ['memorial', '2024-05-27'], ['juneteenth', '2024-06-19'], ['independence', '2024-07-04'], ['labor', '2024-09-02'], ['thanksgiving', '2024-11-28'], ['day-after-thanksgiving', '2024-11-29'], ['christmas', '2024-12-25']] | Passed |
| 2019 november starts friday | [['new-year', '2019-01-01'], ['mlk', '2019-01-21'], ['memorial', '2019-05-27'], ['juneteenth', '2019-06-19'], ['independence', '2019-07-04'], ['labor', '2019-09-02'], ['thanksgiving', '2019-11-28'], ['day-after-thanksgiving', '2019-11-29'], ['christmas', '2019-12-25']] | [['new-year', '2019-01-01'], ['mlk', '2019-01-21'], ['memorial', '2019-05-27'], ['juneteenth', '2019-06-19'], ['independence', '2019-07-04'], ['labor', '2019-09-02'], ['thanksgiving', '2019-11-28'], ['day-after-thanksgiving', '2019-11-29'], ['christmas', '2019-12-25']] | Passed |
| 2020 july 4 saturday | [['new-year', '2020-01-01'], ['mlk', '2020-01-20'], ['memorial', '2020-05-25'], ['juneteenth', '2020-06-19'], ['independence', '2020-07-03'], ['labor', '2020-09-07'], ['thanksgiving', '2020-11-26'], ['day-after-thanksgiving', '2020-11-27'], ['christmas', '2020-12-25']] | [['new-year', '2020-01-01'], ['mlk', '2020-01-20'], ['memorial', '2020-05-25'], ['juneteenth', '2020-06-19'], ['independence', '2020-07-03'], ['labor', '2020-09-07'], ['thanksgiving', '2020-11-26'], ['day-after-thanksgiving', '2020-11-27'], ['christmas', '2020-12-25']] | Passed |
| 2016 next new year sunday | [['new-year', '2016-01-01'], ['mlk', '2016-01-18'], ['memorial', '2016-05-30'], ['juneteenth', '2016-06-20'], ['independence', '2016-07-04'], ['labor', '2016-09-05'], ['thanksgiving', '2016-11-24'], ['day-after-thanksgiving', '2016-11-25'], ['christmas', '2016-12-26'], ['new-year-observed', '2016-12-31']] | [['new-year', '2016-01-01'], ['mlk', '2016-01-18'], ['memorial', '2016-05-30'], ['juneteenth', '2016-06-20'], ['independence', '2016-07-04'], ['labor', '2016-09-05'], ['thanksgiving', '2016-11-24'], ['day-after-thanksgiving', '2016-11-25'], ['christmas', '2016-12-26']] | Failed |
| 2027 five mondays may | [['new-year', '2027-01-01'], ['mlk', '2027-01-18'], ['memorial', '2027-05-31'], ['juneteenth', '2027-06-18'], ['independence', '2027-07-05'], ['labor', '2027-09-06'], ['thanksgiving', '2027-11-25'], ['day-after-thanksgiving', '2027-11-26'], ['christmas', '2027-12-24']] | [['new-year', '2027-01-01'], ['mlk', '2027-01-18'], ['memorial', '2027-05-31'], ['juneteenth', '2027-06-18'], ['independence', '2027-07-05'], ['labor', '2027-09-06'], ['thanksgiving', '2027-11-25'], ['day-after-thanksgiving', '2027-11-26'], ['christmas', '2027-12-24'], ['new-year-observed', '2027-12-31']] | Failed |
SHA-256 / 7704219347cf75ac69ba9e06d1afc91706eb560bed5a56b28ad0969f47d09046
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(year):
def nth(month, wd, n):
first = dt.date(year, month, 1)
return first + dt.timedelta(days=(wd - first.weekday()) % 7 + 7 * (n - 1))
def last(month, wd):
lastd = dt.date(year, month, calendar.monthrange(year, month)[1])
return lastd - dt.timedelta(days=(lastd.weekday() - wd) % 7)
def observed(d):
return d - dt.timedelta(days=1) if d.weekday() == 5 else d + dt.timedelta(days=1) if d.weekday() == 6 else d
thanks = nth(11, 3, 4)
rows = [['new-year', observed(dt.date(year, 1, 1))], ['mlk', nth(1, 0, 3)], ['memorial', last(5, 0)],
['juneteenth', observed(dt.date(year, 6, 19))], ['independence', observed(dt.date(year, 7, 4))],
['labor', nth(9, 0, 1)], ['thanksgiving', thanks], ['day-after-thanksgiving', thanks + dt.timedelta(days=1)],
['christmas', observed(dt.date(year, 12, 25))]]
nxt = dt.date(year + 1, 1, 1)
if nxt.weekday() >= 5:
rows.append(['new-year-observed', nxt - dt.timedelta(days=1)])
rows = [r for r in rows if r[1].year == year]
return [[name, d.isoformat()] for name, d in sorted(rows, key=lambda r: r[1])]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: 2022 new year on saturday',
[2022],
[['mlk', '2022-01-17'],
['memorial', '2022-05-30'],
['juneteenth', '2022-06-20'],
['independence', '2022-07-04'],
['labor', '2022-09-05'],
['thanksgiving', '2022-11-24'],
['day-after-thanksgiving', '2022-11-25'],
['christmas', '2022-12-26']]),
('2021 next new year saturday',
[2021],
[['new-year', '2021-01-01'],
['mlk', '2021-01-18'],
['memorial', '2021-05-31'],
['juneteenth', '2021-06-18'],
['independence', '2021-07-05'],
['labor', '2021-09-06'],
['thanksgiving', '2021-11-25'],
['day-after-thanksgiving', '2021-11-26'],
['christmas', '2021-12-24'],
['new-year-observed', '2021-12-31']]),
('2024 leap',
[2024],
[['new-year', '2024-01-01'],
['mlk', '2024-01-15'],
['memorial', '2024-05-27'],
['juneteenth', '2024-06-19'],
['independence', '2024-07-04'],
['labor', '2024-09-02'],
['thanksgiving', '2024-11-28'],
['day-after-thanksgiving', '2024-11-29'],
['christmas', '2024-12-25']]),
('2019 november starts friday',
[2019],
[['new-year', '2019-01-01'],
['mlk', '2019-01-21'],
['memorial', '2019-05-27'],
['juneteenth', '2019-06-19'],
['independence', '2019-07-04'],
['labor', '2019-09-02'],
['thanksgiving', '2019-11-28'],
['day-after-thanksgiving', '2019-11-29'],
['christmas', '2019-12-25']]),
('2020 july 4 saturday',
[2020],
[['new-year', '2020-01-01'],
['mlk', '2020-01-20'],
['memorial', '2020-05-25'],
['juneteenth', '2020-06-19'],
['independence', '2020-07-03'],
['labor', '2020-09-07'],
['thanksgiving', '2020-11-26'],
['day-after-thanksgiving', '2020-11-27'],
['christmas', '2020-12-25']]),
('2016 next new year sunday',
[2016],
[['new-year', '2016-01-01'],
['mlk', '2016-01-18'],
['memorial', '2016-05-30'],
['juneteenth', '2016-06-20'],
['independence', '2016-07-04'],
['labor', '2016-09-05'],
['thanksgiving', '2016-11-24'],
['day-after-thanksgiving', '2016-11-25'],
['christmas', '2016-12-26']]),
('2027 five mondays may',
[2027],
[['new-year', '2027-01-01'],
['mlk', '2027-01-18'],
['memorial', '2027-05-31'],
['juneteenth', '2027-06-18'],
['independence', '2027-07-05'],
['labor', '2027-09-06'],
['thanksgiving', '2027-11-25'],
['day-after-thanksgiving', '2027-11-26'],
['christmas', '2027-12-24'],
['new-year-observed', '2027-12-31']])],
[('2024 leap',
[2024],
[['new-year', '2024-01-01'],
['mlk', '2024-01-15'],
['memorial', '2024-05-27'],
['juneteenth', '2024-06-19'],
['independence', '2024-07-04'],
['labor', '2024-09-02'],
['thanksgiving', '2024-11-28'],
['day-after-thanksgiving', '2024-11-29'],
['christmas', '2024-12-25']]),
('2019 november starts friday',
[2019],
[['new-year', '2019-01-01'],
['mlk', '2019-01-21'],
['memorial', '2019-05-27'],
['juneteenth', '2019-06-19'],
['independence', '2019-07-04'],
['labor', '2019-09-02'],
['thanksgiving', '2019-11-28'],
['day-after-thanksgiving', '2019-11-29'],
['christmas', '2019-12-25']]),
('2020 july 4 saturday',
[2020],
[['new-year', '2020-01-01'],
['mlk', '2020-01-20'],
['memorial', '2020-05-25'],
['juneteenth', '2020-06-19'],
['independence', '2020-07-03'],
['labor', '2020-09-07'],
['thanksgiving', '2020-11-26'],
['day-after-thanksgiving', '2020-11-27'],
['christmas', '2020-12-25']]),
('2016 next new year sunday',
[2016],
[['new-year', '2016-01-01'],
['mlk', '2016-01-18'],
['memorial', '2016-05-30'],
['juneteenth', '2016-06-20'],
['independence', '2016-07-04'],
['labor', '2016-09-05'],
['thanksgiving', '2016-11-24'],
['day-after-thanksgiving', '2016-11-25'],
['christmas', '2016-12-26']]),
('2027 five mondays may',
[2027],
[['new-year', '2027-01-01'],
['mlk', '2027-01-18'],
['memorial', '2027-05-31'],
['juneteenth', '2027-06-18'],
['independence', '2027-07-05'],
['labor', '2027-09-06'],
['thanksgiving', '2027-11-25'],
['day-after-thanksgiving', '2027-11-26'],
['christmas', '2027-12-24'],
['new-year-observed', '2027-12-31']]),
('2023',
[2023],
[['new-year', '2023-01-02'],
['mlk', '2023-01-16'],
['memorial', '2023-05-29'],
['juneteenth', '2023-06-19'],
['independence', '2023-07-04'],
['labor', '2023-09-04'],
['thanksgiving', '2023-11-23'],
['day-after-thanksgiving', '2023-11-24'],
['christmas', '2023-12-25']]),
('2030',
[2030],
[['new-year', '2030-01-01'],
['mlk', '2030-01-21'],
['memorial', '2030-05-27'],
['juneteenth', '2030-06-19'],
['independence', '2030-07-04'],
['labor', '2030-09-02'],
['thanksgiving', '2030-11-28'],
['day-after-thanksgiving', '2030-11-29'],
['christmas', '2030-12-25']])],
[('2020 july 4 saturday',
[2020],
[['new-year', '2020-01-01'],
['mlk', '2020-01-20'],
['memorial', '2020-05-25'],
['juneteenth', '2020-06-19'],
['independence', '2020-07-03'],
['labor', '2020-09-07'],
['thanksgiving', '2020-11-26'],
['day-after-thanksgiving', '2020-11-27'],
['christmas', '2020-12-25']]),
('2016 next new year sunday',
[2016],
[['new-year', '2016-01-01'],
['mlk', '2016-01-18'],
['memorial', '2016-05-30'],
['juneteenth', '2016-06-20'],
['independence', '2016-07-04'],
['labor', '2016-09-05'],
['thanksgiving', '2016-11-24'],
['day-after-thanksgiving', '2016-11-25'],
['christmas', '2016-12-26']]),
('2027 five mondays may',
[2027],
[['new-year', '2027-01-01'],
['mlk', '2027-01-18'],
['memorial', '2027-05-31'],
['juneteenth', '2027-06-18'],
['independence', '2027-07-05'],
['labor', '2027-09-06'],
['thanksgiving', '2027-11-25'],
['day-after-thanksgiving', '2027-11-26'],
['christmas', '2027-12-24'],
['new-year-observed', '2027-12-31']]),
('2023',
[2023],
[['new-year', '2023-01-02'],
['mlk', '2023-01-16'],
['memorial', '2023-05-29'],
['juneteenth', '2023-06-19'],
['independence', '2023-07-04'],
['labor', '2023-09-04'],
['thanksgiving', '2023-11-23'],
['day-after-thanksgiving', '2023-11-24'],
['christmas', '2023-12-25']]),
('2030',
[2030],
[['new-year', '2030-01-01'],
['mlk', '2030-01-21'],
['memorial', '2030-05-27'],
['juneteenth', '2030-06-19'],
['independence', '2030-07-04'],
['labor', '2030-09-02'],
['thanksgiving', '2030-11-28'],
['day-after-thanksgiving', '2030-11-29'],
['christmas', '2030-12-25']]),
('2032 leap',
[2032],
[['new-year', '2032-01-01'],
['mlk', '2032-01-19'],
['memorial', '2032-05-31'],
['juneteenth', '2032-06-18'],
['independence', '2032-07-05'],
['labor', '2032-09-06'],
['thanksgiving', '2032-11-25'],
['day-after-thanksgiving', '2032-11-26'],
['christmas', '2032-12-24'],
['new-year-observed', '2032-12-31']]),
('2033 new year saturday',
[2033],
[['mlk', '2033-01-17'],
['memorial', '2033-05-30'],
['juneteenth', '2033-06-20'],
['independence', '2033-07-04'],
['labor', '2033-09-05'],
['thanksgiving', '2033-11-24'],
['day-after-thanksgiving', '2033-11-25'],
['christmas', '2033-12-26']])],
[('2027 five mondays may',
[2027],
[['new-year', '2027-01-01'],
['mlk', '2027-01-18'],
['memorial', '2027-05-31'],
['juneteenth', '2027-06-18'],
['independence', '2027-07-05'],
['labor', '2027-09-06'],
['thanksgiving', '2027-11-25'],
['day-after-thanksgiving', '2027-11-26'],
['christmas', '2027-12-24'],
['new-year-observed', '2027-12-31']]),
('2023',
[2023],
[['new-year', '2023-01-02'],
['mlk', '2023-01-16'],
['memorial', '2023-05-29'],
['juneteenth', '2023-06-19'],
['independence', '2023-07-04'],
['labor', '2023-09-04'],
['thanksgiving', '2023-11-23'],
['day-after-thanksgiving', '2023-11-24'],
['christmas', '2023-12-25']]),
('2030',
[2030],
[['new-year', '2030-01-01'],
['mlk', '2030-01-21'],
['memorial', '2030-05-27'],
['juneteenth', '2030-06-19'],
['independence', '2030-07-04'],
['labor', '2030-09-02'],
['thanksgiving', '2030-11-28'],
['day-after-thanksgiving', '2030-11-29'],
['christmas', '2030-12-25']]),
('2032 leap',
[2032],
[['new-year', '2032-01-01'],
['mlk', '2032-01-19'],
['memorial', '2032-05-31'],
['juneteenth', '2032-06-18'],
['independence', '2032-07-05'],
['labor', '2032-09-06'],
['thanksgiving', '2032-11-25'],
['day-after-thanksgiving', '2032-11-26'],
['christmas', '2032-12-24'],
['new-year-observed', '2032-12-31']]),
('2033 new year saturday',
[2033],
[['mlk', '2033-01-17'],
['memorial', '2033-05-30'],
['juneteenth', '2033-06-20'],
['independence', '2033-07-04'],
['labor', '2033-09-05'],
['thanksgiving', '2033-11-24'],
['day-after-thanksgiving', '2033-11-25'],
['christmas', '2033-12-26']]),
('regression: 2022 new year on saturday',
[2022],
[['mlk', '2022-01-17'],
['memorial', '2022-05-30'],
['juneteenth', '2022-06-20'],
['independence', '2022-07-04'],
['labor', '2022-09-05'],
['thanksgiving', '2022-11-24'],
['day-after-thanksgiving', '2022-11-25'],
['christmas', '2022-12-26']]),
('2021 next new year saturday',
[2021],
[['new-year', '2021-01-01'],
['mlk', '2021-01-18'],
['memorial', '2021-05-31'],
['juneteenth', '2021-06-18'],
['independence', '2021-07-05'],
['labor', '2021-09-06'],
['thanksgiving', '2021-11-25'],
['day-after-thanksgiving', '2021-11-26'],
['christmas', '2021-12-24'],
['new-year-observed', '2021-12-31']])],
[('2030',
[2030],
[['new-year', '2030-01-01'],
['mlk', '2030-01-21'],
['memorial', '2030-05-27'],
['juneteenth', '2030-06-19'],
['independence', '2030-07-04'],
['labor', '2030-09-02'],
['thanksgiving', '2030-11-28'],
['day-after-thanksgiving', '2030-11-29'],
['christmas', '2030-12-25']]),
('2032 leap',
[2032],
[['new-year', '2032-01-01'],
['mlk', '2032-01-19'],
['memorial', '2032-05-31'],
['juneteenth', '2032-06-18'],
['independence', '2032-07-05'],
['labor', '2032-09-06'],
['thanksgiving', '2032-11-25'],
['day-after-thanksgiving', '2032-11-26'],
['christmas', '2032-12-24'],
['new-year-observed', '2032-12-31']]),
('2033 new year saturday',
[2033],
[['mlk', '2033-01-17'],
['memorial', '2033-05-30'],
['juneteenth', '2033-06-20'],
['independence', '2033-07-04'],
['labor', '2033-09-05'],
['thanksgiving', '2033-11-24'],
['day-after-thanksgiving', '2033-11-25'],
['christmas', '2033-12-26']]),
('regression: 2022 new year on saturday',
[2022],
[['mlk', '2022-01-17'],
['memorial', '2022-05-30'],
['juneteenth', '2022-06-20'],
['independence', '2022-07-04'],
['labor', '2022-09-05'],
['thanksgiving', '2022-11-24'],
['day-after-thanksgiving', '2022-11-25'],
['christmas', '2022-12-26']]),
('2021 next new year saturday',
[2021],
[['new-year', '2021-01-01'],
['mlk', '2021-01-18'],
['memorial', '2021-05-31'],
['juneteenth', '2021-06-18'],
['independence', '2021-07-05'],
['labor', '2021-09-06'],
['thanksgiving', '2021-11-25'],
['day-after-thanksgiving', '2021-11-26'],
['christmas', '2021-12-24'],
['new-year-observed', '2021-12-31']]),
('2024 leap',
[2024],
[['new-year', '2024-01-01'],
['mlk', '2024-01-15'],
['memorial', '2024-05-27'],
['juneteenth', '2024-06-19'],
['independence', '2024-07-04'],
['labor', '2024-09-02'],
['thanksgiving', '2024-11-28'],
['day-after-thanksgiving', '2024-11-29'],
['christmas', '2024-12-25']]),
('2019 november starts friday',
[2019],
[['new-year', '2019-01-01'],
['mlk', '2019-01-21'],
['memorial', '2019-05-27'],
['juneteenth', '2019-06-19'],
['independence', '2019-07-04'],
['labor', '2019-09-02'],
['thanksgiving', '2019-11-28'],
['day-after-thanksgiving', '2019-11-29'],
['christmas', '2019-12-25']])]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: 2022 new year on saturday | [['mlk', '2022-01-17'], ['memorial', '2022-05-30'], ['juneteenth', '2022-06-20'], ['independence', '2022-07-04'], ['labor', '2022-09-05'], ['thanksgiving', '2022-11-24'], ['day-after-thanksgiving', '2022-11-25'], ['christmas', '2022-12-26'], ['new-year-observed', '2022-12-31']] | [['mlk', '2022-01-17'], ['memorial', '2022-05-30'], ['juneteenth', '2022-06-20'], ['independence', '2022-07-04'], ['labor', '2022-09-05'], ['thanksgiving', '2022-11-24'], ['day-after-thanksgiving', '2022-11-25'], ['christmas', '2022-12-26']] | Failed |
| 2021 next new year saturday | [['new-year', '2021-01-01'], ['mlk', '2021-01-18'], ['memorial', '2021-05-31'], ['juneteenth', '2021-06-18'], ['independence', '2021-07-05'], ['labor', '2021-09-06'], ['thanksgiving', '2021-11-25'], ['day-after-thanksgiving', '2021-11-26'], ['christmas', '2021-12-24'], ['new-year-observed', '2021-12-31']] | [['new-year', '2021-01-01'], ['mlk', '2021-01-18'], ['memorial', '2021-05-31'], ['juneteenth', '2021-06-18'], ['independence', '2021-07-05'], ['labor', '2021-09-06'], ['thanksgiving', '2021-11-25'], ['day-after-thanksgiving', '2021-11-26'], ['christmas', '2021-12-24'], ['new-year-observed', '2021-12-31']] | Passed |
| 2024 leap | [['new-year', '2024-01-01'], ['mlk', '2024-01-15'], ['memorial', '2024-05-27'], ['juneteenth', '2024-06-19'], ['independence', '2024-07-04'], ['labor', '2024-09-02'], ['thanksgiving', '2024-11-28'], ['day-after-thanksgiving', '2024-11-29'], ['christmas', '2024-12-25']] | [['new-year', '2024-01-01'], ['mlk', '2024-01-15'], ['memorial', '2024-05-27'], ['juneteenth', '2024-06-19'], ['independence', '2024-07-04'], ['labor', '2024-09-02'], ['thanksgiving', '2024-11-28'], ['day-after-thanksgiving', '2024-11-29'], ['christmas', '2024-12-25']] | Passed |
| 2019 november starts friday | [['new-year', '2019-01-01'], ['mlk', '2019-01-21'], ['memorial', '2019-05-27'], ['juneteenth', '2019-06-19'], ['independence', '2019-07-04'], ['labor', '2019-09-02'], ['thanksgiving', '2019-11-28'], ['day-after-thanksgiving', '2019-11-29'], ['christmas', '2019-12-25']] | [['new-year', '2019-01-01'], ['mlk', '2019-01-21'], ['memorial', '2019-05-27'], ['juneteenth', '2019-06-19'], ['independence', '2019-07-04'], ['labor', '2019-09-02'], ['thanksgiving', '2019-11-28'], ['day-after-thanksgiving', '2019-11-29'], ['christmas', '2019-12-25']] | Passed |
| 2020 july 4 saturday | [['new-year', '2020-01-01'], ['mlk', '2020-01-20'], ['memorial', '2020-05-25'], ['juneteenth', '2020-06-19'], ['independence', '2020-07-03'], ['labor', '2020-09-07'], ['thanksgiving', '2020-11-26'], ['day-after-thanksgiving', '2020-11-27'], ['christmas', '2020-12-25']] | [['new-year', '2020-01-01'], ['mlk', '2020-01-20'], ['memorial', '2020-05-25'], ['juneteenth', '2020-06-19'], ['independence', '2020-07-03'], ['labor', '2020-09-07'], ['thanksgiving', '2020-11-26'], ['day-after-thanksgiving', '2020-11-27'], ['christmas', '2020-12-25']] | Passed |
| 2016 next new year sunday | [['new-year', '2016-01-01'], ['mlk', '2016-01-18'], ['memorial', '2016-05-30'], ['juneteenth', '2016-06-20'], ['independence', '2016-07-04'], ['labor', '2016-09-05'], ['thanksgiving', '2016-11-24'], ['day-after-thanksgiving', '2016-11-25'], ['christmas', '2016-12-26'], ['new-year-observed', '2016-12-31']] | [['new-year', '2016-01-01'], ['mlk', '2016-01-18'], ['memorial', '2016-05-30'], ['juneteenth', '2016-06-20'], ['independence', '2016-07-04'], ['labor', '2016-09-05'], ['thanksgiving', '2016-11-24'], ['day-after-thanksgiving', '2016-11-25'], ['christmas', '2016-12-26']] | Failed |
| 2027 five mondays may | [['new-year', '2027-01-01'], ['mlk', '2027-01-18'], ['memorial', '2027-05-31'], ['juneteenth', '2027-06-18'], ['independence', '2027-07-05'], ['labor', '2027-09-06'], ['thanksgiving', '2027-11-25'], ['day-after-thanksgiving', '2027-11-26'], ['christmas', '2027-12-24'], ['new-year-observed', '2027-12-31']] | [['new-year', '2027-01-01'], ['mlk', '2027-01-18'], ['memorial', '2027-05-31'], ['juneteenth', '2027-06-18'], ['independence', '2027-07-05'], ['labor', '2027-09-06'], ['thanksgiving', '2027-11-25'], ['day-after-thanksgiving', '2027-11-26'], ['christmas', '2027-12-24'], ['new-year-observed', '2027-12-31']] | Passed |
SHA-256 / 111111817b2839b9876de005cdcabeab41afd2ade5357bb9c98cf5e15cff3976
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(year):
def nth(month, wd, n):
first = dt.date(year, month, 1)
return first + dt.timedelta(days=(wd - first.weekday()) % 7 + 7 * (n - 1))
def last(month, wd):
lastd = dt.date(year, month, calendar.monthrange(year, month)[1])
return lastd - dt.timedelta(days=(lastd.weekday() - wd) % 7)
def observed(d):
return d - dt.timedelta(days=1) if d.weekday() == 5 else d + dt.timedelta(days=1) if d.weekday() == 6 else d
thanks = nth(11, 3, 4)
rows = [['new-year', observed(dt.date(year, 1, 1))], ['mlk', nth(1, 0, 3)], ['memorial', last(5, 0)],
['juneteenth', observed(dt.date(year, 6, 19))], ['independence', observed(dt.date(year, 7, 4))],
['labor', nth(9, 0, 1)], ['thanksgiving', thanks], ['day-after-thanksgiving', thanks + dt.timedelta(days=1)],
['christmas', observed(dt.date(year, 12, 25))]]
nxt = dt.date(year + 1, 1, 1)
if nxt.weekday() == 5:
rows.append(['new-year-observed', nxt - dt.timedelta(days=1)])
rows = [r for r in rows if r[1].year == year]
return [[name, d.isoformat()] for name, d in sorted(rows, key=lambda r: r[1])]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: 2022 new year on saturday',
[2022],
[['mlk', '2022-01-17'],
['memorial', '2022-05-30'],
['juneteenth', '2022-06-20'],
['independence', '2022-07-04'],
['labor', '2022-09-05'],
['thanksgiving', '2022-11-24'],
['day-after-thanksgiving', '2022-11-25'],
['christmas', '2022-12-26']]),
('2021 next new year saturday',
[2021],
[['new-year', '2021-01-01'],
['mlk', '2021-01-18'],
['memorial', '2021-05-31'],
['juneteenth', '2021-06-18'],
['independence', '2021-07-05'],
['labor', '2021-09-06'],
['thanksgiving', '2021-11-25'],
['day-after-thanksgiving', '2021-11-26'],
['christmas', '2021-12-24'],
['new-year-observed', '2021-12-31']]),
('2024 leap',
[2024],
[['new-year', '2024-01-01'],
['mlk', '2024-01-15'],
['memorial', '2024-05-27'],
['juneteenth', '2024-06-19'],
['independence', '2024-07-04'],
['labor', '2024-09-02'],
['thanksgiving', '2024-11-28'],
['day-after-thanksgiving', '2024-11-29'],
['christmas', '2024-12-25']]),
('2019 november starts friday',
[2019],
[['new-year', '2019-01-01'],
['mlk', '2019-01-21'],
['memorial', '2019-05-27'],
['juneteenth', '2019-06-19'],
['independence', '2019-07-04'],
['labor', '2019-09-02'],
['thanksgiving', '2019-11-28'],
['day-after-thanksgiving', '2019-11-29'],
['christmas', '2019-12-25']]),
('2020 july 4 saturday',
[2020],
[['new-year', '2020-01-01'],
['mlk', '2020-01-20'],
['memorial', '2020-05-25'],
['juneteenth', '2020-06-19'],
['independence', '2020-07-03'],
['labor', '2020-09-07'],
['thanksgiving', '2020-11-26'],
['day-after-thanksgiving', '2020-11-27'],
['christmas', '2020-12-25']]),
('2016 next new year sunday',
[2016],
[['new-year', '2016-01-01'],
['mlk', '2016-01-18'],
['memorial', '2016-05-30'],
['juneteenth', '2016-06-20'],
['independence', '2016-07-04'],
['labor', '2016-09-05'],
['thanksgiving', '2016-11-24'],
['day-after-thanksgiving', '2016-11-25'],
['christmas', '2016-12-26']]),
('2027 five mondays may',
[2027],
[['new-year', '2027-01-01'],
['mlk', '2027-01-18'],
['memorial', '2027-05-31'],
['juneteenth', '2027-06-18'],
['independence', '2027-07-05'],
['labor', '2027-09-06'],
['thanksgiving', '2027-11-25'],
['day-after-thanksgiving', '2027-11-26'],
['christmas', '2027-12-24'],
['new-year-observed', '2027-12-31']])],
[('2024 leap',
[2024],
[['new-year', '2024-01-01'],
['mlk', '2024-01-15'],
['memorial', '2024-05-27'],
['juneteenth', '2024-06-19'],
['independence', '2024-07-04'],
['labor', '2024-09-02'],
['thanksgiving', '2024-11-28'],
['day-after-thanksgiving', '2024-11-29'],
['christmas', '2024-12-25']]),
('2019 november starts friday',
[2019],
[['new-year', '2019-01-01'],
['mlk', '2019-01-21'],
['memorial', '2019-05-27'],
['juneteenth', '2019-06-19'],
['independence', '2019-07-04'],
['labor', '2019-09-02'],
['thanksgiving', '2019-11-28'],
['day-after-thanksgiving', '2019-11-29'],
['christmas', '2019-12-25']]),
('2020 july 4 saturday',
[2020],
[['new-year', '2020-01-01'],
['mlk', '2020-01-20'],
['memorial', '2020-05-25'],
['juneteenth', '2020-06-19'],
['independence', '2020-07-03'],
['labor', '2020-09-07'],
['thanksgiving', '2020-11-26'],
['day-after-thanksgiving', '2020-11-27'],
['christmas', '2020-12-25']]),
('2016 next new year sunday',
[2016],
[['new-year', '2016-01-01'],
['mlk', '2016-01-18'],
['memorial', '2016-05-30'],
['juneteenth', '2016-06-20'],
['independence', '2016-07-04'],
['labor', '2016-09-05'],
['thanksgiving', '2016-11-24'],
['day-after-thanksgiving', '2016-11-25'],
['christmas', '2016-12-26']]),
('2027 five mondays may',
[2027],
[['new-year', '2027-01-01'],
['mlk', '2027-01-18'],
['memorial', '2027-05-31'],
['juneteenth', '2027-06-18'],
['independence', '2027-07-05'],
['labor', '2027-09-06'],
['thanksgiving', '2027-11-25'],
['day-after-thanksgiving', '2027-11-26'],
['christmas', '2027-12-24'],
['new-year-observed', '2027-12-31']]),
('2023',
[2023],
[['new-year', '2023-01-02'],
['mlk', '2023-01-16'],
['memorial', '2023-05-29'],
['juneteenth', '2023-06-19'],
['independence', '2023-07-04'],
['labor', '2023-09-04'],
['thanksgiving', '2023-11-23'],
['day-after-thanksgiving', '2023-11-24'],
['christmas', '2023-12-25']]),
('2030',
[2030],
[['new-year', '2030-01-01'],
['mlk', '2030-01-21'],
['memorial', '2030-05-27'],
['juneteenth', '2030-06-19'],
['independence', '2030-07-04'],
['labor', '2030-09-02'],
['thanksgiving', '2030-11-28'],
['day-after-thanksgiving', '2030-11-29'],
['christmas', '2030-12-25']])],
[('2020 july 4 saturday',
[2020],
[['new-year', '2020-01-01'],
['mlk', '2020-01-20'],
['memorial', '2020-05-25'],
['juneteenth', '2020-06-19'],
['independence', '2020-07-03'],
['labor', '2020-09-07'],
['thanksgiving', '2020-11-26'],
['day-after-thanksgiving', '2020-11-27'],
['christmas', '2020-12-25']]),
('2016 next new year sunday',
[2016],
[['new-year', '2016-01-01'],
['mlk', '2016-01-18'],
['memorial', '2016-05-30'],
['juneteenth', '2016-06-20'],
['independence', '2016-07-04'],
['labor', '2016-09-05'],
['thanksgiving', '2016-11-24'],
['day-after-thanksgiving', '2016-11-25'],
['christmas', '2016-12-26']]),
('2027 five mondays may',
[2027],
[['new-year', '2027-01-01'],
['mlk', '2027-01-18'],
['memorial', '2027-05-31'],
['juneteenth', '2027-06-18'],
['independence', '2027-07-05'],
['labor', '2027-09-06'],
['thanksgiving', '2027-11-25'],
['day-after-thanksgiving', '2027-11-26'],
['christmas', '2027-12-24'],
['new-year-observed', '2027-12-31']]),
('2023',
[2023],
[['new-year', '2023-01-02'],
['mlk', '2023-01-16'],
['memorial', '2023-05-29'],
['juneteenth', '2023-06-19'],
['independence', '2023-07-04'],
['labor', '2023-09-04'],
['thanksgiving', '2023-11-23'],
['day-after-thanksgiving', '2023-11-24'],
['christmas', '2023-12-25']]),
('2030',
[2030],
[['new-year', '2030-01-01'],
['mlk', '2030-01-21'],
['memorial', '2030-05-27'],
['juneteenth', '2030-06-19'],
['independence', '2030-07-04'],
['labor', '2030-09-02'],
['thanksgiving', '2030-11-28'],
['day-after-thanksgiving', '2030-11-29'],
['christmas', '2030-12-25']]),
('2032 leap',
[2032],
[['new-year', '2032-01-01'],
['mlk', '2032-01-19'],
['memorial', '2032-05-31'],
['juneteenth', '2032-06-18'],
['independence', '2032-07-05'],
['labor', '2032-09-06'],
['thanksgiving', '2032-11-25'],
['day-after-thanksgiving', '2032-11-26'],
['christmas', '2032-12-24'],
['new-year-observed', '2032-12-31']]),
('2033 new year saturday',
[2033],
[['mlk', '2033-01-17'],
['memorial', '2033-05-30'],
['juneteenth', '2033-06-20'],
['independence', '2033-07-04'],
['labor', '2033-09-05'],
['thanksgiving', '2033-11-24'],
['day-after-thanksgiving', '2033-11-25'],
['christmas', '2033-12-26']])],
[('2027 five mondays may',
[2027],
[['new-year', '2027-01-01'],
['mlk', '2027-01-18'],
['memorial', '2027-05-31'],
['juneteenth', '2027-06-18'],
['independence', '2027-07-05'],
['labor', '2027-09-06'],
['thanksgiving', '2027-11-25'],
['day-after-thanksgiving', '2027-11-26'],
['christmas', '2027-12-24'],
['new-year-observed', '2027-12-31']]),
('2023',
[2023],
[['new-year', '2023-01-02'],
['mlk', '2023-01-16'],
['memorial', '2023-05-29'],
['juneteenth', '2023-06-19'],
['independence', '2023-07-04'],
['labor', '2023-09-04'],
['thanksgiving', '2023-11-23'],
['day-after-thanksgiving', '2023-11-24'],
['christmas', '2023-12-25']]),
('2030',
[2030],
[['new-year', '2030-01-01'],
['mlk', '2030-01-21'],
['memorial', '2030-05-27'],
['juneteenth', '2030-06-19'],
['independence', '2030-07-04'],
['labor', '2030-09-02'],
['thanksgiving', '2030-11-28'],
['day-after-thanksgiving', '2030-11-29'],
['christmas', '2030-12-25']]),
('2032 leap',
[2032],
[['new-year', '2032-01-01'],
['mlk', '2032-01-19'],
['memorial', '2032-05-31'],
['juneteenth', '2032-06-18'],
['independence', '2032-07-05'],
['labor', '2032-09-06'],
['thanksgiving', '2032-11-25'],
['day-after-thanksgiving', '2032-11-26'],
['christmas', '2032-12-24'],
['new-year-observed', '2032-12-31']]),
('2033 new year saturday',
[2033],
[['mlk', '2033-01-17'],
['memorial', '2033-05-30'],
['juneteenth', '2033-06-20'],
['independence', '2033-07-04'],
['labor', '2033-09-05'],
['thanksgiving', '2033-11-24'],
['day-after-thanksgiving', '2033-11-25'],
['christmas', '2033-12-26']]),
('regression: 2022 new year on saturday',
[2022],
[['mlk', '2022-01-17'],
['memorial', '2022-05-30'],
['juneteenth', '2022-06-20'],
['independence', '2022-07-04'],
['labor', '2022-09-05'],
['thanksgiving', '2022-11-24'],
['day-after-thanksgiving', '2022-11-25'],
['christmas', '2022-12-26']]),
('2021 next new year saturday',
[2021],
[['new-year', '2021-01-01'],
['mlk', '2021-01-18'],
['memorial', '2021-05-31'],
['juneteenth', '2021-06-18'],
['independence', '2021-07-05'],
['labor', '2021-09-06'],
['thanksgiving', '2021-11-25'],
['day-after-thanksgiving', '2021-11-26'],
['christmas', '2021-12-24'],
['new-year-observed', '2021-12-31']])],
[('2030',
[2030],
[['new-year', '2030-01-01'],
['mlk', '2030-01-21'],
['memorial', '2030-05-27'],
['juneteenth', '2030-06-19'],
['independence', '2030-07-04'],
['labor', '2030-09-02'],
['thanksgiving', '2030-11-28'],
['day-after-thanksgiving', '2030-11-29'],
['christmas', '2030-12-25']]),
('2032 leap',
[2032],
[['new-year', '2032-01-01'],
['mlk', '2032-01-19'],
['memorial', '2032-05-31'],
['juneteenth', '2032-06-18'],
['independence', '2032-07-05'],
['labor', '2032-09-06'],
['thanksgiving', '2032-11-25'],
['day-after-thanksgiving', '2032-11-26'],
['christmas', '2032-12-24'],
['new-year-observed', '2032-12-31']]),
('2033 new year saturday',
[2033],
[['mlk', '2033-01-17'],
['memorial', '2033-05-30'],
['juneteenth', '2033-06-20'],
['independence', '2033-07-04'],
['labor', '2033-09-05'],
['thanksgiving', '2033-11-24'],
['day-after-thanksgiving', '2033-11-25'],
['christmas', '2033-12-26']]),
('regression: 2022 new year on saturday',
[2022],
[['mlk', '2022-01-17'],
['memorial', '2022-05-30'],
['juneteenth', '2022-06-20'],
['independence', '2022-07-04'],
['labor', '2022-09-05'],
['thanksgiving', '2022-11-24'],
['day-after-thanksgiving', '2022-11-25'],
['christmas', '2022-12-26']]),
('2021 next new year saturday',
[2021],
[['new-year', '2021-01-01'],
['mlk', '2021-01-18'],
['memorial', '2021-05-31'],
['juneteenth', '2021-06-18'],
['independence', '2021-07-05'],
['labor', '2021-09-06'],
['thanksgiving', '2021-11-25'],
['day-after-thanksgiving', '2021-11-26'],
['christmas', '2021-12-24'],
['new-year-observed', '2021-12-31']]),
('2024 leap',
[2024],
[['new-year', '2024-01-01'],
['mlk', '2024-01-15'],
['memorial', '2024-05-27'],
['juneteenth', '2024-06-19'],
['independence', '2024-07-04'],
['labor', '2024-09-02'],
['thanksgiving', '2024-11-28'],
['day-after-thanksgiving', '2024-11-29'],
['christmas', '2024-12-25']]),
('2019 november starts friday',
[2019],
[['new-year', '2019-01-01'],
['mlk', '2019-01-21'],
['memorial', '2019-05-27'],
['juneteenth', '2019-06-19'],
['independence', '2019-07-04'],
['labor', '2019-09-02'],
['thanksgiving', '2019-11-28'],
['day-after-thanksgiving', '2019-11-29'],
['christmas', '2019-12-25']])]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: 2022 new year on saturday | [['mlk', '2022-01-17'], ['memorial', '2022-05-30'], ['juneteenth', '2022-06-20'], ['independence', '2022-07-04'], ['labor', '2022-09-05'], ['thanksgiving', '2022-11-24'], ['day-after-thanksgiving', '2022-11-25'], ['christmas', '2022-12-26']] | [['mlk', '2022-01-17'], ['memorial', '2022-05-30'], ['juneteenth', '2022-06-20'], ['independence', '2022-07-04'], ['labor', '2022-09-05'], ['thanksgiving', '2022-11-24'], ['day-after-thanksgiving', '2022-11-25'], ['christmas', '2022-12-26']] | Passed |
| 2021 next new year saturday | [['new-year', '2021-01-01'], ['mlk', '2021-01-18'], ['memorial', '2021-05-31'], ['juneteenth', '2021-06-18'], ['independence', '2021-07-05'], ['labor', '2021-09-06'], ['thanksgiving', '2021-11-25'], ['day-after-thanksgiving', '2021-11-26'], ['christmas', '2021-12-24'], ['new-year-observed', '2021-12-31']] | [['new-year', '2021-01-01'], ['mlk', '2021-01-18'], ['memorial', '2021-05-31'], ['juneteenth', '2021-06-18'], ['independence', '2021-07-05'], ['labor', '2021-09-06'], ['thanksgiving', '2021-11-25'], ['day-after-thanksgiving', '2021-11-26'], ['christmas', '2021-12-24'], ['new-year-observed', '2021-12-31']] | Passed |
| 2024 leap | [['new-year', '2024-01-01'], ['mlk', '2024-01-15'], ['memorial', '2024-05-27'], ['juneteenth', '2024-06-19'], ['independence', '2024-07-04'], ['labor', '2024-09-02'], ['thanksgiving', '2024-11-28'], ['day-after-thanksgiving', '2024-11-29'], ['christmas', '2024-12-25']] | [['new-year', '2024-01-01'], ['mlk', '2024-01-15'], ['memorial', '2024-05-27'], ['juneteenth', '2024-06-19'], ['independence', '2024-07-04'], ['labor', '2024-09-02'], ['thanksgiving', '2024-11-28'], ['day-after-thanksgiving', '2024-11-29'], ['christmas', '2024-12-25']] | Passed |
| 2019 november starts friday | [['new-year', '2019-01-01'], ['mlk', '2019-01-21'], ['memorial', '2019-05-27'], ['juneteenth', '2019-06-19'], ['independence', '2019-07-04'], ['labor', '2019-09-02'], ['thanksgiving', '2019-11-28'], ['day-after-thanksgiving', '2019-11-29'], ['christmas', '2019-12-25']] | [['new-year', '2019-01-01'], ['mlk', '2019-01-21'], ['memorial', '2019-05-27'], ['juneteenth', '2019-06-19'], ['independence', '2019-07-04'], ['labor', '2019-09-02'], ['thanksgiving', '2019-11-28'], ['day-after-thanksgiving', '2019-11-29'], ['christmas', '2019-12-25']] | Passed |
| 2020 july 4 saturday | [['new-year', '2020-01-01'], ['mlk', '2020-01-20'], ['memorial', '2020-05-25'], ['juneteenth', '2020-06-19'], ['independence', '2020-07-03'], ['labor', '2020-09-07'], ['thanksgiving', '2020-11-26'], ['day-after-thanksgiving', '2020-11-27'], ['christmas', '2020-12-25']] | [['new-year', '2020-01-01'], ['mlk', '2020-01-20'], ['memorial', '2020-05-25'], ['juneteenth', '2020-06-19'], ['independence', '2020-07-03'], ['labor', '2020-09-07'], ['thanksgiving', '2020-11-26'], ['day-after-thanksgiving', '2020-11-27'], ['christmas', '2020-12-25']] | Passed |
| 2016 next new year sunday | [['new-year', '2016-01-01'], ['mlk', '2016-01-18'], ['memorial', '2016-05-30'], ['juneteenth', '2016-06-20'], ['independence', '2016-07-04'], ['labor', '2016-09-05'], ['thanksgiving', '2016-11-24'], ['day-after-thanksgiving', '2016-11-25'], ['christmas', '2016-12-26']] | [['new-year', '2016-01-01'], ['mlk', '2016-01-18'], ['memorial', '2016-05-30'], ['juneteenth', '2016-06-20'], ['independence', '2016-07-04'], ['labor', '2016-09-05'], ['thanksgiving', '2016-11-24'], ['day-after-thanksgiving', '2016-11-25'], ['christmas', '2016-12-26']] | Passed |
| 2027 five mondays may | [['new-year', '2027-01-01'], ['mlk', '2027-01-18'], ['memorial', '2027-05-31'], ['juneteenth', '2027-06-18'], ['independence', '2027-07-05'], ['labor', '2027-09-06'], ['thanksgiving', '2027-11-25'], ['day-after-thanksgiving', '2027-11-26'], ['christmas', '2027-12-24'], ['new-year-observed', '2027-12-31']] | [['new-year', '2027-01-01'], ['mlk', '2027-01-18'], ['memorial', '2027-05-31'], ['juneteenth', '2027-06-18'], ['independence', '2027-07-05'], ['labor', '2027-09-06'], ['thanksgiving', '2027-11-25'], ['day-after-thanksgiving', '2027-11-26'], ['christmas', '2027-12-24'], ['new-year-observed', '2027-12-31']] | Passed |
SHA-256 / 5c8868ffe6478fd4783a5042af62a12709080d244ad020110633f2c916794ad9
Verification & scope
Stipulated toy deadline rules evaluated offline on explicit fixtures. The contract is inspired by common court-rule structures but is not legal advice and makes no claim to reproduce any jurisdiction's rules. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:49:27.900643+00:00.
Case digest / 8a20c25e84e982687a061688e95a3ab3d2b86918938d2b5635892eea4a6d7cfe