FA-68606 / Toll and parking fee computation / Open access
Pay-by-plate invoice and tag discount: a single invoice fee is added regardless of invoices · case 01
Pay-by-plate invoice and tag discount returns a wrong result when a single invoice fee is added regardless of invoices.
ROOT CAUSE
Invoice fees are counted but never billed.
VERIFIED REPAIR
Restore the invoice fee total rule so that the step reads `'plate': plate + fees`.
Unsuccessful approach: One flat fee ignores multiple invoice periods and charges accounts with no plate trips.
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, 'invoices': len(periods)}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'trips': [[25, 175, 'exempt'], [34, 410, 'plate'], [15, 250, 'plate'], [87, 175, 'exempt'], [2, 175, 'tag'], [22, 250, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 405, 'plate': 1292, 'invoices': 2}), ({'trips': [[94, 250, 'exempt'], [10, 410, 'tag'], [27, 333, 'plate'], [90, 175, 'plate'], [20, 410, 'plate'], [82, 525, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 796, 'plate': 1549, 'invoices': 2}), ({'trips': [[93, 333, 'tag'], [94, 333, 'tag'], [77, 333, 'tag'], [35, 175, 'exempt'], [63, 333, 'exempt'], [46, 175, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 1118, 'plate': 0, 'invoices': 0}), ({'trips': [[14, 410, 'plate'], [57, 333, 'exempt'], [15, 175, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 0, 'plate': 941, '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': [[72, 175, 'plate'], [36, 333, 'tag'], [69, 525, 'tag'], [34, 525, 'tag'], [42, 525, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 1625, 'plate': 663, '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': [[30, 175, 'tag'], [60, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 596, 'plate': 0, 'invoices': 0})], [({'trips': [[67, 410, 'plate'], [33, 410, 'tag'], [41, 250, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 594, 'plate': 1015, 'invoices': 1}), ({'trips': [[60, 175, 'tag'], [33, 333, 'exempt'], [92, 410, 'plate'], [20, 333, 'tag'], [34, 525, 'tag'], [54, 250, 'tag'], [60, 525, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 1221, 'plate': 713, 'invoices': 1}), ({'trips': [[3, 525, 'tag'], [27, 525, 'tag'], [24, 333, 'exempt'], [25, 250, 'plate'], [17, 175, 'exempt'], [40, 175, 'plate'], [92, 410, 'exempt'], [0, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 1315, 'plate': 932, 'invoices': 2}), ({'trips': [[49, 410, 'exempt'], [6, 525, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 1188, 'invoices': 1}), ({'trips': [[21, 410, 'plate'], [90, 250, 'plate'], [6, 250, 'tag'], [80, 525, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 660, 'plate': 1126, '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': [[69, 410, 'plate'], [79, 410, 'plate'], [50, 175, 'tag'], [1, 333, 'plate'], [78, 250, 'tag'], [95, 175, 'exempt'], [93, 175, 'tag'], [68, 175, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 739, 'plate': 2130, '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, 333, 'tag'], [29, 175, 'plate'], [74, 410, 'plate'], [22, 250, 'plate'], [2, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 816, 'plate': 1429, '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': [[85, 175, 'tag'], [52, 410, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 149, 'plate': 765, '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': [[46, 250, 'plate'], [53, 175, 'exempt'], [25, 333, 'plate'], [61, 250, 'exempt'], [80, 333, 'exempt'], [54, 525, 'tag'], [88, 175, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 666, 'plate': 1088, 'invoices': 2}), ({'trips': [[40, 250, 'tag'], [88, 175, 'exempt'], [93, 410, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 628, 'plate': 0, 'invoices': 0}), ({'trips': [[2, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 317, 'plate': 0, 'invoices': 0}), ({'trips': [[28, 333, 'exempt']], 'plate_surcharge_pct': 35, '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': [[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': [[50, 250, 'tag'], [32, 410, 'exempt'], [37, 525, 'plate'], [58, 333, 'plate'], [45, 250, 'plate'], [20, 525, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 238, 'plate': 1863, 'invoices': 1}), ({'trips': [[63, 525, 'plate'], [69, 250, 'exempt'], [43, 175, 'plate'], [45, 333, 'plate'], [25, 175, 'exempt'], [63, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 300, 'plate': 1951, 'invoices': 2}), ({'trips': [[6, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 317, 'plate': 0, 'invoices': 0}), ({'trips': [[42, 410, 'tag'], [26, 250, 'plate'], [17, 525, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 1170, 'invoices': 1}), ({'trips': [[65, 410, 'exempt'], [81, 175, 'tag'], [49, 525, 'tag'], [41, 410, 'tag'], [37, 525, 'tag'], [51, 333, 'tag'], [1, 250, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 1889, 'plate': 0, 'invoices': 0}), ({'trips': [[40, 175, 'tag'], [49, 525, 'tag'], [43, 175, 'plate'], [3, 250, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 904, 'plate': 437, 'invoices': 1})], [({'trips': [[69, 175, 'exempt']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 0, 'invoices': 0}), ({'trips': [[3, 250, 'tag'], [58, 333, 'tag'], [42, 525, 'tag'], [72, 175, 'exempt'], [25, 175, 'tag'], [73, 410, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 1156, 'plate': 754, 'invoices': 1}), ({'trips': [[39, 250, 'exempt'], [93, 410, 'plate'], [0, 333, 'plate'], [7, 525, 'tag'], [48, 333, 'tag'], [53, 175, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 773, 'plate': 1599, 'invoices': 3}), ({'trips': [[47, 175, 'tag'], [51, 525, 'exempt'], [26, 333, 'plate'], [37, 250, 'exempt'], [1, 250, 'exempt'], [61, 333, 'tag'], [11, 333, 'tag'], [69, 175, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 916, 'plate': 850, 'invoices': 1}), ({'trips': [[72, 525, 'tag'], [84, 175, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 596, 'plate': 0, 'invoices': 0}), ({'trips': [[81, 333, 'plate'], [52, 410, 'tag'], [43, 175, 'plate'], [72, 525, 'tag'], [45, 525, 'plate'], [20, 525, 'plate'], [43, 250, 'plate'], [28, 333, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 889, 'plate': 3493, 'invoices': 3}), ({'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': [[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})]]
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': 2, 'plate': 892, 'tag': 405} | {'invoices': 2, 'plate': 1292, 'tag': 405} | Failed |
| fee oracle 1 | {'invoices': 2, 'plate': 1149, 'tag': 796} | {'invoices': 2, 'plate': 1549, 'tag': 796} | Failed |
| fee oracle 2 | {'invoices': 0, 'plate': 0, 'tag': 1118} | {'invoices': 0, 'plate': 0, 'tag': 1118} | Passed |
| fee oracle 3 | {'invoices': 1, 'plate': 791, 'tag': 0} | {'invoices': 1, 'plate': 941, 'tag': 0} | Failed |
| fee oracle 4 | {'invoices': 2, 'plate': 676, 'tag': 284} | {'invoices': 2, 'plate': 1076, 'tag': 284} | Failed |
| fee oracle 5 | {'invoices': 1, 'plate': 263, 'tag': 1625} | {'invoices': 1, 'plate': 663, 'tag': 1625} | Failed |
| fee oracle 6 | {'invoices': 0, 'plate': 0, 'tag': 369} | {'invoices': 0, 'plate': 0, 'tag': 369} | Passed |
| fee oracle 7 | {'invoices': 0, 'plate': 0, 'tag': 596} | {'invoices': 0, 'plate': 0, 'tag': 596} | Passed |
SHA-256 / b17285a7b7b17ef269b322f9f13a07f6d50b33d851971853b3e9bd8d719e27d8
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 + -(-base * x['plate_surcharge_pct'] // 100)
periods.add(day // x['cycle_days'])
fees = len(periods) * x['invoice_fee']
return {'tag': tag, 'plate': plate + x['invoice_fee'], 'invoices': len(periods)}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'trips': [[25, 175, 'exempt'], [34, 410, 'plate'], [15, 250, 'plate'], [87, 175, 'exempt'], [2, 175, 'tag'], [22, 250, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 405, 'plate': 1292, 'invoices': 2}), ({'trips': [[94, 250, 'exempt'], [10, 410, 'tag'], [27, 333, 'plate'], [90, 175, 'plate'], [20, 410, 'plate'], [82, 525, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 796, 'plate': 1549, 'invoices': 2}), ({'trips': [[93, 333, 'tag'], [94, 333, 'tag'], [77, 333, 'tag'], [35, 175, 'exempt'], [63, 333, 'exempt'], [46, 175, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 1118, 'plate': 0, 'invoices': 0}), ({'trips': [[14, 410, 'plate'], [57, 333, 'exempt'], [15, 175, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 0, 'plate': 941, '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': [[72, 175, 'plate'], [36, 333, 'tag'], [69, 525, 'tag'], [34, 525, 'tag'], [42, 525, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 1625, 'plate': 663, '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': [[30, 175, 'tag'], [60, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 596, 'plate': 0, 'invoices': 0})], [({'trips': [[67, 410, 'plate'], [33, 410, 'tag'], [41, 250, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 594, 'plate': 1015, 'invoices': 1}), ({'trips': [[60, 175, 'tag'], [33, 333, 'exempt'], [92, 410, 'plate'], [20, 333, 'tag'], [34, 525, 'tag'], [54, 250, 'tag'], [60, 525, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 1221, 'plate': 713, 'invoices': 1}), ({'trips': [[3, 525, 'tag'], [27, 525, 'tag'], [24, 333, 'exempt'], [25, 250, 'plate'], [17, 175, 'exempt'], [40, 175, 'plate'], [92, 410, 'exempt'], [0, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 1315, 'plate': 932, 'invoices': 2}), ({'trips': [[49, 410, 'exempt'], [6, 525, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 1188, 'invoices': 1}), ({'trips': [[21, 410, 'plate'], [90, 250, 'plate'], [6, 250, 'tag'], [80, 525, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 660, 'plate': 1126, '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': [[69, 410, 'plate'], [79, 410, 'plate'], [50, 175, 'tag'], [1, 333, 'plate'], [78, 250, 'tag'], [95, 175, 'exempt'], [93, 175, 'tag'], [68, 175, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 739, 'plate': 2130, '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, 333, 'tag'], [29, 175, 'plate'], [74, 410, 'plate'], [22, 250, 'plate'], [2, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 816, 'plate': 1429, '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': [[85, 175, 'tag'], [52, 410, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 149, 'plate': 765, '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': [[46, 250, 'plate'], [53, 175, 'exempt'], [25, 333, 'plate'], [61, 250, 'exempt'], [80, 333, 'exempt'], [54, 525, 'tag'], [88, 175, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 666, 'plate': 1088, 'invoices': 2}), ({'trips': [[40, 250, 'tag'], [88, 175, 'exempt'], [93, 410, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 628, 'plate': 0, 'invoices': 0}), ({'trips': [[2, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 317, 'plate': 0, 'invoices': 0}), ({'trips': [[28, 333, 'exempt']], 'plate_surcharge_pct': 35, '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': [[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': [[50, 250, 'tag'], [32, 410, 'exempt'], [37, 525, 'plate'], [58, 333, 'plate'], [45, 250, 'plate'], [20, 525, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 238, 'plate': 1863, 'invoices': 1}), ({'trips': [[63, 525, 'plate'], [69, 250, 'exempt'], [43, 175, 'plate'], [45, 333, 'plate'], [25, 175, 'exempt'], [63, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 300, 'plate': 1951, 'invoices': 2}), ({'trips': [[6, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 317, 'plate': 0, 'invoices': 0}), ({'trips': [[42, 410, 'tag'], [26, 250, 'plate'], [17, 525, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 1170, 'invoices': 1}), ({'trips': [[65, 410, 'exempt'], [81, 175, 'tag'], [49, 525, 'tag'], [41, 410, 'tag'], [37, 525, 'tag'], [51, 333, 'tag'], [1, 250, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 1889, 'plate': 0, 'invoices': 0}), ({'trips': [[40, 175, 'tag'], [49, 525, 'tag'], [43, 175, 'plate'], [3, 250, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 904, 'plate': 437, 'invoices': 1})], [({'trips': [[69, 175, 'exempt']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 0, 'invoices': 0}), ({'trips': [[3, 250, 'tag'], [58, 333, 'tag'], [42, 525, 'tag'], [72, 175, 'exempt'], [25, 175, 'tag'], [73, 410, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 1156, 'plate': 754, 'invoices': 1}), ({'trips': [[39, 250, 'exempt'], [93, 410, 'plate'], [0, 333, 'plate'], [7, 525, 'tag'], [48, 333, 'tag'], [53, 175, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 773, 'plate': 1599, 'invoices': 3}), ({'trips': [[47, 175, 'tag'], [51, 525, 'exempt'], [26, 333, 'plate'], [37, 250, 'exempt'], [1, 250, 'exempt'], [61, 333, 'tag'], [11, 333, 'tag'], [69, 175, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 916, 'plate': 850, 'invoices': 1}), ({'trips': [[72, 525, 'tag'], [84, 175, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 596, 'plate': 0, 'invoices': 0}), ({'trips': [[81, 333, 'plate'], [52, 410, 'tag'], [43, 175, 'plate'], [72, 525, 'tag'], [45, 525, 'plate'], [20, 525, 'plate'], [43, 250, 'plate'], [28, 333, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 889, 'plate': 3493, 'invoices': 3}), ({'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': [[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})]]
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': 2, 'plate': 1092, 'tag': 405} | {'invoices': 2, 'plate': 1292, 'tag': 405} | Failed |
| fee oracle 1 | {'invoices': 2, 'plate': 1349, 'tag': 796} | {'invoices': 2, 'plate': 1549, 'tag': 796} | Failed |
| fee oracle 2 | {'invoices': 0, 'plate': 200, 'tag': 1118} | {'invoices': 0, 'plate': 0, 'tag': 1118} | Failed |
| fee oracle 3 | {'invoices': 1, 'plate': 941, 'tag': 0} | {'invoices': 1, 'plate': 941, 'tag': 0} | Passed |
| fee oracle 4 | {'invoices': 2, 'plate': 876, 'tag': 284} | {'invoices': 2, 'plate': 1076, 'tag': 284} | Failed |
| fee oracle 5 | {'invoices': 1, 'plate': 663, 'tag': 1625} | {'invoices': 1, 'plate': 663, 'tag': 1625} | Passed |
| fee oracle 6 | {'invoices': 0, 'plate': 200, 'tag': 369} | {'invoices': 0, 'plate': 0, 'tag': 369} | Failed |
| fee oracle 7 | {'invoices': 0, 'plate': 200, 'tag': 596} | {'invoices': 0, 'plate': 0, 'tag': 596} | Failed |
SHA-256 / 9a6e0b0dfc70551a7d531c9e80d234dad58bfb04b98880e0884a560ee3b51783
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': [[25, 175, 'exempt'], [34, 410, 'plate'], [15, 250, 'plate'], [87, 175, 'exempt'], [2, 175, 'tag'], [22, 250, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 405, 'plate': 1292, 'invoices': 2}), ({'trips': [[94, 250, 'exempt'], [10, 410, 'tag'], [27, 333, 'plate'], [90, 175, 'plate'], [20, 410, 'plate'], [82, 525, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 796, 'plate': 1549, 'invoices': 2}), ({'trips': [[93, 333, 'tag'], [94, 333, 'tag'], [77, 333, 'tag'], [35, 175, 'exempt'], [63, 333, 'exempt'], [46, 175, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 1118, 'plate': 0, 'invoices': 0}), ({'trips': [[14, 410, 'plate'], [57, 333, 'exempt'], [15, 175, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 0, 'plate': 941, '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': [[72, 175, 'plate'], [36, 333, 'tag'], [69, 525, 'tag'], [34, 525, 'tag'], [42, 525, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 1625, 'plate': 663, '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': [[30, 175, 'tag'], [60, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 596, 'plate': 0, 'invoices': 0})], [({'trips': [[67, 410, 'plate'], [33, 410, 'tag'], [41, 250, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 594, 'plate': 1015, 'invoices': 1}), ({'trips': [[60, 175, 'tag'], [33, 333, 'exempt'], [92, 410, 'plate'], [20, 333, 'tag'], [34, 525, 'tag'], [54, 250, 'tag'], [60, 525, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 1221, 'plate': 713, 'invoices': 1}), ({'trips': [[3, 525, 'tag'], [27, 525, 'tag'], [24, 333, 'exempt'], [25, 250, 'plate'], [17, 175, 'exempt'], [40, 175, 'plate'], [92, 410, 'exempt'], [0, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 1315, 'plate': 932, 'invoices': 2}), ({'trips': [[49, 410, 'exempt'], [6, 525, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 1188, 'invoices': 1}), ({'trips': [[21, 410, 'plate'], [90, 250, 'plate'], [6, 250, 'tag'], [80, 525, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 660, 'plate': 1126, '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': [[69, 410, 'plate'], [79, 410, 'plate'], [50, 175, 'tag'], [1, 333, 'plate'], [78, 250, 'tag'], [95, 175, 'exempt'], [93, 175, 'tag'], [68, 175, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 739, 'plate': 2130, '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, 333, 'tag'], [29, 175, 'plate'], [74, 410, 'plate'], [22, 250, 'plate'], [2, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 816, 'plate': 1429, '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': [[85, 175, 'tag'], [52, 410, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 149, 'plate': 765, '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': [[46, 250, 'plate'], [53, 175, 'exempt'], [25, 333, 'plate'], [61, 250, 'exempt'], [80, 333, 'exempt'], [54, 525, 'tag'], [88, 175, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 666, 'plate': 1088, 'invoices': 2}), ({'trips': [[40, 250, 'tag'], [88, 175, 'exempt'], [93, 410, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 628, 'plate': 0, 'invoices': 0}), ({'trips': [[2, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 317, 'plate': 0, 'invoices': 0}), ({'trips': [[28, 333, 'exempt']], 'plate_surcharge_pct': 35, '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': [[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': [[50, 250, 'tag'], [32, 410, 'exempt'], [37, 525, 'plate'], [58, 333, 'plate'], [45, 250, 'plate'], [20, 525, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 238, 'plate': 1863, 'invoices': 1}), ({'trips': [[63, 525, 'plate'], [69, 250, 'exempt'], [43, 175, 'plate'], [45, 333, 'plate'], [25, 175, 'exempt'], [63, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 300, 'plate': 1951, 'invoices': 2}), ({'trips': [[6, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 317, 'plate': 0, 'invoices': 0}), ({'trips': [[42, 410, 'tag'], [26, 250, 'plate'], [17, 525, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 1170, 'invoices': 1}), ({'trips': [[65, 410, 'exempt'], [81, 175, 'tag'], [49, 525, 'tag'], [41, 410, 'tag'], [37, 525, 'tag'], [51, 333, 'tag'], [1, 250, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 1889, 'plate': 0, 'invoices': 0}), ({'trips': [[40, 175, 'tag'], [49, 525, 'tag'], [43, 175, 'plate'], [3, 250, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 904, 'plate': 437, 'invoices': 1})], [({'trips': [[69, 175, 'exempt']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 0, 'invoices': 0}), ({'trips': [[3, 250, 'tag'], [58, 333, 'tag'], [42, 525, 'tag'], [72, 175, 'exempt'], [25, 175, 'tag'], [73, 410, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 1156, 'plate': 754, 'invoices': 1}), ({'trips': [[39, 250, 'exempt'], [93, 410, 'plate'], [0, 333, 'plate'], [7, 525, 'tag'], [48, 333, 'tag'], [53, 175, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 773, 'plate': 1599, 'invoices': 3}), ({'trips': [[47, 175, 'tag'], [51, 525, 'exempt'], [26, 333, 'plate'], [37, 250, 'exempt'], [1, 250, 'exempt'], [61, 333, 'tag'], [11, 333, 'tag'], [69, 175, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 916, 'plate': 850, 'invoices': 1}), ({'trips': [[72, 525, 'tag'], [84, 175, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 596, 'plate': 0, 'invoices': 0}), ({'trips': [[81, 333, 'plate'], [52, 410, 'tag'], [43, 175, 'plate'], [72, 525, 'tag'], [45, 525, 'plate'], [20, 525, 'plate'], [43, 250, 'plate'], [28, 333, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 889, 'plate': 3493, 'invoices': 3}), ({'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': [[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})]]
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': 2, 'plate': 1292, 'tag': 405} | {'invoices': 2, 'plate': 1292, 'tag': 405} | Passed |
| fee oracle 1 | {'invoices': 2, 'plate': 1549, 'tag': 796} | {'invoices': 2, 'plate': 1549, 'tag': 796} | Passed |
| fee oracle 2 | {'invoices': 0, 'plate': 0, 'tag': 1118} | {'invoices': 0, 'plate': 0, 'tag': 1118} | Passed |
| fee oracle 3 | {'invoices': 1, 'plate': 941, 'tag': 0} | {'invoices': 1, 'plate': 941, 'tag': 0} | Passed |
| fee oracle 4 | {'invoices': 2, 'plate': 1076, 'tag': 284} | {'invoices': 2, 'plate': 1076, 'tag': 284} | Passed |
| fee oracle 5 | {'invoices': 1, 'plate': 663, 'tag': 1625} | {'invoices': 1, 'plate': 663, 'tag': 1625} | Passed |
| fee oracle 6 | {'invoices': 0, 'plate': 0, 'tag': 369} | {'invoices': 0, 'plate': 0, 'tag': 369} | Passed |
| fee oracle 7 | {'invoices': 0, 'plate': 0, 'tag': 596} | {'invoices': 0, 'plate': 0, 'tag': 596} | Passed |
SHA-256 / 6b52432db7efdbd1336a77bc5263fdab8465deb0e33bdbe4f3c783972744e257
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.780237+00:00.
Case digest / 002c19d35685915e0ce9037e922ed0d425c7e23787297abeaa2686370597ef7b