FAILURE MAP
← Case archive

FA-66776 / Airline fare rule evaluation / Open access

Flight number ranges compared as strings · case 01

Flight AA99 qualifies for a 100-999 range, and zero-padded numbers fall outside ranges they belong to.

Verified by executionVariant 1 · 9 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Flight numbers and range bounds are compared lexicographically as text.

VERIFIED REPAIR

Convert flight numbers and bounds to integers before comparing.

Unsuccessful approach: Stripping leading zeros still compares text, so "99" sorts after "100".

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 = fno
        ok = any(c == rc and lo <= n <= hi for rc, lo, hi in x['ranges'])
        if any(c == ec and n == 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 fixtureActualExpectedOutcome
three-digit versus two-digit[True, True, True][False, True, True]Failed
leading zeros[True, False, True, False][True, True, True, False]Failed
excepted flight inside range[True, False, False, True][False, False, False, True]Failed
lowercase carrier[False, True, True][True, True, True]Failed
range end points[True, True, True, True][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, True][False, False, False]Failed

SHA-256 / f94a0cda2e397ea6c3f90d9584b32b81b2221158e66481ff44b7721ec1638daf

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 = fno.lstrip('0')
        ok = any(c == rc and lo.lstrip('0') <= n <= hi.lstrip('0') for rc, lo, hi in x['ranges'])
        if any(c == ec and n == ef.lstrip('0') 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 fixtureActualExpectedOutcome
three-digit versus two-digit[True, True, 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[True, True, True, True][True, True, True, False]Failed
exception for uncovered carrier[False, False][False, False]Passed
sampled case 1[False, False, True][False, False, False]Failed
sampled case 2[True, False][False, False]Failed
sampled case 3[True, False, True][False, False, False]Failed

SHA-256 / 6b9925f94d22275d2cd417e5c64ca318c0aa4b29ccce4e093d8b0b818b1c3234

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 fixtureActualExpectedOutcome
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.844905+00:00.

Case digest / 3ec8e1640b0e4b11081ef3ed7f03d5f7263ab9fa5ee73ab6273c9a5f42cf22c7