broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    s = x
    if not s or not s[0].isalpha(): return 'ERR_BASIS'
    out = {'rbd': s[0], 'season': None, 'days': 'ANY', 'ap': 0, 'flags': []}
    i = 1
    if i < len(s) and s[i] in 'HL':
        out['season'] = s[i]
        i += 1
    if i < len(s) and s[i] in 'WX':
        out['days'] = 'WEEKEND' if s[i] == 'W' else 'WEEKDAY'
        i += 1
    j = i
    while j < len(s) and s[j].isdigit():
        j += 1
    out['ap'] = int(s[i:j]) if j > i else 0
    rest = s[j:]
    if len(rest) % 2: return 'ERR_TOKEN'
    for k in range(0, len(rest), 2):
        tok = rest[k:k + 2]
        if tok not in ('CH', 'IN', 'NR'): return 'ERR_TOKEN'
        out['flags'].append(tok)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['full basis', 'QLX8NRCH', {'rbd': 'Q', 'season': 'L', 'days': 'WEEKDAY', 'ap': 8, 'flags': ['NR', 'CH']}], ['three-digit advance purchase', 'VHW110IN', {'rbd': 'V', 'season': 'H', 'days': 'WEEKEND', 'ap': 110, 'flags': ['IN']}], ['rbd only', 'Y', {'rbd': 'Y', 'season': None, 'days': 'ANY', 'ap': 0, 'flags': []}], ['weekend without season', 'KW3NR', {'rbd': 'K', 'season': None, 'days': 'WEEKEND', 'ap': 3, 'flags': ['NR']}], ['unknown suffix token', 'MH14ZZ', 'ERR_TOKEN'], ['odd suffix length', 'BL3NRC', 'ERR_TOKEN'], ['non-ASCII leading letter', 'ÉL7', 'ERR_BASIS'], ['lowercase basis', 'qlx7', 'ERR_BASIS'], ['digits right after rbd', 'T21CH', {'rbd': 'T', 'season': None, 'days': 'ANY', 'ap': 21, 'flags': ['CH']}], ['sampled case 1', 'NHX120', {'rbd': 'N', 'season': 'H', 'days': 'WEEKDAY', 'ap': 120, 'flags': []}], ['sampled case 2', 'qX14C', 'ERR_BASIS'], ['sampled case 3', 'THW', {'rbd': 'T', 'season': 'H', 'days': 'WEEKEND', 'ap': 0, 'flags': []}]], [['full basis', 'QLX9NRCH', {'rbd': 'Q', 'season': 'L', 'days': 'WEEKDAY', 'ap': 9, 'flags': ['NR', 'CH']}], ['three-digit advance purchase', 'VHW120IN', {'rbd': 'V', 'season': 'H', 'days': 'WEEKEND', 'ap': 120, 'flags': ['IN']}], ['rbd only', 'Y', {'rbd': 'Y', 'season': None, 'days': 'ANY', 'ap': 0, 'flags': []}], ['weekend without season', 'KW4NR', {'rbd': 'K', 'season': None, 'days': 'WEEKEND', 'ap': 4, 'flags': ['NR']}], ['unknown suffix token', 'MH14ZZ', 'ERR_TOKEN'], ['odd suffix length', 'BL3NRC', 'ERR_TOKEN'], ['non-ASCII leading letter', 'ÉL7', 'ERR_BASIS'], ['lowercase basis', 'qlx7', 'ERR_BASIS'], ['digits right after rbd', 'T21CH', {'rbd': 'T', 'season': None, 'days': 'ANY', 'ap': 21, 'flags': ['CH']}], ['sampled case 1', '7W1', 'ERR_BASIS'], ['sampled case 2', 'q1', 'ERR_BASIS'], ['sampled case 3', 'qHXZZ', 'ERR_BASIS']], [['full basis', 'QLX10NRCH', {'rbd': 'Q', 'season': 'L', 'days': 'WEEKDAY', 'ap': 10, 'flags': ['NR', 'CH']}], ['three-digit advance purchase', 'VHW130IN', {'rbd': 'V', 'season': 'H', 'days': 'WEEKEND', 'ap': 130, 'flags': ['IN']}], ['rbd only', 'Y', {'rbd': 'Y', 'season': None, 'days': 'ANY', 'ap': 0, 'flags': []}], ['weekend without season', 'KW5NR', {'rbd': 'K', 'season': None, 'days': 'WEEKEND', 'ap': 5, 'flags': ['NR']}], ['unknown suffix token', 'MH14ZZ', 'ERR_TOKEN'], ['odd suffix length', 'BL3NRC', 'ERR_TOKEN'], ['non-ASCII leading letter', 'ÉL7', 'ERR_BASIS'], ['lowercase basis', 'qlx7', 'ERR_BASIS'], ['digits right after rbd', 'T21CH', {'rbd': 'T', 'season': None, 'days': 'ANY', 'ap': 21, 'flags': ['CH']}], ['sampled case 1', 'VLXINC', 'ERR_TOKEN'], ['sampled case 2', 'QHW30CH', {'rbd': 'Q', 'season': 'H', 'days': 'WEEKEND', 'ap': 30, 'flags': ['CH']}], ['sampled case 3', 'B14CHIN', {'rbd': 'B', 'season': None, 'days': 'ANY', 'ap': 14, 'flags': ['CH', 'IN']}]], [['full basis', 'QLX11NRCH', {'rbd': 'Q', 'season': 'L', 'days': 'WEEKDAY', 'ap': 11, 'flags': ['NR', 'CH']}], ['three-digit advance purchase', 'VHW140IN', {'rbd': 'V', 'season': 'H', 'days': 'WEEKEND', 'ap': 140, 'flags': ['IN']}], ['rbd only', 'Y', {'rbd': 'Y', 'season': None, 'days': 'ANY', 'ap': 0, 'flags': []}], ['weekend without season', 'KW6NR', {'rbd': 'K', 'season': None, 'days': 'WEEKEND', 'ap': 6, 'flags': ['NR']}], ['unknown suffix token', 'MH14ZZ', 'ERR_TOKEN'], ['odd suffix length', 'BL3NRC', 'ERR_TOKEN'], ['non-ASCII leading letter', 'ÉL7', 'ERR_BASIS'], ['lowercase basis', 'qlx7', 'ERR_BASIS'], ['digits right after rbd', 'T21CH', {'rbd': 'T', 'season': None, 'days': 'ANY', 'ap': 21, 'flags': ['CH']}], ['sampled case 1', 'MZZIN', 'ERR_TOKEN'], ['sampled case 2', 'MLC', 'ERR_TOKEN'], ['sampled case 3', 'THIN', {'rbd': 'T', 'season': 'H', 'days': 'ANY', 'ap': 0, 'flags': ['IN']}]], [['full basis', 'QLX12NRCH', {'rbd': 'Q', 'season': 'L', 'days': 'WEEKDAY', 'ap': 12, 'flags': ['NR', 'CH']}], ['three-digit advance purchase', 'VHW150IN', {'rbd': 'V', 'season': 'H', 'days': 'WEEKEND', 'ap': 150, 'flags': ['IN']}], ['rbd only', 'Y', {'rbd': 'Y', 'season': None, 'days': 'ANY', 'ap': 0, 'flags': []}], ['weekend without season', 'KW7NR', {'rbd': 'K', 'season': None, 'days': 'WEEKEND', 'ap': 7, 'flags': ['NR']}], ['unknown suffix token', 'MH14ZZ', 'ERR_TOKEN'], ['odd suffix length', 'BL3NRC', 'ERR_TOKEN'], ['non-ASCII leading letter', 'ÉL7', 'ERR_BASIS'], ['lowercase basis', 'qlx7', 'ERR_BASIS'], ['digits right after rbd', 'T21CH', {'rbd': 'T', 'season': None, 'days': 'ANY', 'ap': 21, 'flags': ['CH']}], ['sampled case 1', 'LLWNRNR', {'rbd': 'L', 'season': 'L', 'days': 'WEEKEND', 'ap': 0, 'flags': ['NR', 'NR']}], ['sampled case 2', 'NHXNRZZ', 'ERR_TOKEN'], ['sampled case 3', 'TNR', {'rbd': 'T', 'season': None, 'days': 'ANY', 'ap': 0, 'flags': ['NR']}]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    s = x
    if not s or not s[0].isupper(): return 'ERR_BASIS'
    out = {'rbd': s[0], 'season': None, 'days': 'ANY', 'ap': 0, 'flags': []}
    i = 1
    if i < len(s) and s[i] in 'HL':
        out['season'] = s[i]
        i += 1
    if i < len(s) and s[i] in 'WX':
        out['days'] = 'WEEKEND' if s[i] == 'W' else 'WEEKDAY'
        i += 1
    j = i
    while j < len(s) and s[j].isdigit():
        j += 1
    out['ap'] = int(s[i:j]) if j > i else 0
    rest = s[j:]
    if len(rest) % 2: return 'ERR_TOKEN'
    for k in range(0, len(rest), 2):
        tok = rest[k:k + 2]
        if tok not in ('CH', 'IN', 'NR'): return 'ERR_TOKEN'
        out['flags'].append(tok)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['full basis', 'QLX8NRCH', {'rbd': 'Q', 'season': 'L', 'days': 'WEEKDAY', 'ap': 8, 'flags': ['NR', 'CH']}], ['three-digit advance purchase', 'VHW110IN', {'rbd': 'V', 'season': 'H', 'days': 'WEEKEND', 'ap': 110, 'flags': ['IN']}], ['rbd only', 'Y', {'rbd': 'Y', 'season': None, 'days': 'ANY', 'ap': 0, 'flags': []}], ['weekend without season', 'KW3NR', {'rbd': 'K', 'season': None, 'days': 'WEEKEND', 'ap': 3, 'flags': ['NR']}], ['unknown suffix token', 'MH14ZZ', 'ERR_TOKEN'], ['odd suffix length', 'BL3NRC', 'ERR_TOKEN'], ['non-ASCII leading letter', 'ÉL7', 'ERR_BASIS'], ['lowercase basis', 'qlx7', 'ERR_BASIS'], ['digits right after rbd', 'T21CH', {'rbd': 'T', 'season': None, 'days': 'ANY', 'ap': 21, 'flags': ['CH']}], ['sampled case 1', 'NHX120', {'rbd': 'N', 'season': 'H', 'days': 'WEEKDAY', 'ap': 120, 'flags': []}], ['sampled case 2', 'qX14C', 'ERR_BASIS'], ['sampled case 3', 'THW', {'rbd': 'T', 'season': 'H', 'days': 'WEEKEND', 'ap': 0, 'flags': []}]], [['full basis', 'QLX9NRCH', {'rbd': 'Q', 'season': 'L', 'days': 'WEEKDAY', 'ap': 9, 'flags': ['NR', 'CH']}], ['three-digit advance purchase', 'VHW120IN', {'rbd': 'V', 'season': 'H', 'days': 'WEEKEND', 'ap': 120, 'flags': ['IN']}], ['rbd only', 'Y', {'rbd': 'Y', 'season': None, 'days': 'ANY', 'ap': 0, 'flags': []}], ['weekend without season', 'KW4NR', {'rbd': 'K', 'season': None, 'days': 'WEEKEND', 'ap': 4, 'flags': ['NR']}], ['unknown suffix token', 'MH14ZZ', 'ERR_TOKEN'], ['odd suffix length', 'BL3NRC', 'ERR_TOKEN'], ['non-ASCII leading letter', 'ÉL7', 'ERR_BASIS'], ['lowercase basis', 'qlx7', 'ERR_BASIS'], ['digits right after rbd', 'T21CH', {'rbd': 'T', 'season': None, 'days': 'ANY', 'ap': 21, 'flags': ['CH']}], ['sampled case 1', '7W1', 'ERR_BASIS'], ['sampled case 2', 'q1', 'ERR_BASIS'], ['sampled case 3', 'qHXZZ', 'ERR_BASIS']], [['full basis', 'QLX10NRCH', {'rbd': 'Q', 'season': 'L', 'days': 'WEEKDAY', 'ap': 10, 'flags': ['NR', 'CH']}], ['three-digit advance purchase', 'VHW130IN', {'rbd': 'V', 'season': 'H', 'days': 'WEEKEND', 'ap': 130, 'flags': ['IN']}], ['rbd only', 'Y', {'rbd': 'Y', 'season': None, 'days': 'ANY', 'ap': 0, 'flags': []}], ['weekend without season', 'KW5NR', {'rbd': 'K', 'season': None, 'days': 'WEEKEND', 'ap': 5, 'flags': ['NR']}], ['unknown suffix token', 'MH14ZZ', 'ERR_TOKEN'], ['odd suffix length', 'BL3NRC', 'ERR_TOKEN'], ['non-ASCII leading letter', 'ÉL7', 'ERR_BASIS'], ['lowercase basis', 'qlx7', 'ERR_BASIS'], ['digits right after rbd', 'T21CH', {'rbd': 'T', 'season': None, 'days': 'ANY', 'ap': 21, 'flags': ['CH']}], ['sampled case 1', 'VLXINC', 'ERR_TOKEN'], ['sampled case 2', 'QHW30CH', {'rbd': 'Q', 'season': 'H', 'days': 'WEEKEND', 'ap': 30, 'flags': ['CH']}], ['sampled case 3', 'B14CHIN', {'rbd': 'B', 'season': None, 'days': 'ANY', 'ap': 14, 'flags': ['CH', 'IN']}]], [['full basis', 'QLX11NRCH', {'rbd': 'Q', 'season': 'L', 'days': 'WEEKDAY', 'ap': 11, 'flags': ['NR', 'CH']}], ['three-digit advance purchase', 'VHW140IN', {'rbd': 'V', 'season': 'H', 'days': 'WEEKEND', 'ap': 140, 'flags': ['IN']}], ['rbd only', 'Y', {'rbd': 'Y', 'season': None, 'days': 'ANY', 'ap': 0, 'flags': []}], ['weekend without season', 'KW6NR', {'rbd': 'K', 'season': None, 'days': 'WEEKEND', 'ap': 6, 'flags': ['NR']}], ['unknown suffix token', 'MH14ZZ', 'ERR_TOKEN'], ['odd suffix length', 'BL3NRC', 'ERR_TOKEN'], ['non-ASCII leading letter', 'ÉL7', 'ERR_BASIS'], ['lowercase basis', 'qlx7', 'ERR_BASIS'], ['digits right after rbd', 'T21CH', {'rbd': 'T', 'season': None, 'days': 'ANY', 'ap': 21, 'flags': ['CH']}], ['sampled case 1', 'MZZIN', 'ERR_TOKEN'], ['sampled case 2', 'MLC', 'ERR_TOKEN'], ['sampled case 3', 'THIN', {'rbd': 'T', 'season': 'H', 'days': 'ANY', 'ap': 0, 'flags': ['IN']}]], [['full basis', 'QLX12NRCH', {'rbd': 'Q', 'season': 'L', 'days': 'WEEKDAY', 'ap': 12, 'flags': ['NR', 'CH']}], ['three-digit advance purchase', 'VHW150IN', {'rbd': 'V', 'season': 'H', 'days': 'WEEKEND', 'ap': 150, 'flags': ['IN']}], ['rbd only', 'Y', {'rbd': 'Y', 'season': None, 'days': 'ANY', 'ap': 0, 'flags': []}], ['weekend without season', 'KW7NR', {'rbd': 'K', 'season': None, 'days': 'WEEKEND', 'ap': 7, 'flags': ['NR']}], ['unknown suffix token', 'MH14ZZ', 'ERR_TOKEN'], ['odd suffix length', 'BL3NRC', 'ERR_TOKEN'], ['non-ASCII leading letter', 'ÉL7', 'ERR_BASIS'], ['lowercase basis', 'qlx7', 'ERR_BASIS'], ['digits right after rbd', 'T21CH', {'rbd': 'T', 'season': None, 'days': 'ANY', 'ap': 21, 'flags': ['CH']}], ['sampled case 1', 'LLWNRNR', {'rbd': 'L', 'season': 'L', 'days': 'WEEKEND', 'ap': 0, 'flags': ['NR', 'NR']}], ['sampled case 2', 'NHXNRZZ', 'ERR_TOKEN'], ['sampled case 3', 'TNR', {'rbd': 'T', 'season': None, 'days': 'ANY', 'ap': 0, 'flags': ['NR']}]]]
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)

prompt:
A basis beginning with a lowercase or accented letter decodes with an invalid RBD.

Input: a fare basis string. Grammar: RBD letter A-Z (ASCII uppercase, else 'ERR_BASIS'), optional season H|L, optional day code W (WEEKEND) | X (WEEKDAY), optional advance purchase digits of any length (default 0), then two-letter tokens from CH, IN, NR (otherwise or odd length -> 'ERR_TOKEN'). Return {'rbd','season','days','ap','flags'}.

split: open-access


meaning: Fixture-count band, not measured model difficulty

deps: stdlib

prompt:
Interline settlement is short by a few cents on most tickets.

Input {'fare','tpm':[miles per coupon, 0 for surface]}. Work in integer cents: each coupon gets floor(cents*tpm/total); the rounding remainder goes to the last coupon with nonzero miles; surface coupons get 0. No miles -> 'ERR_NO_MILES'. Return coupon values in currency units.

split: open-access


prompt:
The first coupon carries the remainder, even when it is a surface sector with no miles.

Input {'fare','tpm':[miles per coupon, 0 for surface]}. Work in integer cents: each coupon gets floor(cents*tpm/total); the rounding remainder goes to the last coupon with nonzero miles; surface coupons get 0. No miles -> 'ERR_NO_MILES'. Return coupon values in currency units.

split: open-access


prompt:
A short hop receives the same value as a long-haul sector.

Input {'fare','tpm':[miles per coupon, 0 for surface]}. Work in integer cents: each coupon gets floor(cents*tpm/total); the rounding remainder goes to the last coupon with nonzero miles; surface coupons get 0. No miles -> 'ERR_NO_MILES'. Return coupon values in currency units.

split: open-access


prompt:
Earlier coupons gain or lose a cent compared with the settlement contract.

Input {'fare','tpm':[miles per coupon, 0 for surface]}. Work in integer cents: each coupon gets floor(cents*tpm/total); the rounding remainder goes to the last coupon with nonzero miles; surface coupons get 0. No miles -> 'ERR_NO_MILES'. Return coupon values in currency units.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    st = list(x['status'])
    fee = 0
    seen = False
    for i, s in enumerate(st):
        if s == 'NOSHOW':
            if not seen: fee += x['fee']
            seen = True
        elif s == 'OPEN' and 'NOSHOW' in st:
            st[i] = 'VOID'
    return [st, fee]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 101}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 101]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 75}, [['OPEN', 'NOSHOW', 'VOID'], 75]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'NOSHOW', 'OPEN', 'NOSHOW', 'NOSHOW', 'OPEN'], 'fee': 100}, [['OPEN', 'NOSHOW', 'VOID', 'NOSHOW', 'NOSHOW', 'VOID'], 100]], ['sampled case 2', {'status': ['FLOWN', 'OPEN', 'FLOWN', 'OPEN', 'OPEN', 'OPEN'], 'fee': 150}, [['FLOWN', 'OPEN', 'FLOWN', 'OPEN', 'OPEN', 'OPEN'], 0]], ['sampled case 3', {'status': ['OPEN'], 'fee': 100}, [['OPEN'], 0]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 102}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 102]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 150}, [['OPEN', 'NOSHOW', 'VOID'], 150]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 150}, [['OPEN', 'OPEN', 'NOSHOW', 'VOID'], 150]], ['sampled case 2', {'status': ['OPEN', 'OPEN', 'NOSHOW', 'NOSHOW', 'NOSHOW'], 'fee': 50}, [['OPEN', 'OPEN', 'NOSHOW', 'NOSHOW', 'NOSHOW'], 50]], ['sampled case 3', {'status': ['FLOWN', 'NOSHOW', 'NOSHOW', 'NOSHOW', 'OPEN'], 'fee': 100}, [['FLOWN', 'NOSHOW', 'NOSHOW', 'NOSHOW', 'VOID'], 100]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 103}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 103]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 225}, [['OPEN', 'NOSHOW', 'VOID'], 225]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'FLOWN', 'FLOWN', 'FLOWN', 'NOSHOW', 'NOSHOW'], 'fee': 75}, [['OPEN', 'FLOWN', 'FLOWN', 'FLOWN', 'NOSHOW', 'NOSHOW'], 75]], ['sampled case 2', {'status': ['FLOWN', 'OPEN', 'OPEN', 'OPEN', 'OPEN', 'FLOWN'], 'fee': 75}, [['FLOWN', 'OPEN', 'OPEN', 'OPEN', 'OPEN', 'FLOWN'], 0]], ['sampled case 3', {'status': ['OPEN'], 'fee': 50}, [['OPEN'], 0]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 104}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 104]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 300}, [['OPEN', 'NOSHOW', 'VOID'], 300]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'NOSHOW', 'OPEN', 'OPEN', 'FLOWN'], 'fee': 75}, [['OPEN', 'NOSHOW', 'VOID', 'VOID', 'FLOWN'], 75]], ['sampled case 2', {'status': ['NOSHOW', 'OPEN', 'OPEN', 'FLOWN'], 'fee': 75}, [['NOSHOW', 'VOID', 'VOID', 'FLOWN'], 75]], ['sampled case 3', {'status': ['OPEN', 'OPEN', 'OPEN', 'FLOWN', 'OPEN', 'NOSHOW'], 'fee': 50}, [['OPEN', 'OPEN', 'OPEN', 'FLOWN', 'OPEN', 'NOSHOW'], 50]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 105}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 105]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 375}, [['OPEN', 'NOSHOW', 'VOID'], 375]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['NOSHOW', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID'], 150]], ['sampled case 2', {'status': ['OPEN', 'OPEN', 'FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 50}, [['OPEN', 'OPEN', 'FLOWN', 'NOSHOW', 'VOID', 'VOID'], 50]], ['sampled case 3', {'status': ['FLOWN', 'OPEN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 150}, [['FLOWN', 'OPEN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 150]]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    st = list(x['status'])
    fee = 0
    seen = False
    for i, s in enumerate(st):
        if s == 'NOSHOW':
            if not seen: fee += x['fee']
            seen = True
        elif s == 'OPEN' and 'NOSHOW' in st[max(0, i - 1):]:
            st[i] = 'VOID'
    return [st, fee]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 101}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 101]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 75}, [['OPEN', 'NOSHOW', 'VOID'], 75]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'NOSHOW', 'OPEN', 'NOSHOW', 'NOSHOW', 'OPEN'], 'fee': 100}, [['OPEN', 'NOSHOW', 'VOID', 'NOSHOW', 'NOSHOW', 'VOID'], 100]], ['sampled case 2', {'status': ['FLOWN', 'OPEN', 'FLOWN', 'OPEN', 'OPEN', 'OPEN'], 'fee': 150}, [['FLOWN', 'OPEN', 'FLOWN', 'OPEN', 'OPEN', 'OPEN'], 0]], ['sampled case 3', {'status': ['OPEN'], 'fee': 100}, [['OPEN'], 0]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 102}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 102]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 150}, [['OPEN', 'NOSHOW', 'VOID'], 150]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 150}, [['OPEN', 'OPEN', 'NOSHOW', 'VOID'], 150]], ['sampled case 2', {'status': ['OPEN', 'OPEN', 'NOSHOW', 'NOSHOW', 'NOSHOW'], 'fee': 50}, [['OPEN', 'OPEN', 'NOSHOW', 'NOSHOW', 'NOSHOW'], 50]], ['sampled case 3', {'status': ['FLOWN', 'NOSHOW', 'NOSHOW', 'NOSHOW', 'OPEN'], 'fee': 100}, [['FLOWN', 'NOSHOW', 'NOSHOW', 'NOSHOW', 'VOID'], 100]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 103}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 103]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 225}, [['OPEN', 'NOSHOW', 'VOID'], 225]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'FLOWN', 'FLOWN', 'FLOWN', 'NOSHOW', 'NOSHOW'], 'fee': 75}, [['OPEN', 'FLOWN', 'FLOWN', 'FLOWN', 'NOSHOW', 'NOSHOW'], 75]], ['sampled case 2', {'status': ['FLOWN', 'OPEN', 'OPEN', 'OPEN', 'OPEN', 'FLOWN'], 'fee': 75}, [['FLOWN', 'OPEN', 'OPEN', 'OPEN', 'OPEN', 'FLOWN'], 0]], ['sampled case 3', {'status': ['OPEN'], 'fee': 50}, [['OPEN'], 0]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 104}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 104]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 300}, [['OPEN', 'NOSHOW', 'VOID'], 300]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'NOSHOW', 'OPEN', 'OPEN', 'FLOWN'], 'fee': 75}, [['OPEN', 'NOSHOW', 'VOID', 'VOID', 'FLOWN'], 75]], ['sampled case 2', {'status': ['NOSHOW', 'OPEN', 'OPEN', 'FLOWN'], 'fee': 75}, [['NOSHOW', 'VOID', 'VOID', 'FLOWN'], 75]], ['sampled case 3', {'status': ['OPEN', 'OPEN', 'OPEN', 'FLOWN', 'OPEN', 'NOSHOW'], 'fee': 50}, [['OPEN', 'OPEN', 'OPEN', 'FLOWN', 'OPEN', 'NOSHOW'], 50]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 105}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 105]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 375}, [['OPEN', 'NOSHOW', 'VOID'], 375]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['NOSHOW', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID'], 150]], ['sampled case 2', {'status': ['OPEN', 'OPEN', 'FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 50}, [['OPEN', 'OPEN', 'FLOWN', 'NOSHOW', 'VOID', 'VOID'], 50]], ['sampled case 3', {'status': ['FLOWN', 'OPEN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 150}, [['FLOWN', 'OPEN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 150]]]]
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)

prompt:
An open coupon earlier in the itinerary is voided because a later sector was missed.

Input {'status':[FLOWN|OPEN|NOSHOW per coupon],'fee'}. After the first NOSHOW, every later OPEN coupon becomes VOID (earlier coupons are untouched, FLOWN stays FLOWN). The no-show fee is charged once per ticket. Return [statuses, fee].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    st = list(x['status'])
    fee = 0
    seen = False
    for i, s in enumerate(st):
        if s == 'NOSHOW':
            if not seen: fee += x['fee']
            seen = True
        elif seen and s == 'OPEN':
            st[i] = 'VOID'
            seen = False
    return [st, fee]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 101}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 101]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 75}, [['OPEN', 'NOSHOW', 'VOID'], 75]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'NOSHOW', 'OPEN', 'NOSHOW', 'NOSHOW', 'OPEN'], 'fee': 100}, [['OPEN', 'NOSHOW', 'VOID', 'NOSHOW', 'NOSHOW', 'VOID'], 100]], ['sampled case 2', {'status': ['FLOWN', 'OPEN', 'FLOWN', 'OPEN', 'OPEN', 'OPEN'], 'fee': 150}, [['FLOWN', 'OPEN', 'FLOWN', 'OPEN', 'OPEN', 'OPEN'], 0]], ['sampled case 3', {'status': ['OPEN'], 'fee': 100}, [['OPEN'], 0]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 102}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 102]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 150}, [['OPEN', 'NOSHOW', 'VOID'], 150]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 150}, [['OPEN', 'OPEN', 'NOSHOW', 'VOID'], 150]], ['sampled case 2', {'status': ['OPEN', 'OPEN', 'NOSHOW', 'NOSHOW', 'NOSHOW'], 'fee': 50}, [['OPEN', 'OPEN', 'NOSHOW', 'NOSHOW', 'NOSHOW'], 50]], ['sampled case 3', {'status': ['FLOWN', 'NOSHOW', 'NOSHOW', 'NOSHOW', 'OPEN'], 'fee': 100}, [['FLOWN', 'NOSHOW', 'NOSHOW', 'NOSHOW', 'VOID'], 100]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 103}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 103]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 225}, [['OPEN', 'NOSHOW', 'VOID'], 225]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'FLOWN', 'FLOWN', 'FLOWN', 'NOSHOW', 'NOSHOW'], 'fee': 75}, [['OPEN', 'FLOWN', 'FLOWN', 'FLOWN', 'NOSHOW', 'NOSHOW'], 75]], ['sampled case 2', {'status': ['FLOWN', 'OPEN', 'OPEN', 'OPEN', 'OPEN', 'FLOWN'], 'fee': 75}, [['FLOWN', 'OPEN', 'OPEN', 'OPEN', 'OPEN', 'FLOWN'], 0]], ['sampled case 3', {'status': ['OPEN'], 'fee': 50}, [['OPEN'], 0]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 104}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 104]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 300}, [['OPEN', 'NOSHOW', 'VOID'], 300]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'NOSHOW', 'OPEN', 'OPEN', 'FLOWN'], 'fee': 75}, [['OPEN', 'NOSHOW', 'VOID', 'VOID', 'FLOWN'], 75]], ['sampled case 2', {'status': ['NOSHOW', 'OPEN', 'OPEN', 'FLOWN'], 'fee': 75}, [['NOSHOW', 'VOID', 'VOID', 'FLOWN'], 75]], ['sampled case 3', {'status': ['OPEN', 'OPEN', 'OPEN', 'FLOWN', 'OPEN', 'NOSHOW'], 'fee': 50}, [['OPEN', 'OPEN', 'OPEN', 'FLOWN', 'OPEN', 'NOSHOW'], 50]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 105}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 105]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 375}, [['OPEN', 'NOSHOW', 'VOID'], 375]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['NOSHOW', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID'], 150]], ['sampled case 2', {'status': ['OPEN', 'OPEN', 'FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 50}, [['OPEN', 'OPEN', 'FLOWN', 'NOSHOW', 'VOID', 'VOID'], 50]], ['sampled case 3', {'status': ['FLOWN', 'OPEN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 150}, [['FLOWN', 'OPEN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 150]]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    st = list(x['status'])
    fee = 0
    seen = False
    for i, s in enumerate(st):
        if s == 'NOSHOW':
            if not seen: fee += x['fee']
            seen = True
        elif seen and s == 'OPEN' and st[i - 1] in ('NOSHOW', 'VOID'):
            st[i] = 'VOID'
    return [st, fee]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 101}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 101]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 75}, [['OPEN', 'NOSHOW', 'VOID'], 75]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'NOSHOW', 'OPEN', 'NOSHOW', 'NOSHOW', 'OPEN'], 'fee': 100}, [['OPEN', 'NOSHOW', 'VOID', 'NOSHOW', 'NOSHOW', 'VOID'], 100]], ['sampled case 2', {'status': ['FLOWN', 'OPEN', 'FLOWN', 'OPEN', 'OPEN', 'OPEN'], 'fee': 150}, [['FLOWN', 'OPEN', 'FLOWN', 'OPEN', 'OPEN', 'OPEN'], 0]], ['sampled case 3', {'status': ['OPEN'], 'fee': 100}, [['OPEN'], 0]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 102}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 102]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 150}, [['OPEN', 'NOSHOW', 'VOID'], 150]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 150}, [['OPEN', 'OPEN', 'NOSHOW', 'VOID'], 150]], ['sampled case 2', {'status': ['OPEN', 'OPEN', 'NOSHOW', 'NOSHOW', 'NOSHOW'], 'fee': 50}, [['OPEN', 'OPEN', 'NOSHOW', 'NOSHOW', 'NOSHOW'], 50]], ['sampled case 3', {'status': ['FLOWN', 'NOSHOW', 'NOSHOW', 'NOSHOW', 'OPEN'], 'fee': 100}, [['FLOWN', 'NOSHOW', 'NOSHOW', 'NOSHOW', 'VOID'], 100]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 103}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 103]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 225}, [['OPEN', 'NOSHOW', 'VOID'], 225]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'FLOWN', 'FLOWN', 'FLOWN', 'NOSHOW', 'NOSHOW'], 'fee': 75}, [['OPEN', 'FLOWN', 'FLOWN', 'FLOWN', 'NOSHOW', 'NOSHOW'], 75]], ['sampled case 2', {'status': ['FLOWN', 'OPEN', 'OPEN', 'OPEN', 'OPEN', 'FLOWN'], 'fee': 75}, [['FLOWN', 'OPEN', 'OPEN', 'OPEN', 'OPEN', 'FLOWN'], 0]], ['sampled case 3', {'status': ['OPEN'], 'fee': 50}, [['OPEN'], 0]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 104}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 104]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 300}, [['OPEN', 'NOSHOW', 'VOID'], 300]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'NOSHOW', 'OPEN', 'OPEN', 'FLOWN'], 'fee': 75}, [['OPEN', 'NOSHOW', 'VOID', 'VOID', 'FLOWN'], 75]], ['sampled case 2', {'status': ['NOSHOW', 'OPEN', 'OPEN', 'FLOWN'], 'fee': 75}, [['NOSHOW', 'VOID', 'VOID', 'FLOWN'], 75]], ['sampled case 3', {'status': ['OPEN', 'OPEN', 'OPEN', 'FLOWN', 'OPEN', 'NOSHOW'], 'fee': 50}, [['OPEN', 'OPEN', 'OPEN', 'FLOWN', 'OPEN', 'NOSHOW'], 50]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 105}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 105]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 375}, [['OPEN', 'NOSHOW', 'VOID'], 375]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['NOSHOW', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID'], 150]], ['sampled case 2', {'status': ['OPEN', 'OPEN', 'FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 50}, [['OPEN', 'OPEN', 'FLOWN', 'NOSHOW', 'VOID', 'VOID'], 50]], ['sampled case 3', {'status': ['FLOWN', 'OPEN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 150}, [['FLOWN', 'OPEN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 150]]]]
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)

prompt:
The third sector of an itinerary remains open after the passenger missed the first.

Input {'status':[FLOWN|OPEN|NOSHOW per coupon],'fee'}. After the first NOSHOW, every later OPEN coupon becomes VOID (earlier coupons are untouched, FLOWN stays FLOWN). The no-show fee is charged once per ticket. Return [statuses, fee].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    st = list(x['status'])
    fee = 0
    seen = False
    for i, s in enumerate(st):
        if s == 'NOSHOW':
            fee += x['fee']
            seen = True
        elif seen and s == 'OPEN':
            st[i] = 'VOID'
    return [st, fee]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 101}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 101]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 75}, [['OPEN', 'NOSHOW', 'VOID'], 75]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'NOSHOW', 'OPEN', 'NOSHOW', 'NOSHOW', 'OPEN'], 'fee': 100}, [['OPEN', 'NOSHOW', 'VOID', 'NOSHOW', 'NOSHOW', 'VOID'], 100]], ['sampled case 2', {'status': ['FLOWN', 'OPEN', 'FLOWN', 'OPEN', 'OPEN', 'OPEN'], 'fee': 150}, [['FLOWN', 'OPEN', 'FLOWN', 'OPEN', 'OPEN', 'OPEN'], 0]], ['sampled case 3', {'status': ['OPEN'], 'fee': 100}, [['OPEN'], 0]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 102}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 102]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 150}, [['OPEN', 'NOSHOW', 'VOID'], 150]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 150}, [['OPEN', 'OPEN', 'NOSHOW', 'VOID'], 150]], ['sampled case 2', {'status': ['OPEN', 'OPEN', 'NOSHOW', 'NOSHOW', 'NOSHOW'], 'fee': 50}, [['OPEN', 'OPEN', 'NOSHOW', 'NOSHOW', 'NOSHOW'], 50]], ['sampled case 3', {'status': ['FLOWN', 'NOSHOW', 'NOSHOW', 'NOSHOW', 'OPEN'], 'fee': 100}, [['FLOWN', 'NOSHOW', 'NOSHOW', 'NOSHOW', 'VOID'], 100]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 103}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 103]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 225}, [['OPEN', 'NOSHOW', 'VOID'], 225]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'FLOWN', 'FLOWN', 'FLOWN', 'NOSHOW', 'NOSHOW'], 'fee': 75}, [['OPEN', 'FLOWN', 'FLOWN', 'FLOWN', 'NOSHOW', 'NOSHOW'], 75]], ['sampled case 2', {'status': ['FLOWN', 'OPEN', 'OPEN', 'OPEN', 'OPEN', 'FLOWN'], 'fee': 75}, [['FLOWN', 'OPEN', 'OPEN', 'OPEN', 'OPEN', 'FLOWN'], 0]], ['sampled case 3', {'status': ['OPEN'], 'fee': 50}, [['OPEN'], 0]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 104}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 104]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 300}, [['OPEN', 'NOSHOW', 'VOID'], 300]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'NOSHOW', 'OPEN', 'OPEN', 'FLOWN'], 'fee': 75}, [['OPEN', 'NOSHOW', 'VOID', 'VOID', 'FLOWN'], 75]], ['sampled case 2', {'status': ['NOSHOW', 'OPEN', 'OPEN', 'FLOWN'], 'fee': 75}, [['NOSHOW', 'VOID', 'VOID', 'FLOWN'], 75]], ['sampled case 3', {'status': ['OPEN', 'OPEN', 'OPEN', 'FLOWN', 'OPEN', 'NOSHOW'], 'fee': 50}, [['OPEN', 'OPEN', 'OPEN', 'FLOWN', 'OPEN', 'NOSHOW'], 50]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 105}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 105]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 375}, [['OPEN', 'NOSHOW', 'VOID'], 375]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['NOSHOW', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID'], 150]], ['sampled case 2', {'status': ['OPEN', 'OPEN', 'FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 50}, [['OPEN', 'OPEN', 'FLOWN', 'NOSHOW', 'VOID', 'VOID'], 50]], ['sampled case 3', {'status': ['FLOWN', 'OPEN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 150}, [['FLOWN', 'OPEN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 150]]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    st = list(x['status'])
    fee = 0
    seen = False
    for i, s in enumerate(st):
        if s == 'NOSHOW':
            if not seen or st[i - 1] != 'NOSHOW': fee += x['fee']
            seen = True
        elif seen and s == 'OPEN':
            st[i] = 'VOID'
    return [st, fee]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 101}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 101]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 75}, [['OPEN', 'NOSHOW', 'VOID'], 75]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'NOSHOW', 'OPEN', 'NOSHOW', 'NOSHOW', 'OPEN'], 'fee': 100}, [['OPEN', 'NOSHOW', 'VOID', 'NOSHOW', 'NOSHOW', 'VOID'], 100]], ['sampled case 2', {'status': ['FLOWN', 'OPEN', 'FLOWN', 'OPEN', 'OPEN', 'OPEN'], 'fee': 150}, [['FLOWN', 'OPEN', 'FLOWN', 'OPEN', 'OPEN', 'OPEN'], 0]], ['sampled case 3', {'status': ['OPEN'], 'fee': 100}, [['OPEN'], 0]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 102}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 102]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 150}, [['OPEN', 'NOSHOW', 'VOID'], 150]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 150}, [['OPEN', 'OPEN', 'NOSHOW', 'VOID'], 150]], ['sampled case 2', {'status': ['OPEN', 'OPEN', 'NOSHOW', 'NOSHOW', 'NOSHOW'], 'fee': 50}, [['OPEN', 'OPEN', 'NOSHOW', 'NOSHOW', 'NOSHOW'], 50]], ['sampled case 3', {'status': ['FLOWN', 'NOSHOW', 'NOSHOW', 'NOSHOW', 'OPEN'], 'fee': 100}, [['FLOWN', 'NOSHOW', 'NOSHOW', 'NOSHOW', 'VOID'], 100]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 103}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 103]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 225}, [['OPEN', 'NOSHOW', 'VOID'], 225]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'FLOWN', 'FLOWN', 'FLOWN', 'NOSHOW', 'NOSHOW'], 'fee': 75}, [['OPEN', 'FLOWN', 'FLOWN', 'FLOWN', 'NOSHOW', 'NOSHOW'], 75]], ['sampled case 2', {'status': ['FLOWN', 'OPEN', 'OPEN', 'OPEN', 'OPEN', 'FLOWN'], 'fee': 75}, [['FLOWN', 'OPEN', 'OPEN', 'OPEN', 'OPEN', 'FLOWN'], 0]], ['sampled case 3', {'status': ['OPEN'], 'fee': 50}, [['OPEN'], 0]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 104}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 104]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 300}, [['OPEN', 'NOSHOW', 'VOID'], 300]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['OPEN', 'NOSHOW', 'OPEN', 'OPEN', 'FLOWN'], 'fee': 75}, [['OPEN', 'NOSHOW', 'VOID', 'VOID', 'FLOWN'], 75]], ['sampled case 2', {'status': ['NOSHOW', 'OPEN', 'OPEN', 'FLOWN'], 'fee': 75}, [['NOSHOW', 'VOID', 'VOID', 'FLOWN'], 75]], ['sampled case 3', {'status': ['OPEN', 'OPEN', 'OPEN', 'FLOWN', 'OPEN', 'NOSHOW'], 'fee': 50}, [['OPEN', 'OPEN', 'OPEN', 'FLOWN', 'OPEN', 'NOSHOW'], 50]]], [['missed second leg', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 105}, [['FLOWN', 'NOSHOW', 'VOID', 'VOID'], 105]], ['missed first leg', {'status': ['NOSHOW', 'OPEN', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID', 'VOID'], 150]], ['open before noshow', {'status': ['OPEN', 'NOSHOW', 'OPEN'], 'fee': 375}, [['OPEN', 'NOSHOW', 'VOID'], 375]], ['two noshows', {'status': ['FLOWN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 120}, [['FLOWN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 120]], ['flown anomaly after noshow', {'status': ['NOSHOW', 'FLOWN', 'OPEN'], 'fee': 90}, [['NOSHOW', 'FLOWN', 'VOID'], 90]], ['all flown', {'status': ['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 'fee': 100}, [['FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN', 'FLOWN'], 0]], ['sampled case 1', {'status': ['NOSHOW', 'OPEN'], 'fee': 150}, [['NOSHOW', 'VOID'], 150]], ['sampled case 2', {'status': ['OPEN', 'OPEN', 'FLOWN', 'NOSHOW', 'OPEN', 'OPEN'], 'fee': 50}, [['OPEN', 'OPEN', 'FLOWN', 'NOSHOW', 'VOID', 'VOID'], 50]], ['sampled case 3', {'status': ['FLOWN', 'OPEN', 'NOSHOW', 'OPEN', 'NOSHOW', 'OPEN'], 'fee': 150}, [['FLOWN', 'OPEN', 'NOSHOW', 'VOID', 'NOSHOW', 'VOID'], 150]]]]
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)

prompt:
A ticket with two no-show coupons is charged two penalties.

Input {'status':[FLOWN|OPEN|NOSHOW per coupon],'fee'}. After the first NOSHOW, every later OPEN coupon becomes VOID (earlier coupons are untouched, FLOWN stays FLOWN). The no-show fee is charged once per ticket. Return [statuses, fee].

split: open-access


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

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.

split: open-access


prompt:
Flight AA500 is sold on a fare that explicitly excludes it.

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.

split: open-access


prompt:
Segments entered as "ba" are rejected although BA flights are in range.

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.

split: open-access


prompt:
Flight LH2999 is not covered by a 2000-2999 range.

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.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    for i, kg in enumerate(x['bags']):
        if kg > 32: return 'ERR_OVERWEIGHT_%d' % i
    free = x['allowance'] + (1 if x['elite'] else 0)
    sched = [30, 40]
    total = 0
    for pos, kg in enumerate(x['bags'], 1):
        if pos > free:
            total += sched[pos - free - 1] if pos - free <= len(sched) else 150
        if kg > 23:
            total += 100
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['basic fare three bags', {'bags': [20.0, 18.5, 22.1], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [28.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.2], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 150], ['sampled case 1', {'bags': [23.3, 23.3], 'allowance': 0, 'elite': False}, 270], ['sampled case 2', {'bags': [23.0], 'allowance': 1, 'elite': False}, 0], ['sampled case 3', {'bags': [23.3, 11.4, 20.9, 8.6], 'allowance': 2, 'elite': False}, 400]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.2], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [29.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.300000000000004], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 300], ['sampled case 1', {'bags': [], 'allowance': 0, 'elite': True}, 0], ['sampled case 2', {'bags': [18.6, 32.0, 22.6], 'allowance': 2, 'elite': False}, 250], ['sampled case 3', {'bags': [18.1, 23.0, 32.0, 23.3, 23.0], 'allowance': 0, 'elite': False}, 720]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.3], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [30.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.4], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 0], ['sampled case 1', {'bags': [32.0], 'allowance': 2, 'elite': True}, 100], ['sampled case 2', {'bags': [32.0, 23.3, 23.0], 'allowance': 0, 'elite': False}, 420], ['sampled case 3', {'bags': [], 'allowance': 1, 'elite': False}, 0]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.4], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [31.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.5], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 150], ['sampled case 1', {'bags': [32.0, 32.0, 32.0, 23.3, 23.3], 'allowance': 0, 'elite': False}, 1020], ['sampled case 2', {'bags': [], 'allowance': 1, 'elite': False}, 0], ['sampled case 3', {'bags': [20.4, 23.3], 'allowance': 1, 'elite': True}, 100]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.5], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [32.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.6], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 300], ['sampled case 1', {'bags': [31.9, 23.3, 22.9, 32.0], 'allowance': 0, 'elite': False}, 670], ['sampled case 2', {'bags': [23.3, 32.0, 32.0, 23.0], 'allowance': 1, 'elite': True}, 600], ['sampled case 3', {'bags': [7.7, 32.0], 'allowance': 2, 'elite': True}, 100]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    for i, kg in enumerate(x['bags']):
        if kg > 32: return 'ERR_OVERWEIGHT_%d' % i
    free = x['allowance'] + (1 if x['elite'] else 0)
    sched = [30, 40]
    total = 0
    for pos, kg in enumerate(x['bags'], 1):
        if pos > free:
            total += sched[min(pos, len(sched)) - 1]
        if kg > 23:
            total += 100
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['basic fare three bags', {'bags': [20.0, 18.5, 22.1], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [28.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.2], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 150], ['sampled case 1', {'bags': [23.3, 23.3], 'allowance': 0, 'elite': False}, 270], ['sampled case 2', {'bags': [23.0], 'allowance': 1, 'elite': False}, 0], ['sampled case 3', {'bags': [23.3, 11.4, 20.9, 8.6], 'allowance': 2, 'elite': False}, 400]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.2], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [29.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.300000000000004], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 300], ['sampled case 1', {'bags': [], 'allowance': 0, 'elite': True}, 0], ['sampled case 2', {'bags': [18.6, 32.0, 22.6], 'allowance': 2, 'elite': False}, 250], ['sampled case 3', {'bags': [18.1, 23.0, 32.0, 23.3, 23.0], 'allowance': 0, 'elite': False}, 720]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.3], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [30.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.4], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 0], ['sampled case 1', {'bags': [32.0], 'allowance': 2, 'elite': True}, 100], ['sampled case 2', {'bags': [32.0, 23.3, 23.0], 'allowance': 0, 'elite': False}, 420], ['sampled case 3', {'bags': [], 'allowance': 1, 'elite': False}, 0]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.4], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [31.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.5], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 150], ['sampled case 1', {'bags': [32.0, 32.0, 32.0, 23.3, 23.3], 'allowance': 0, 'elite': False}, 1020], ['sampled case 2', {'bags': [], 'allowance': 1, 'elite': False}, 0], ['sampled case 3', {'bags': [20.4, 23.3], 'allowance': 1, 'elite': True}, 100]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.5], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [32.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.6], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 300], ['sampled case 1', {'bags': [31.9, 23.3, 22.9, 32.0], 'allowance': 0, 'elite': False}, 670], ['sampled case 2', {'bags': [23.3, 32.0, 32.0, 23.0], 'allowance': 1, 'elite': True}, 600], ['sampled case 3', {'bags': [7.7, 32.0], 'allowance': 2, 'elite': True}, 100]]]
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)

prompt:
With one free bag the second bag is charged 30 instead of 40.

Input {'bags':[kg in check-in order],'allowance','elite'}. Any bag over 32 kg -> 'ERR_OVERWEIGHT_<i>' (first, zero-based). Free bags = allowance + 1 if elite, applied to the first bags. Base fee by overall bag position: 1st 30, 2nd 40, 3rd and later 150 (only for bags beyond the free count). Each bag over 23 kg adds 100, free or not. Return total.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    for i, kg in enumerate(x['bags']):
        if kg > 32: return 'ERR_OVERWEIGHT_%d' % i
    free = x['allowance'] + (1 if x['elite'] else 0)
    sched = [30, 40]
    total = 0
    for pos, kg in enumerate(x['bags'], 1):
        if pos > free:
            total += sched[pos - 1] if pos <= len(sched) else 150
        if kg >= 23:
            total += 100
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['basic fare three bags', {'bags': [20.0, 18.5, 22.1], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [28.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.2], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 150], ['sampled case 1', {'bags': [23.3, 23.3], 'allowance': 0, 'elite': False}, 270], ['sampled case 2', {'bags': [23.0], 'allowance': 1, 'elite': False}, 0], ['sampled case 3', {'bags': [23.3, 11.4, 20.9, 8.6], 'allowance': 2, 'elite': False}, 400]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.2], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [29.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.300000000000004], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 300], ['sampled case 1', {'bags': [], 'allowance': 0, 'elite': True}, 0], ['sampled case 2', {'bags': [18.6, 32.0, 22.6], 'allowance': 2, 'elite': False}, 250], ['sampled case 3', {'bags': [18.1, 23.0, 32.0, 23.3, 23.0], 'allowance': 0, 'elite': False}, 720]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.3], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [30.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.4], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 0], ['sampled case 1', {'bags': [32.0], 'allowance': 2, 'elite': True}, 100], ['sampled case 2', {'bags': [32.0, 23.3, 23.0], 'allowance': 0, 'elite': False}, 420], ['sampled case 3', {'bags': [], 'allowance': 1, 'elite': False}, 0]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.4], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [31.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.5], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 150], ['sampled case 1', {'bags': [32.0, 32.0, 32.0, 23.3, 23.3], 'allowance': 0, 'elite': False}, 1020], ['sampled case 2', {'bags': [], 'allowance': 1, 'elite': False}, 0], ['sampled case 3', {'bags': [20.4, 23.3], 'allowance': 1, 'elite': True}, 100]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.5], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [32.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.6], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 300], ['sampled case 1', {'bags': [31.9, 23.3, 22.9, 32.0], 'allowance': 0, 'elite': False}, 670], ['sampled case 2', {'bags': [23.3, 32.0, 32.0, 23.0], 'allowance': 1, 'elite': True}, 600], ['sampled case 3', {'bags': [7.7, 32.0], 'allowance': 2, 'elite': True}, 100]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    for i, kg in enumerate(x['bags']):
        if kg > 32: return 'ERR_OVERWEIGHT_%d' % i
    free = x['allowance'] + (1 if x['elite'] else 0)
    sched = [30, 40]
    total = 0
    for pos, kg in enumerate(x['bags'], 1):
        if pos > free:
            total += sched[pos - 1] if pos <= len(sched) else 150
        if round(kg) > 23:
            total += 100
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['basic fare three bags', {'bags': [20.0, 18.5, 22.1], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [28.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.2], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 150], ['sampled case 1', {'bags': [23.3, 23.3], 'allowance': 0, 'elite': False}, 270], ['sampled case 2', {'bags': [23.0], 'allowance': 1, 'elite': False}, 0], ['sampled case 3', {'bags': [23.3, 11.4, 20.9, 8.6], 'allowance': 2, 'elite': False}, 400]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.2], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [29.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.300000000000004], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 300], ['sampled case 1', {'bags': [], 'allowance': 0, 'elite': True}, 0], ['sampled case 2', {'bags': [18.6, 32.0, 22.6], 'allowance': 2, 'elite': False}, 250], ['sampled case 3', {'bags': [18.1, 23.0, 32.0, 23.3, 23.0], 'allowance': 0, 'elite': False}, 720]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.3], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [30.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.4], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 0], ['sampled case 1', {'bags': [32.0], 'allowance': 2, 'elite': True}, 100], ['sampled case 2', {'bags': [32.0, 23.3, 23.0], 'allowance': 0, 'elite': False}, 420], ['sampled case 3', {'bags': [], 'allowance': 1, 'elite': False}, 0]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.4], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [31.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.5], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 150], ['sampled case 1', {'bags': [32.0, 32.0, 32.0, 23.3, 23.3], 'allowance': 0, 'elite': False}, 1020], ['sampled case 2', {'bags': [], 'allowance': 1, 'elite': False}, 0], ['sampled case 3', {'bags': [20.4, 23.3], 'allowance': 1, 'elite': True}, 100]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.5], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [32.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.6], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 300], ['sampled case 1', {'bags': [31.9, 23.3, 22.9, 32.0], 'allowance': 0, 'elite': False}, 670], ['sampled case 2', {'bags': [23.3, 32.0, 32.0, 23.0], 'allowance': 1, 'elite': True}, 600], ['sampled case 3', {'bags': [7.7, 32.0], 'allowance': 2, 'elite': True}, 100]]]
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)

prompt:
A bag weighing exactly the free weight limit incurs the 100 surcharge.

Input {'bags':[kg in check-in order],'allowance','elite'}. Any bag over 32 kg -> 'ERR_OVERWEIGHT_<i>' (first, zero-based). Free bags = allowance + 1 if elite, applied to the first bags. Base fee by overall bag position: 1st 30, 2nd 40, 3rd and later 150 (only for bags beyond the free count). Each bag over 23 kg adds 100, free or not. Return total.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    free = x['allowance'] + (1 if x['elite'] else 0)
    for i, kg in enumerate(x['bags']):
        if kg > 32 and i >= free: return 'ERR_OVERWEIGHT_%d' % i
    sched = [30, 40]
    total = 0
    for pos, kg in enumerate(x['bags'], 1):
        if pos > free:
            total += sched[pos - 1] if pos <= len(sched) else 150
        if kg > 23:
            total += 100
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['basic fare three bags', {'bags': [20.0, 18.5, 22.1], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [28.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.2], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 150], ['sampled case 1', {'bags': [23.3, 23.3], 'allowance': 0, 'elite': False}, 270], ['sampled case 2', {'bags': [23.0], 'allowance': 1, 'elite': False}, 0], ['sampled case 3', {'bags': [23.3, 11.4, 20.9, 8.6], 'allowance': 2, 'elite': False}, 400]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.2], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [29.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.300000000000004], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 300], ['sampled case 1', {'bags': [], 'allowance': 0, 'elite': True}, 0], ['sampled case 2', {'bags': [18.6, 32.0, 22.6], 'allowance': 2, 'elite': False}, 250], ['sampled case 3', {'bags': [18.1, 23.0, 32.0, 23.3, 23.0], 'allowance': 0, 'elite': False}, 720]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.3], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [30.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.4], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 0], ['sampled case 1', {'bags': [32.0], 'allowance': 2, 'elite': True}, 100], ['sampled case 2', {'bags': [32.0, 23.3, 23.0], 'allowance': 0, 'elite': False}, 420], ['sampled case 3', {'bags': [], 'allowance': 1, 'elite': False}, 0]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.4], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [31.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.5], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 150], ['sampled case 1', {'bags': [32.0, 32.0, 32.0, 23.3, 23.3], 'allowance': 0, 'elite': False}, 1020], ['sampled case 2', {'bags': [], 'allowance': 1, 'elite': False}, 0], ['sampled case 3', {'bags': [20.4, 23.3], 'allowance': 1, 'elite': True}, 100]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.5], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [32.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.6], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 300], ['sampled case 1', {'bags': [31.9, 23.3, 22.9, 32.0], 'allowance': 0, 'elite': False}, 670], ['sampled case 2', {'bags': [23.3, 32.0, 32.0, 23.0], 'allowance': 1, 'elite': True}, 600], ['sampled case 3', {'bags': [7.7, 32.0], 'allowance': 2, 'elite': True}, 100]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    for i, kg in enumerate(x['bags']):
        if kg > 32 and not x['elite']: return 'ERR_OVERWEIGHT_%d' % i
    free = x['allowance'] + (1 if x['elite'] else 0)
    sched = [30, 40]
    total = 0
    for pos, kg in enumerate(x['bags'], 1):
        if pos > free:
            total += sched[pos - 1] if pos <= len(sched) else 150
        if kg > 23:
            total += 100
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['basic fare three bags', {'bags': [20.0, 18.5, 22.1], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [28.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.2], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 150], ['sampled case 1', {'bags': [23.3, 23.3], 'allowance': 0, 'elite': False}, 270], ['sampled case 2', {'bags': [23.0], 'allowance': 1, 'elite': False}, 0], ['sampled case 3', {'bags': [23.3, 11.4, 20.9, 8.6], 'allowance': 2, 'elite': False}, 400]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.2], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [29.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.300000000000004], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 300], ['sampled case 1', {'bags': [], 'allowance': 0, 'elite': True}, 0], ['sampled case 2', {'bags': [18.6, 32.0, 22.6], 'allowance': 2, 'elite': False}, 250], ['sampled case 3', {'bags': [18.1, 23.0, 32.0, 23.3, 23.0], 'allowance': 0, 'elite': False}, 720]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.3], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [30.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.4], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 0], ['sampled case 1', {'bags': [32.0], 'allowance': 2, 'elite': True}, 100], ['sampled case 2', {'bags': [32.0, 23.3, 23.0], 'allowance': 0, 'elite': False}, 420], ['sampled case 3', {'bags': [], 'allowance': 1, 'elite': False}, 0]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.4], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [31.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.5], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 150], ['sampled case 1', {'bags': [32.0, 32.0, 32.0, 23.3, 23.3], 'allowance': 0, 'elite': False}, 1020], ['sampled case 2', {'bags': [], 'allowance': 1, 'elite': False}, 0], ['sampled case 3', {'bags': [20.4, 23.3], 'allowance': 1, 'elite': True}, 100]], [['basic fare three bags', {'bags': [20.0, 18.5, 22.5], 'allowance': 0, 'elite': False}, 220], ['one free bag two paid', {'bags': [23.0, 21.0, 15.0], 'allowance': 1, 'elite': False}, 190], ['elite extra bag', {'bags': [19.0, 22.0, 20.0, 12.0], 'allowance': 1, 'elite': True}, 300], ['heavy free bag', {'bags': [32.0, 10.0], 'allowance': 1, 'elite': False}, 140], ['exactly hard limit', {'bags': [32.0, 23.4], 'allowance': 0, 'elite': False}, 270], ['over hard limit', {'bags': [20.0, 32.6], 'allowance': 2, 'elite': True}, 'ERR_OVERWEIGHT_1'], ['elite with two allowance', {'bags': [23.0, 23.0, 23.0, 23.0, 23.0], 'allowance': 2, 'elite': True}, 300], ['sampled case 1', {'bags': [31.9, 23.3, 22.9, 32.0], 'allowance': 0, 'elite': False}, 670], ['sampled case 2', {'bags': [23.3, 32.0, 32.0, 23.0], 'allowance': 1, 'elite': True}, 600], ['sampled case 3', {'bags': [7.7, 32.0], 'allowance': 2, 'elite': True}, 100]]]
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)

prompt:
A 33 kg first bag on a fare with one free piece is accepted and priced.

Input {'bags':[kg in check-in order],'allowance','elite'}. Any bag over 32 kg -> 'ERR_OVERWEIGHT_<i>' (first, zero-based). Free bags = allowance + 1 if elite, applied to the first bags. Base fee by overall bag position: 1st 30, 2nd 40, 3rd and later 150 (only for bags beyond the free count). Each bag over 23 kg adds 100, free or not. Return total.

split: open-access