FA-68596 / Toll and parking fee computation / Open access
Pay-by-plate invoice and tag discount: the plate surcharge is floored · case 01
Pay-by-plate invoice and tag discount returns a wrong result when the plate surcharge is floored.
ROOT CAUSE
Fractional surcharge cents are dropped although the tariff rounds them up.
VERIFIED REPAIR
Restore the plate surcharge rounding rule so that the step reads `-(-base * x['plate_surcharge_pct'] // 100)`.
Unsuccessful approach: Rounding to nearest (with banker ties) still drops fractions below one half.
Case contract
Input {trips: [[day (0-based), base cents, tag|plate|exempt]], plate_surcharge_pct, tag_discount_pct, invoice_fee, cycle_days}. Exempt trips are ignored. Tag trips pay base minus a discount floored to cents. Plate trips pay base plus a surcharge rounded up to cents and are grouped into invoices by billing period day // cycle_days; each invoice adds one invoice_fee to the plate total. Return {tag, plate, invoices}.
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):
tag = plate = 0
periods = set()
for day, base, method in x['trips']:
if method == 'exempt':
continue
if method == 'tag':
tag += base - base * x['tag_discount_pct'] // 100
else:
plate += base + base * x['plate_surcharge_pct'] // 100
periods.add(day // x['cycle_days'])
fees = len(periods) * x['invoice_fee']
return {'tag': tag, 'plate': plate + fees, 'invoices': len(periods)}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[84, 250, 'tag'], [82, 250, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 225, 'plate': 575, 'invoices': 1}), ({'trips': [[76, 250, 'tag'], [71, 525, 'tag'], [40, 250, 'tag'], [16, 525, 'plate'], [18, 250, 'plate'], [35, 333, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 1292, 'plate': 1370, 'invoices': 1}), ({'trips': [[74, 175, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 0, 'plate': 463, 'invoices': 1}), ({'trips': [[10, 250, 'plate'], [0, 250, 'plate'], [89, 410, 'tag'], [19, 410, 'tag'], [44, 250, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 911, 'plate': 1150, 'invoices': 1}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[36, 410, 'plate'], [12, 175, 'exempt'], [24, 333, 'plate'], [48, 250, 'tag'], [7, 525, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 225, 'plate': 1730, 'invoices': 2}), ({'trips': [[44, 410, 'exempt']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 0, 'plate': 0, 'invoices': 0})], [({'trips': [[51, 175, 'tag'], [42, 410, 'tag'], [70, 175, 'exempt'], [17, 175, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 685, 'plate': 0, 'invoices': 0}), ({'trips': [[55, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 473, 'plate': 0, 'invoices': 0}), ({'trips': [[64, 410, 'tag'], [0, 250, 'exempt'], [74, 250, 'exempt'], [12, 175, 'plate'], [4, 250, 'exempt'], [77, 410, 'tag'], [29, 250, 'plate'], [86, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 1170, 'plate': 932, 'invoices': 1}), ({'trips': [[44, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 300, 'plate': 0, 'invoices': 0}), ({'trips': [[80, 333, 'tag'], [37, 250, 'exempt'], [93, 525, 'tag'], [24, 175, 'plate'], [73, 525, 'tag'], [91, 250, 'plate'], [14, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 1546, 'plate': 1038, 'invoices': 2}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[48, 175, 'plate'], [37, 525, 'tag'], [81, 333, 'plate'], [42, 175, 'tag'], [11, 250, 'exempt']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 631, 'plate': 987, 'invoices': 2}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2})], [({'trips': [[20, 250, 'tag'], [55, 250, 'plate'], [77, 333, 'plate'], [83, 333, 'plate'], [95, 410, 'tag'], [27, 250, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 628, 'plate': 1910, 'invoices': 3}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[1, 410, 'tag'], [95, 250, 'exempt'], [59, 250, 'tag'], [51, 410, 'exempt'], [40, 333, 'plate'], [26, 410, 'plate'], [84, 333, 'plate'], [8, 250, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 775, 'plate': 2547, 'invoices': 3}), ({'trips': [[17, 525, 'tag'], [95, 175, 'plate'], [42, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 842, 'plate': 369, 'invoices': 1}), ({'trips': [[22, 250, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 225, 'plate': 0, 'invoices': 0}), ({'trips': [[22, 250, 'exempt'], [95, 525, 'exempt'], [7, 410, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 0, 'invoices': 0}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[89, 175, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 167, 'plate': 0, 'invoices': 0})], [({'trips': [[73, 250, 'plate'], [32, 410, 'tag'], [6, 333, 'plate'], [16, 250, 'plate'], [46, 250, 'tag'], [86, 175, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 752, 'plate': 1526, 'invoices': 2}), ({'trips': [[52, 410, 'exempt'], [6, 333, 'plate'], [26, 175, 'plate'], [18, 333, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 1663, 'invoices': 1}), ({'trips': [[8, 525, 'plate'], [27, 333, 'plate'], [72, 410, 'plate'], [15, 525, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 0, 'plate': 2644, 'invoices': 2}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[94, 525, 'exempt'], [50, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 447, 'plate': 0, 'invoices': 0}), ({'trips': [[41, 333, 'tag'], [76, 250, 'plate'], [33, 410, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 317, 'plate': 525, 'invoices': 1}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[43, 175, 'exempt'], [36, 175, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 0, 'plate': 0, 'invoices': 0})], [({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[72, 525, 'tag'], [18, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 998, 'plate': 0, 'invoices': 0}), ({'trips': [[24, 175, 'plate'], [4, 525, 'plate'], [22, 333, 'tag'], [63, 525, 'tag'], [10, 525, 'tag'], [0, 525, 'plate'], [6, 410, 'tag'], [39, 525, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 2088, 'plate': 1989, 'invoices': 1}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[82, 250, 'exempt'], [20, 175, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 149, 'plate': 0, 'invoices': 0}), ({'trips': [[88, 410, 'tag'], [89, 250, 'plate'], [5, 525, 'tag'], [38, 175, 'exempt'], [64, 525, 'plate'], [28, 175, 'tag'], [62, 333, 'exempt'], [9, 250, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 945, 'plate': 1683, 'invoices': 2}), ({'trips': [[82, 333, 'plate'], [35, 410, 'plate'], [24, 175, 'plate'], [34, 410, 'tag'], [60, 333, 'exempt'], [10, 250, 'tag'], [40, 175, 'plate'], [47, 250, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 594, 'plate': 2466, 'invoices': 3}), ({'trips': [[76, 175, 'exempt'], [69, 410, 'exempt'], [75, 175, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 167, 'plate': 0, 'invoices': 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 | {'invoices': 0, 'plate': 0, 'tag': 369} | {'invoices': 0, 'plate': 0, 'tag': 369} | Passed |
| fee oracle 1 | {'invoices': 1, 'plate': 575, 'tag': 225} | {'invoices': 1, 'plate': 575, 'tag': 225} | Passed |
| fee oracle 2 | {'invoices': 1, 'plate': 1368, 'tag': 1292} | {'invoices': 1, 'plate': 1370, 'tag': 1292} | Failed |
| fee oracle 3 | {'invoices': 1, 'plate': 462, 'tag': 0} | {'invoices': 1, 'plate': 463, 'tag': 0} | Failed |
| fee oracle 4 | {'invoices': 1, 'plate': 1150, 'tag': 911} | {'invoices': 1, 'plate': 1150, 'tag': 911} | Passed |
| fee oracle 5 | {'invoices': 2, 'plate': 1074, 'tag': 284} | {'invoices': 2, 'plate': 1076, 'tag': 284} | Failed |
| fee oracle 6 | {'invoices': 2, 'plate': 1728, 'tag': 225} | {'invoices': 2, 'plate': 1730, 'tag': 225} | Failed |
| fee oracle 7 | {'invoices': 0, 'plate': 0, 'tag': 0} | {'invoices': 0, 'plate': 0, 'tag': 0} | Passed |
SHA-256 / 6ca5fb415b8a588dcf0b609ac334b17adec13d92158ba347ebddbc29fdb92a0f
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
tag = plate = 0
periods = set()
for day, base, method in x['trips']:
if method == 'exempt':
continue
if method == 'tag':
tag += base - base * x['tag_discount_pct'] // 100
else:
plate += base + round(base * x['plate_surcharge_pct'] / 100)
periods.add(day // x['cycle_days'])
fees = len(periods) * x['invoice_fee']
return {'tag': tag, 'plate': plate + fees, 'invoices': len(periods)}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[84, 250, 'tag'], [82, 250, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 225, 'plate': 575, 'invoices': 1}), ({'trips': [[76, 250, 'tag'], [71, 525, 'tag'], [40, 250, 'tag'], [16, 525, 'plate'], [18, 250, 'plate'], [35, 333, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 1292, 'plate': 1370, 'invoices': 1}), ({'trips': [[74, 175, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 0, 'plate': 463, 'invoices': 1}), ({'trips': [[10, 250, 'plate'], [0, 250, 'plate'], [89, 410, 'tag'], [19, 410, 'tag'], [44, 250, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 911, 'plate': 1150, 'invoices': 1}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[36, 410, 'plate'], [12, 175, 'exempt'], [24, 333, 'plate'], [48, 250, 'tag'], [7, 525, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 225, 'plate': 1730, 'invoices': 2}), ({'trips': [[44, 410, 'exempt']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 0, 'plate': 0, 'invoices': 0})], [({'trips': [[51, 175, 'tag'], [42, 410, 'tag'], [70, 175, 'exempt'], [17, 175, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 685, 'plate': 0, 'invoices': 0}), ({'trips': [[55, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 473, 'plate': 0, 'invoices': 0}), ({'trips': [[64, 410, 'tag'], [0, 250, 'exempt'], [74, 250, 'exempt'], [12, 175, 'plate'], [4, 250, 'exempt'], [77, 410, 'tag'], [29, 250, 'plate'], [86, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 1170, 'plate': 932, 'invoices': 1}), ({'trips': [[44, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 300, 'plate': 0, 'invoices': 0}), ({'trips': [[80, 333, 'tag'], [37, 250, 'exempt'], [93, 525, 'tag'], [24, 175, 'plate'], [73, 525, 'tag'], [91, 250, 'plate'], [14, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 1546, 'plate': 1038, 'invoices': 2}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[48, 175, 'plate'], [37, 525, 'tag'], [81, 333, 'plate'], [42, 175, 'tag'], [11, 250, 'exempt']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 631, 'plate': 987, 'invoices': 2}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2})], [({'trips': [[20, 250, 'tag'], [55, 250, 'plate'], [77, 333, 'plate'], [83, 333, 'plate'], [95, 410, 'tag'], [27, 250, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 628, 'plate': 1910, 'invoices': 3}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[1, 410, 'tag'], [95, 250, 'exempt'], [59, 250, 'tag'], [51, 410, 'exempt'], [40, 333, 'plate'], [26, 410, 'plate'], [84, 333, 'plate'], [8, 250, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 775, 'plate': 2547, 'invoices': 3}), ({'trips': [[17, 525, 'tag'], [95, 175, 'plate'], [42, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 842, 'plate': 369, 'invoices': 1}), ({'trips': [[22, 250, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 225, 'plate': 0, 'invoices': 0}), ({'trips': [[22, 250, 'exempt'], [95, 525, 'exempt'], [7, 410, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 0, 'invoices': 0}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[89, 175, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 167, 'plate': 0, 'invoices': 0})], [({'trips': [[73, 250, 'plate'], [32, 410, 'tag'], [6, 333, 'plate'], [16, 250, 'plate'], [46, 250, 'tag'], [86, 175, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 752, 'plate': 1526, 'invoices': 2}), ({'trips': [[52, 410, 'exempt'], [6, 333, 'plate'], [26, 175, 'plate'], [18, 333, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 1663, 'invoices': 1}), ({'trips': [[8, 525, 'plate'], [27, 333, 'plate'], [72, 410, 'plate'], [15, 525, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 0, 'plate': 2644, 'invoices': 2}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[94, 525, 'exempt'], [50, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 447, 'plate': 0, 'invoices': 0}), ({'trips': [[41, 333, 'tag'], [76, 250, 'plate'], [33, 410, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 317, 'plate': 525, 'invoices': 1}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[43, 175, 'exempt'], [36, 175, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 0, 'plate': 0, 'invoices': 0})], [({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[72, 525, 'tag'], [18, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 998, 'plate': 0, 'invoices': 0}), ({'trips': [[24, 175, 'plate'], [4, 525, 'plate'], [22, 333, 'tag'], [63, 525, 'tag'], [10, 525, 'tag'], [0, 525, 'plate'], [6, 410, 'tag'], [39, 525, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 2088, 'plate': 1989, 'invoices': 1}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[82, 250, 'exempt'], [20, 175, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 149, 'plate': 0, 'invoices': 0}), ({'trips': [[88, 410, 'tag'], [89, 250, 'plate'], [5, 525, 'tag'], [38, 175, 'exempt'], [64, 525, 'plate'], [28, 175, 'tag'], [62, 333, 'exempt'], [9, 250, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 945, 'plate': 1683, 'invoices': 2}), ({'trips': [[82, 333, 'plate'], [35, 410, 'plate'], [24, 175, 'plate'], [34, 410, 'tag'], [60, 333, 'exempt'], [10, 250, 'tag'], [40, 175, 'plate'], [47, 250, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 594, 'plate': 2466, 'invoices': 3}), ({'trips': [[76, 175, 'exempt'], [69, 410, 'exempt'], [75, 175, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 167, 'plate': 0, 'invoices': 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 | {'invoices': 0, 'plate': 0, 'tag': 369} | {'invoices': 0, 'plate': 0, 'tag': 369} | Passed |
| fee oracle 1 | {'invoices': 1, 'plate': 575, 'tag': 225} | {'invoices': 1, 'plate': 575, 'tag': 225} | Passed |
| fee oracle 2 | {'invoices': 1, 'plate': 1368, 'tag': 1292} | {'invoices': 1, 'plate': 1370, 'tag': 1292} | Failed |
| fee oracle 3 | {'invoices': 1, 'plate': 463, 'tag': 0} | {'invoices': 1, 'plate': 463, 'tag': 0} | Passed |
| fee oracle 4 | {'invoices': 1, 'plate': 1150, 'tag': 911} | {'invoices': 1, 'plate': 1150, 'tag': 911} | Passed |
| fee oracle 5 | {'invoices': 2, 'plate': 1076, 'tag': 284} | {'invoices': 2, 'plate': 1076, 'tag': 284} | Passed |
| fee oracle 6 | {'invoices': 2, 'plate': 1728, 'tag': 225} | {'invoices': 2, 'plate': 1730, 'tag': 225} | Failed |
| fee oracle 7 | {'invoices': 0, 'plate': 0, 'tag': 0} | {'invoices': 0, 'plate': 0, 'tag': 0} | Passed |
SHA-256 / 5f411103fc6ccd325dccc6aa7ff8cb787529eb836918a44a9cdfa26e019a7709
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
tag = plate = 0
periods = set()
for day, base, method in x['trips']:
if method == 'exempt':
continue
if method == 'tag':
tag += base - base * x['tag_discount_pct'] // 100
else:
plate += base + -(-base * x['plate_surcharge_pct'] // 100)
periods.add(day // x['cycle_days'])
fees = len(periods) * x['invoice_fee']
return {'tag': tag, 'plate': plate + fees, 'invoices': len(periods)}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[84, 250, 'tag'], [82, 250, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 225, 'plate': 575, 'invoices': 1}), ({'trips': [[76, 250, 'tag'], [71, 525, 'tag'], [40, 250, 'tag'], [16, 525, 'plate'], [18, 250, 'plate'], [35, 333, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 1292, 'plate': 1370, 'invoices': 1}), ({'trips': [[74, 175, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 0, 'plate': 463, 'invoices': 1}), ({'trips': [[10, 250, 'plate'], [0, 250, 'plate'], [89, 410, 'tag'], [19, 410, 'tag'], [44, 250, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 911, 'plate': 1150, 'invoices': 1}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[36, 410, 'plate'], [12, 175, 'exempt'], [24, 333, 'plate'], [48, 250, 'tag'], [7, 525, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 225, 'plate': 1730, 'invoices': 2}), ({'trips': [[44, 410, 'exempt']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 0, 'plate': 0, 'invoices': 0})], [({'trips': [[51, 175, 'tag'], [42, 410, 'tag'], [70, 175, 'exempt'], [17, 175, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 685, 'plate': 0, 'invoices': 0}), ({'trips': [[55, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 473, 'plate': 0, 'invoices': 0}), ({'trips': [[64, 410, 'tag'], [0, 250, 'exempt'], [74, 250, 'exempt'], [12, 175, 'plate'], [4, 250, 'exempt'], [77, 410, 'tag'], [29, 250, 'plate'], [86, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 1170, 'plate': 932, 'invoices': 1}), ({'trips': [[44, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 300, 'plate': 0, 'invoices': 0}), ({'trips': [[80, 333, 'tag'], [37, 250, 'exempt'], [93, 525, 'tag'], [24, 175, 'plate'], [73, 525, 'tag'], [91, 250, 'plate'], [14, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 1546, 'plate': 1038, 'invoices': 2}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[48, 175, 'plate'], [37, 525, 'tag'], [81, 333, 'plate'], [42, 175, 'tag'], [11, 250, 'exempt']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 631, 'plate': 987, 'invoices': 2}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2})], [({'trips': [[20, 250, 'tag'], [55, 250, 'plate'], [77, 333, 'plate'], [83, 333, 'plate'], [95, 410, 'tag'], [27, 250, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 628, 'plate': 1910, 'invoices': 3}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[1, 410, 'tag'], [95, 250, 'exempt'], [59, 250, 'tag'], [51, 410, 'exempt'], [40, 333, 'plate'], [26, 410, 'plate'], [84, 333, 'plate'], [8, 250, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 775, 'plate': 2547, 'invoices': 3}), ({'trips': [[17, 525, 'tag'], [95, 175, 'plate'], [42, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 842, 'plate': 369, 'invoices': 1}), ({'trips': [[22, 250, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 225, 'plate': 0, 'invoices': 0}), ({'trips': [[22, 250, 'exempt'], [95, 525, 'exempt'], [7, 410, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 0, 'invoices': 0}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[89, 175, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 167, 'plate': 0, 'invoices': 0})], [({'trips': [[73, 250, 'plate'], [32, 410, 'tag'], [6, 333, 'plate'], [16, 250, 'plate'], [46, 250, 'tag'], [86, 175, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 752, 'plate': 1526, 'invoices': 2}), ({'trips': [[52, 410, 'exempt'], [6, 333, 'plate'], [26, 175, 'plate'], [18, 333, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 1663, 'invoices': 1}), ({'trips': [[8, 525, 'plate'], [27, 333, 'plate'], [72, 410, 'plate'], [15, 525, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 0, 'plate': 2644, 'invoices': 2}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[94, 525, 'exempt'], [50, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 447, 'plate': 0, 'invoices': 0}), ({'trips': [[41, 333, 'tag'], [76, 250, 'plate'], [33, 410, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 317, 'plate': 525, 'invoices': 1}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[43, 175, 'exempt'], [36, 175, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 0, 'plate': 0, 'invoices': 0})], [({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[72, 525, 'tag'], [18, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 998, 'plate': 0, 'invoices': 0}), ({'trips': [[24, 175, 'plate'], [4, 525, 'plate'], [22, 333, 'tag'], [63, 525, 'tag'], [10, 525, 'tag'], [0, 525, 'plate'], [6, 410, 'tag'], [39, 525, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 2088, 'plate': 1989, 'invoices': 1}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[82, 250, 'exempt'], [20, 175, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 149, 'plate': 0, 'invoices': 0}), ({'trips': [[88, 410, 'tag'], [89, 250, 'plate'], [5, 525, 'tag'], [38, 175, 'exempt'], [64, 525, 'plate'], [28, 175, 'tag'], [62, 333, 'exempt'], [9, 250, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 945, 'plate': 1683, 'invoices': 2}), ({'trips': [[82, 333, 'plate'], [35, 410, 'plate'], [24, 175, 'plate'], [34, 410, 'tag'], [60, 333, 'exempt'], [10, 250, 'tag'], [40, 175, 'plate'], [47, 250, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 594, 'plate': 2466, 'invoices': 3}), ({'trips': [[76, 175, 'exempt'], [69, 410, 'exempt'], [75, 175, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 167, 'plate': 0, 'invoices': 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 | {'invoices': 0, 'plate': 0, 'tag': 369} | {'invoices': 0, 'plate': 0, 'tag': 369} | Passed |
| fee oracle 1 | {'invoices': 1, 'plate': 575, 'tag': 225} | {'invoices': 1, 'plate': 575, 'tag': 225} | Passed |
| fee oracle 2 | {'invoices': 1, 'plate': 1370, 'tag': 1292} | {'invoices': 1, 'plate': 1370, 'tag': 1292} | Passed |
| fee oracle 3 | {'invoices': 1, 'plate': 463, 'tag': 0} | {'invoices': 1, 'plate': 463, 'tag': 0} | Passed |
| fee oracle 4 | {'invoices': 1, 'plate': 1150, 'tag': 911} | {'invoices': 1, 'plate': 1150, 'tag': 911} | Passed |
| fee oracle 5 | {'invoices': 2, 'plate': 1076, 'tag': 284} | {'invoices': 2, 'plate': 1076, 'tag': 284} | Passed |
| fee oracle 6 | {'invoices': 2, 'plate': 1730, 'tag': 225} | {'invoices': 2, 'plate': 1730, 'tag': 225} | Passed |
| fee oracle 7 | {'invoices': 0, 'plate': 0, 'tag': 0} | {'invoices': 0, 'plate': 0, 'tag': 0} | Passed |
SHA-256 / 5c90b4ad194acc5518db5f1e5ebed0d24ea663dc66f6f41d92d8bca70ea18f46
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.648150+00:00.
Case digest / f73077401133ebf7a17a9164efd0bbed9ed374d2e22afb254581c671dc95fbeb