broken_source:
"""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=(first.weekday() - wd) % 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)

source:
"""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 - 7 * (first.weekday() == wd))
    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)

prompt:
The third Monday of January is computed on a non-Monday.

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.

split: open-access


broken_source:
"""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() == 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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""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=2) 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)

prompt:
Independence Day on a Saturday produces no weekday closure.

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.

split: open-access


broken_source:
"""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', nth(5, 0, 4)],
            ['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']]),
  ('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']])],
 [('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']]),
  ('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']])]]
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)

source:
"""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', nth(5, 0, 4) if nth(5, 0, 4).day > 25 else nth(5, 0, 5)],
            ['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']]),
  ('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']])],
 [('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']]),
  ('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']])]]
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)

prompt:
In years with five Mondays in May the memorial closure is a week early.

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.

split: open-access