FAILURE MAP
← Case archive

FA-68541 / Toll and parking fee computation / Open access

Cordon congestion charge: the peak window includes its end minute · case 01

Cordon congestion charge returns a wrong result when the peak window includes its end minute.

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

ROOT CAUSE

A crossing at the minute the peak ends is charged the peak fee.

VERIFIED REPAIR

Restore the peak window edges rule so that the step reads `s <= m < e`.

Unsuccessful approach: Shifting both edges charges the first peak minute off-peak and the minute after the peak as peak.

Case contract

Input {crossings: [[day, minute]] unordered, peak: [[start, end)] windows, peak_fee, offpeak_fee, daily_cap, weekend_free, zero_emission, grace}. Zero-emission vehicles pay 0. Days with day % 7 in {5, 6} are free when weekend_free. Within a day, a crossing no more than grace minutes after the last charged crossing is free (the grace anchor is the charged crossing). Each charged crossing pays the peak fee inside a window else off-peak; each day's sum is capped at daily_cap.

Why this case matters

Fee engines bill customers in integer cents; a wrong boundary, rounding stage or cap scope silently over- or under-charges.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    if x['zero_emission']:
        return 0
    byday = {}
    for d, m in sorted(x['crossings']):
        byday.setdefault(d, []).append(m)
    total = 0
    for d, ms in byday.items():
        if x['weekend_free'] and d % 7 >= 5:
            continue
        last = None
        day_sum = 0
        for m in ms:
            if last is not None and m - last <= x['grace']:
                continue
            last = m
            peak = any(s <= m <= e for s, e in x['peak'])
            day_sum += x['peak_fee'] if peak else x['offpeak_fee']
        total += min(day_sum, x['daily_cap'])
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'crossings': [[6, 406], [9, 1150], [9, 365], [9, 1140], [7, 883]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 1500, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 600), ({'crossings': [[7, 419], [0, 577], [2, 538], [3, 418], [2, 1056], [1, 1275], [1, 303], [9, 333]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 1500, 'weekend_free': False, 'zero_emission': False, 'grace': 10}, 3650), ({'crossings': [[6, 1265], [2, 510], [3, 1249], [5, 658], [5, 673]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 3000, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 1150), ({'crossings': [[3, 805], [5, 356], [9, 391], [3, 810], [0, 368]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 3000, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 750), ({'crossings': [[2, 600], [2, 420], [2, 1140]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 1400), ({'crossings': [[7, 573], [3, 540], [5, 1030], [7, 739], [3, 960], [8, 906]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 300, 'daily_cap': 2000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 3600), ({'crossings': [[1, 500], [1, 508], [1, 516], [1, 530]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2700), ({'crossings': [[6, 500], [0, 500], [5, 500]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 900)], [({'crossings': [[1, 1172], [1, 565], [0, 799], [6, 1296], [1, 550], [1, 600], [1, 570]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 300, 'daily_cap': 3000, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 2900), ({'crossings': [[2, 600], [2, 420], [2, 1140]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 1400), ({'crossings': [[4, 815], [3, 796], [6, 713], [4, 566], [3, 366], [1, 666], [5, 664], [4, 1087]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 3000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2600), ({'crossings': [[1, 500], [1, 508], [1, 516], [1, 530]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2700), ({'crossings': [[3, 1140], [1, 924], [5, 1081], [0, 886], [1, 467], [1, 1255], [7, 1290], [1, 472], [1, 353]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 1500, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2100), ({'crossings': [[6, 500], [0, 500], [5, 500]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 900), ({'crossings': [[9, 1080], [8, 999], [9, 572], [8, 814], [7, 656]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 2000, 'weekend_free': False, 'zero_emission': False, 'grace': 15}, 3100), ({'crossings': [[0, 1157], [1, 338], [3, 478], [1, 1304], [1, 1292], [4, 1195], [5, 620], [1, 793]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 200, 'daily_cap': 2000, 'weekend_free': False, 'zero_emission': False, 'grace': 10}, 2400)], [({'crossings': [[1, 500], [1, 508], [1, 516], [1, 530]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2700), ({'crossings': [[9, 740], [3, 1230], [3, 1225]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 300, 'daily_cap': 1500, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 600), ({'crossings': [[9, 1224], [9, 685], [2, 831], [3, 1244], [9, 611], [9, 1204]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 300, 'daily_cap': 2000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 1800), ({'crossings': [[0, 598], [3, 426], [6, 1284], [6, 1274], [6, 330], [4, 420], [3, 444], [4, 1214]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 300, 'daily_cap': 1500, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 3800), ({'crossings': [[2, 600], [2, 420], [2, 1140]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 1400), ({'crossings': [[4, 451], [5, 385], [6, 676], [4, 466], [9, 918], [2, 1010]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 3000, 'weekend_free': False, 'zero_emission': False, 'grace': 10}, 3300), ({'crossings': [[0, 1120], [9, 1245], [0, 1140]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 300, 'daily_cap': 2000, 'weekend_free': False, 'zero_emission': False, 'grace': 10}, 1500), ({'crossings': [[6, 500], [0, 500], [5, 500]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 900)], [({'crossings': [[6, 500], [0, 500], [5, 500]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 900), ({'crossings': [[9, 1140], [6, 401], [1, 561], [1, 581], [1, 586]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 300, 'daily_cap': 3000, 'weekend_free': False, 'zero_emission': False, 'grace': 15}, 2400), ({'crossings': [[3, 633], [7, 1147], [4, 1075], [2, 1207], [0, 952], [0, 932], [7, 754], [4, 306], [1, 1277]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 200, 'daily_cap': 1500, 'weekend_free': False, 'zero_emission': False, 'grace': 10}, 2600), ({'crossings': [[9, 898], [1, 377], [9, 1185], [7, 543], [9, 1195], [9, 1173], [2, 1261], [8, 806], [9, 1133]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 3000, 'weekend_free': False, 'zero_emission': False, 'grace': 15}, 3300), ({'crossings': [[1, 500], [1, 508], [1, 516], [1, 530]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2700), ({'crossings': [[0, 457], [0, 442], [0, 871]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 250, 'daily_cap': 1500, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 1250), ({'crossings': [[6, 1192], [0, 573], [0, 625], [7, 449], [1, 600]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 2000, 'weekend_free': False, 'zero_emission': False, 'grace': 15}, 2400), ({'crossings': [[2, 600], [2, 420], [2, 1140]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 1400)], [({'crossings': [[8, 1081], [8, 805]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 200, 'daily_cap': 2000, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 1200), ({'crossings': [[2, 1101], [2, 600], [8, 434], [8, 439], [5, 601], [2, 1015]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 3000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2900), ({'crossings': [[7, 571], [1, 883], [1, 1152], [4, 405], [0, 1151], [9, 471], [9, 456], [3, 837], [9, 359]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 300, 'daily_cap': 1500, 'weekend_free': False, 'zero_emission': False, 'grace': 15}, 3600), ({'crossings': [[6, 500], [0, 500], [5, 500]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 900), ({'crossings': [[7, 314], [8, 752], [4, 372], [8, 737]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 2000, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 750), ({'crossings': [[2, 600], [2, 420], [2, 1140]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 1400), ({'crossings': [[7, 600], [8, 992], [3, 436], [3, 983], [0, 965], [2, 862], [3, 441]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 300, 'daily_cap': 2000, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 4200), ({'crossings': [[1, 500], [1, 508], [1, 516], [1, 530]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2700)]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('fee oracle' + ' %d' % i, 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
fee oracle 01300600Failed
fee oracle 136503650Passed
fee oracle 211501150Passed
fee oracle 3750750Passed
fee oracle 427001400Failed
fee oracle 536003600Passed
fee oracle 627002700Passed
fee oracle 7900900Passed

SHA-256 / ba34e9d177936273c40c909c3021b09a3c8104f1da7e960d7d4e8ef5a71349ee

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    if x['zero_emission']:
        return 0
    byday = {}
    for d, m in sorted(x['crossings']):
        byday.setdefault(d, []).append(m)
    total = 0
    for d, ms in byday.items():
        if x['weekend_free'] and d % 7 >= 5:
            continue
        last = None
        day_sum = 0
        for m in ms:
            if last is not None and m - last <= x['grace']:
                continue
            last = m
            peak = any(s < m <= e for s, e in x['peak'])
            day_sum += x['peak_fee'] if peak else x['offpeak_fee']
        total += min(day_sum, x['daily_cap'])
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'crossings': [[6, 406], [9, 1150], [9, 365], [9, 1140], [7, 883]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 1500, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 600), ({'crossings': [[7, 419], [0, 577], [2, 538], [3, 418], [2, 1056], [1, 1275], [1, 303], [9, 333]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 1500, 'weekend_free': False, 'zero_emission': False, 'grace': 10}, 3650), ({'crossings': [[6, 1265], [2, 510], [3, 1249], [5, 658], [5, 673]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 3000, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 1150), ({'crossings': [[3, 805], [5, 356], [9, 391], [3, 810], [0, 368]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 3000, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 750), ({'crossings': [[2, 600], [2, 420], [2, 1140]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 1400), ({'crossings': [[7, 573], [3, 540], [5, 1030], [7, 739], [3, 960], [8, 906]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 300, 'daily_cap': 2000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 3600), ({'crossings': [[1, 500], [1, 508], [1, 516], [1, 530]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2700), ({'crossings': [[6, 500], [0, 500], [5, 500]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 900)], [({'crossings': [[1, 1172], [1, 565], [0, 799], [6, 1296], [1, 550], [1, 600], [1, 570]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 300, 'daily_cap': 3000, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 2900), ({'crossings': [[2, 600], [2, 420], [2, 1140]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 1400), ({'crossings': [[4, 815], [3, 796], [6, 713], [4, 566], [3, 366], [1, 666], [5, 664], [4, 1087]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 3000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2600), ({'crossings': [[1, 500], [1, 508], [1, 516], [1, 530]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2700), ({'crossings': [[3, 1140], [1, 924], [5, 1081], [0, 886], [1, 467], [1, 1255], [7, 1290], [1, 472], [1, 353]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 1500, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2100), ({'crossings': [[6, 500], [0, 500], [5, 500]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 900), ({'crossings': [[9, 1080], [8, 999], [9, 572], [8, 814], [7, 656]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 2000, 'weekend_free': False, 'zero_emission': False, 'grace': 15}, 3100), ({'crossings': [[0, 1157], [1, 338], [3, 478], [1, 1304], [1, 1292], [4, 1195], [5, 620], [1, 793]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 200, 'daily_cap': 2000, 'weekend_free': False, 'zero_emission': False, 'grace': 10}, 2400)], [({'crossings': [[1, 500], [1, 508], [1, 516], [1, 530]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2700), ({'crossings': [[9, 740], [3, 1230], [3, 1225]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 300, 'daily_cap': 1500, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 600), ({'crossings': [[9, 1224], [9, 685], [2, 831], [3, 1244], [9, 611], [9, 1204]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 300, 'daily_cap': 2000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 1800), ({'crossings': [[0, 598], [3, 426], [6, 1284], [6, 1274], [6, 330], [4, 420], [3, 444], [4, 1214]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 300, 'daily_cap': 1500, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 3800), ({'crossings': [[2, 600], [2, 420], [2, 1140]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 1400), ({'crossings': [[4, 451], [5, 385], [6, 676], [4, 466], [9, 918], [2, 1010]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 3000, 'weekend_free': False, 'zero_emission': False, 'grace': 10}, 3300), ({'crossings': [[0, 1120], [9, 1245], [0, 1140]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 300, 'daily_cap': 2000, 'weekend_free': False, 'zero_emission': False, 'grace': 10}, 1500), ({'crossings': [[6, 500], [0, 500], [5, 500]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 900)], [({'crossings': [[6, 500], [0, 500], [5, 500]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 900), ({'crossings': [[9, 1140], [6, 401], [1, 561], [1, 581], [1, 586]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 300, 'daily_cap': 3000, 'weekend_free': False, 'zero_emission': False, 'grace': 15}, 2400), ({'crossings': [[3, 633], [7, 1147], [4, 1075], [2, 1207], [0, 952], [0, 932], [7, 754], [4, 306], [1, 1277]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 200, 'daily_cap': 1500, 'weekend_free': False, 'zero_emission': False, 'grace': 10}, 2600), ({'crossings': [[9, 898], [1, 377], [9, 1185], [7, 543], [9, 1195], [9, 1173], [2, 1261], [8, 806], [9, 1133]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 3000, 'weekend_free': False, 'zero_emission': False, 'grace': 15}, 3300), ({'crossings': [[1, 500], [1, 508], [1, 516], [1, 530]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2700), ({'crossings': [[0, 457], [0, 442], [0, 871]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 250, 'daily_cap': 1500, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 1250), ({'crossings': [[6, 1192], [0, 573], [0, 625], [7, 449], [1, 600]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 2000, 'weekend_free': False, 'zero_emission': False, 'grace': 15}, 2400), ({'crossings': [[2, 600], [2, 420], [2, 1140]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 1400)], [({'crossings': [[8, 1081], [8, 805]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 200, 'daily_cap': 2000, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 1200), ({'crossings': [[2, 1101], [2, 600], [8, 434], [8, 439], [5, 601], [2, 1015]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 3000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2900), ({'crossings': [[7, 571], [1, 883], [1, 1152], [4, 405], [0, 1151], [9, 471], [9, 456], [3, 837], [9, 359]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 300, 'daily_cap': 1500, 'weekend_free': False, 'zero_emission': False, 'grace': 15}, 3600), ({'crossings': [[6, 500], [0, 500], [5, 500]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 900), ({'crossings': [[7, 314], [8, 752], [4, 372], [8, 737]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 2000, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 750), ({'crossings': [[2, 600], [2, 420], [2, 1140]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 1400), ({'crossings': [[7, 600], [8, 992], [3, 436], [3, 983], [0, 965], [2, 862], [3, 441]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 300, 'daily_cap': 2000, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 4200), ({'crossings': [[1, 500], [1, 508], [1, 516], [1, 530]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2700)]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('fee oracle' + ' %d' % i, 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
fee oracle 01300600Failed
fee oracle 136503650Passed
fee oracle 211501150Passed
fee oracle 3750750Passed
fee oracle 420501400Failed
fee oracle 529003600Failed
fee oracle 627002700Passed
fee oracle 7900900Passed

SHA-256 / ea888eac7a684ce37edee6c91ad001d73580fed1b8e6921bc351fda487d3261e

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    if x['zero_emission']:
        return 0
    byday = {}
    for d, m in sorted(x['crossings']):
        byday.setdefault(d, []).append(m)
    total = 0
    for d, ms in byday.items():
        if x['weekend_free'] and d % 7 >= 5:
            continue
        last = None
        day_sum = 0
        for m in ms:
            if last is not None and m - last <= x['grace']:
                continue
            last = m
            peak = any(s <= m < e for s, e in x['peak'])
            day_sum += x['peak_fee'] if peak else x['offpeak_fee']
        total += min(day_sum, x['daily_cap'])
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'crossings': [[6, 406], [9, 1150], [9, 365], [9, 1140], [7, 883]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 1500, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 600), ({'crossings': [[7, 419], [0, 577], [2, 538], [3, 418], [2, 1056], [1, 1275], [1, 303], [9, 333]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 1500, 'weekend_free': False, 'zero_emission': False, 'grace': 10}, 3650), ({'crossings': [[6, 1265], [2, 510], [3, 1249], [5, 658], [5, 673]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 3000, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 1150), ({'crossings': [[3, 805], [5, 356], [9, 391], [3, 810], [0, 368]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 3000, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 750), ({'crossings': [[2, 600], [2, 420], [2, 1140]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 1400), ({'crossings': [[7, 573], [3, 540], [5, 1030], [7, 739], [3, 960], [8, 906]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 300, 'daily_cap': 2000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 3600), ({'crossings': [[1, 500], [1, 508], [1, 516], [1, 530]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2700), ({'crossings': [[6, 500], [0, 500], [5, 500]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 900)], [({'crossings': [[1, 1172], [1, 565], [0, 799], [6, 1296], [1, 550], [1, 600], [1, 570]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 300, 'daily_cap': 3000, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 2900), ({'crossings': [[2, 600], [2, 420], [2, 1140]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 1400), ({'crossings': [[4, 815], [3, 796], [6, 713], [4, 566], [3, 366], [1, 666], [5, 664], [4, 1087]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 3000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2600), ({'crossings': [[1, 500], [1, 508], [1, 516], [1, 530]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2700), ({'crossings': [[3, 1140], [1, 924], [5, 1081], [0, 886], [1, 467], [1, 1255], [7, 1290], [1, 472], [1, 353]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 1500, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2100), ({'crossings': [[6, 500], [0, 500], [5, 500]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 900), ({'crossings': [[9, 1080], [8, 999], [9, 572], [8, 814], [7, 656]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 2000, 'weekend_free': False, 'zero_emission': False, 'grace': 15}, 3100), ({'crossings': [[0, 1157], [1, 338], [3, 478], [1, 1304], [1, 1292], [4, 1195], [5, 620], [1, 793]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 200, 'daily_cap': 2000, 'weekend_free': False, 'zero_emission': False, 'grace': 10}, 2400)], [({'crossings': [[1, 500], [1, 508], [1, 516], [1, 530]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2700), ({'crossings': [[9, 740], [3, 1230], [3, 1225]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 300, 'daily_cap': 1500, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 600), ({'crossings': [[9, 1224], [9, 685], [2, 831], [3, 1244], [9, 611], [9, 1204]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 300, 'daily_cap': 2000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 1800), ({'crossings': [[0, 598], [3, 426], [6, 1284], [6, 1274], [6, 330], [4, 420], [3, 444], [4, 1214]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 300, 'daily_cap': 1500, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 3800), ({'crossings': [[2, 600], [2, 420], [2, 1140]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 1400), ({'crossings': [[4, 451], [5, 385], [6, 676], [4, 466], [9, 918], [2, 1010]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 3000, 'weekend_free': False, 'zero_emission': False, 'grace': 10}, 3300), ({'crossings': [[0, 1120], [9, 1245], [0, 1140]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 300, 'daily_cap': 2000, 'weekend_free': False, 'zero_emission': False, 'grace': 10}, 1500), ({'crossings': [[6, 500], [0, 500], [5, 500]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 900)], [({'crossings': [[6, 500], [0, 500], [5, 500]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 900), ({'crossings': [[9, 1140], [6, 401], [1, 561], [1, 581], [1, 586]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 300, 'daily_cap': 3000, 'weekend_free': False, 'zero_emission': False, 'grace': 15}, 2400), ({'crossings': [[3, 633], [7, 1147], [4, 1075], [2, 1207], [0, 952], [0, 932], [7, 754], [4, 306], [1, 1277]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 200, 'daily_cap': 1500, 'weekend_free': False, 'zero_emission': False, 'grace': 10}, 2600), ({'crossings': [[9, 898], [1, 377], [9, 1185], [7, 543], [9, 1195], [9, 1173], [2, 1261], [8, 806], [9, 1133]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 3000, 'weekend_free': False, 'zero_emission': False, 'grace': 15}, 3300), ({'crossings': [[1, 500], [1, 508], [1, 516], [1, 530]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2700), ({'crossings': [[0, 457], [0, 442], [0, 871]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 250, 'daily_cap': 1500, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 1250), ({'crossings': [[6, 1192], [0, 573], [0, 625], [7, 449], [1, 600]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 2000, 'weekend_free': False, 'zero_emission': False, 'grace': 15}, 2400), ({'crossings': [[2, 600], [2, 420], [2, 1140]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 1400)], [({'crossings': [[8, 1081], [8, 805]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 1000, 'offpeak_fee': 200, 'daily_cap': 2000, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 1200), ({'crossings': [[2, 1101], [2, 600], [8, 434], [8, 439], [5, 601], [2, 1015]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 200, 'daily_cap': 3000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2900), ({'crossings': [[7, 571], [1, 883], [1, 1152], [4, 405], [0, 1151], [9, 471], [9, 456], [3, 837], [9, 359]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 300, 'daily_cap': 1500, 'weekend_free': False, 'zero_emission': False, 'grace': 15}, 3600), ({'crossings': [[6, 500], [0, 500], [5, 500]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 900), ({'crossings': [[7, 314], [8, 752], [4, 372], [8, 737]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 2000, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 750), ({'crossings': [[2, 600], [2, 420], [2, 1140]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 1400), ({'crossings': [[7, 600], [8, 992], [3, 436], [3, 983], [0, 965], [2, 862], [3, 441]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 300, 'daily_cap': 2000, 'weekend_free': True, 'zero_emission': False, 'grace': 15}, 4200), ({'crossings': [[1, 500], [1, 508], [1, 516], [1, 530]], 'peak': [[420, 600], [960, 1140]], 'peak_fee': 900, 'offpeak_fee': 250, 'daily_cap': 5000, 'weekend_free': True, 'zero_emission': False, 'grace': 10}, 2700)]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('fee oracle' + ' %d' % i, 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
fee oracle 0600600Passed
fee oracle 136503650Passed
fee oracle 211501150Passed
fee oracle 3750750Passed
fee oracle 414001400Passed
fee oracle 536003600Passed
fee oracle 627002700Passed
fee oracle 7900900Passed

SHA-256 / 41aecc6d620aedebc25558f131b4875064cd1ef818d794a959bb4d7b2b7b0fa2

Verification & scope

A deterministic, bounded toy model with a stipulated contract; it makes no claim of conformance to any agency manual or standard. 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:48:03.174311+00:00.

Case digest / 1b8e59ecfeb90c69bd222a80b2ce24ffdc54edf6a9c12ca9655b9780e0b3be02