FA-68581 / Toll and parking fee computation / Open access
Express lane dynamic price: the HOV2 price is not floored to 5 cents · case 01
Express lane dynamic price returns a wrong result when the HOV2 price is not floored to 5 cents.
ROOT CAUSE
HOV2 charges like 227 cents are billed instead of the 5 cent grid.
VERIFIED REPAIR
Restore the HOV2 discount rounding rule so that the step reads `price * x['hov2_pct'] // 100 // 5 * 5`.
Unsuccessful approach: Rounding before applying the percentage still leaves off-grid results.
Case contract
Input {density, prev_price, bands: [[density upto, price]] ascending, max_step, min_price, max_price, occupancy, hov_free_min, hov2_pct}. The target is the first band whose upto is >= density, else max_price. The posted price moves from prev_price toward the target by at most max_step either way, then is clamped to [min_price, max_price]. Vehicles with occupancy >= hov_free_min pay 0; occupancy 2 (when not free) pays hov2_pct percent floored to 5 cents. Return [posted, charged].
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):
target = x['max_price']
for upto, price in x['bands']:
if x['density'] <= upto:
target = price
break
prev = x['prev_price']
step = max(-x['max_step'], min(x['max_step'], target - prev))
price = max(x['min_price'], min(x['max_price'], prev + step))
if x['occupancy'] >= x['hov_free_min']:
return [price, 0]
if x['occupancy'] == 2:
return [price, price * x['hov2_pct'] // 100]
return [price, price]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'density': 45, 'prev_price': 1100, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [1000, 1000]), ({'density': 21, 'prev_price': 50, 'bands': [[10, 350], [18, 575], [35, 850], [43, 875]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 50}, [75, 35]), ({'density': 20, 'prev_price': 300, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [350, 245]), ({'density': 25, 'prev_price': 0, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [50, 50]), ({'density': 32, 'prev_price': 1175, 'bands': [[15, 250], [16, 350], [21, 700], [32, 950]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 2, 'hov2_pct': 50}, [1000, 1000]), ({'density': 16, 'prev_price': 150, 'bands': [[10, 125], [16, 275], [23, 450], [35, 575]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 3, 'hov_free_min': 4, 'hov2_pct': 70}, [250, 250]), ({'density': 23, 'prev_price': 200, 'bands': [[12, 250], [23, 275], [24, 350], [34, 625]], 'max_step': 100, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 70}, [275, 190]), ({'density': 19, 'prev_price': 825, 'bands': [[17, 50], [19, 75], [30, 475], [35, 550]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 50}, [725, 360])], [({'density': 12, 'prev_price': 1200, 'bands': [[12, 325], [14, 475], [18, 700], [22, 800]], 'max_step': 100, 'min_price': 50, 'max_price': 1200, 'occupancy': 1, 'hov_free_min': 2, 'hov2_pct': 50}, [1100, 1100]), ({'density': 25, 'prev_price': 725, 'bands': [[11, 225], [15, 350], [25, 500], [40, 750]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [625, 435]), ({'density': 38, 'prev_price': 400, 'bands': [[17, 625], [22, 775], [35, 850], [38, 950]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [425, 295]), ({'density': 45, 'prev_price': 1100, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [1000, 1000]), ({'density': 11, 'prev_price': 500, 'bands': [[11, 100], [28, 350], [39, 875], [43, 950]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 2, 'hov2_pct': 70}, [450, 0]), ({'density': 21, 'prev_price': 425, 'bands': [[21, 225], [23, 825], [25, 875], [37, 950]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 50}, [325, 160]), ({'density': 25, 'prev_price': 0, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [50, 50]), ({'density': 20, 'prev_price': 300, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [350, 245])], [({'density': 20, 'prev_price': 300, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [350, 245]), ({'density': 25, 'prev_price': 0, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [50, 50]), ({'density': 12, 'prev_price': 325, 'bands': [[12, 75], [16, 150], [25, 200], [34, 825]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 50}, [275, 135]), ({'density': 27, 'prev_price': 375, 'bands': [[17, 75], [27, 425], [35, 650], [40, 950]], 'max_step': 100, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 50}, [425, 210]), ({'density': 15, 'prev_price': 300, 'bands': [[15, 250], [26, 425], [39, 500], [41, 600]], 'max_step': 50, 'min_price': 50, 'max_price': 1200, 'occupancy': 1, 'hov_free_min': 4, 'hov2_pct': 70}, [250, 250]), ({'density': 44, 'prev_price': 1250, 'bands': [[30, 125], [34, 175], [38, 325], [44, 650]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [1000, 0]), ({'density': 45, 'prev_price': 1100, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [1000, 1000]), ({'density': 29, 'prev_price': 1000, 'bands': [[14, 100], [26, 125], [27, 375], [40, 550]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 50}, [975, 485])], [({'density': 36, 'prev_price': 1300, 'bands': [[18, 75], [24, 475], [28, 675], [36, 1000]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [800, 800]), ({'density': 14, 'prev_price': 1200, 'bands': [[14, 75], [17, 100], [19, 250], [35, 1000]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 50}, [1175, 585]), ({'density': 12, 'prev_price': 325, 'bands': [[12, 175], [19, 400], [30, 875], [31, 900]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 70}, [225, 155]), ({'density': 35, 'prev_price': 275, 'bands': [[17, 50], [31, 200], [35, 650], [36, 900]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 4, 'hov_free_min': 3, 'hov2_pct': 70}, [375, 0]), ({'density': 45, 'prev_price': 1100, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [1000, 1000]), ({'density': 25, 'prev_price': 0, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [50, 50]), ({'density': 32, 'prev_price': 900, 'bands': [[10, 50], [32, 300], [36, 400], [44, 950]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [875, 610]), ({'density': 20, 'prev_price': 300, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [350, 245])], [({'density': 11, 'prev_price': 1100, 'bands': [[11, 300], [12, 550], [30, 575], [31, 800]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 50}, [1075, 535]), ({'density': 36, 'prev_price': 325, 'bands': [[11, 225], [36, 525], [37, 900], [42, 950]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 50}, [425, 210]), ({'density': 50, 'prev_price': 50, 'bands': [[21, 50], [26, 150], [32, 625], [36, 850]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 50}, [100, 50]), ({'density': 45, 'prev_price': 1100, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [1000, 1000]), ({'density': 23, 'prev_price': 1175, 'bands': [[29, 75], [34, 675], [39, 850], [42, 1000]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 4, 'hov_free_min': 2, 'hov2_pct': 50}, [1150, 0]), ({'density': 35, 'prev_price': 825, 'bands': [[14, 50], [15, 300], [35, 600], [36, 750]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 50}, [725, 360]), ({'density': 20, 'prev_price': 300, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [350, 245]), ({'density': 25, 'prev_price': 0, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [50, 50])]]
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 | [1000, 1000] | [1000, 1000] | Passed |
| fee oracle 1 | [75, 37] | [75, 35] | Failed |
| fee oracle 2 | [350, 245] | [350, 245] | Passed |
| fee oracle 3 | [50, 50] | [50, 50] | Passed |
| fee oracle 4 | [1000, 1000] | [1000, 1000] | Passed |
| fee oracle 5 | [250, 250] | [250, 250] | Passed |
| fee oracle 6 | [275, 192] | [275, 190] | Failed |
| fee oracle 7 | [725, 362] | [725, 360] | Failed |
SHA-256 / 5e6db0e04192ed9bee0040fc2c66c1f902f49e2621639a499f2d02a67c313444
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
target = x['max_price']
for upto, price in x['bands']:
if x['density'] <= upto:
target = price
break
prev = x['prev_price']
step = max(-x['max_step'], min(x['max_step'], target - prev))
price = max(x['min_price'], min(x['max_price'], prev + step))
if x['occupancy'] >= x['hov_free_min']:
return [price, 0]
if x['occupancy'] == 2:
return [price, price // 5 * 5 * x['hov2_pct'] // 100]
return [price, price]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'density': 45, 'prev_price': 1100, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [1000, 1000]), ({'density': 21, 'prev_price': 50, 'bands': [[10, 350], [18, 575], [35, 850], [43, 875]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 50}, [75, 35]), ({'density': 20, 'prev_price': 300, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [350, 245]), ({'density': 25, 'prev_price': 0, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [50, 50]), ({'density': 32, 'prev_price': 1175, 'bands': [[15, 250], [16, 350], [21, 700], [32, 950]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 2, 'hov2_pct': 50}, [1000, 1000]), ({'density': 16, 'prev_price': 150, 'bands': [[10, 125], [16, 275], [23, 450], [35, 575]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 3, 'hov_free_min': 4, 'hov2_pct': 70}, [250, 250]), ({'density': 23, 'prev_price': 200, 'bands': [[12, 250], [23, 275], [24, 350], [34, 625]], 'max_step': 100, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 70}, [275, 190]), ({'density': 19, 'prev_price': 825, 'bands': [[17, 50], [19, 75], [30, 475], [35, 550]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 50}, [725, 360])], [({'density': 12, 'prev_price': 1200, 'bands': [[12, 325], [14, 475], [18, 700], [22, 800]], 'max_step': 100, 'min_price': 50, 'max_price': 1200, 'occupancy': 1, 'hov_free_min': 2, 'hov2_pct': 50}, [1100, 1100]), ({'density': 25, 'prev_price': 725, 'bands': [[11, 225], [15, 350], [25, 500], [40, 750]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [625, 435]), ({'density': 38, 'prev_price': 400, 'bands': [[17, 625], [22, 775], [35, 850], [38, 950]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [425, 295]), ({'density': 45, 'prev_price': 1100, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [1000, 1000]), ({'density': 11, 'prev_price': 500, 'bands': [[11, 100], [28, 350], [39, 875], [43, 950]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 2, 'hov2_pct': 70}, [450, 0]), ({'density': 21, 'prev_price': 425, 'bands': [[21, 225], [23, 825], [25, 875], [37, 950]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 50}, [325, 160]), ({'density': 25, 'prev_price': 0, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [50, 50]), ({'density': 20, 'prev_price': 300, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [350, 245])], [({'density': 20, 'prev_price': 300, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [350, 245]), ({'density': 25, 'prev_price': 0, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [50, 50]), ({'density': 12, 'prev_price': 325, 'bands': [[12, 75], [16, 150], [25, 200], [34, 825]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 50}, [275, 135]), ({'density': 27, 'prev_price': 375, 'bands': [[17, 75], [27, 425], [35, 650], [40, 950]], 'max_step': 100, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 50}, [425, 210]), ({'density': 15, 'prev_price': 300, 'bands': [[15, 250], [26, 425], [39, 500], [41, 600]], 'max_step': 50, 'min_price': 50, 'max_price': 1200, 'occupancy': 1, 'hov_free_min': 4, 'hov2_pct': 70}, [250, 250]), ({'density': 44, 'prev_price': 1250, 'bands': [[30, 125], [34, 175], [38, 325], [44, 650]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [1000, 0]), ({'density': 45, 'prev_price': 1100, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [1000, 1000]), ({'density': 29, 'prev_price': 1000, 'bands': [[14, 100], [26, 125], [27, 375], [40, 550]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 50}, [975, 485])], [({'density': 36, 'prev_price': 1300, 'bands': [[18, 75], [24, 475], [28, 675], [36, 1000]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [800, 800]), ({'density': 14, 'prev_price': 1200, 'bands': [[14, 75], [17, 100], [19, 250], [35, 1000]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 50}, [1175, 585]), ({'density': 12, 'prev_price': 325, 'bands': [[12, 175], [19, 400], [30, 875], [31, 900]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 70}, [225, 155]), ({'density': 35, 'prev_price': 275, 'bands': [[17, 50], [31, 200], [35, 650], [36, 900]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 4, 'hov_free_min': 3, 'hov2_pct': 70}, [375, 0]), ({'density': 45, 'prev_price': 1100, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [1000, 1000]), ({'density': 25, 'prev_price': 0, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [50, 50]), ({'density': 32, 'prev_price': 900, 'bands': [[10, 50], [32, 300], [36, 400], [44, 950]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [875, 610]), ({'density': 20, 'prev_price': 300, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [350, 245])], [({'density': 11, 'prev_price': 1100, 'bands': [[11, 300], [12, 550], [30, 575], [31, 800]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 50}, [1075, 535]), ({'density': 36, 'prev_price': 325, 'bands': [[11, 225], [36, 525], [37, 900], [42, 950]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 50}, [425, 210]), ({'density': 50, 'prev_price': 50, 'bands': [[21, 50], [26, 150], [32, 625], [36, 850]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 50}, [100, 50]), ({'density': 45, 'prev_price': 1100, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [1000, 1000]), ({'density': 23, 'prev_price': 1175, 'bands': [[29, 75], [34, 675], [39, 850], [42, 1000]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 4, 'hov_free_min': 2, 'hov2_pct': 50}, [1150, 0]), ({'density': 35, 'prev_price': 825, 'bands': [[14, 50], [15, 300], [35, 600], [36, 750]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 50}, [725, 360]), ({'density': 20, 'prev_price': 300, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [350, 245]), ({'density': 25, 'prev_price': 0, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [50, 50])]]
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 | [1000, 1000] | [1000, 1000] | Passed |
| fee oracle 1 | [75, 37] | [75, 35] | Failed |
| fee oracle 2 | [350, 245] | [350, 245] | Passed |
| fee oracle 3 | [50, 50] | [50, 50] | Passed |
| fee oracle 4 | [1000, 1000] | [1000, 1000] | Passed |
| fee oracle 5 | [250, 250] | [250, 250] | Passed |
| fee oracle 6 | [275, 192] | [275, 190] | Failed |
| fee oracle 7 | [725, 362] | [725, 360] | Failed |
SHA-256 / 3aa4a7f58b2dc2594a6df1f870b993f6168500346025ee4e622269e18d53bc14
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
target = x['max_price']
for upto, price in x['bands']:
if x['density'] <= upto:
target = price
break
prev = x['prev_price']
step = max(-x['max_step'], min(x['max_step'], target - prev))
price = max(x['min_price'], min(x['max_price'], prev + step))
if x['occupancy'] >= x['hov_free_min']:
return [price, 0]
if x['occupancy'] == 2:
return [price, price * x['hov2_pct'] // 100 // 5 * 5]
return [price, price]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'density': 45, 'prev_price': 1100, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [1000, 1000]), ({'density': 21, 'prev_price': 50, 'bands': [[10, 350], [18, 575], [35, 850], [43, 875]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 50}, [75, 35]), ({'density': 20, 'prev_price': 300, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [350, 245]), ({'density': 25, 'prev_price': 0, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [50, 50]), ({'density': 32, 'prev_price': 1175, 'bands': [[15, 250], [16, 350], [21, 700], [32, 950]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 2, 'hov2_pct': 50}, [1000, 1000]), ({'density': 16, 'prev_price': 150, 'bands': [[10, 125], [16, 275], [23, 450], [35, 575]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 3, 'hov_free_min': 4, 'hov2_pct': 70}, [250, 250]), ({'density': 23, 'prev_price': 200, 'bands': [[12, 250], [23, 275], [24, 350], [34, 625]], 'max_step': 100, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 70}, [275, 190]), ({'density': 19, 'prev_price': 825, 'bands': [[17, 50], [19, 75], [30, 475], [35, 550]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 50}, [725, 360])], [({'density': 12, 'prev_price': 1200, 'bands': [[12, 325], [14, 475], [18, 700], [22, 800]], 'max_step': 100, 'min_price': 50, 'max_price': 1200, 'occupancy': 1, 'hov_free_min': 2, 'hov2_pct': 50}, [1100, 1100]), ({'density': 25, 'prev_price': 725, 'bands': [[11, 225], [15, 350], [25, 500], [40, 750]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [625, 435]), ({'density': 38, 'prev_price': 400, 'bands': [[17, 625], [22, 775], [35, 850], [38, 950]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [425, 295]), ({'density': 45, 'prev_price': 1100, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [1000, 1000]), ({'density': 11, 'prev_price': 500, 'bands': [[11, 100], [28, 350], [39, 875], [43, 950]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 2, 'hov2_pct': 70}, [450, 0]), ({'density': 21, 'prev_price': 425, 'bands': [[21, 225], [23, 825], [25, 875], [37, 950]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 50}, [325, 160]), ({'density': 25, 'prev_price': 0, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [50, 50]), ({'density': 20, 'prev_price': 300, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [350, 245])], [({'density': 20, 'prev_price': 300, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [350, 245]), ({'density': 25, 'prev_price': 0, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [50, 50]), ({'density': 12, 'prev_price': 325, 'bands': [[12, 75], [16, 150], [25, 200], [34, 825]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 50}, [275, 135]), ({'density': 27, 'prev_price': 375, 'bands': [[17, 75], [27, 425], [35, 650], [40, 950]], 'max_step': 100, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 50}, [425, 210]), ({'density': 15, 'prev_price': 300, 'bands': [[15, 250], [26, 425], [39, 500], [41, 600]], 'max_step': 50, 'min_price': 50, 'max_price': 1200, 'occupancy': 1, 'hov_free_min': 4, 'hov2_pct': 70}, [250, 250]), ({'density': 44, 'prev_price': 1250, 'bands': [[30, 125], [34, 175], [38, 325], [44, 650]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [1000, 0]), ({'density': 45, 'prev_price': 1100, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [1000, 1000]), ({'density': 29, 'prev_price': 1000, 'bands': [[14, 100], [26, 125], [27, 375], [40, 550]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 50}, [975, 485])], [({'density': 36, 'prev_price': 1300, 'bands': [[18, 75], [24, 475], [28, 675], [36, 1000]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [800, 800]), ({'density': 14, 'prev_price': 1200, 'bands': [[14, 75], [17, 100], [19, 250], [35, 1000]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 50}, [1175, 585]), ({'density': 12, 'prev_price': 325, 'bands': [[12, 175], [19, 400], [30, 875], [31, 900]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 70}, [225, 155]), ({'density': 35, 'prev_price': 275, 'bands': [[17, 50], [31, 200], [35, 650], [36, 900]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 4, 'hov_free_min': 3, 'hov2_pct': 70}, [375, 0]), ({'density': 45, 'prev_price': 1100, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [1000, 1000]), ({'density': 25, 'prev_price': 0, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [50, 50]), ({'density': 32, 'prev_price': 900, 'bands': [[10, 50], [32, 300], [36, 400], [44, 950]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [875, 610]), ({'density': 20, 'prev_price': 300, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [350, 245])], [({'density': 11, 'prev_price': 1100, 'bands': [[11, 300], [12, 550], [30, 575], [31, 800]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 50}, [1075, 535]), ({'density': 36, 'prev_price': 325, 'bands': [[11, 225], [36, 525], [37, 900], [42, 950]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 2, 'hov_free_min': 4, 'hov2_pct': 50}, [425, 210]), ({'density': 50, 'prev_price': 50, 'bands': [[21, 50], [26, 150], [32, 625], [36, 850]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 50}, [100, 50]), ({'density': 45, 'prev_price': 1100, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [1000, 1000]), ({'density': 23, 'prev_price': 1175, 'bands': [[29, 75], [34, 675], [39, 850], [42, 1000]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 4, 'hov_free_min': 2, 'hov2_pct': 50}, [1150, 0]), ({'density': 35, 'prev_price': 825, 'bands': [[14, 50], [15, 300], [35, 600], [36, 750]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 50}, [725, 360]), ({'density': 20, 'prev_price': 300, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [350, 245]), ({'density': 25, 'prev_price': 0, 'bands': [[12, 100], [20, 400], [30, 700], [40, 900]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [50, 50])]]
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 | [1000, 1000] | [1000, 1000] | Passed |
| fee oracle 1 | [75, 35] | [75, 35] | Passed |
| fee oracle 2 | [350, 245] | [350, 245] | Passed |
| fee oracle 3 | [50, 50] | [50, 50] | Passed |
| fee oracle 4 | [1000, 1000] | [1000, 1000] | Passed |
| fee oracle 5 | [250, 250] | [250, 250] | Passed |
| fee oracle 6 | [275, 190] | [275, 190] | Passed |
| fee oracle 7 | [725, 360] | [725, 360] | Passed |
SHA-256 / aa3f1b90f053f462a3a130c5ec458888db5479c88459e5addb1b16c4622f83fb
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.521533+00:00.
Case digest / e6d9d82cb835252127176c1cb5fd11bb6079d67b234c5b0190f73293a88c40e6