FA-66791 / Airline fare rule evaluation / Open access
Last flight number of a range excluded · case 01
Flight LH2999 is not covered by a 2000-2999 range.
ROOT CAUSE
The range test excludes its upper bound.
VERIFIED REPAIR
Treat both range bounds as inclusive.
Unsuccessful approach: Excluding the lower bound instead drops the first flight of each range.
Case contract
Input {'segments':[[carrier, flight number string]],'ranges':[[carrier, lo, hi]],'except':[[carrier, flight]]}. Flight numbers are numeric strings that may carry leading zeros; carriers are case-insensitive (tables are uppercase). A segment qualifies if some inclusive range covers it numerically and it is not an exception; exceptions always win. Return one boolean per segment.
Why this case matters
Fare rules restrict validity to flight number ranges with exceptions; flight numbers are identifiers encoded as zero-padded digits.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
out = []
for carrier, fno in x['segments']:
c = carrier.upper()
n = int(fno)
ok = any(c == rc and int(lo) <= n < int(hi) for rc, lo, hi in x['ranges'])
if any(c == ec and n == int(ef) for ec, ef in x['except']):
ok = False
out.append(ok)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['three-digit versus two-digit', {'segments': [['AA', '99'], ['AA', '100'], ['AA', '151']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, True]], ['leading zeros', {'segments': [['BA', '0045'], ['BA', '45'], ['BA', '0450'], ['BA', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['excepted flight inside range', {'segments': [['AA', '500'], ['AA', '0500'], ['LH', '2400'], ['LH', '2401']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, True]], ['lowercase carrier', {'segments': [['ba', '120'], ['lh', '2100'], ['Aa', '101']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True]], ['range end points', {'segments': [['LH', '2000'], ['LH', '2999'], ['AA', '999'], ['AA', '1000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['exception for uncovered carrier', {'segments': [['LH', '2400'], ['UA', '11']], 'ranges': [['AA', '1', '9999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 1', {'segments': [['UA', '0500'], ['ba', '500'], ['BA', '2999']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False]], ['sampled case 2', {'segments': [['BA', '1000'], ['UA', '0500']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 3', {'segments': [['BA', '2000'], ['BA', '500'], ['AA', '2000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False]]], [['three-digit versus two-digit', {'segments': [['AA', '99'], ['AA', '100'], ['AA', '152']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, True]], ['leading zeros', {'segments': [['BA', '0045'], ['BA', '45'], ['BA', '0450'], ['BA', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['excepted flight inside range', {'segments': [['AA', '500'], ['AA', '0500'], ['LH', '2400'], ['LH', '2402']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, True]], ['lowercase carrier', {'segments': [['ba', '120'], ['lh', '2200'], ['Aa', '101']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True]], ['range end points', {'segments': [['LH', '2000'], ['LH', '2999'], ['AA', '999'], ['AA', '1000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['exception for uncovered carrier', {'segments': [['LH', '2400'], ['UA', '12']], 'ranges': [['AA', '1', '9999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 1', {'segments': [['aa', '451'], ['BA', '1873'], ['aa', '1000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, False, False]], ['sampled case 2', {'segments': [['BA', '2400'], ['ba', '0999']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 3', {'segments': [['ba', '1000'], ['UA', '500'], ['aa', '0451'], ['ba', '2000'], ['ba', '999']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, True, False, False]]], [['three-digit versus two-digit', {'segments': [['AA', '99'], ['AA', '100'], ['AA', '153']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, True]], ['leading zeros', {'segments': [['BA', '0045'], ['BA', '45'], ['BA', '0450'], ['BA', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['excepted flight inside range', {'segments': [['AA', '500'], ['AA', '0500'], ['LH', '2400'], ['LH', '2403']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, True]], ['lowercase carrier', {'segments': [['ba', '120'], ['lh', '2300'], ['Aa', '101']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True]], ['range end points', {'segments': [['LH', '2000'], ['LH', '2999'], ['AA', '999'], ['AA', '1000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['exception for uncovered carrier', {'segments': [['LH', '2400'], ['UA', '13']], 'ranges': [['AA', '1', '9999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 1', {'segments': [['UA', '2000'], ['AA', '500']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 2', {'segments': [['AA', '2999'], ['AA', '450'], ['aa', '100'], ['LH', '2000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, True, True]], ['sampled case 3', {'segments': [['BA', '2400'], ['UA', '0500']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]]], [['three-digit versus two-digit', {'segments': [['AA', '99'], ['AA', '100'], ['AA', '154']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, True]], ['leading zeros', {'segments': [['BA', '0045'], ['BA', '45'], ['BA', '0450'], ['BA', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['excepted flight inside range', {'segments': [['AA', '500'], ['AA', '0500'], ['LH', '2400'], ['LH', '2404']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, True]], ['lowercase carrier', {'segments': [['ba', '120'], ['lh', '2400'], ['Aa', '101']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, False, True]], ['range end points', {'segments': [['LH', '2000'], ['LH', '2999'], ['AA', '999'], ['AA', '1000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['exception for uncovered carrier', {'segments': [['LH', '2400'], ['UA', '14']], 'ranges': [['AA', '1', '9999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 1', {'segments': [['ba', '2000'], ['UA', '0450'], ['ba', '1000'], ['AA', '100'], ['BA', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, True, False]], ['sampled case 2', {'segments': [['LH', '0451'], ['aa', '1543'], ['BA', '999'], ['aa', '1000'], ['LH', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, False, False]], ['sampled case 3', {'segments': [['UA', '450'], ['BA', '2999'], ['LH', '099'], ['LH', '0500']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, False]]], [['three-digit versus two-digit', {'segments': [['AA', '99'], ['AA', '100'], ['AA', '155']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, True]], ['leading zeros', {'segments': [['BA', '0045'], ['BA', '45'], ['BA', '0450'], ['BA', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['excepted flight inside range', {'segments': [['AA', '500'], ['AA', '0500'], ['LH', '2400'], ['LH', '2405']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, True]], ['lowercase carrier', {'segments': [['ba', '120'], ['lh', '2500'], ['Aa', '101']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True]], ['range end points', {'segments': [['LH', '2000'], ['LH', '2999'], ['AA', '999'], ['AA', '1000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['exception for uncovered carrier', {'segments': [['LH', '2400'], ['UA', '15']], 'ranges': [['AA', '1', '9999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 1', {'segments': [['BA', '0655'], ['BA', '2000'], ['UA', '1000'], ['AA', '1386']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, False]], ['sampled case 2', {'segments': [['AA', '0999']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True]], ['sampled case 3', {'segments': [['UA', '500'], ['AA', '451'], ['BA', '999'], ['ba', '100']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, False, True]]]]
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 |
|---|---|---|---|
| three-digit versus two-digit | [False, True, True] | [False, True, True] | Passed |
| leading zeros | [True, True, False, False] | [True, True, True, False] | Failed |
| excepted flight inside range | [False, False, False, True] | [False, False, False, True] | Passed |
| lowercase carrier | [True, True, True] | [True, True, True] | Passed |
| range end points | [True, False, False, False] | [True, True, True, False] | Failed |
| exception for uncovered carrier | [False, False] | [False, False] | Passed |
| sampled case 1 | [False, False, False] | [False, False, False] | Passed |
| sampled case 2 | [False, False] | [False, False] | Passed |
| sampled case 3 | [False, False, False] | [False, False, False] | Passed |
SHA-256 / 31a718e7bb219cf10a722aa40ba149b8616d6be1ec98dae908aabbc2a2e799a1
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
out = []
for carrier, fno in x['segments']:
c = carrier.upper()
n = int(fno)
ok = any(c == rc and int(lo) < n <= int(hi) for rc, lo, hi in x['ranges'])
if any(c == ec and n == int(ef) for ec, ef in x['except']):
ok = False
out.append(ok)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['three-digit versus two-digit', {'segments': [['AA', '99'], ['AA', '100'], ['AA', '151']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, True]], ['leading zeros', {'segments': [['BA', '0045'], ['BA', '45'], ['BA', '0450'], ['BA', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['excepted flight inside range', {'segments': [['AA', '500'], ['AA', '0500'], ['LH', '2400'], ['LH', '2401']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, True]], ['lowercase carrier', {'segments': [['ba', '120'], ['lh', '2100'], ['Aa', '101']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True]], ['range end points', {'segments': [['LH', '2000'], ['LH', '2999'], ['AA', '999'], ['AA', '1000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['exception for uncovered carrier', {'segments': [['LH', '2400'], ['UA', '11']], 'ranges': [['AA', '1', '9999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 1', {'segments': [['UA', '0500'], ['ba', '500'], ['BA', '2999']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False]], ['sampled case 2', {'segments': [['BA', '1000'], ['UA', '0500']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 3', {'segments': [['BA', '2000'], ['BA', '500'], ['AA', '2000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False]]], [['three-digit versus two-digit', {'segments': [['AA', '99'], ['AA', '100'], ['AA', '152']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, True]], ['leading zeros', {'segments': [['BA', '0045'], ['BA', '45'], ['BA', '0450'], ['BA', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['excepted flight inside range', {'segments': [['AA', '500'], ['AA', '0500'], ['LH', '2400'], ['LH', '2402']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, True]], ['lowercase carrier', {'segments': [['ba', '120'], ['lh', '2200'], ['Aa', '101']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True]], ['range end points', {'segments': [['LH', '2000'], ['LH', '2999'], ['AA', '999'], ['AA', '1000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['exception for uncovered carrier', {'segments': [['LH', '2400'], ['UA', '12']], 'ranges': [['AA', '1', '9999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 1', {'segments': [['aa', '451'], ['BA', '1873'], ['aa', '1000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, False, False]], ['sampled case 2', {'segments': [['BA', '2400'], ['ba', '0999']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 3', {'segments': [['ba', '1000'], ['UA', '500'], ['aa', '0451'], ['ba', '2000'], ['ba', '999']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, True, False, False]]], [['three-digit versus two-digit', {'segments': [['AA', '99'], ['AA', '100'], ['AA', '153']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, True]], ['leading zeros', {'segments': [['BA', '0045'], ['BA', '45'], ['BA', '0450'], ['BA', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['excepted flight inside range', {'segments': [['AA', '500'], ['AA', '0500'], ['LH', '2400'], ['LH', '2403']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, True]], ['lowercase carrier', {'segments': [['ba', '120'], ['lh', '2300'], ['Aa', '101']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True]], ['range end points', {'segments': [['LH', '2000'], ['LH', '2999'], ['AA', '999'], ['AA', '1000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['exception for uncovered carrier', {'segments': [['LH', '2400'], ['UA', '13']], 'ranges': [['AA', '1', '9999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 1', {'segments': [['UA', '2000'], ['AA', '500']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 2', {'segments': [['AA', '2999'], ['AA', '450'], ['aa', '100'], ['LH', '2000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, True, True]], ['sampled case 3', {'segments': [['BA', '2400'], ['UA', '0500']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]]], [['three-digit versus two-digit', {'segments': [['AA', '99'], ['AA', '100'], ['AA', '154']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, True]], ['leading zeros', {'segments': [['BA', '0045'], ['BA', '45'], ['BA', '0450'], ['BA', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['excepted flight inside range', {'segments': [['AA', '500'], ['AA', '0500'], ['LH', '2400'], ['LH', '2404']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, True]], ['lowercase carrier', {'segments': [['ba', '120'], ['lh', '2400'], ['Aa', '101']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, False, True]], ['range end points', {'segments': [['LH', '2000'], ['LH', '2999'], ['AA', '999'], ['AA', '1000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['exception for uncovered carrier', {'segments': [['LH', '2400'], ['UA', '14']], 'ranges': [['AA', '1', '9999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 1', {'segments': [['ba', '2000'], ['UA', '0450'], ['ba', '1000'], ['AA', '100'], ['BA', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, True, False]], ['sampled case 2', {'segments': [['LH', '0451'], ['aa', '1543'], ['BA', '999'], ['aa', '1000'], ['LH', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, False, False]], ['sampled case 3', {'segments': [['UA', '450'], ['BA', '2999'], ['LH', '099'], ['LH', '0500']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, False]]], [['three-digit versus two-digit', {'segments': [['AA', '99'], ['AA', '100'], ['AA', '155']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, True]], ['leading zeros', {'segments': [['BA', '0045'], ['BA', '45'], ['BA', '0450'], ['BA', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['excepted flight inside range', {'segments': [['AA', '500'], ['AA', '0500'], ['LH', '2400'], ['LH', '2405']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, True]], ['lowercase carrier', {'segments': [['ba', '120'], ['lh', '2500'], ['Aa', '101']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True]], ['range end points', {'segments': [['LH', '2000'], ['LH', '2999'], ['AA', '999'], ['AA', '1000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['exception for uncovered carrier', {'segments': [['LH', '2400'], ['UA', '15']], 'ranges': [['AA', '1', '9999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 1', {'segments': [['BA', '0655'], ['BA', '2000'], ['UA', '1000'], ['AA', '1386']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, False]], ['sampled case 2', {'segments': [['AA', '0999']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True]], ['sampled case 3', {'segments': [['UA', '500'], ['AA', '451'], ['BA', '999'], ['ba', '100']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, False, True]]]]
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 |
|---|---|---|---|
| three-digit versus two-digit | [False, False, True] | [False, True, True] | Failed |
| leading zeros | [True, True, True, False] | [True, True, True, False] | Passed |
| excepted flight inside range | [False, False, False, True] | [False, False, False, True] | Passed |
| lowercase carrier | [True, True, True] | [True, True, True] | Passed |
| range end points | [False, True, True, False] | [True, True, True, False] | Failed |
| exception for uncovered carrier | [False, False] | [False, False] | Passed |
| sampled case 1 | [False, False, False] | [False, False, False] | Passed |
| sampled case 2 | [False, False] | [False, False] | Passed |
| sampled case 3 | [False, False, False] | [False, False, False] | Passed |
SHA-256 / 8667918cb230ea85cd150bc654960b7cb38f6deae0999642e588b2a6f2cb9613
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
out = []
for carrier, fno in x['segments']:
c = carrier.upper()
n = int(fno)
ok = any(c == rc and int(lo) <= n <= int(hi) for rc, lo, hi in x['ranges'])
if any(c == ec and n == int(ef) for ec, ef in x['except']):
ok = False
out.append(ok)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['three-digit versus two-digit', {'segments': [['AA', '99'], ['AA', '100'], ['AA', '151']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, True]], ['leading zeros', {'segments': [['BA', '0045'], ['BA', '45'], ['BA', '0450'], ['BA', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['excepted flight inside range', {'segments': [['AA', '500'], ['AA', '0500'], ['LH', '2400'], ['LH', '2401']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, True]], ['lowercase carrier', {'segments': [['ba', '120'], ['lh', '2100'], ['Aa', '101']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True]], ['range end points', {'segments': [['LH', '2000'], ['LH', '2999'], ['AA', '999'], ['AA', '1000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['exception for uncovered carrier', {'segments': [['LH', '2400'], ['UA', '11']], 'ranges': [['AA', '1', '9999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 1', {'segments': [['UA', '0500'], ['ba', '500'], ['BA', '2999']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False]], ['sampled case 2', {'segments': [['BA', '1000'], ['UA', '0500']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 3', {'segments': [['BA', '2000'], ['BA', '500'], ['AA', '2000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False]]], [['three-digit versus two-digit', {'segments': [['AA', '99'], ['AA', '100'], ['AA', '152']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, True]], ['leading zeros', {'segments': [['BA', '0045'], ['BA', '45'], ['BA', '0450'], ['BA', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['excepted flight inside range', {'segments': [['AA', '500'], ['AA', '0500'], ['LH', '2400'], ['LH', '2402']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, True]], ['lowercase carrier', {'segments': [['ba', '120'], ['lh', '2200'], ['Aa', '101']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True]], ['range end points', {'segments': [['LH', '2000'], ['LH', '2999'], ['AA', '999'], ['AA', '1000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['exception for uncovered carrier', {'segments': [['LH', '2400'], ['UA', '12']], 'ranges': [['AA', '1', '9999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 1', {'segments': [['aa', '451'], ['BA', '1873'], ['aa', '1000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, False, False]], ['sampled case 2', {'segments': [['BA', '2400'], ['ba', '0999']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 3', {'segments': [['ba', '1000'], ['UA', '500'], ['aa', '0451'], ['ba', '2000'], ['ba', '999']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, True, False, False]]], [['three-digit versus two-digit', {'segments': [['AA', '99'], ['AA', '100'], ['AA', '153']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, True]], ['leading zeros', {'segments': [['BA', '0045'], ['BA', '45'], ['BA', '0450'], ['BA', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['excepted flight inside range', {'segments': [['AA', '500'], ['AA', '0500'], ['LH', '2400'], ['LH', '2403']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, True]], ['lowercase carrier', {'segments': [['ba', '120'], ['lh', '2300'], ['Aa', '101']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True]], ['range end points', {'segments': [['LH', '2000'], ['LH', '2999'], ['AA', '999'], ['AA', '1000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['exception for uncovered carrier', {'segments': [['LH', '2400'], ['UA', '13']], 'ranges': [['AA', '1', '9999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 1', {'segments': [['UA', '2000'], ['AA', '500']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 2', {'segments': [['AA', '2999'], ['AA', '450'], ['aa', '100'], ['LH', '2000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, True, True]], ['sampled case 3', {'segments': [['BA', '2400'], ['UA', '0500']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]]], [['three-digit versus two-digit', {'segments': [['AA', '99'], ['AA', '100'], ['AA', '154']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, True]], ['leading zeros', {'segments': [['BA', '0045'], ['BA', '45'], ['BA', '0450'], ['BA', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['excepted flight inside range', {'segments': [['AA', '500'], ['AA', '0500'], ['LH', '2400'], ['LH', '2404']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, True]], ['lowercase carrier', {'segments': [['ba', '120'], ['lh', '2400'], ['Aa', '101']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, False, True]], ['range end points', {'segments': [['LH', '2000'], ['LH', '2999'], ['AA', '999'], ['AA', '1000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['exception for uncovered carrier', {'segments': [['LH', '2400'], ['UA', '14']], 'ranges': [['AA', '1', '9999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 1', {'segments': [['ba', '2000'], ['UA', '0450'], ['ba', '1000'], ['AA', '100'], ['BA', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, True, False]], ['sampled case 2', {'segments': [['LH', '0451'], ['aa', '1543'], ['BA', '999'], ['aa', '1000'], ['LH', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, False, False]], ['sampled case 3', {'segments': [['UA', '450'], ['BA', '2999'], ['LH', '099'], ['LH', '0500']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, False]]], [['three-digit versus two-digit', {'segments': [['AA', '99'], ['AA', '100'], ['AA', '155']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, True]], ['leading zeros', {'segments': [['BA', '0045'], ['BA', '45'], ['BA', '0450'], ['BA', '451']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['excepted flight inside range', {'segments': [['AA', '500'], ['AA', '0500'], ['LH', '2400'], ['LH', '2405']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, True]], ['lowercase carrier', {'segments': [['ba', '120'], ['lh', '2500'], ['Aa', '101']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True]], ['range end points', {'segments': [['LH', '2000'], ['LH', '2999'], ['AA', '999'], ['AA', '1000']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True, True, True, False]], ['exception for uncovered carrier', {'segments': [['LH', '2400'], ['UA', '15']], 'ranges': [['AA', '1', '9999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False]], ['sampled case 1', {'segments': [['BA', '0655'], ['BA', '2000'], ['UA', '1000'], ['AA', '1386']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, False, False, False]], ['sampled case 2', {'segments': [['AA', '0999']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [True]], ['sampled case 3', {'segments': [['UA', '500'], ['AA', '451'], ['BA', '999'], ['ba', '100']], 'ranges': [['AA', '100', '999'], ['BA', '0001', '0450'], ['LH', '2000', '2999']], 'except': [['AA', '0500'], ['LH', '2400']]}, [False, True, False, True]]]]
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 |
|---|---|---|---|
| three-digit versus two-digit | [False, True, True] | [False, True, True] | Passed |
| leading zeros | [True, True, True, False] | [True, True, True, False] | Passed |
| excepted flight inside range | [False, False, False, True] | [False, False, False, True] | Passed |
| lowercase carrier | [True, True, True] | [True, True, True] | Passed |
| range end points | [True, True, True, False] | [True, True, True, False] | Passed |
| exception for uncovered carrier | [False, False] | [False, False] | Passed |
| sampled case 1 | [False, False, False] | [False, False, False] | Passed |
| sampled case 2 | [False, False] | [False, False] | Passed |
| sampled case 3 | [False, False, False] | [False, False, False] | Passed |
SHA-256 / 74ae8d1ba28a412bbf915b300a05f47c819d3bf26051a11f4cbf6b1992591897
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:46.889673+00:00.
Case digest / f2987d2c05aad8e10c29db18144780a802b2e3f8773848023621e450e97211ae