FA-66346 / Airline fare rule evaluation / Open access
Ticket bought exactly AP days ahead rejected · case 01
A 7-day advance purchase fare cannot be ticketed exactly seven days before departure.
ROOT CAUSE
The comparison fails day counts equal to the requirement.
VERIFIED REPAIR
Pass when the calendar day count is at least the AP requirement.
Unsuccessful approach: Measuring from the reservation date instead of ticketing lets late ticketing satisfy AP.
Case contract
Input {'res','ticket','depart' ISO local datetimes,'ap_days','ticket_within_h'}. Ticket before reservation -> 'ERR_ORDER'. AP counts calendar days between the ticketing date and the departure date (>= ap_days passes) and is checked before the ticketing time limit; ticketing must be at or before reservation + ticket_within_h hours. Return 'PASS', 'FAIL_AP' or 'FAIL_TKT_TL'.
Why this case matters
Advance purchase rules count calendar days, not elapsed 24-hour periods, and interact with a separate ticketing time limit after booking.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
T = datetime.datetime.fromisoformat(x['ticket'])
D = datetime.datetime.fromisoformat(x['depart'])
R = datetime.datetime.fromisoformat(x['res'])
if T < R: return 'ERR_ORDER'
if (D.date() - T.date()).days <= x['ap_days']: return 'FAIL_AP'
if T > R + datetime.timedelta(hours=x['ticket_within_h']): return 'FAIL_TKT_TL'
return 'PASS'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-15T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 25}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:05', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:51', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_AP'], ['sampled case 1', {'res': '2029-04-23T19:45', 'ticket': '2029-04-25T19:45', 'depart': '2029-05-10T07:45', 'ap_days': 21, 'ticket_within_h': 72}, 'FAIL_AP'], ['sampled case 2', {'res': '2028-12-29T20:45', 'ticket': '2028-12-30T21:15', 'depart': '2029-01-24T15:15', 'ap_days': 3, 'ticket_within_h': 72}, 'PASS'], ['sampled case 3', {'res': '2029-11-28T18:15', 'ticket': '2029-11-29T14:45', 'depart': '2029-12-08T20:45', 'ap_days': 21, 'ticket_within_h': 72}, 'FAIL_AP']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-16T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 26}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:10', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:52', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['sampled case 1', {'res': '2029-03-02T18:30', 'ticket': '2029-03-05T19:00', 'depart': '2029-03-14T02:00', 'ap_days': 14, 'ticket_within_h': 72}, 'FAIL_AP'], ['sampled case 2', {'res': '2028-11-19T00:15', 'ticket': '2028-11-20T00:15', 'depart': '2028-12-13T04:15', 'ap_days': 7, 'ticket_within_h': 24}, 'PASS'], ['sampled case 3', {'res': '2028-08-13T05:15', 'ticket': '2028-08-13T20:45', 'depart': '2028-08-18T10:45', 'ap_days': 3, 'ticket_within_h': 72}, 'PASS']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-17T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 27}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:15', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:53', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 72}, 'FAIL_AP'], ['sampled case 1', {'res': '2028-01-07T10:45', 'ticket': '2028-01-10T11:15', 'depart': '2028-01-27T06:15', 'ap_days': 14, 'ticket_within_h': 72}, 'FAIL_TKT_TL'], ['sampled case 2', {'res': '2027-11-20T22:00', 'ticket': '2027-11-23T02:00', 'depart': '2027-12-12T09:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_AP'], ['sampled case 3', {'res': '2029-01-16T10:15', 'ticket': '2029-01-17T10:45', 'depart': '2029-02-13T03:45', 'ap_days': 14, 'ticket_within_h': 24}, 'FAIL_TKT_TL']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-18T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 28}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:20', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:54', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 96}, 'FAIL_AP'], ['sampled case 1', {'res': '2028-04-10T05:15', 'ticket': '2028-04-13T05:15', 'depart': '2028-04-21T10:15', 'ap_days': 14, 'ticket_within_h': 48}, 'FAIL_AP'], ['sampled case 2', {'res': '2029-06-06T12:45', 'ticket': '2029-06-09T12:45', 'depart': '2029-07-06T08:45', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['sampled case 3', {'res': '2029-10-21T12:00', 'ticket': '2029-10-24T12:00', 'depart': '2029-11-15T19:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_TKT_TL']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-19T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 29}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:25', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:55', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 120}, 'FAIL_AP'], ['sampled case 1', {'res': '2029-04-07T13:45', 'ticket': '2029-04-08T19:15', 'depart': '2029-04-19T08:15', 'ap_days': 3, 'ticket_within_h': 48}, 'PASS'], ['sampled case 2', {'res': '2027-04-03T07:45', 'ticket': '2027-04-05T08:15', 'depart': '2027-05-01T01:15', 'ap_days': 3, 'ticket_within_h': 48}, 'FAIL_TKT_TL'], ['sampled case 3', {'res': '2029-01-24T00:30', 'ticket': '2029-01-25T01:00', 'depart': '2029-02-11T22:00', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_TKT_TL']]]
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 |
|---|---|---|---|
| late evening ticket, early departure | FAIL_AP | PASS | Failed |
| exactly AP days | FAIL_AP | PASS | Failed |
| one day short | FAIL_AP | FAIL_AP | Passed |
| ticketed at exact time limit | PASS | PASS | Passed |
| ticketed after time limit | FAIL_TKT_TL | FAIL_TKT_TL | Passed |
| ticket before reservation | ERR_ORDER | ERR_ORDER | Passed |
| AP and time limit both fail | FAIL_AP | FAIL_AP | Passed |
| sampled case 1 | FAIL_AP | FAIL_AP | Passed |
| sampled case 2 | PASS | PASS | Passed |
| sampled case 3 | FAIL_AP | FAIL_AP | Passed |
SHA-256 / 17480758115a6f95254c4d95d8b633f380e56ce701c57abc16364acf2576771e
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
T = datetime.datetime.fromisoformat(x['ticket'])
D = datetime.datetime.fromisoformat(x['depart'])
R = datetime.datetime.fromisoformat(x['res'])
if T < R: return 'ERR_ORDER'
if (D.date() - R.date()).days < x['ap_days']: return 'FAIL_AP'
if T > R + datetime.timedelta(hours=x['ticket_within_h']): return 'FAIL_TKT_TL'
return 'PASS'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-15T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 25}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:05', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:51', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_AP'], ['sampled case 1', {'res': '2029-04-23T19:45', 'ticket': '2029-04-25T19:45', 'depart': '2029-05-10T07:45', 'ap_days': 21, 'ticket_within_h': 72}, 'FAIL_AP'], ['sampled case 2', {'res': '2028-12-29T20:45', 'ticket': '2028-12-30T21:15', 'depart': '2029-01-24T15:15', 'ap_days': 3, 'ticket_within_h': 72}, 'PASS'], ['sampled case 3', {'res': '2029-11-28T18:15', 'ticket': '2029-11-29T14:45', 'depart': '2029-12-08T20:45', 'ap_days': 21, 'ticket_within_h': 72}, 'FAIL_AP']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-16T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 26}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:10', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:52', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['sampled case 1', {'res': '2029-03-02T18:30', 'ticket': '2029-03-05T19:00', 'depart': '2029-03-14T02:00', 'ap_days': 14, 'ticket_within_h': 72}, 'FAIL_AP'], ['sampled case 2', {'res': '2028-11-19T00:15', 'ticket': '2028-11-20T00:15', 'depart': '2028-12-13T04:15', 'ap_days': 7, 'ticket_within_h': 24}, 'PASS'], ['sampled case 3', {'res': '2028-08-13T05:15', 'ticket': '2028-08-13T20:45', 'depart': '2028-08-18T10:45', 'ap_days': 3, 'ticket_within_h': 72}, 'PASS']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-17T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 27}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:15', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:53', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 72}, 'FAIL_AP'], ['sampled case 1', {'res': '2028-01-07T10:45', 'ticket': '2028-01-10T11:15', 'depart': '2028-01-27T06:15', 'ap_days': 14, 'ticket_within_h': 72}, 'FAIL_TKT_TL'], ['sampled case 2', {'res': '2027-11-20T22:00', 'ticket': '2027-11-23T02:00', 'depart': '2027-12-12T09:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_AP'], ['sampled case 3', {'res': '2029-01-16T10:15', 'ticket': '2029-01-17T10:45', 'depart': '2029-02-13T03:45', 'ap_days': 14, 'ticket_within_h': 24}, 'FAIL_TKT_TL']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-18T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 28}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:20', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:54', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 96}, 'FAIL_AP'], ['sampled case 1', {'res': '2028-04-10T05:15', 'ticket': '2028-04-13T05:15', 'depart': '2028-04-21T10:15', 'ap_days': 14, 'ticket_within_h': 48}, 'FAIL_AP'], ['sampled case 2', {'res': '2029-06-06T12:45', 'ticket': '2029-06-09T12:45', 'depart': '2029-07-06T08:45', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['sampled case 3', {'res': '2029-10-21T12:00', 'ticket': '2029-10-24T12:00', 'depart': '2029-11-15T19:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_TKT_TL']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-19T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 29}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:25', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:55', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 120}, 'FAIL_AP'], ['sampled case 1', {'res': '2029-04-07T13:45', 'ticket': '2029-04-08T19:15', 'depart': '2029-04-19T08:15', 'ap_days': 3, 'ticket_within_h': 48}, 'PASS'], ['sampled case 2', {'res': '2027-04-03T07:45', 'ticket': '2027-04-05T08:15', 'depart': '2027-05-01T01:15', 'ap_days': 3, 'ticket_within_h': 48}, 'FAIL_TKT_TL'], ['sampled case 3', {'res': '2029-01-24T00:30', 'ticket': '2029-01-25T01:00', 'depart': '2029-02-11T22:00', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_TKT_TL']]]
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 |
|---|---|---|---|
| late evening ticket, early departure | PASS | PASS | Passed |
| exactly AP days | PASS | PASS | Passed |
| one day short | PASS | FAIL_AP | Failed |
| ticketed at exact time limit | PASS | PASS | Passed |
| ticketed after time limit | FAIL_TKT_TL | FAIL_TKT_TL | Passed |
| ticket before reservation | ERR_ORDER | ERR_ORDER | Passed |
| AP and time limit both fail | FAIL_TKT_TL | FAIL_AP | Failed |
| sampled case 1 | FAIL_AP | FAIL_AP | Passed |
| sampled case 2 | PASS | PASS | Passed |
| sampled case 3 | FAIL_AP | FAIL_AP | Passed |
SHA-256 / 3536bb6757e8b42222c5383c48cd31beb8fea220cb63fe22cecfee7772c4368a
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
T = datetime.datetime.fromisoformat(x['ticket'])
D = datetime.datetime.fromisoformat(x['depart'])
R = datetime.datetime.fromisoformat(x['res'])
if T < R: return 'ERR_ORDER'
if (D.date() - T.date()).days < x['ap_days']: return 'FAIL_AP'
if T > R + datetime.timedelta(hours=x['ticket_within_h']): return 'FAIL_TKT_TL'
return 'PASS'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-15T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 25}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:05', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:51', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_AP'], ['sampled case 1', {'res': '2029-04-23T19:45', 'ticket': '2029-04-25T19:45', 'depart': '2029-05-10T07:45', 'ap_days': 21, 'ticket_within_h': 72}, 'FAIL_AP'], ['sampled case 2', {'res': '2028-12-29T20:45', 'ticket': '2028-12-30T21:15', 'depart': '2029-01-24T15:15', 'ap_days': 3, 'ticket_within_h': 72}, 'PASS'], ['sampled case 3', {'res': '2029-11-28T18:15', 'ticket': '2029-11-29T14:45', 'depart': '2029-12-08T20:45', 'ap_days': 21, 'ticket_within_h': 72}, 'FAIL_AP']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-16T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 26}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:10', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:52', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['sampled case 1', {'res': '2029-03-02T18:30', 'ticket': '2029-03-05T19:00', 'depart': '2029-03-14T02:00', 'ap_days': 14, 'ticket_within_h': 72}, 'FAIL_AP'], ['sampled case 2', {'res': '2028-11-19T00:15', 'ticket': '2028-11-20T00:15', 'depart': '2028-12-13T04:15', 'ap_days': 7, 'ticket_within_h': 24}, 'PASS'], ['sampled case 3', {'res': '2028-08-13T05:15', 'ticket': '2028-08-13T20:45', 'depart': '2028-08-18T10:45', 'ap_days': 3, 'ticket_within_h': 72}, 'PASS']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-17T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 27}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:15', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:53', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 72}, 'FAIL_AP'], ['sampled case 1', {'res': '2028-01-07T10:45', 'ticket': '2028-01-10T11:15', 'depart': '2028-01-27T06:15', 'ap_days': 14, 'ticket_within_h': 72}, 'FAIL_TKT_TL'], ['sampled case 2', {'res': '2027-11-20T22:00', 'ticket': '2027-11-23T02:00', 'depart': '2027-12-12T09:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_AP'], ['sampled case 3', {'res': '2029-01-16T10:15', 'ticket': '2029-01-17T10:45', 'depart': '2029-02-13T03:45', 'ap_days': 14, 'ticket_within_h': 24}, 'FAIL_TKT_TL']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-18T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 28}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:20', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:54', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 96}, 'FAIL_AP'], ['sampled case 1', {'res': '2028-04-10T05:15', 'ticket': '2028-04-13T05:15', 'depart': '2028-04-21T10:15', 'ap_days': 14, 'ticket_within_h': 48}, 'FAIL_AP'], ['sampled case 2', {'res': '2029-06-06T12:45', 'ticket': '2029-06-09T12:45', 'depart': '2029-07-06T08:45', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['sampled case 3', {'res': '2029-10-21T12:00', 'ticket': '2029-10-24T12:00', 'depart': '2029-11-15T19:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_TKT_TL']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-19T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 29}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:25', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:55', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 120}, 'FAIL_AP'], ['sampled case 1', {'res': '2029-04-07T13:45', 'ticket': '2029-04-08T19:15', 'depart': '2029-04-19T08:15', 'ap_days': 3, 'ticket_within_h': 48}, 'PASS'], ['sampled case 2', {'res': '2027-04-03T07:45', 'ticket': '2027-04-05T08:15', 'depart': '2027-05-01T01:15', 'ap_days': 3, 'ticket_within_h': 48}, 'FAIL_TKT_TL'], ['sampled case 3', {'res': '2029-01-24T00:30', 'ticket': '2029-01-25T01:00', 'depart': '2029-02-11T22:00', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_TKT_TL']]]
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 |
|---|---|---|---|
| late evening ticket, early departure | PASS | PASS | Passed |
| exactly AP days | PASS | PASS | Passed |
| one day short | FAIL_AP | FAIL_AP | Passed |
| ticketed at exact time limit | PASS | PASS | Passed |
| ticketed after time limit | FAIL_TKT_TL | FAIL_TKT_TL | Passed |
| ticket before reservation | ERR_ORDER | ERR_ORDER | Passed |
| AP and time limit both fail | FAIL_AP | FAIL_AP | Passed |
| sampled case 1 | FAIL_AP | FAIL_AP | Passed |
| sampled case 2 | PASS | PASS | Passed |
| sampled case 3 | FAIL_AP | FAIL_AP | Passed |
SHA-256 / 00361ee3d649fecca35ffdf6d415456c28a96667457ab271009a410a44facfb5
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:42.659386+00:00.
Case digest / 291e1dbb3217e8b0e01d5483c3a351bf638fb10d77492d08e47b92d051a921de