FA-66431 / Airline fare rule evaluation / Open access
Final blackout day open for travel · case 01
Departures on the last day of a blackout period are sold.
ROOT CAUSE
The range test excludes the end date.
VERIFIED REPAIR
Treat blackout ranges as inclusive at both ends.
Unsuccessful approach: Excluding the start instead opens the first blackout day.
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:
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'] | Failed |
| single-day blackout | [] | ['IN'] | Failed |
| 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 / 48ad494d51c6915ee2c53b25e001e7038fb19960d3c9e9221f185bc547ad1478
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:
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'] | Failed |
| inbound in second range | ['IN'] | ['IN'] | Passed |
| both directions blocked | ['OUT', 'IN'] | ['OUT', 'IN'] | Passed |
| clear trip | [] | [] | Passed |
| start day of range | [] | ['OUT'] | Failed |
| sampled case 1 | [] | [] | Passed |
| sampled case 2 | [] | [] | Passed |
| sampled case 3 | [] | [] | Passed |
SHA-256 / 8eacf689955a76f4290b6cca62de047c7b101ff6db7a2e93949bc688cfddbe8e
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.618995+00:00.
Case digest / 8a3d1806ace8c6220cba71e1c7cc1da4ddc79391993e13cb9d529c56751db8bc