FA-66426 / Airline fare rule evaluation / Open access
Staying through a blackout blocks the return · case 01
A trip out on 11 December and back on 5 January is refused because the Christmas blackout falls in between.
ROOT CAUSE
The inbound direction is also blocked when any blackout overlaps the stay period.
VERIFIED REPAIR
Test only each direction departure date against the blackout ranges.
Unsuccessful approach: Blocking only blackouts fully contained within the stay is still a stay-period rule.
Case contract
Input {'outbound','inbound' (ISO date or None),'blackouts':[[start, end] or [single date]]}. Blackouts apply only to each direction's departure date (inclusive ranges), not to days in between. Return the list of blocked directions in order 'OUT','IN', each at most once.
Why this case matters
Blackout rules restrict travel dates per direction; staying through a blackout period is permitted.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
out = []
for tag, ds in (('OUT', x['outbound']), ('IN', x['inbound'])):
if ds is None: continue
d = datetime.date.fromisoformat(ds)
for rng in x['blackouts']:
a = datetime.date.fromisoformat(rng[0])
b = datetime.date.fromisoformat(rng[-1])
if a <= d <= b or (tag == 'IN' and a <= d and b >= datetime.date.fromisoformat(x['outbound'])):
out.append(tag)
break
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['trip spans a blackout', {'outbound': '2027-12-11', 'inbound': '2028-01-05', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['outbound on end date', {'outbound': '2028-04-17', 'inbound': None, 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['single-day blackout', {'outbound': '2028-02-09', 'inbound': '2028-02-14', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['inbound in second range', {'outbound': '2027-12-02', 'inbound': '2027-12-30', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['both directions blocked', {'outbound': '2027-12-24', 'inbound': '2027-12-26', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT', 'IN']], ['clear trip', {'outbound': '2028-03-01', 'inbound': '2028-03-20', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['start day of range', {'outbound': '2028-04-10', 'inbound': '2028-04-21', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['sampled case 1', {'outbound': '2027-04-27', 'inbound': '2027-05-20', 'blackouts': [['2028-11-06']]}, []], ['sampled case 2', {'outbound': '2028-09-02', 'inbound': '2028-09-14', 'blackouts': [['2027-02-28', '2027-03-11'], ['2028-04-27'], ['2027-05-07', '2027-05-14']]}, []], ['sampled case 3', {'outbound': '2027-06-30', 'inbound': '2027-07-31', 'blackouts': [['2028-07-23'], ['2028-02-18', '2028-02-24'], ['2028-02-06', '2028-02-10'], ['2028-04-11', '2028-04-21']]}, []]], [['trip spans a blackout', {'outbound': '2027-12-12', 'inbound': '2028-01-05', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['outbound on end date', {'outbound': '2028-04-17', 'inbound': None, 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['single-day blackout', {'outbound': '2028-02-10', 'inbound': '2028-02-14', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['inbound in second range', {'outbound': '2027-12-03', 'inbound': '2027-12-30', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['both directions blocked', {'outbound': '2027-12-24', 'inbound': '2027-12-26', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT', 'IN']], ['clear trip', {'outbound': '2028-03-02', 'inbound': '2028-03-20', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['start day of range', {'outbound': '2028-04-10', 'inbound': '2028-04-22', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['sampled case 1', {'outbound': '2027-12-03', 'inbound': '2027-12-13', 'blackouts': [['2027-05-07', '2027-05-15'], ['2027-11-09', '2027-11-20'], ['2027-02-15', '2027-02-26'], ['2027-05-24', '2027-05-31']]}, []], ['sampled case 2', {'outbound': '2027-12-20', 'inbound': '2028-01-12', 'blackouts': [['2028-11-01', '2028-11-09'], ['2028-12-29', '2029-01-07']]}, []], ['sampled case 3', {'outbound': '2027-06-18', 'inbound': '2027-07-26', 'blackouts': [['2028-10-29', '2028-11-08']]}, []]], [['trip spans a blackout', {'outbound': '2027-12-13', 'inbound': '2028-01-05', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['outbound on end date', {'outbound': '2028-04-17', 'inbound': None, 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['single-day blackout', {'outbound': '2028-02-11', 'inbound': '2028-02-14', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['inbound in second range', {'outbound': '2027-12-04', 'inbound': '2027-12-30', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['both directions blocked', {'outbound': '2027-12-24', 'inbound': '2027-12-26', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT', 'IN']], ['clear trip', {'outbound': '2028-03-03', 'inbound': '2028-03-20', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['start day of range', {'outbound': '2028-04-10', 'inbound': '2028-04-23', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['sampled case 1', {'outbound': '2027-01-26', 'inbound': None, 'blackouts': [['2028-12-08', '2028-12-08'], ['2027-08-12'], ['2028-08-20', '2028-08-23']]}, []], ['sampled case 2', {'outbound': '2028-07-28', 'inbound': '2028-09-03', 'blackouts': [['2027-08-10', '2027-08-11'], ['2027-02-12'], ['2027-03-22', '2027-03-30'], ['2028-01-03', '2028-01-03']]}, []], ['sampled case 3', {'outbound': '2028-05-10', 'inbound': '2028-05-17', 'blackouts': [['2027-03-25', '2027-03-26']]}, []]], [['trip spans a blackout', {'outbound': '2027-12-14', 'inbound': '2028-01-05', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['outbound on end date', {'outbound': '2028-04-17', 'inbound': None, 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['single-day blackout', {'outbound': '2028-02-12', 'inbound': '2028-02-14', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['inbound in second range', {'outbound': '2027-12-05', 'inbound': '2027-12-30', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['both directions blocked', {'outbound': '2027-12-24', 'inbound': '2027-12-26', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT', 'IN']], ['clear trip', {'outbound': '2028-03-04', 'inbound': '2028-03-20', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['start day of range', {'outbound': '2028-04-10', 'inbound': '2028-04-24', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['sampled case 1', {'outbound': '2028-05-25', 'inbound': '2028-06-06', 'blackouts': [['2028-05-14'], ['2028-11-03', '2028-11-14']]}, []], ['sampled case 2', {'outbound': '2027-05-21', 'inbound': None, 'blackouts': [['2028-07-14', '2028-07-14']]}, []], ['sampled case 3', {'outbound': '2028-11-12', 'inbound': '2028-12-09', 'blackouts': [['2028-09-06', '2028-09-09']]}, []]], [['trip spans a blackout', {'outbound': '2027-12-15', 'inbound': '2028-01-05', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['outbound on end date', {'outbound': '2028-04-17', 'inbound': None, 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['single-day blackout', {'outbound': '2028-02-13', 'inbound': '2028-02-14', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['inbound in second range', {'outbound': '2027-12-06', 'inbound': '2027-12-30', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['both directions blocked', {'outbound': '2027-12-24', 'inbound': '2027-12-26', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT', 'IN']], ['clear trip', {'outbound': '2028-03-05', 'inbound': '2028-03-20', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['start day of range', {'outbound': '2028-04-10', 'inbound': '2028-04-25', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['sampled case 1', {'outbound': '2027-04-06', 'inbound': None, 'blackouts': [['2027-05-03', '2027-05-11'], ['2027-09-16', '2027-09-16']]}, []], ['sampled case 2', {'outbound': '2028-09-10', 'inbound': None, 'blackouts': [['2027-05-03', '2027-05-05'], ['2027-05-06']]}, []], ['sampled case 3', {'outbound': '2027-01-31', 'inbound': '2027-02-06', 'blackouts': [['2028-04-06', '2028-04-16'], ['2028-06-24', '2028-06-27']]}, []]]]
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 |
|---|---|---|---|
| trip spans a blackout | ['IN'] | [] | Failed |
| outbound on end date | ['OUT'] | ['OUT'] | Passed |
| single-day blackout | ['IN'] | ['IN'] | Passed |
| inbound in second range | ['IN'] | ['IN'] | Passed |
| both directions blocked | ['OUT', 'IN'] | ['OUT', 'IN'] | Passed |
| clear trip | [] | [] | Passed |
| start day of range | ['OUT', 'IN'] | ['OUT'] | Failed |
| sampled case 1 | [] | [] | Passed |
| sampled case 2 | [] | [] | Passed |
| sampled case 3 | [] | [] | Passed |
SHA-256 / 6855bc253a1e558849560c96eca9a95ed227fc7449e8b2f8c297499410bc78d0
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
out = []
for tag, ds in (('OUT', x['outbound']), ('IN', x['inbound'])):
if ds is None: continue
d = datetime.date.fromisoformat(ds)
for rng in x['blackouts']:
a = datetime.date.fromisoformat(rng[0])
b = datetime.date.fromisoformat(rng[-1])
if a <= d <= b or (tag == 'IN' and a >= datetime.date.fromisoformat(x['outbound']) and b <= d):
out.append(tag)
break
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['trip spans a blackout', {'outbound': '2027-12-11', 'inbound': '2028-01-05', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['outbound on end date', {'outbound': '2028-04-17', 'inbound': None, 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['single-day blackout', {'outbound': '2028-02-09', 'inbound': '2028-02-14', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['inbound in second range', {'outbound': '2027-12-02', 'inbound': '2027-12-30', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['both directions blocked', {'outbound': '2027-12-24', 'inbound': '2027-12-26', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT', 'IN']], ['clear trip', {'outbound': '2028-03-01', 'inbound': '2028-03-20', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['start day of range', {'outbound': '2028-04-10', 'inbound': '2028-04-21', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['sampled case 1', {'outbound': '2027-04-27', 'inbound': '2027-05-20', 'blackouts': [['2028-11-06']]}, []], ['sampled case 2', {'outbound': '2028-09-02', 'inbound': '2028-09-14', 'blackouts': [['2027-02-28', '2027-03-11'], ['2028-04-27'], ['2027-05-07', '2027-05-14']]}, []], ['sampled case 3', {'outbound': '2027-06-30', 'inbound': '2027-07-31', 'blackouts': [['2028-07-23'], ['2028-02-18', '2028-02-24'], ['2028-02-06', '2028-02-10'], ['2028-04-11', '2028-04-21']]}, []]], [['trip spans a blackout', {'outbound': '2027-12-12', 'inbound': '2028-01-05', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['outbound on end date', {'outbound': '2028-04-17', 'inbound': None, 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['single-day blackout', {'outbound': '2028-02-10', 'inbound': '2028-02-14', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['inbound in second range', {'outbound': '2027-12-03', 'inbound': '2027-12-30', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['both directions blocked', {'outbound': '2027-12-24', 'inbound': '2027-12-26', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT', 'IN']], ['clear trip', {'outbound': '2028-03-02', 'inbound': '2028-03-20', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['start day of range', {'outbound': '2028-04-10', 'inbound': '2028-04-22', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['sampled case 1', {'outbound': '2027-12-03', 'inbound': '2027-12-13', 'blackouts': [['2027-05-07', '2027-05-15'], ['2027-11-09', '2027-11-20'], ['2027-02-15', '2027-02-26'], ['2027-05-24', '2027-05-31']]}, []], ['sampled case 2', {'outbound': '2027-12-20', 'inbound': '2028-01-12', 'blackouts': [['2028-11-01', '2028-11-09'], ['2028-12-29', '2029-01-07']]}, []], ['sampled case 3', {'outbound': '2027-06-18', 'inbound': '2027-07-26', 'blackouts': [['2028-10-29', '2028-11-08']]}, []]], [['trip spans a blackout', {'outbound': '2027-12-13', 'inbound': '2028-01-05', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['outbound on end date', {'outbound': '2028-04-17', 'inbound': None, 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['single-day blackout', {'outbound': '2028-02-11', 'inbound': '2028-02-14', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['inbound in second range', {'outbound': '2027-12-04', 'inbound': '2027-12-30', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['both directions blocked', {'outbound': '2027-12-24', 'inbound': '2027-12-26', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT', 'IN']], ['clear trip', {'outbound': '2028-03-03', 'inbound': '2028-03-20', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['start day of range', {'outbound': '2028-04-10', 'inbound': '2028-04-23', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['sampled case 1', {'outbound': '2027-01-26', 'inbound': None, 'blackouts': [['2028-12-08', '2028-12-08'], ['2027-08-12'], ['2028-08-20', '2028-08-23']]}, []], ['sampled case 2', {'outbound': '2028-07-28', 'inbound': '2028-09-03', 'blackouts': [['2027-08-10', '2027-08-11'], ['2027-02-12'], ['2027-03-22', '2027-03-30'], ['2028-01-03', '2028-01-03']]}, []], ['sampled case 3', {'outbound': '2028-05-10', 'inbound': '2028-05-17', 'blackouts': [['2027-03-25', '2027-03-26']]}, []]], [['trip spans a blackout', {'outbound': '2027-12-14', 'inbound': '2028-01-05', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['outbound on end date', {'outbound': '2028-04-17', 'inbound': None, 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['single-day blackout', {'outbound': '2028-02-12', 'inbound': '2028-02-14', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['inbound in second range', {'outbound': '2027-12-05', 'inbound': '2027-12-30', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['both directions blocked', {'outbound': '2027-12-24', 'inbound': '2027-12-26', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT', 'IN']], ['clear trip', {'outbound': '2028-03-04', 'inbound': '2028-03-20', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['start day of range', {'outbound': '2028-04-10', 'inbound': '2028-04-24', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['sampled case 1', {'outbound': '2028-05-25', 'inbound': '2028-06-06', 'blackouts': [['2028-05-14'], ['2028-11-03', '2028-11-14']]}, []], ['sampled case 2', {'outbound': '2027-05-21', 'inbound': None, 'blackouts': [['2028-07-14', '2028-07-14']]}, []], ['sampled case 3', {'outbound': '2028-11-12', 'inbound': '2028-12-09', 'blackouts': [['2028-09-06', '2028-09-09']]}, []]], [['trip spans a blackout', {'outbound': '2027-12-15', 'inbound': '2028-01-05', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['outbound on end date', {'outbound': '2028-04-17', 'inbound': None, 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['single-day blackout', {'outbound': '2028-02-13', 'inbound': '2028-02-14', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['inbound in second range', {'outbound': '2027-12-06', 'inbound': '2027-12-30', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['both directions blocked', {'outbound': '2027-12-24', 'inbound': '2027-12-26', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT', 'IN']], ['clear trip', {'outbound': '2028-03-05', 'inbound': '2028-03-20', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['start day of range', {'outbound': '2028-04-10', 'inbound': '2028-04-25', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['sampled case 1', {'outbound': '2027-04-06', 'inbound': None, 'blackouts': [['2027-05-03', '2027-05-11'], ['2027-09-16', '2027-09-16']]}, []], ['sampled case 2', {'outbound': '2028-09-10', 'inbound': None, 'blackouts': [['2027-05-03', '2027-05-05'], ['2027-05-06']]}, []], ['sampled case 3', {'outbound': '2027-01-31', 'inbound': '2027-02-06', 'blackouts': [['2028-04-06', '2028-04-16'], ['2028-06-24', '2028-06-27']]}, []]]]
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 |
|---|---|---|---|
| trip spans a blackout | ['IN'] | [] | Failed |
| outbound on end date | ['OUT'] | ['OUT'] | Passed |
| single-day blackout | ['IN'] | ['IN'] | Passed |
| inbound in second range | ['IN'] | ['IN'] | Passed |
| both directions blocked | ['OUT', 'IN'] | ['OUT', 'IN'] | Passed |
| clear trip | [] | [] | Passed |
| start day of range | ['OUT', 'IN'] | ['OUT'] | Failed |
| sampled case 1 | [] | [] | Passed |
| sampled case 2 | [] | [] | Passed |
| sampled case 3 | [] | [] | Passed |
SHA-256 / e549de036f4ea6175eabd9ca1b1f2898c304e7cf896148973f34987e8a83a2cb
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
out = []
for tag, ds in (('OUT', x['outbound']), ('IN', x['inbound'])):
if ds is None: continue
d = datetime.date.fromisoformat(ds)
for rng in x['blackouts']:
a = datetime.date.fromisoformat(rng[0])
b = datetime.date.fromisoformat(rng[-1])
if a <= d <= b:
out.append(tag)
break
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['trip spans a blackout', {'outbound': '2027-12-11', 'inbound': '2028-01-05', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['outbound on end date', {'outbound': '2028-04-17', 'inbound': None, 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['single-day blackout', {'outbound': '2028-02-09', 'inbound': '2028-02-14', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['inbound in second range', {'outbound': '2027-12-02', 'inbound': '2027-12-30', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['both directions blocked', {'outbound': '2027-12-24', 'inbound': '2027-12-26', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT', 'IN']], ['clear trip', {'outbound': '2028-03-01', 'inbound': '2028-03-20', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['start day of range', {'outbound': '2028-04-10', 'inbound': '2028-04-21', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['sampled case 1', {'outbound': '2027-04-27', 'inbound': '2027-05-20', 'blackouts': [['2028-11-06']]}, []], ['sampled case 2', {'outbound': '2028-09-02', 'inbound': '2028-09-14', 'blackouts': [['2027-02-28', '2027-03-11'], ['2028-04-27'], ['2027-05-07', '2027-05-14']]}, []], ['sampled case 3', {'outbound': '2027-06-30', 'inbound': '2027-07-31', 'blackouts': [['2028-07-23'], ['2028-02-18', '2028-02-24'], ['2028-02-06', '2028-02-10'], ['2028-04-11', '2028-04-21']]}, []]], [['trip spans a blackout', {'outbound': '2027-12-12', 'inbound': '2028-01-05', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['outbound on end date', {'outbound': '2028-04-17', 'inbound': None, 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['single-day blackout', {'outbound': '2028-02-10', 'inbound': '2028-02-14', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['inbound in second range', {'outbound': '2027-12-03', 'inbound': '2027-12-30', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['both directions blocked', {'outbound': '2027-12-24', 'inbound': '2027-12-26', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT', 'IN']], ['clear trip', {'outbound': '2028-03-02', 'inbound': '2028-03-20', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['start day of range', {'outbound': '2028-04-10', 'inbound': '2028-04-22', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['sampled case 1', {'outbound': '2027-12-03', 'inbound': '2027-12-13', 'blackouts': [['2027-05-07', '2027-05-15'], ['2027-11-09', '2027-11-20'], ['2027-02-15', '2027-02-26'], ['2027-05-24', '2027-05-31']]}, []], ['sampled case 2', {'outbound': '2027-12-20', 'inbound': '2028-01-12', 'blackouts': [['2028-11-01', '2028-11-09'], ['2028-12-29', '2029-01-07']]}, []], ['sampled case 3', {'outbound': '2027-06-18', 'inbound': '2027-07-26', 'blackouts': [['2028-10-29', '2028-11-08']]}, []]], [['trip spans a blackout', {'outbound': '2027-12-13', 'inbound': '2028-01-05', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['outbound on end date', {'outbound': '2028-04-17', 'inbound': None, 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['single-day blackout', {'outbound': '2028-02-11', 'inbound': '2028-02-14', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['inbound in second range', {'outbound': '2027-12-04', 'inbound': '2027-12-30', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['both directions blocked', {'outbound': '2027-12-24', 'inbound': '2027-12-26', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT', 'IN']], ['clear trip', {'outbound': '2028-03-03', 'inbound': '2028-03-20', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['start day of range', {'outbound': '2028-04-10', 'inbound': '2028-04-23', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['sampled case 1', {'outbound': '2027-01-26', 'inbound': None, 'blackouts': [['2028-12-08', '2028-12-08'], ['2027-08-12'], ['2028-08-20', '2028-08-23']]}, []], ['sampled case 2', {'outbound': '2028-07-28', 'inbound': '2028-09-03', 'blackouts': [['2027-08-10', '2027-08-11'], ['2027-02-12'], ['2027-03-22', '2027-03-30'], ['2028-01-03', '2028-01-03']]}, []], ['sampled case 3', {'outbound': '2028-05-10', 'inbound': '2028-05-17', 'blackouts': [['2027-03-25', '2027-03-26']]}, []]], [['trip spans a blackout', {'outbound': '2027-12-14', 'inbound': '2028-01-05', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['outbound on end date', {'outbound': '2028-04-17', 'inbound': None, 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['single-day blackout', {'outbound': '2028-02-12', 'inbound': '2028-02-14', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['inbound in second range', {'outbound': '2027-12-05', 'inbound': '2027-12-30', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['both directions blocked', {'outbound': '2027-12-24', 'inbound': '2027-12-26', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT', 'IN']], ['clear trip', {'outbound': '2028-03-04', 'inbound': '2028-03-20', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['start day of range', {'outbound': '2028-04-10', 'inbound': '2028-04-24', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['sampled case 1', {'outbound': '2028-05-25', 'inbound': '2028-06-06', 'blackouts': [['2028-05-14'], ['2028-11-03', '2028-11-14']]}, []], ['sampled case 2', {'outbound': '2027-05-21', 'inbound': None, 'blackouts': [['2028-07-14', '2028-07-14']]}, []], ['sampled case 3', {'outbound': '2028-11-12', 'inbound': '2028-12-09', 'blackouts': [['2028-09-06', '2028-09-09']]}, []]], [['trip spans a blackout', {'outbound': '2027-12-15', 'inbound': '2028-01-05', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['outbound on end date', {'outbound': '2028-04-17', 'inbound': None, 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['single-day blackout', {'outbound': '2028-02-13', 'inbound': '2028-02-14', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['inbound in second range', {'outbound': '2027-12-06', 'inbound': '2027-12-30', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['IN']], ['both directions blocked', {'outbound': '2027-12-24', 'inbound': '2027-12-26', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT', 'IN']], ['clear trip', {'outbound': '2028-03-05', 'inbound': '2028-03-20', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, []], ['start day of range', {'outbound': '2028-04-10', 'inbound': '2028-04-25', 'blackouts': [['2027-12-20', '2027-12-27'], ['2027-12-24', '2028-01-02'], ['2028-02-14'], ['2028-04-10', '2028-04-17']]}, ['OUT']], ['sampled case 1', {'outbound': '2027-04-06', 'inbound': None, 'blackouts': [['2027-05-03', '2027-05-11'], ['2027-09-16', '2027-09-16']]}, []], ['sampled case 2', {'outbound': '2028-09-10', 'inbound': None, 'blackouts': [['2027-05-03', '2027-05-05'], ['2027-05-06']]}, []], ['sampled case 3', {'outbound': '2027-01-31', 'inbound': '2027-02-06', 'blackouts': [['2028-04-06', '2028-04-16'], ['2028-06-24', '2028-06-27']]}, []]]]
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 |
|---|---|---|---|
| trip spans a blackout | [] | [] | Passed |
| outbound on end date | ['OUT'] | ['OUT'] | Passed |
| single-day blackout | ['IN'] | ['IN'] | Passed |
| inbound in second range | ['IN'] | ['IN'] | Passed |
| both directions blocked | ['OUT', 'IN'] | ['OUT', 'IN'] | Passed |
| clear trip | [] | [] | Passed |
| start day of range | ['OUT'] | ['OUT'] | Passed |
| sampled case 1 | [] | [] | Passed |
| sampled case 2 | [] | [] | Passed |
| sampled case 3 | [] | [] | Passed |
SHA-256 / ed72aa5bbb3305394cce52d8ecde4d38ad2fbedcf2ade498666e7bc7c9012230
Verification & scope
A stipulated toy fare-rule contract with invented constants; it is not an ATPCO or carrier tariff implementation and makes no claim of industry-standard conformance. 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:47:43.562655+00:00.
Case digest / 12495a0365ada45bf7769ebc976fc80e51ddf601ba5a455b0ccd926db46eac98