FA-68601 / Toll and parking fee computation / Open access
Pay-by-plate invoice and tag discount: the discounted price is floored instead of the discount · case 01
Pay-by-plate invoice and tag discount returns a wrong result when the discounted price is floored instead of the discount.
ROOT CAUSE
Flooring the discounted price gives the customer the fractional cent the contract keeps.
VERIFIED REPAIR
Restore the tag discount rounding rule so that the step reads `base - base * x['tag_discount_pct'] // 100`.
Unsuccessful approach: Rounding the discount up has the same effect from the other side.
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 * (100 - 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': [[91, 175, 'tag'], [42, 250, 'tag'], [44, 333, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 383, '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': [[76, 333, 'plate'], [50, 525, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 0, 'plate': 650, 'invoices': 1}), ({'trips': [[26, 333, 'tag'], [88, 175, 'tag'], [11, 525, 'exempt'], [80, 175, 'tag'], [18, 175, 'plate'], [51, 333, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 582, 'plate': 1436, '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': [[40, 250, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 0, 'plate': 488, 'invoices': 1}), ({'trips': [[63, 525, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 1109, 'invoices': 1}), ({'trips': [[61, 333, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 284, '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': [[27, 250, 'tag'], [39, 410, 'plate'], [68, 525, 'tag'], [60, 525, 'plate'], [21, 175, 'tag'], [32, 250, 'exempt'], [67, 410, 'exempt'], [95, 410, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 904, 'plate': 1370, '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': [[91, 333, 'exempt'], [12, 525, 'tag'], [73, 175, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 499, 'plate': 619, 'invoices': 1}), ({'trips': [[54, 525, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 1109, 'invoices': 1}), ({'trips': [[48, 410, 'plate'], [33, 175, 'exempt'], [49, 175, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 0, 'plate': 882, 'invoices': 1}), ({'trips': [[1, 333, 'plate'], [37, 250, 'plate'], [50, 175, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 0, 'plate': 1425, 'invoices': 2}), ({'trips': [[21, 525, 'tag'], [11, 525, 'tag'], [62, 410, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 946, 'plate': 0, 'invoices': 0})], [({'trips': [[10, 410, 'plate'], [15, 250, 'exempt'], [21, 525, 'plate'], [36, 250, 'plate'], [56, 175, 'plate'], [35, 250, 'tag'], [94, 525, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 225, 'plate': 2809, 'invoices': 3}), ({'trips': [[25, 175, 'exempt'], [7, 175, 'exempt'], [95, 410, 'plate'], [12, 250, 'exempt'], [95, 175, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 0, 'plate': 932, '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': [[54, 410, 'tag'], [50, 250, 'plate'], [25, 333, 'tag'], [46, 333, 'plate'], [39, 333, 'plate'], [41, 175, 'plate'], [49, 175, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 633, 'plate': 1985, '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': [[81, 250, 'tag'], [14, 250, 'plate'], [37, 333, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 525, 'plate': 713, 'invoices': 1}), ({'trips': [[31, 525, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 0, 'plate': 909, 'invoices': 1}), ({'trips': [[46, 333, 'exempt'], [24, 250, 'tag'], [31, 175, 'plate'], [4, 250, 'exempt'], [28, 333, 'exempt'], [14, 250, 'tag'], [79, 410, 'plate'], [1, 525, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 426, 'plate': 1950, 'invoices': 3})], [({'trips': [[20, 410, 'plate'], [72, 525, 'plate'], [58, 525, 'plate'], [6, 250, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 0, 'plate': 2791, 'invoices': 3}), ({'trips': [[74, 250, 'plate'], [2, 250, 'plate'], [8, 525, 'plate'], [44, 175, 'tag'], [92, 250, 'plate'], [31, 175, 'plate'], [50, 333, 'plate'], [74, 250, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 362, 'plate': 3832, 'invoices': 4}), ({'trips': [[78, 250, 'tag'], [20, 250, 'plate'], [57, 175, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 225, 'plate': 775, 'invoices': 1}), ({'trips': [[15, 250, 'tag'], [8, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 628, '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': [[8, 333, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 0, 'plate': 617, 'invoices': 1}), ({'trips': [[46, 410, 'exempt'], [86, 525, 'plate'], [35, 250, 'tag'], [77, 333, 'tag'], [63, 250, 'plate'], [34, 250, 'exempt'], [50, 525, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 555, 'plate': 2351, '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': [[22, 175, 'plate'], [60, 250, 'plate'], [21, 333, 'tag'], [66, 333, 'plate'], [60, 525, 'plate'], [14, 250, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 555, 'plate': 2406, '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': [[68, 410, 'tag'], [4, 410, 'plate'], [20, 250, 'plate'], [32, 525, 'exempt'], [72, 250, 'plate'], [75, 250, 'plate'], [93, 525, 'plate'], [84, 250, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 3128, 'invoices': 3}), ({'trips': [[18, 250, 'plate'], [23, 175, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 167, 'plate': 713, 'invoices': 1}), ({'trips': [[27, 333, 'plate'], [18, 250, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 0, 'plate': 1075, 'invoices': 1}), ({'trips': [[51, 250, 'plate'], [31, 333, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 0, 'plate': 938, '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': [[3, 410, 'exempt'], [13, 250, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 213, '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': 382} | {'invoices': 0, 'plate': 0, 'tag': 383} | Failed |
| fee oracle 1 | {'invoices': 0, 'plate': 0, 'tag': 369} | {'invoices': 0, 'plate': 0, 'tag': 369} | Passed |
| fee oracle 2 | {'invoices': 1, 'plate': 650, 'tag': 0} | {'invoices': 1, 'plate': 650, 'tag': 0} | Passed |
| fee oracle 3 | {'invoices': 2, 'plate': 1436, 'tag': 579} | {'invoices': 2, 'plate': 1436, 'tag': 582} | Failed |
| fee oracle 4 | {'invoices': 2, 'plate': 1076, 'tag': 283} | {'invoices': 2, 'plate': 1076, 'tag': 284} | Failed |
| fee oracle 5 | {'invoices': 1, 'plate': 488, 'tag': 0} | {'invoices': 1, 'plate': 488, 'tag': 0} | Passed |
| fee oracle 6 | {'invoices': 1, 'plate': 1109, 'tag': 0} | {'invoices': 1, 'plate': 1109, 'tag': 0} | Passed |
| fee oracle 7 | {'invoices': 0, 'plate': 0, 'tag': 283} | {'invoices': 0, 'plate': 0, 'tag': 284} | Failed |
SHA-256 / 24ea8c5abba3676be6400efe114eb680187b0eed9cd86c45a8824262335b60a1
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 + fees, 'invoices': len(periods)}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'trips': [[91, 175, 'tag'], [42, 250, 'tag'], [44, 333, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 383, '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': [[76, 333, 'plate'], [50, 525, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 0, 'plate': 650, 'invoices': 1}), ({'trips': [[26, 333, 'tag'], [88, 175, 'tag'], [11, 525, 'exempt'], [80, 175, 'tag'], [18, 175, 'plate'], [51, 333, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 582, 'plate': 1436, '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': [[40, 250, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 0, 'plate': 488, 'invoices': 1}), ({'trips': [[63, 525, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 1109, 'invoices': 1}), ({'trips': [[61, 333, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 284, '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': [[27, 250, 'tag'], [39, 410, 'plate'], [68, 525, 'tag'], [60, 525, 'plate'], [21, 175, 'tag'], [32, 250, 'exempt'], [67, 410, 'exempt'], [95, 410, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 904, 'plate': 1370, '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': [[91, 333, 'exempt'], [12, 525, 'tag'], [73, 175, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 499, 'plate': 619, 'invoices': 1}), ({'trips': [[54, 525, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 1109, 'invoices': 1}), ({'trips': [[48, 410, 'plate'], [33, 175, 'exempt'], [49, 175, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 0, 'plate': 882, 'invoices': 1}), ({'trips': [[1, 333, 'plate'], [37, 250, 'plate'], [50, 175, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 0, 'plate': 1425, 'invoices': 2}), ({'trips': [[21, 525, 'tag'], [11, 525, 'tag'], [62, 410, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 946, 'plate': 0, 'invoices': 0})], [({'trips': [[10, 410, 'plate'], [15, 250, 'exempt'], [21, 525, 'plate'], [36, 250, 'plate'], [56, 175, 'plate'], [35, 250, 'tag'], [94, 525, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 225, 'plate': 2809, 'invoices': 3}), ({'trips': [[25, 175, 'exempt'], [7, 175, 'exempt'], [95, 410, 'plate'], [12, 250, 'exempt'], [95, 175, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 0, 'plate': 932, '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': [[54, 410, 'tag'], [50, 250, 'plate'], [25, 333, 'tag'], [46, 333, 'plate'], [39, 333, 'plate'], [41, 175, 'plate'], [49, 175, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 633, 'plate': 1985, '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': [[81, 250, 'tag'], [14, 250, 'plate'], [37, 333, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 525, 'plate': 713, 'invoices': 1}), ({'trips': [[31, 525, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 0, 'plate': 909, 'invoices': 1}), ({'trips': [[46, 333, 'exempt'], [24, 250, 'tag'], [31, 175, 'plate'], [4, 250, 'exempt'], [28, 333, 'exempt'], [14, 250, 'tag'], [79, 410, 'plate'], [1, 525, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 426, 'plate': 1950, 'invoices': 3})], [({'trips': [[20, 410, 'plate'], [72, 525, 'plate'], [58, 525, 'plate'], [6, 250, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 0, 'plate': 2791, 'invoices': 3}), ({'trips': [[74, 250, 'plate'], [2, 250, 'plate'], [8, 525, 'plate'], [44, 175, 'tag'], [92, 250, 'plate'], [31, 175, 'plate'], [50, 333, 'plate'], [74, 250, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 362, 'plate': 3832, 'invoices': 4}), ({'trips': [[78, 250, 'tag'], [20, 250, 'plate'], [57, 175, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 225, 'plate': 775, 'invoices': 1}), ({'trips': [[15, 250, 'tag'], [8, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 628, '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': [[8, 333, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 0, 'plate': 617, 'invoices': 1}), ({'trips': [[46, 410, 'exempt'], [86, 525, 'plate'], [35, 250, 'tag'], [77, 333, 'tag'], [63, 250, 'plate'], [34, 250, 'exempt'], [50, 525, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 555, 'plate': 2351, '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': [[22, 175, 'plate'], [60, 250, 'plate'], [21, 333, 'tag'], [66, 333, 'plate'], [60, 525, 'plate'], [14, 250, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 555, 'plate': 2406, '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': [[68, 410, 'tag'], [4, 410, 'plate'], [20, 250, 'plate'], [32, 525, 'exempt'], [72, 250, 'plate'], [75, 250, 'plate'], [93, 525, 'plate'], [84, 250, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 3128, 'invoices': 3}), ({'trips': [[18, 250, 'plate'], [23, 175, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 167, 'plate': 713, 'invoices': 1}), ({'trips': [[27, 333, 'plate'], [18, 250, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 0, 'plate': 1075, 'invoices': 1}), ({'trips': [[51, 250, 'plate'], [31, 333, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 0, 'plate': 938, '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': [[3, 410, 'exempt'], [13, 250, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 213, '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': 382} | {'invoices': 0, 'plate': 0, 'tag': 383} | Failed |
| fee oracle 1 | {'invoices': 0, 'plate': 0, 'tag': 369} | {'invoices': 0, 'plate': 0, 'tag': 369} | Passed |
| fee oracle 2 | {'invoices': 1, 'plate': 650, 'tag': 0} | {'invoices': 1, 'plate': 650, 'tag': 0} | Passed |
| fee oracle 3 | {'invoices': 2, 'plate': 1436, 'tag': 579} | {'invoices': 2, 'plate': 1436, 'tag': 582} | Failed |
| fee oracle 4 | {'invoices': 2, 'plate': 1076, 'tag': 283} | {'invoices': 2, 'plate': 1076, 'tag': 284} | Failed |
| fee oracle 5 | {'invoices': 1, 'plate': 488, 'tag': 0} | {'invoices': 1, 'plate': 488, 'tag': 0} | Passed |
| fee oracle 6 | {'invoices': 1, 'plate': 1109, 'tag': 0} | {'invoices': 1, 'plate': 1109, 'tag': 0} | Passed |
| fee oracle 7 | {'invoices': 0, 'plate': 0, 'tag': 283} | {'invoices': 0, 'plate': 0, 'tag': 284} | Failed |
SHA-256 / ed3cdf81f8fecd89d74da2106b08252d1d49e26f322b197c522c5d63890e2900
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': [[91, 175, 'tag'], [42, 250, 'tag'], [44, 333, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 383, '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': [[76, 333, 'plate'], [50, 525, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 0, 'plate': 650, 'invoices': 1}), ({'trips': [[26, 333, 'tag'], [88, 175, 'tag'], [11, 525, 'exempt'], [80, 175, 'tag'], [18, 175, 'plate'], [51, 333, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 582, 'plate': 1436, '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': [[40, 250, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 0, 'plate': 488, 'invoices': 1}), ({'trips': [[63, 525, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 1109, 'invoices': 1}), ({'trips': [[61, 333, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 284, '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': [[27, 250, 'tag'], [39, 410, 'plate'], [68, 525, 'tag'], [60, 525, 'plate'], [21, 175, 'tag'], [32, 250, 'exempt'], [67, 410, 'exempt'], [95, 410, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 904, 'plate': 1370, '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': [[91, 333, 'exempt'], [12, 525, 'tag'], [73, 175, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 499, 'plate': 619, 'invoices': 1}), ({'trips': [[54, 525, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 1109, 'invoices': 1}), ({'trips': [[48, 410, 'plate'], [33, 175, 'exempt'], [49, 175, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 0, 'plate': 882, 'invoices': 1}), ({'trips': [[1, 333, 'plate'], [37, 250, 'plate'], [50, 175, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 0, 'plate': 1425, 'invoices': 2}), ({'trips': [[21, 525, 'tag'], [11, 525, 'tag'], [62, 410, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 946, 'plate': 0, 'invoices': 0})], [({'trips': [[10, 410, 'plate'], [15, 250, 'exempt'], [21, 525, 'plate'], [36, 250, 'plate'], [56, 175, 'plate'], [35, 250, 'tag'], [94, 525, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 225, 'plate': 2809, 'invoices': 3}), ({'trips': [[25, 175, 'exempt'], [7, 175, 'exempt'], [95, 410, 'plate'], [12, 250, 'exempt'], [95, 175, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 0, 'plate': 932, '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': [[54, 410, 'tag'], [50, 250, 'plate'], [25, 333, 'tag'], [46, 333, 'plate'], [39, 333, 'plate'], [41, 175, 'plate'], [49, 175, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 633, 'plate': 1985, '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': [[81, 250, 'tag'], [14, 250, 'plate'], [37, 333, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 525, 'plate': 713, 'invoices': 1}), ({'trips': [[31, 525, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 0, 'plate': 909, 'invoices': 1}), ({'trips': [[46, 333, 'exempt'], [24, 250, 'tag'], [31, 175, 'plate'], [4, 250, 'exempt'], [28, 333, 'exempt'], [14, 250, 'tag'], [79, 410, 'plate'], [1, 525, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 426, 'plate': 1950, 'invoices': 3})], [({'trips': [[20, 410, 'plate'], [72, 525, 'plate'], [58, 525, 'plate'], [6, 250, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 0, 'plate': 2791, 'invoices': 3}), ({'trips': [[74, 250, 'plate'], [2, 250, 'plate'], [8, 525, 'plate'], [44, 175, 'tag'], [92, 250, 'plate'], [31, 175, 'plate'], [50, 333, 'plate'], [74, 250, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 362, 'plate': 3832, 'invoices': 4}), ({'trips': [[78, 250, 'tag'], [20, 250, 'plate'], [57, 175, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 225, 'plate': 775, 'invoices': 1}), ({'trips': [[15, 250, 'tag'], [8, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 628, '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': [[8, 333, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 0, 'plate': 617, 'invoices': 1}), ({'trips': [[46, 410, 'exempt'], [86, 525, 'plate'], [35, 250, 'tag'], [77, 333, 'tag'], [63, 250, 'plate'], [34, 250, 'exempt'], [50, 525, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 555, 'plate': 2351, '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': [[22, 175, 'plate'], [60, 250, 'plate'], [21, 333, 'tag'], [66, 333, 'plate'], [60, 525, 'plate'], [14, 250, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 555, 'plate': 2406, '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': [[68, 410, 'tag'], [4, 410, 'plate'], [20, 250, 'plate'], [32, 525, 'exempt'], [72, 250, 'plate'], [75, 250, 'plate'], [93, 525, 'plate'], [84, 250, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 3128, 'invoices': 3}), ({'trips': [[18, 250, 'plate'], [23, 175, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 167, 'plate': 713, 'invoices': 1}), ({'trips': [[27, 333, 'plate'], [18, 250, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 0, 'plate': 1075, 'invoices': 1}), ({'trips': [[51, 250, 'plate'], [31, 333, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 0, 'plate': 938, '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': [[3, 410, 'exempt'], [13, 250, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 213, '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': 383} | {'invoices': 0, 'plate': 0, 'tag': 383} | Passed |
| fee oracle 1 | {'invoices': 0, 'plate': 0, 'tag': 369} | {'invoices': 0, 'plate': 0, 'tag': 369} | Passed |
| fee oracle 2 | {'invoices': 1, 'plate': 650, 'tag': 0} | {'invoices': 1, 'plate': 650, 'tag': 0} | Passed |
| fee oracle 3 | {'invoices': 2, 'plate': 1436, 'tag': 582} | {'invoices': 2, 'plate': 1436, 'tag': 582} | Passed |
| fee oracle 4 | {'invoices': 2, 'plate': 1076, 'tag': 284} | {'invoices': 2, 'plate': 1076, 'tag': 284} | Passed |
| fee oracle 5 | {'invoices': 1, 'plate': 488, 'tag': 0} | {'invoices': 1, 'plate': 488, 'tag': 0} | Passed |
| fee oracle 6 | {'invoices': 1, 'plate': 1109, 'tag': 0} | {'invoices': 1, 'plate': 1109, 'tag': 0} | Passed |
| fee oracle 7 | {'invoices': 0, 'plate': 0, 'tag': 284} | {'invoices': 0, 'plate': 0, 'tag': 284} | Passed |
SHA-256 / 520394fc2a5497e3d43a9094efb07f63c05a8ed62b5189c57d19386c301a2b8d
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.734171+00:00.
Case digest / 468676d984091687bf29dcf4fd5f215c97801a30cb2fba0f94396bdad00fdb41