FA-66446 / Airline fare rule evaluation / Open access
A direction inside overlapping blackouts reported twice · case 01
Christmas Eve travel shows OUT twice because two blackout ranges overlap.
ROOT CAUSE
Scanning continues after the first matching range, appending the tag for every overlap.
VERIFIED REPAIR
Record each direction once, at the first matching range.
Unsuccessful approach: Deduplicating through a set also reorders the result alphabetically.
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)
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', 'OUT', 'IN', 'IN'] | ['OUT', 'IN'] | Failed |
| clear trip | [] | [] | Passed |
| start day of range | ['OUT'] | ['OUT'] | Passed |
| sampled case 1 | [] | [] | Passed |
| sampled case 2 | [] | [] | Passed |
| sampled case 3 | [] | [] | Passed |
SHA-256 / ba484198e1f624a942d05d58f45251e8829d1f094292d3138b0adb828e48f953
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)
return sorted(set(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 | ['IN', 'OUT'] | ['OUT', 'IN'] | Failed |
| clear trip | [] | [] | Passed |
| start day of range | ['OUT'] | ['OUT'] | Passed |
| sampled case 1 | [] | [] | Passed |
| sampled case 2 | [] | [] | Passed |
| sampled case 3 | [] | [] | Passed |
SHA-256 / 5a4c13da8f6e8ee1176c701d74496a80730bdbd83c0b4dca1df52c3dc959a7c7
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.722695+00:00.
Case digest / 56ed5c219d52d91b8418411d6a7826868d2c20c1293ca16a5e9e64513cf2b687