FA-68646 / Toll and parking fee computation / Open access
One-way bridge toll with frequent-user discount: carpools of exactly the minimum occupancy are charged · case 01
One-way bridge toll with frequent-user discount returns a wrong result when carpools of exactly the minimum occupancy are charged.
ROOT CAUSE
Vehicles at exactly the carpool minimum pay the toll.
VERIFIED REPAIR
Restore the carpool threshold rule so that the step reads `if occ >= x['carpool_min']:`.
Unsuccessful approach: A hard-coded three ignores two-person carpool rules.
Case contract
Input {trips: [[month index, direction, occupancy]], toll_dir, base, threshold, discount_pct, carpool_min}. Only trips in toll_dir are tolled. Carpools (occupancy >= carpool_min) are free and do not count. Paid trips are counted per month index (no carry-over between months); trips beyond threshold in a month pay floor(base*(100-discount)/100).
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):
counts = {}
total = 0
for month, d, occ in x['trips']:
if d != x['toll_dir']:
continue
if occ > x['carpool_min']:
continue
k = counts.get(month, 0) + 1
counts[month] = k
if k > x['threshold']:
total += x['base'] * (100 - x['discount_pct']) // 100
else:
total += x['base']
return total
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'trips': [[2, 'E', 1], [1, 'E', 4], [1, 'E', 1]], 'toll_dir': 'W', 'base': 850, 'threshold': 4, 'discount_pct': 40, 'carpool_min': 2}, 0), ({'trips': [[2, 'W', 1], [13, 'E', 2], [13, 'E', 1], [1, 'E', 2], [1, 'W', 3], [1, 'E', 1], [1, 'E', 3], [1, 'W', 2], [13, 'E', 2], [2, 'W', 1], [1, 'E', 4], [1, 'W', 1], [2, 'W', 1], [2, 'E', 3]], 'toll_dir': 'E', 'base': 600, 'threshold': 1, 'discount_pct': 25, 'carpool_min': 2}, 1200), ({'trips': [[1, 'E', 4], [1, 'W', 2], [1, 'E', 3], [2, 'E', 3], [1, 'W', 2], [1, 'E', 4], [13, 'W', 1], [1, 'W', 4], [1, 'E', 1]], 'toll_dir': 'E', 'base': 850, 'threshold': 1, 'discount_pct': 40, 'carpool_min': 2}, 850), ({'trips': [[2, 'W', 1], [1, 'W', 1], [1, 'E', 1], [1, 'E', 1], [1, 'E', 1], [1, 'W', 2], [1, 'W', 2]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 40, 'carpool_min': 3}, 2610), ({'trips': [[1, 'W', 1], [1, 'W', 3], [2, 'E', 1], [1, 'E', 4], [1, 'E', 3], [2, 'E', 4], [1, 'E', 4], [1, 'E', 4], [13, 'E', 3], [1, 'W', 1], [2, 'E', 3]], 'toll_dir': 'W', 'base': 600, 'threshold': 3, 'discount_pct': 40, 'carpool_min': 3}, 1200), ({'trips': [[13, 'W', 1], [1, 'E', 3], [1, 'E', 2], [13, 'W', 2], [1, 'E', 3], [13, 'W', 1], [13, 'W', 1], [13, 'W', 1], [1, 'W', 1], [2, 'W', 2], [1, 'E', 1], [13, 'E', 3], [1, 'W', 2]], 'toll_dir': 'W', 'base': 600, 'threshold': 2, 'discount_pct': 25, 'carpool_min': 2}, 2700), ({'trips': [[1, 'W', 1], [1, 'W', 1], [1, 'W', 3], [1, 'W', 1], [13, 'W', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 33, 'carpool_min': 3}, 2660), ({'trips': [[13, 'W', 1], [13, 'E', 1], [1, 'E', 1], [1, 'W', 1], [13, 'W', 3], [2, 'E', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 3, 'discount_pct': 40, 'carpool_min': 2}, 1450)], [({'trips': [[1, 'W', 1], [1, 'W', 1], [1, 'W', 3], [1, 'W', 1], [13, 'W', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 33, 'carpool_min': 3}, 2660), ({'trips': [[13, 'W', 2], [13, 'E', 4], [13, 'E', 4], [13, 'E', 2], [13, 'E', 1]], 'toll_dir': 'W', 'base': 850, 'threshold': 5, 'discount_pct': 40, 'carpool_min': 3}, 850), ({'trips': [[1, 'E', 1], [1, 'E', 1], [2, 'W', 3]], 'toll_dir': 'E', 'base': 850, 'threshold': 1, 'discount_pct': 25, 'carpool_min': 2}, 1487), ({'trips': [[13, 'W', 2], [13, 'W', 1], [13, 'W', 1], [13, 'W', 4], [1, 'W', 1]], 'toll_dir': 'E', 'base': 600, 'threshold': 4, 'discount_pct': 33, 'carpool_min': 2}, 0), ({'trips': [[1, 'E', 1], [1, 'W', 1], [1, 'E', 1], [2, 'E', 2], [2, 'W', 2], [1, 'W', 1]], 'toll_dir': 'W', 'base': 600, 'threshold': 1, 'discount_pct': 33, 'carpool_min': 2}, 1002), ({'trips': [[13, 'W', 2], [1, 'E', 2], [2, 'W', 1], [13, 'W', 4], [1, 'E', 3], [1, 'W', 3], [1, 'E', 1], [2, 'E', 2]], 'toll_dir': 'W', 'base': 850, 'threshold': 1, 'discount_pct': 33, 'carpool_min': 2}, 850), ({'trips': [[13, 'W', 1], [1, 'E', 2], [13, 'W', 1], [1, 'W', 1], [1, 'E', 1], [1, 'E', 2], [1, 'E', 3], [2, 'E', 1], [1, 'W', 2], [1, 'W', 1], [1, 'E', 1], [2, 'W', 1], [1, 'W', 1], [2, 'E', 1], [1, 'E', 3], [1, 'E', 2]], 'toll_dir': 'W', 'base': 850, 'threshold': 3, 'discount_pct': 40, 'carpool_min': 3}, 5610), ({'trips': [[1, 'W', 2], [1, 'W', 1], [13, 'W', 1], [2, 'W', 1]], 'toll_dir': 'E', 'base': 725, 'threshold': 2, 'discount_pct': 40, 'carpool_min': 2}, 0)], [({'trips': [[1, 'W', 1], [1, 'W', 1], [1, 'W', 3], [1, 'W', 1], [13, 'W', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 33, 'carpool_min': 3}, 2660), ({'trips': [[1, 'W', 1], [2, 'W', 4], [1, 'E', 3], [1, 'E', 3], [1, 'W', 1], [13, 'E', 1], [1, 'E', 4], [2, 'E', 1], [1, 'W', 2], [2, 'E', 1], [2, 'E', 3]], 'toll_dir': 'E', 'base': 850, 'threshold': 3, 'discount_pct': 25, 'carpool_min': 2}, 2550), ({'trips': [[13, 'E', 1], [1, 'W', 1], [13, 'E', 2], [1, 'E', 1], [1, 'W', 1], [1, 'W', 2], [1, 'W', 4], [1, 'W', 1], [2, 'W', 1]], 'toll_dir': 'E', 'base': 600, 'threshold': 1, 'discount_pct': 25, 'carpool_min': 3}, 1650), ({'trips': [[1, 'W', 2], [1, 'W', 4], [1, 'E', 1], [13, 'E', 1], [1, 'E', 1], [2, 'E', 1], [2, 'W', 1], [2, 'W', 1], [2, 'E', 1]], 'toll_dir': 'W', 'base': 850, 'threshold': 5, 'discount_pct': 40, 'carpool_min': 2}, 1700), ({'trips': [[13, 'E', 1], [13, 'E', 2], [1, 'W', 2], [1, 'E', 3], [2, 'W', 4], [1, 'W', 2]], 'toll_dir': 'W', 'base': 725, 'threshold': 4, 'discount_pct': 40, 'carpool_min': 2}, 0), ({'trips': [[13, 'E', 3], [1, 'E', 3], [1, 'E', 3], [1, 'E', 1], [1, 'E', 1], [1, 'W', 4]], 'toll_dir': 'W', 'base': 600, 'threshold': 5, 'discount_pct': 25, 'carpool_min': 2}, 0), ({'trips': [[1, 'E', 2], [1, 'W', 1], [1, 'W', 1], [1, 'W', 1], [13, 'W', 3], [13, 'E', 4], [1, 'W', 3], [1, 'E', 3], [1, 'E', 1], [1, 'W', 1], [1, 'E', 3]], 'toll_dir': 'W', 'base': 725, 'threshold': 3, 'discount_pct': 25, 'carpool_min': 2}, 2718), ({'trips': [[2, 'E', 3], [2, 'W', 1], [1, 'E', 2], [1, 'E', 2], [2, 'W', 1], [1, 'E', 1]], 'toll_dir': 'W', 'base': 850, 'threshold': 3, 'discount_pct': 33, 'carpool_min': 2}, 1700)], [({'trips': [[1, 'W', 1], [1, 'W', 1], [1, 'W', 3], [1, 'W', 1], [13, 'W', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 33, 'carpool_min': 3}, 2660), ({'trips': [[13, 'E', 3], [1, 'E', 1], [1, 'W', 1], [2, 'E', 1], [1, 'E', 1], [13, 'W', 1], [13, 'E', 1], [13, 'E', 3]], 'toll_dir': 'W', 'base': 850, 'threshold': 2, 'discount_pct': 25, 'carpool_min': 3}, 1700), ({'trips': [[2, 'E', 2], [2, 'E', 4], [13, 'E', 2], [1, 'W', 2], [2, 'W', 3], [2, 'E', 1], [2, 'W', 1], [2, 'E', 1], [2, 'E', 2], [1, 'W', 2], [13, 'W', 1]], 'toll_dir': 'E', 'base': 600, 'threshold': 3, 'discount_pct': 40, 'carpool_min': 3}, 2760), ({'trips': [[13, 'W', 1], [2, 'W', 1], [1, 'W', 2], [1, 'W', 1], [13, 'W', 1], [1, 'E', 1], [1, 'W', 1], [1, 'W', 4], [1, 'W', 1], [2, 'E', 1]], 'toll_dir': 'E', 'base': 725, 'threshold': 1, 'discount_pct': 25, 'carpool_min': 2}, 1450), ({'trips': [[1, 'E', 1], [13, 'W', 1], [1, 'E', 2], [1, 'W', 3], [1, 'W', 1], [2, 'W', 3], [1, 'E', 1], [1, 'E', 1], [2, 'E', 2]], 'toll_dir': 'E', 'base': 725, 'threshold': 3, 'discount_pct': 33, 'carpool_min': 2}, 2175), ({'trips': [[1, 'E', 1], [2, 'W', 2], [2, 'E', 1], [2, 'W', 1], [1, 'E', 2], [13, 'E', 1], [1, 'W', 2], [1, 'W', 1]], 'toll_dir': 'E', 'base': 600, 'threshold': 5, 'discount_pct': 40, 'carpool_min': 3}, 2400), ({'trips': [[1, 'E', 1], [13, 'E', 4], [2, 'E', 1], [13, 'W', 4], [1, 'W', 1], [1, 'W', 1]], 'toll_dir': 'W', 'base': 850, 'threshold': 1, 'discount_pct': 40, 'carpool_min': 3}, 1360), ({'trips': [[13, 'E', 4], [1, 'E', 4], [1, 'W', 1], [1, 'W', 1], [1, 'E', 1], [1, 'W', 2], [13, 'E', 1], [1, 'E', 3], [1, 'W', 3], [1, 'W', 2], [13, 'E', 1]], 'toll_dir': 'W', 'base': 600, 'threshold': 5, 'discount_pct': 40, 'carpool_min': 2}, 1200)], [({'trips': [[13, 'E', 4], [13, 'W', 1], [1, 'W', 1], [1, 'E', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 25, 'carpool_min': 3}, 1450), ({'trips': [[1, 'W', 1], [13, 'E', 1], [1, 'E', 1], [2, 'W', 1], [1, 'E', 1], [1, 'E', 2], [2, 'E', 2], [1, 'W', 1], [1, 'E', 2]], 'toll_dir': 'E', 'base': 600, 'threshold': 2, 'discount_pct': 40, 'carpool_min': 2}, 1800), ({'trips': [[2, 'E', 4], [2, 'W', 1], [2, 'E', 1], [1, 'E', 3], [1, 'W', 2], [13, 'W', 1], [2, 'W', 4], [1, 'E', 1], [1, 'E', 1], [2, 'W', 1], [13, 'W', 2], [1, 'E', 2], [2, 'E', 2], [1, 'W', 1], [1, 'W', 3]], 'toll_dir': 'E', 'base': 725, 'threshold': 2, 'discount_pct': 40, 'carpool_min': 3}, 3335), ({'trips': [[1, 'E', 2], [2, 'W', 3], [1, 'W', 1], [2, 'E', 3], [13, 'E', 1], [1, 'E', 3], [1, 'W', 2], [1, 'W', 1], [1, 'E', 3], [1, 'W', 3], [13, 'E', 1], [13, 'E', 3], [1, 'W', 1], [1, 'W', 1], [1, 'W', 4]], 'toll_dir': 'W', 'base': 600, 'threshold': 1, 'discount_pct': 40, 'carpool_min': 3}, 2040), ({'trips': [[1, 'W', 1], [1, 'W', 1], [1, 'W', 3], [1, 'W', 1], [13, 'W', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 33, 'carpool_min': 3}, 2660), ({'trips': [[1, 'E', 2], [1, 'W', 1], [1, 'E', 3], [2, 'W', 2], [1, 'W', 1], [1, 'E', 1], [2, 'W', 4], [1, 'W', 3], [1, 'E', 3], [2, 'E', 3], [2, 'E', 1], [2, 'E', 2], [13, 'E', 1], [1, 'W', 1], [1, 'E', 1]], 'toll_dir': 'E', 'base': 600, 'threshold': 4, 'discount_pct': 25, 'carpool_min': 2}, 2400), ({'trips': [[13, 'E', 1], [1, 'E', 3], [1, 'W', 1], [1, 'W', 3], [1, 'E', 3], [1, 'E', 1], [2, 'E', 2], [1, 'E', 3], [13, 'W', 1], [13, 'W', 3]], 'toll_dir': 'W', 'base': 600, 'threshold': 4, 'discount_pct': 33, 'carpool_min': 2}, 1200), ({'trips': [[2, 'W', 4], [1, 'E', 1], [1, 'E', 1], [13, 'E', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 5, 'discount_pct': 33, 'carpool_min': 3}, 0)]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| fee oracle 0 | 0 | 0 | Passed |
| fee oracle 1 | 2550 | 1200 | Failed |
| fee oracle 2 | 850 | 850 | Passed |
| fee oracle 3 | 2610 | 2610 | Passed |
| fee oracle 4 | 1800 | 1200 | Failed |
| fee oracle 5 | 4350 | 2700 | Failed |
| fee oracle 6 | 3145 | 2660 | Failed |
| fee oracle 7 | 1450 | 1450 | Passed |
SHA-256 / 93ce345ee84c1af0700f3d1cf7a4fbe907e2a021043dbf4d1a8e5242557f7523
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
counts = {}
total = 0
for month, d, occ in x['trips']:
if d != x['toll_dir']:
continue
if occ >= 3:
continue
k = counts.get(month, 0) + 1
counts[month] = k
if k > x['threshold']:
total += x['base'] * (100 - x['discount_pct']) // 100
else:
total += x['base']
return total
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'trips': [[2, 'E', 1], [1, 'E', 4], [1, 'E', 1]], 'toll_dir': 'W', 'base': 850, 'threshold': 4, 'discount_pct': 40, 'carpool_min': 2}, 0), ({'trips': [[2, 'W', 1], [13, 'E', 2], [13, 'E', 1], [1, 'E', 2], [1, 'W', 3], [1, 'E', 1], [1, 'E', 3], [1, 'W', 2], [13, 'E', 2], [2, 'W', 1], [1, 'E', 4], [1, 'W', 1], [2, 'W', 1], [2, 'E', 3]], 'toll_dir': 'E', 'base': 600, 'threshold': 1, 'discount_pct': 25, 'carpool_min': 2}, 1200), ({'trips': [[1, 'E', 4], [1, 'W', 2], [1, 'E', 3], [2, 'E', 3], [1, 'W', 2], [1, 'E', 4], [13, 'W', 1], [1, 'W', 4], [1, 'E', 1]], 'toll_dir': 'E', 'base': 850, 'threshold': 1, 'discount_pct': 40, 'carpool_min': 2}, 850), ({'trips': [[2, 'W', 1], [1, 'W', 1], [1, 'E', 1], [1, 'E', 1], [1, 'E', 1], [1, 'W', 2], [1, 'W', 2]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 40, 'carpool_min': 3}, 2610), ({'trips': [[1, 'W', 1], [1, 'W', 3], [2, 'E', 1], [1, 'E', 4], [1, 'E', 3], [2, 'E', 4], [1, 'E', 4], [1, 'E', 4], [13, 'E', 3], [1, 'W', 1], [2, 'E', 3]], 'toll_dir': 'W', 'base': 600, 'threshold': 3, 'discount_pct': 40, 'carpool_min': 3}, 1200), ({'trips': [[13, 'W', 1], [1, 'E', 3], [1, 'E', 2], [13, 'W', 2], [1, 'E', 3], [13, 'W', 1], [13, 'W', 1], [13, 'W', 1], [1, 'W', 1], [2, 'W', 2], [1, 'E', 1], [13, 'E', 3], [1, 'W', 2]], 'toll_dir': 'W', 'base': 600, 'threshold': 2, 'discount_pct': 25, 'carpool_min': 2}, 2700), ({'trips': [[1, 'W', 1], [1, 'W', 1], [1, 'W', 3], [1, 'W', 1], [13, 'W', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 33, 'carpool_min': 3}, 2660), ({'trips': [[13, 'W', 1], [13, 'E', 1], [1, 'E', 1], [1, 'W', 1], [13, 'W', 3], [2, 'E', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 3, 'discount_pct': 40, 'carpool_min': 2}, 1450)], [({'trips': [[1, 'W', 1], [1, 'W', 1], [1, 'W', 3], [1, 'W', 1], [13, 'W', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 33, 'carpool_min': 3}, 2660), ({'trips': [[13, 'W', 2], [13, 'E', 4], [13, 'E', 4], [13, 'E', 2], [13, 'E', 1]], 'toll_dir': 'W', 'base': 850, 'threshold': 5, 'discount_pct': 40, 'carpool_min': 3}, 850), ({'trips': [[1, 'E', 1], [1, 'E', 1], [2, 'W', 3]], 'toll_dir': 'E', 'base': 850, 'threshold': 1, 'discount_pct': 25, 'carpool_min': 2}, 1487), ({'trips': [[13, 'W', 2], [13, 'W', 1], [13, 'W', 1], [13, 'W', 4], [1, 'W', 1]], 'toll_dir': 'E', 'base': 600, 'threshold': 4, 'discount_pct': 33, 'carpool_min': 2}, 0), ({'trips': [[1, 'E', 1], [1, 'W', 1], [1, 'E', 1], [2, 'E', 2], [2, 'W', 2], [1, 'W', 1]], 'toll_dir': 'W', 'base': 600, 'threshold': 1, 'discount_pct': 33, 'carpool_min': 2}, 1002), ({'trips': [[13, 'W', 2], [1, 'E', 2], [2, 'W', 1], [13, 'W', 4], [1, 'E', 3], [1, 'W', 3], [1, 'E', 1], [2, 'E', 2]], 'toll_dir': 'W', 'base': 850, 'threshold': 1, 'discount_pct': 33, 'carpool_min': 2}, 850), ({'trips': [[13, 'W', 1], [1, 'E', 2], [13, 'W', 1], [1, 'W', 1], [1, 'E', 1], [1, 'E', 2], [1, 'E', 3], [2, 'E', 1], [1, 'W', 2], [1, 'W', 1], [1, 'E', 1], [2, 'W', 1], [1, 'W', 1], [2, 'E', 1], [1, 'E', 3], [1, 'E', 2]], 'toll_dir': 'W', 'base': 850, 'threshold': 3, 'discount_pct': 40, 'carpool_min': 3}, 5610), ({'trips': [[1, 'W', 2], [1, 'W', 1], [13, 'W', 1], [2, 'W', 1]], 'toll_dir': 'E', 'base': 725, 'threshold': 2, 'discount_pct': 40, 'carpool_min': 2}, 0)], [({'trips': [[1, 'W', 1], [1, 'W', 1], [1, 'W', 3], [1, 'W', 1], [13, 'W', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 33, 'carpool_min': 3}, 2660), ({'trips': [[1, 'W', 1], [2, 'W', 4], [1, 'E', 3], [1, 'E', 3], [1, 'W', 1], [13, 'E', 1], [1, 'E', 4], [2, 'E', 1], [1, 'W', 2], [2, 'E', 1], [2, 'E', 3]], 'toll_dir': 'E', 'base': 850, 'threshold': 3, 'discount_pct': 25, 'carpool_min': 2}, 2550), ({'trips': [[13, 'E', 1], [1, 'W', 1], [13, 'E', 2], [1, 'E', 1], [1, 'W', 1], [1, 'W', 2], [1, 'W', 4], [1, 'W', 1], [2, 'W', 1]], 'toll_dir': 'E', 'base': 600, 'threshold': 1, 'discount_pct': 25, 'carpool_min': 3}, 1650), ({'trips': [[1, 'W', 2], [1, 'W', 4], [1, 'E', 1], [13, 'E', 1], [1, 'E', 1], [2, 'E', 1], [2, 'W', 1], [2, 'W', 1], [2, 'E', 1]], 'toll_dir': 'W', 'base': 850, 'threshold': 5, 'discount_pct': 40, 'carpool_min': 2}, 1700), ({'trips': [[13, 'E', 1], [13, 'E', 2], [1, 'W', 2], [1, 'E', 3], [2, 'W', 4], [1, 'W', 2]], 'toll_dir': 'W', 'base': 725, 'threshold': 4, 'discount_pct': 40, 'carpool_min': 2}, 0), ({'trips': [[13, 'E', 3], [1, 'E', 3], [1, 'E', 3], [1, 'E', 1], [1, 'E', 1], [1, 'W', 4]], 'toll_dir': 'W', 'base': 600, 'threshold': 5, 'discount_pct': 25, 'carpool_min': 2}, 0), ({'trips': [[1, 'E', 2], [1, 'W', 1], [1, 'W', 1], [1, 'W', 1], [13, 'W', 3], [13, 'E', 4], [1, 'W', 3], [1, 'E', 3], [1, 'E', 1], [1, 'W', 1], [1, 'E', 3]], 'toll_dir': 'W', 'base': 725, 'threshold': 3, 'discount_pct': 25, 'carpool_min': 2}, 2718), ({'trips': [[2, 'E', 3], [2, 'W', 1], [1, 'E', 2], [1, 'E', 2], [2, 'W', 1], [1, 'E', 1]], 'toll_dir': 'W', 'base': 850, 'threshold': 3, 'discount_pct': 33, 'carpool_min': 2}, 1700)], [({'trips': [[1, 'W', 1], [1, 'W', 1], [1, 'W', 3], [1, 'W', 1], [13, 'W', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 33, 'carpool_min': 3}, 2660), ({'trips': [[13, 'E', 3], [1, 'E', 1], [1, 'W', 1], [2, 'E', 1], [1, 'E', 1], [13, 'W', 1], [13, 'E', 1], [13, 'E', 3]], 'toll_dir': 'W', 'base': 850, 'threshold': 2, 'discount_pct': 25, 'carpool_min': 3}, 1700), ({'trips': [[2, 'E', 2], [2, 'E', 4], [13, 'E', 2], [1, 'W', 2], [2, 'W', 3], [2, 'E', 1], [2, 'W', 1], [2, 'E', 1], [2, 'E', 2], [1, 'W', 2], [13, 'W', 1]], 'toll_dir': 'E', 'base': 600, 'threshold': 3, 'discount_pct': 40, 'carpool_min': 3}, 2760), ({'trips': [[13, 'W', 1], [2, 'W', 1], [1, 'W', 2], [1, 'W', 1], [13, 'W', 1], [1, 'E', 1], [1, 'W', 1], [1, 'W', 4], [1, 'W', 1], [2, 'E', 1]], 'toll_dir': 'E', 'base': 725, 'threshold': 1, 'discount_pct': 25, 'carpool_min': 2}, 1450), ({'trips': [[1, 'E', 1], [13, 'W', 1], [1, 'E', 2], [1, 'W', 3], [1, 'W', 1], [2, 'W', 3], [1, 'E', 1], [1, 'E', 1], [2, 'E', 2]], 'toll_dir': 'E', 'base': 725, 'threshold': 3, 'discount_pct': 33, 'carpool_min': 2}, 2175), ({'trips': [[1, 'E', 1], [2, 'W', 2], [2, 'E', 1], [2, 'W', 1], [1, 'E', 2], [13, 'E', 1], [1, 'W', 2], [1, 'W', 1]], 'toll_dir': 'E', 'base': 600, 'threshold': 5, 'discount_pct': 40, 'carpool_min': 3}, 2400), ({'trips': [[1, 'E', 1], [13, 'E', 4], [2, 'E', 1], [13, 'W', 4], [1, 'W', 1], [1, 'W', 1]], 'toll_dir': 'W', 'base': 850, 'threshold': 1, 'discount_pct': 40, 'carpool_min': 3}, 1360), ({'trips': [[13, 'E', 4], [1, 'E', 4], [1, 'W', 1], [1, 'W', 1], [1, 'E', 1], [1, 'W', 2], [13, 'E', 1], [1, 'E', 3], [1, 'W', 3], [1, 'W', 2], [13, 'E', 1]], 'toll_dir': 'W', 'base': 600, 'threshold': 5, 'discount_pct': 40, 'carpool_min': 2}, 1200)], [({'trips': [[13, 'E', 4], [13, 'W', 1], [1, 'W', 1], [1, 'E', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 25, 'carpool_min': 3}, 1450), ({'trips': [[1, 'W', 1], [13, 'E', 1], [1, 'E', 1], [2, 'W', 1], [1, 'E', 1], [1, 'E', 2], [2, 'E', 2], [1, 'W', 1], [1, 'E', 2]], 'toll_dir': 'E', 'base': 600, 'threshold': 2, 'discount_pct': 40, 'carpool_min': 2}, 1800), ({'trips': [[2, 'E', 4], [2, 'W', 1], [2, 'E', 1], [1, 'E', 3], [1, 'W', 2], [13, 'W', 1], [2, 'W', 4], [1, 'E', 1], [1, 'E', 1], [2, 'W', 1], [13, 'W', 2], [1, 'E', 2], [2, 'E', 2], [1, 'W', 1], [1, 'W', 3]], 'toll_dir': 'E', 'base': 725, 'threshold': 2, 'discount_pct': 40, 'carpool_min': 3}, 3335), ({'trips': [[1, 'E', 2], [2, 'W', 3], [1, 'W', 1], [2, 'E', 3], [13, 'E', 1], [1, 'E', 3], [1, 'W', 2], [1, 'W', 1], [1, 'E', 3], [1, 'W', 3], [13, 'E', 1], [13, 'E', 3], [1, 'W', 1], [1, 'W', 1], [1, 'W', 4]], 'toll_dir': 'W', 'base': 600, 'threshold': 1, 'discount_pct': 40, 'carpool_min': 3}, 2040), ({'trips': [[1, 'W', 1], [1, 'W', 1], [1, 'W', 3], [1, 'W', 1], [13, 'W', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 33, 'carpool_min': 3}, 2660), ({'trips': [[1, 'E', 2], [1, 'W', 1], [1, 'E', 3], [2, 'W', 2], [1, 'W', 1], [1, 'E', 1], [2, 'W', 4], [1, 'W', 3], [1, 'E', 3], [2, 'E', 3], [2, 'E', 1], [2, 'E', 2], [13, 'E', 1], [1, 'W', 1], [1, 'E', 1]], 'toll_dir': 'E', 'base': 600, 'threshold': 4, 'discount_pct': 25, 'carpool_min': 2}, 2400), ({'trips': [[13, 'E', 1], [1, 'E', 3], [1, 'W', 1], [1, 'W', 3], [1, 'E', 3], [1, 'E', 1], [2, 'E', 2], [1, 'E', 3], [13, 'W', 1], [13, 'W', 3]], 'toll_dir': 'W', 'base': 600, 'threshold': 4, 'discount_pct': 33, 'carpool_min': 2}, 1200), ({'trips': [[2, 'W', 4], [1, 'E', 1], [1, 'E', 1], [13, 'E', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 5, 'discount_pct': 33, 'carpool_min': 3}, 0)]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| fee oracle 0 | 0 | 0 | Passed |
| fee oracle 1 | 2550 | 1200 | Failed |
| fee oracle 2 | 850 | 850 | Passed |
| fee oracle 3 | 2610 | 2610 | Passed |
| fee oracle 4 | 1200 | 1200 | Passed |
| fee oracle 5 | 4350 | 2700 | Failed |
| fee oracle 6 | 2660 | 2660 | Passed |
| fee oracle 7 | 1450 | 1450 | Passed |
SHA-256 / 253b65447f3c93b916dd1b337ef6e0af692fb9a25ecbc47553aa252172601dae
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
counts = {}
total = 0
for month, d, occ in x['trips']:
if d != x['toll_dir']:
continue
if occ >= x['carpool_min']:
continue
k = counts.get(month, 0) + 1
counts[month] = k
if k > x['threshold']:
total += x['base'] * (100 - x['discount_pct']) // 100
else:
total += x['base']
return total
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'trips': [[2, 'E', 1], [1, 'E', 4], [1, 'E', 1]], 'toll_dir': 'W', 'base': 850, 'threshold': 4, 'discount_pct': 40, 'carpool_min': 2}, 0), ({'trips': [[2, 'W', 1], [13, 'E', 2], [13, 'E', 1], [1, 'E', 2], [1, 'W', 3], [1, 'E', 1], [1, 'E', 3], [1, 'W', 2], [13, 'E', 2], [2, 'W', 1], [1, 'E', 4], [1, 'W', 1], [2, 'W', 1], [2, 'E', 3]], 'toll_dir': 'E', 'base': 600, 'threshold': 1, 'discount_pct': 25, 'carpool_min': 2}, 1200), ({'trips': [[1, 'E', 4], [1, 'W', 2], [1, 'E', 3], [2, 'E', 3], [1, 'W', 2], [1, 'E', 4], [13, 'W', 1], [1, 'W', 4], [1, 'E', 1]], 'toll_dir': 'E', 'base': 850, 'threshold': 1, 'discount_pct': 40, 'carpool_min': 2}, 850), ({'trips': [[2, 'W', 1], [1, 'W', 1], [1, 'E', 1], [1, 'E', 1], [1, 'E', 1], [1, 'W', 2], [1, 'W', 2]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 40, 'carpool_min': 3}, 2610), ({'trips': [[1, 'W', 1], [1, 'W', 3], [2, 'E', 1], [1, 'E', 4], [1, 'E', 3], [2, 'E', 4], [1, 'E', 4], [1, 'E', 4], [13, 'E', 3], [1, 'W', 1], [2, 'E', 3]], 'toll_dir': 'W', 'base': 600, 'threshold': 3, 'discount_pct': 40, 'carpool_min': 3}, 1200), ({'trips': [[13, 'W', 1], [1, 'E', 3], [1, 'E', 2], [13, 'W', 2], [1, 'E', 3], [13, 'W', 1], [13, 'W', 1], [13, 'W', 1], [1, 'W', 1], [2, 'W', 2], [1, 'E', 1], [13, 'E', 3], [1, 'W', 2]], 'toll_dir': 'W', 'base': 600, 'threshold': 2, 'discount_pct': 25, 'carpool_min': 2}, 2700), ({'trips': [[1, 'W', 1], [1, 'W', 1], [1, 'W', 3], [1, 'W', 1], [13, 'W', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 33, 'carpool_min': 3}, 2660), ({'trips': [[13, 'W', 1], [13, 'E', 1], [1, 'E', 1], [1, 'W', 1], [13, 'W', 3], [2, 'E', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 3, 'discount_pct': 40, 'carpool_min': 2}, 1450)], [({'trips': [[1, 'W', 1], [1, 'W', 1], [1, 'W', 3], [1, 'W', 1], [13, 'W', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 33, 'carpool_min': 3}, 2660), ({'trips': [[13, 'W', 2], [13, 'E', 4], [13, 'E', 4], [13, 'E', 2], [13, 'E', 1]], 'toll_dir': 'W', 'base': 850, 'threshold': 5, 'discount_pct': 40, 'carpool_min': 3}, 850), ({'trips': [[1, 'E', 1], [1, 'E', 1], [2, 'W', 3]], 'toll_dir': 'E', 'base': 850, 'threshold': 1, 'discount_pct': 25, 'carpool_min': 2}, 1487), ({'trips': [[13, 'W', 2], [13, 'W', 1], [13, 'W', 1], [13, 'W', 4], [1, 'W', 1]], 'toll_dir': 'E', 'base': 600, 'threshold': 4, 'discount_pct': 33, 'carpool_min': 2}, 0), ({'trips': [[1, 'E', 1], [1, 'W', 1], [1, 'E', 1], [2, 'E', 2], [2, 'W', 2], [1, 'W', 1]], 'toll_dir': 'W', 'base': 600, 'threshold': 1, 'discount_pct': 33, 'carpool_min': 2}, 1002), ({'trips': [[13, 'W', 2], [1, 'E', 2], [2, 'W', 1], [13, 'W', 4], [1, 'E', 3], [1, 'W', 3], [1, 'E', 1], [2, 'E', 2]], 'toll_dir': 'W', 'base': 850, 'threshold': 1, 'discount_pct': 33, 'carpool_min': 2}, 850), ({'trips': [[13, 'W', 1], [1, 'E', 2], [13, 'W', 1], [1, 'W', 1], [1, 'E', 1], [1, 'E', 2], [1, 'E', 3], [2, 'E', 1], [1, 'W', 2], [1, 'W', 1], [1, 'E', 1], [2, 'W', 1], [1, 'W', 1], [2, 'E', 1], [1, 'E', 3], [1, 'E', 2]], 'toll_dir': 'W', 'base': 850, 'threshold': 3, 'discount_pct': 40, 'carpool_min': 3}, 5610), ({'trips': [[1, 'W', 2], [1, 'W', 1], [13, 'W', 1], [2, 'W', 1]], 'toll_dir': 'E', 'base': 725, 'threshold': 2, 'discount_pct': 40, 'carpool_min': 2}, 0)], [({'trips': [[1, 'W', 1], [1, 'W', 1], [1, 'W', 3], [1, 'W', 1], [13, 'W', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 33, 'carpool_min': 3}, 2660), ({'trips': [[1, 'W', 1], [2, 'W', 4], [1, 'E', 3], [1, 'E', 3], [1, 'W', 1], [13, 'E', 1], [1, 'E', 4], [2, 'E', 1], [1, 'W', 2], [2, 'E', 1], [2, 'E', 3]], 'toll_dir': 'E', 'base': 850, 'threshold': 3, 'discount_pct': 25, 'carpool_min': 2}, 2550), ({'trips': [[13, 'E', 1], [1, 'W', 1], [13, 'E', 2], [1, 'E', 1], [1, 'W', 1], [1, 'W', 2], [1, 'W', 4], [1, 'W', 1], [2, 'W', 1]], 'toll_dir': 'E', 'base': 600, 'threshold': 1, 'discount_pct': 25, 'carpool_min': 3}, 1650), ({'trips': [[1, 'W', 2], [1, 'W', 4], [1, 'E', 1], [13, 'E', 1], [1, 'E', 1], [2, 'E', 1], [2, 'W', 1], [2, 'W', 1], [2, 'E', 1]], 'toll_dir': 'W', 'base': 850, 'threshold': 5, 'discount_pct': 40, 'carpool_min': 2}, 1700), ({'trips': [[13, 'E', 1], [13, 'E', 2], [1, 'W', 2], [1, 'E', 3], [2, 'W', 4], [1, 'W', 2]], 'toll_dir': 'W', 'base': 725, 'threshold': 4, 'discount_pct': 40, 'carpool_min': 2}, 0), ({'trips': [[13, 'E', 3], [1, 'E', 3], [1, 'E', 3], [1, 'E', 1], [1, 'E', 1], [1, 'W', 4]], 'toll_dir': 'W', 'base': 600, 'threshold': 5, 'discount_pct': 25, 'carpool_min': 2}, 0), ({'trips': [[1, 'E', 2], [1, 'W', 1], [1, 'W', 1], [1, 'W', 1], [13, 'W', 3], [13, 'E', 4], [1, 'W', 3], [1, 'E', 3], [1, 'E', 1], [1, 'W', 1], [1, 'E', 3]], 'toll_dir': 'W', 'base': 725, 'threshold': 3, 'discount_pct': 25, 'carpool_min': 2}, 2718), ({'trips': [[2, 'E', 3], [2, 'W', 1], [1, 'E', 2], [1, 'E', 2], [2, 'W', 1], [1, 'E', 1]], 'toll_dir': 'W', 'base': 850, 'threshold': 3, 'discount_pct': 33, 'carpool_min': 2}, 1700)], [({'trips': [[1, 'W', 1], [1, 'W', 1], [1, 'W', 3], [1, 'W', 1], [13, 'W', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 33, 'carpool_min': 3}, 2660), ({'trips': [[13, 'E', 3], [1, 'E', 1], [1, 'W', 1], [2, 'E', 1], [1, 'E', 1], [13, 'W', 1], [13, 'E', 1], [13, 'E', 3]], 'toll_dir': 'W', 'base': 850, 'threshold': 2, 'discount_pct': 25, 'carpool_min': 3}, 1700), ({'trips': [[2, 'E', 2], [2, 'E', 4], [13, 'E', 2], [1, 'W', 2], [2, 'W', 3], [2, 'E', 1], [2, 'W', 1], [2, 'E', 1], [2, 'E', 2], [1, 'W', 2], [13, 'W', 1]], 'toll_dir': 'E', 'base': 600, 'threshold': 3, 'discount_pct': 40, 'carpool_min': 3}, 2760), ({'trips': [[13, 'W', 1], [2, 'W', 1], [1, 'W', 2], [1, 'W', 1], [13, 'W', 1], [1, 'E', 1], [1, 'W', 1], [1, 'W', 4], [1, 'W', 1], [2, 'E', 1]], 'toll_dir': 'E', 'base': 725, 'threshold': 1, 'discount_pct': 25, 'carpool_min': 2}, 1450), ({'trips': [[1, 'E', 1], [13, 'W', 1], [1, 'E', 2], [1, 'W', 3], [1, 'W', 1], [2, 'W', 3], [1, 'E', 1], [1, 'E', 1], [2, 'E', 2]], 'toll_dir': 'E', 'base': 725, 'threshold': 3, 'discount_pct': 33, 'carpool_min': 2}, 2175), ({'trips': [[1, 'E', 1], [2, 'W', 2], [2, 'E', 1], [2, 'W', 1], [1, 'E', 2], [13, 'E', 1], [1, 'W', 2], [1, 'W', 1]], 'toll_dir': 'E', 'base': 600, 'threshold': 5, 'discount_pct': 40, 'carpool_min': 3}, 2400), ({'trips': [[1, 'E', 1], [13, 'E', 4], [2, 'E', 1], [13, 'W', 4], [1, 'W', 1], [1, 'W', 1]], 'toll_dir': 'W', 'base': 850, 'threshold': 1, 'discount_pct': 40, 'carpool_min': 3}, 1360), ({'trips': [[13, 'E', 4], [1, 'E', 4], [1, 'W', 1], [1, 'W', 1], [1, 'E', 1], [1, 'W', 2], [13, 'E', 1], [1, 'E', 3], [1, 'W', 3], [1, 'W', 2], [13, 'E', 1]], 'toll_dir': 'W', 'base': 600, 'threshold': 5, 'discount_pct': 40, 'carpool_min': 2}, 1200)], [({'trips': [[13, 'E', 4], [13, 'W', 1], [1, 'W', 1], [1, 'E', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 25, 'carpool_min': 3}, 1450), ({'trips': [[1, 'W', 1], [13, 'E', 1], [1, 'E', 1], [2, 'W', 1], [1, 'E', 1], [1, 'E', 2], [2, 'E', 2], [1, 'W', 1], [1, 'E', 2]], 'toll_dir': 'E', 'base': 600, 'threshold': 2, 'discount_pct': 40, 'carpool_min': 2}, 1800), ({'trips': [[2, 'E', 4], [2, 'W', 1], [2, 'E', 1], [1, 'E', 3], [1, 'W', 2], [13, 'W', 1], [2, 'W', 4], [1, 'E', 1], [1, 'E', 1], [2, 'W', 1], [13, 'W', 2], [1, 'E', 2], [2, 'E', 2], [1, 'W', 1], [1, 'W', 3]], 'toll_dir': 'E', 'base': 725, 'threshold': 2, 'discount_pct': 40, 'carpool_min': 3}, 3335), ({'trips': [[1, 'E', 2], [2, 'W', 3], [1, 'W', 1], [2, 'E', 3], [13, 'E', 1], [1, 'E', 3], [1, 'W', 2], [1, 'W', 1], [1, 'E', 3], [1, 'W', 3], [13, 'E', 1], [13, 'E', 3], [1, 'W', 1], [1, 'W', 1], [1, 'W', 4]], 'toll_dir': 'W', 'base': 600, 'threshold': 1, 'discount_pct': 40, 'carpool_min': 3}, 2040), ({'trips': [[1, 'W', 1], [1, 'W', 1], [1, 'W', 3], [1, 'W', 1], [13, 'W', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 2, 'discount_pct': 33, 'carpool_min': 3}, 2660), ({'trips': [[1, 'E', 2], [1, 'W', 1], [1, 'E', 3], [2, 'W', 2], [1, 'W', 1], [1, 'E', 1], [2, 'W', 4], [1, 'W', 3], [1, 'E', 3], [2, 'E', 3], [2, 'E', 1], [2, 'E', 2], [13, 'E', 1], [1, 'W', 1], [1, 'E', 1]], 'toll_dir': 'E', 'base': 600, 'threshold': 4, 'discount_pct': 25, 'carpool_min': 2}, 2400), ({'trips': [[13, 'E', 1], [1, 'E', 3], [1, 'W', 1], [1, 'W', 3], [1, 'E', 3], [1, 'E', 1], [2, 'E', 2], [1, 'E', 3], [13, 'W', 1], [13, 'W', 3]], 'toll_dir': 'W', 'base': 600, 'threshold': 4, 'discount_pct': 33, 'carpool_min': 2}, 1200), ({'trips': [[2, 'W', 4], [1, 'E', 1], [1, 'E', 1], [13, 'E', 1]], 'toll_dir': 'W', 'base': 725, 'threshold': 5, 'discount_pct': 33, 'carpool_min': 3}, 0)]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| fee oracle 0 | 0 | 0 | Passed |
| fee oracle 1 | 1200 | 1200 | Passed |
| fee oracle 2 | 850 | 850 | Passed |
| fee oracle 3 | 2610 | 2610 | Passed |
| fee oracle 4 | 1200 | 1200 | Passed |
| fee oracle 5 | 2700 | 2700 | Passed |
| fee oracle 6 | 2660 | 2660 | Passed |
| fee oracle 7 | 1450 | 1450 | Passed |
SHA-256 / 9bd71e8623b224f340db9a8cc0999f72b40511eeb988f47d7025f9d5a00aa55b
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:04.186675+00:00.
Case digest / cd5e11a9f2b66cd578ad064878f3f91363602c1a9e22298ff3aac30fecc5a9b2