FA-77836 / Legal deadline computation / Open access
Extending a last day when the clerk office is inaccessible: next accessible · case 01
When the office stays closed a second day, the deadline lands on that inaccessible day.
ROOT CAUSE
The continuation only skips weekends and holidays, not further inaccessible days.
VERIFIED REPAIR
At the next accessible decision use `d.weekday() >= 5 or d in hol or inaccessible(d)`, leaving the other decision sites of the model unchanged.
Unsuccessful approach: The partial repair `inaccessible(d)` skips further closures but not weekends.
Case contract
Stipulated: closures are [date, start] where start is "all" (full-day outage) or a local "HH:MM" time the office closed early; several entries for one day merge to "all" if any is "all", else the earliest start. A last day is inaccessible for paper or fax filing if closed all day or early before office_close; for electronic filing only a full-day outage counts. If the last day is inaccessible, the period continues to the first later day that is not a weekend, listed holiday or itself inaccessible.
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(last_day, method, closures, office_close, holidays):
ld = dt.date.fromisoformat(last_day)
hol = {dt.date.fromisoformat(x) for x in holidays}
cl = {}
for day, start in closures:
k = dt.date.fromisoformat(day)
cl[k] = 'all' if start == 'all' or cl.get(k) == 'all' else min(start, cl.get(k, start))
def inaccessible(d):
if d not in cl:
return False
if cl[d] == 'all':
return True
return method in ('paper', 'fax') and cl[d] < office_close
d = ld
if inaccessible(d):
d += dt.timedelta(days=1)
while d.weekday() >= 5 or d in hol:
d += dt.timedelta(days=1)
return d.isoformat()
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: partial then full outage same day',
['2024-03-05',
'paper',
[['2024-03-05', 'all'], ['2024-03-05', '15:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('electronic partial closure',
['2024-03-05',
'electronic',
[['2024-03-05', '14:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('fax partial closure',
['2024-03-05',
'fax',
[['2024-03-05', '14:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('closure at office close',
['2024-03-05',
'paper',
[['2024-03-05', '17:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('afternoon closure paper',
['2024-03-05',
'paper',
[['2024-03-05', '13:30']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('two-day outage',
['2024-03-05',
'electronic',
[['2024-03-05', 'all'], ['2024-03-06', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-07'),
('friday outage',
['2024-03-08',
'electronic',
[['2024-03-08', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-11')],
[('fax partial closure',
['2024-03-05',
'fax',
[['2024-03-05', '14:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('closure at office close',
['2024-03-05',
'paper',
[['2024-03-05', '17:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('afternoon closure paper',
['2024-03-05',
'paper',
[['2024-03-05', '13:30']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('two-day outage',
['2024-03-05',
'electronic',
[['2024-03-05', 'all'], ['2024-03-06', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-07'),
('friday outage',
['2024-03-08',
'electronic',
[['2024-03-08', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-11'),
('outage before holiday',
['2024-07-03',
'paper',
[['2024-07-03', '10:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-07-05'),
('no closure on last day',
['2024-03-05',
'paper',
[['2024-03-04', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05')],
[('afternoon closure paper',
['2024-03-05',
'paper',
[['2024-03-05', '13:30']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('two-day outage',
['2024-03-05',
'electronic',
[['2024-03-05', 'all'], ['2024-03-06', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-07'),
('friday outage',
['2024-03-08',
'electronic',
[['2024-03-08', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-11'),
('outage before holiday',
['2024-07-03',
'paper',
[['2024-07-03', '10:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-07-05'),
('no closure on last day',
['2024-03-05',
'paper',
[['2024-03-04', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('friday outage then monday closure',
['2024-03-08',
'paper',
[['2024-03-08', 'all'], ['2024-03-11', '09:00']],
'16:30',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-12'),
('two partials same day',
['2024-04-10',
'paper',
[['2024-04-10', '16:45'], ['2024-04-10', '17:30']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-04-11')],
[('friday outage',
['2024-03-08',
'electronic',
[['2024-03-08', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-11'),
('outage before holiday',
['2024-07-03',
'paper',
[['2024-07-03', '10:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-07-05'),
('no closure on last day',
['2024-03-05',
'paper',
[['2024-03-04', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('friday outage then monday closure',
['2024-03-08',
'paper',
[['2024-03-08', 'all'], ['2024-03-11', '09:00']],
'16:30',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-12'),
('two partials same day',
['2024-04-10',
'paper',
[['2024-04-10', '16:45'], ['2024-04-10', '17:30']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-04-11'),
('electronic partial then full outage',
['2024-04-10',
'electronic',
[['2024-04-10', '15:00'], ['2024-04-10', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-04-11'),
('regression: partial then full outage same day',
['2024-03-05',
'paper',
[['2024-03-05', 'all'], ['2024-03-05', '15:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06')],
[('no closure on last day',
['2024-03-05',
'paper',
[['2024-03-04', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('friday outage then monday closure',
['2024-03-08',
'paper',
[['2024-03-08', 'all'], ['2024-03-11', '09:00']],
'16:30',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-12'),
('two partials same day',
['2024-04-10',
'paper',
[['2024-04-10', '16:45'], ['2024-04-10', '17:30']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-04-11'),
('electronic partial then full outage',
['2024-04-10',
'electronic',
[['2024-04-10', '15:00'], ['2024-04-10', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-04-11'),
('regression: partial then full outage same day',
['2024-03-05',
'paper',
[['2024-03-05', 'all'], ['2024-03-05', '15:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('electronic partial closure',
['2024-03-05',
'electronic',
[['2024-03-05', '14:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('fax partial closure',
['2024-03-05',
'fax',
[['2024-03-05', '14:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06')]]
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: partial then full outage same day | 2024-03-06 | 2024-03-06 | Passed |
| electronic partial closure | 2024-03-05 | 2024-03-05 | Passed |
| fax partial closure | 2024-03-06 | 2024-03-06 | Passed |
| closure at office close | 2024-03-05 | 2024-03-05 | Passed |
| afternoon closure paper | 2024-03-06 | 2024-03-06 | Passed |
| two-day outage | 2024-03-06 | 2024-03-07 | Failed |
| friday outage | 2024-03-11 | 2024-03-11 | Passed |
SHA-256 / 3df1e327208c74a0d295a05ce510a304ba5a496e39f145937dbec510bce8c2ae
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(last_day, method, closures, office_close, holidays):
ld = dt.date.fromisoformat(last_day)
hol = {dt.date.fromisoformat(x) for x in holidays}
cl = {}
for day, start in closures:
k = dt.date.fromisoformat(day)
cl[k] = 'all' if start == 'all' or cl.get(k) == 'all' else min(start, cl.get(k, start))
def inaccessible(d):
if d not in cl:
return False
if cl[d] == 'all':
return True
return method in ('paper', 'fax') and cl[d] < office_close
d = ld
if inaccessible(d):
d += dt.timedelta(days=1)
while inaccessible(d):
d += dt.timedelta(days=1)
return d.isoformat()
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: partial then full outage same day',
['2024-03-05',
'paper',
[['2024-03-05', 'all'], ['2024-03-05', '15:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('electronic partial closure',
['2024-03-05',
'electronic',
[['2024-03-05', '14:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('fax partial closure',
['2024-03-05',
'fax',
[['2024-03-05', '14:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('closure at office close',
['2024-03-05',
'paper',
[['2024-03-05', '17:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('afternoon closure paper',
['2024-03-05',
'paper',
[['2024-03-05', '13:30']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('two-day outage',
['2024-03-05',
'electronic',
[['2024-03-05', 'all'], ['2024-03-06', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-07'),
('friday outage',
['2024-03-08',
'electronic',
[['2024-03-08', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-11')],
[('fax partial closure',
['2024-03-05',
'fax',
[['2024-03-05', '14:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('closure at office close',
['2024-03-05',
'paper',
[['2024-03-05', '17:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('afternoon closure paper',
['2024-03-05',
'paper',
[['2024-03-05', '13:30']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('two-day outage',
['2024-03-05',
'electronic',
[['2024-03-05', 'all'], ['2024-03-06', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-07'),
('friday outage',
['2024-03-08',
'electronic',
[['2024-03-08', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-11'),
('outage before holiday',
['2024-07-03',
'paper',
[['2024-07-03', '10:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-07-05'),
('no closure on last day',
['2024-03-05',
'paper',
[['2024-03-04', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05')],
[('afternoon closure paper',
['2024-03-05',
'paper',
[['2024-03-05', '13:30']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('two-day outage',
['2024-03-05',
'electronic',
[['2024-03-05', 'all'], ['2024-03-06', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-07'),
('friday outage',
['2024-03-08',
'electronic',
[['2024-03-08', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-11'),
('outage before holiday',
['2024-07-03',
'paper',
[['2024-07-03', '10:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-07-05'),
('no closure on last day',
['2024-03-05',
'paper',
[['2024-03-04', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('friday outage then monday closure',
['2024-03-08',
'paper',
[['2024-03-08', 'all'], ['2024-03-11', '09:00']],
'16:30',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-12'),
('two partials same day',
['2024-04-10',
'paper',
[['2024-04-10', '16:45'], ['2024-04-10', '17:30']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-04-11')],
[('friday outage',
['2024-03-08',
'electronic',
[['2024-03-08', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-11'),
('outage before holiday',
['2024-07-03',
'paper',
[['2024-07-03', '10:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-07-05'),
('no closure on last day',
['2024-03-05',
'paper',
[['2024-03-04', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('friday outage then monday closure',
['2024-03-08',
'paper',
[['2024-03-08', 'all'], ['2024-03-11', '09:00']],
'16:30',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-12'),
('two partials same day',
['2024-04-10',
'paper',
[['2024-04-10', '16:45'], ['2024-04-10', '17:30']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-04-11'),
('electronic partial then full outage',
['2024-04-10',
'electronic',
[['2024-04-10', '15:00'], ['2024-04-10', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-04-11'),
('regression: partial then full outage same day',
['2024-03-05',
'paper',
[['2024-03-05', 'all'], ['2024-03-05', '15:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06')],
[('no closure on last day',
['2024-03-05',
'paper',
[['2024-03-04', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('friday outage then monday closure',
['2024-03-08',
'paper',
[['2024-03-08', 'all'], ['2024-03-11', '09:00']],
'16:30',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-12'),
('two partials same day',
['2024-04-10',
'paper',
[['2024-04-10', '16:45'], ['2024-04-10', '17:30']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-04-11'),
('electronic partial then full outage',
['2024-04-10',
'electronic',
[['2024-04-10', '15:00'], ['2024-04-10', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-04-11'),
('regression: partial then full outage same day',
['2024-03-05',
'paper',
[['2024-03-05', 'all'], ['2024-03-05', '15:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('electronic partial closure',
['2024-03-05',
'electronic',
[['2024-03-05', '14:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('fax partial closure',
['2024-03-05',
'fax',
[['2024-03-05', '14:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06')]]
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: partial then full outage same day | 2024-03-06 | 2024-03-06 | Passed |
| electronic partial closure | 2024-03-05 | 2024-03-05 | Passed |
| fax partial closure | 2024-03-06 | 2024-03-06 | Passed |
| closure at office close | 2024-03-05 | 2024-03-05 | Passed |
| afternoon closure paper | 2024-03-06 | 2024-03-06 | Passed |
| two-day outage | 2024-03-07 | 2024-03-07 | Passed |
| friday outage | 2024-03-09 | 2024-03-11 | Failed |
SHA-256 / 9089d81d2d5e33981c84e98488a2aa14f0b8c3bed7a0e5fa0f4b81d5aad1ceb0
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(last_day, method, closures, office_close, holidays):
ld = dt.date.fromisoformat(last_day)
hol = {dt.date.fromisoformat(x) for x in holidays}
cl = {}
for day, start in closures:
k = dt.date.fromisoformat(day)
cl[k] = 'all' if start == 'all' or cl.get(k) == 'all' else min(start, cl.get(k, start))
def inaccessible(d):
if d not in cl:
return False
if cl[d] == 'all':
return True
return method in ('paper', 'fax') and cl[d] < office_close
d = ld
if inaccessible(d):
d += dt.timedelta(days=1)
while d.weekday() >= 5 or d in hol or inaccessible(d):
d += dt.timedelta(days=1)
return d.isoformat()
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: partial then full outage same day',
['2024-03-05',
'paper',
[['2024-03-05', 'all'], ['2024-03-05', '15:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('electronic partial closure',
['2024-03-05',
'electronic',
[['2024-03-05', '14:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('fax partial closure',
['2024-03-05',
'fax',
[['2024-03-05', '14:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('closure at office close',
['2024-03-05',
'paper',
[['2024-03-05', '17:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('afternoon closure paper',
['2024-03-05',
'paper',
[['2024-03-05', '13:30']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('two-day outage',
['2024-03-05',
'electronic',
[['2024-03-05', 'all'], ['2024-03-06', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-07'),
('friday outage',
['2024-03-08',
'electronic',
[['2024-03-08', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-11')],
[('fax partial closure',
['2024-03-05',
'fax',
[['2024-03-05', '14:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('closure at office close',
['2024-03-05',
'paper',
[['2024-03-05', '17:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('afternoon closure paper',
['2024-03-05',
'paper',
[['2024-03-05', '13:30']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('two-day outage',
['2024-03-05',
'electronic',
[['2024-03-05', 'all'], ['2024-03-06', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-07'),
('friday outage',
['2024-03-08',
'electronic',
[['2024-03-08', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-11'),
('outage before holiday',
['2024-07-03',
'paper',
[['2024-07-03', '10:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-07-05'),
('no closure on last day',
['2024-03-05',
'paper',
[['2024-03-04', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05')],
[('afternoon closure paper',
['2024-03-05',
'paper',
[['2024-03-05', '13:30']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('two-day outage',
['2024-03-05',
'electronic',
[['2024-03-05', 'all'], ['2024-03-06', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-07'),
('friday outage',
['2024-03-08',
'electronic',
[['2024-03-08', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-11'),
('outage before holiday',
['2024-07-03',
'paper',
[['2024-07-03', '10:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-07-05'),
('no closure on last day',
['2024-03-05',
'paper',
[['2024-03-04', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('friday outage then monday closure',
['2024-03-08',
'paper',
[['2024-03-08', 'all'], ['2024-03-11', '09:00']],
'16:30',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-12'),
('two partials same day',
['2024-04-10',
'paper',
[['2024-04-10', '16:45'], ['2024-04-10', '17:30']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-04-11')],
[('friday outage',
['2024-03-08',
'electronic',
[['2024-03-08', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-11'),
('outage before holiday',
['2024-07-03',
'paper',
[['2024-07-03', '10:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-07-05'),
('no closure on last day',
['2024-03-05',
'paper',
[['2024-03-04', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('friday outage then monday closure',
['2024-03-08',
'paper',
[['2024-03-08', 'all'], ['2024-03-11', '09:00']],
'16:30',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-12'),
('two partials same day',
['2024-04-10',
'paper',
[['2024-04-10', '16:45'], ['2024-04-10', '17:30']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-04-11'),
('electronic partial then full outage',
['2024-04-10',
'electronic',
[['2024-04-10', '15:00'], ['2024-04-10', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-04-11'),
('regression: partial then full outage same day',
['2024-03-05',
'paper',
[['2024-03-05', 'all'], ['2024-03-05', '15:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06')],
[('no closure on last day',
['2024-03-05',
'paper',
[['2024-03-04', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('friday outage then monday closure',
['2024-03-08',
'paper',
[['2024-03-08', 'all'], ['2024-03-11', '09:00']],
'16:30',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-12'),
('two partials same day',
['2024-04-10',
'paper',
[['2024-04-10', '16:45'], ['2024-04-10', '17:30']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-04-11'),
('electronic partial then full outage',
['2024-04-10',
'electronic',
[['2024-04-10', '15:00'], ['2024-04-10', 'all']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-04-11'),
('regression: partial then full outage same day',
['2024-03-05',
'paper',
[['2024-03-05', 'all'], ['2024-03-05', '15:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06'),
('electronic partial closure',
['2024-03-05',
'electronic',
[['2024-03-05', '14:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-05'),
('fax partial closure',
['2024-03-05',
'fax',
[['2024-03-05', '14:00']],
'17:00',
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
'2024-03-06')]]
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: partial then full outage same day | 2024-03-06 | 2024-03-06 | Passed |
| electronic partial closure | 2024-03-05 | 2024-03-05 | Passed |
| fax partial closure | 2024-03-06 | 2024-03-06 | Passed |
| closure at office close | 2024-03-05 | 2024-03-05 | Passed |
| afternoon closure paper | 2024-03-06 | 2024-03-06 | Passed |
| two-day outage | 2024-03-07 | 2024-03-07 | Passed |
| friday outage | 2024-03-11 | 2024-03-11 | Passed |
SHA-256 / 4a1cd4f6fdacd91d06b5c384ce693f0b317afc8c4afc0805ef9fecb5b614635c
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:29.407801+00:00.
Case digest / ff8a0447ed341cbdc28336afe7d435ad88c9f84d5513eeac2962c15c7614e39a