broken_source:
"""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': 33, 'prev_price': 975, 'bands': [[26, 225], [33, 250], [37, 350], [38, 775]], 'max_step': 25, 'min_price': 50, 'max_price': 800, 'occupancy': 2, 'hov_free_min': 2, 'hov2_pct': 50}, [800, 0]), ({'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': 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': 14, 'prev_price': 1100, 'bands': [[14, 125], [20, 175], [23, 475], [37, 800]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [1000, 0]), ({'density': 41, 'prev_price': 475, 'bands': [[18, 400], [21, 850], [41, 925], [43, 1000]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 3, 'hov_free_min': 4, 'hov2_pct': 70}, [575, 575]), ({'density': 16, 'prev_price': 1100, 'bands': [[16, 275], [18, 500], [29, 800], [30, 975]], 'max_step': 50, 'min_price': 50, 'max_price': 800, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [800, 0]), ({'density': 22, 'prev_price': 25, 'bands': [[22, 200], [26, 250], [34, 525], [42, 825]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [125, 0])], [({'density': 20, 'prev_price': 575, 'bands': [[16, 50], [17, 225], [20, 325], [35, 575]], 'max_step': 25, 'min_price': 50, 'max_price': 800, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [550, 0]), ({'density': 25, 'prev_price': 800, 'bands': [[19, 50], [23, 450], [38, 650], [39, 775]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 70}, [700, 0]), ({'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': 12, 'prev_price': 450, 'bands': [[12, 75], [35, 400], [42, 800], [44, 825]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 2, 'hov2_pct': 70}, [400, 0]), ({'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': 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': 24, 'prev_price': 600, 'bands': [[11, 75], [21, 675], [24, 850], [36, 925]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [625, 0]), ({'density': 41, 'prev_price': 0, 'bands': [[13, 400], [14, 550], [24, 775], [39, 975]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 3, 'hov_free_min': 4, 'hov2_pct': 50}, [100, 100])], [({'density': 34, 'prev_price': 1125, 'bands': [[16, 200], [23, 450], [32, 600], [34, 875]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 3, 'hov_free_min': 4, 'hov2_pct': 70}, [1100, 1100]), ({'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': 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': 18, 'prev_price': 200, 'bands': [[18, 200], [26, 300], [38, 475], [40, 825]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [200, 0]), ({'density': 26, 'prev_price': 1050, 'bands': [[15, 225], [23, 250], [29, 650], [40, 1000]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 4, 'hov_free_min': 4, 'hov2_pct': 70}, [1025, 0]), ({'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': 26, 'prev_price': 750, 'bands': [[13, 50], [22, 625], [26, 875], [43, 1000]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [800, 800]), ({'density': 18, 'prev_price': 0, 'bands': [[16, 150], [18, 550], [36, 675], [41, 1000]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 2, 'hov2_pct': 50}, [50, 0])], [({'density': 41, 'prev_price': 325, 'bands': [[16, 100], [25, 225], [32, 500], [44, 675]], 'max_step': 25, 'min_price': 50, 'max_price': 800, 'occupancy': 2, 'hov_free_min': 2, 'hov2_pct': 70}, [350, 0]), ({'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': 34, 'prev_price': 550, 'bands': [[21, 50], [27, 525], [32, 675], [34, 750]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 4, 'hov_free_min': 4, 'hov2_pct': 50}, [650, 0]), ({'density': 17, 'prev_price': 1025, 'bands': [[10, 325], [17, 350], [29, 550], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 800, 'occupancy': 3, 'hov_free_min': 4, 'hov2_pct': 50}, [800, 800]), ({'density': 21, 'prev_price': 775, 'bands': [[18, 50], [21, 75], [23, 775], [37, 925]], 'max_step': 100, 'min_price': 50, 'max_price': 1200, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 70}, [675, 0]), ({'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': 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': 1200, 'bands': [[21, 125], [23, 175], [25, 325], [37, 725]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [1000, 1000])], [({'density': 29, 'prev_price': 350, 'bands': [[11, 200], [12, 425], [29, 550], [43, 750]], 'max_step': 50, 'min_price': 50, 'max_price': 800, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [400, 0]), ({'density': 41, 'prev_price': 800, 'bands': [[12, 125], [15, 150], [18, 475], [41, 575]], 'max_step': 50, 'min_price': 50, 'max_price': 1200, 'occupancy': 3, 'hov_free_min': 4, 'hov2_pct': 70}, [750, 750]), ({'density': 35, 'prev_price': 1275, 'bands': [[30, 200], [31, 475], [35, 550], [37, 675]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 3, 'hov_free_min': 4, 'hov2_pct': 50}, [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': 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': 34, 'prev_price': 1225, 'bands': [[15, 175], [28, 450], [32, 575], [34, 950]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 2, 'hov2_pct': 70}, [1000, 0]), ({'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': 39, 'prev_price': 100, 'bands': [[13, 375], [31, 450], [37, 725], [43, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 800, 'occupancy': 4, 'hov_free_min': 4, 'hov2_pct': 70}, [150, 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)

source:
"""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'] >= 3:
        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': 33, 'prev_price': 975, 'bands': [[26, 225], [33, 250], [37, 350], [38, 775]], 'max_step': 25, 'min_price': 50, 'max_price': 800, 'occupancy': 2, 'hov_free_min': 2, 'hov2_pct': 50}, [800, 0]), ({'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': 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': 14, 'prev_price': 1100, 'bands': [[14, 125], [20, 175], [23, 475], [37, 800]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [1000, 0]), ({'density': 41, 'prev_price': 475, 'bands': [[18, 400], [21, 850], [41, 925], [43, 1000]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 3, 'hov_free_min': 4, 'hov2_pct': 70}, [575, 575]), ({'density': 16, 'prev_price': 1100, 'bands': [[16, 275], [18, 500], [29, 800], [30, 975]], 'max_step': 50, 'min_price': 50, 'max_price': 800, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [800, 0]), ({'density': 22, 'prev_price': 25, 'bands': [[22, 200], [26, 250], [34, 525], [42, 825]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [125, 0])], [({'density': 20, 'prev_price': 575, 'bands': [[16, 50], [17, 225], [20, 325], [35, 575]], 'max_step': 25, 'min_price': 50, 'max_price': 800, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [550, 0]), ({'density': 25, 'prev_price': 800, 'bands': [[19, 50], [23, 450], [38, 650], [39, 775]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 70}, [700, 0]), ({'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': 12, 'prev_price': 450, 'bands': [[12, 75], [35, 400], [42, 800], [44, 825]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 2, 'hov2_pct': 70}, [400, 0]), ({'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': 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': 24, 'prev_price': 600, 'bands': [[11, 75], [21, 675], [24, 850], [36, 925]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [625, 0]), ({'density': 41, 'prev_price': 0, 'bands': [[13, 400], [14, 550], [24, 775], [39, 975]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 3, 'hov_free_min': 4, 'hov2_pct': 50}, [100, 100])], [({'density': 34, 'prev_price': 1125, 'bands': [[16, 200], [23, 450], [32, 600], [34, 875]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 3, 'hov_free_min': 4, 'hov2_pct': 70}, [1100, 1100]), ({'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': 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': 18, 'prev_price': 200, 'bands': [[18, 200], [26, 300], [38, 475], [40, 825]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [200, 0]), ({'density': 26, 'prev_price': 1050, 'bands': [[15, 225], [23, 250], [29, 650], [40, 1000]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 4, 'hov_free_min': 4, 'hov2_pct': 70}, [1025, 0]), ({'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': 26, 'prev_price': 750, 'bands': [[13, 50], [22, 625], [26, 875], [43, 1000]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [800, 800]), ({'density': 18, 'prev_price': 0, 'bands': [[16, 150], [18, 550], [36, 675], [41, 1000]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 2, 'hov2_pct': 50}, [50, 0])], [({'density': 41, 'prev_price': 325, 'bands': [[16, 100], [25, 225], [32, 500], [44, 675]], 'max_step': 25, 'min_price': 50, 'max_price': 800, 'occupancy': 2, 'hov_free_min': 2, 'hov2_pct': 70}, [350, 0]), ({'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': 34, 'prev_price': 550, 'bands': [[21, 50], [27, 525], [32, 675], [34, 750]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 4, 'hov_free_min': 4, 'hov2_pct': 50}, [650, 0]), ({'density': 17, 'prev_price': 1025, 'bands': [[10, 325], [17, 350], [29, 550], [40, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 800, 'occupancy': 3, 'hov_free_min': 4, 'hov2_pct': 50}, [800, 800]), ({'density': 21, 'prev_price': 775, 'bands': [[18, 50], [21, 75], [23, 775], [37, 925]], 'max_step': 100, 'min_price': 50, 'max_price': 1200, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 70}, [675, 0]), ({'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': 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': 1200, 'bands': [[21, 125], [23, 175], [25, 325], [37, 725]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [1000, 1000])], [({'density': 29, 'prev_price': 350, 'bands': [[11, 200], [12, 425], [29, 550], [43, 750]], 'max_step': 50, 'min_price': 50, 'max_price': 800, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [400, 0]), ({'density': 41, 'prev_price': 800, 'bands': [[12, 125], [15, 150], [18, 475], [41, 575]], 'max_step': 50, 'min_price': 50, 'max_price': 1200, 'occupancy': 3, 'hov_free_min': 4, 'hov2_pct': 70}, [750, 750]), ({'density': 35, 'prev_price': 1275, 'bands': [[30, 200], [31, 475], [35, 550], [37, 675]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 3, 'hov_free_min': 4, 'hov2_pct': 50}, [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': 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': 34, 'prev_price': 1225, 'bands': [[15, 175], [28, 450], [32, 575], [34, 950]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 2, 'hov2_pct': 70}, [1000, 0]), ({'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': 39, 'prev_price': 100, 'bands': [[13, 375], [31, 450], [37, 725], [43, 900]], 'max_step': 50, 'min_price': 50, 'max_price': 800, 'occupancy': 4, 'hov_free_min': 4, 'hov2_pct': 70}, [150, 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)

prompt:
Express lane dynamic price returns a wrong result when the HOV free threshold is hard-coded.

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].

split: open-access


broken_source:
"""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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""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)

prompt:
Express lane dynamic price returns a wrong result when the HOV2 price is not floored to 5 cents.

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].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    target = x['bands'][-1][1]
    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': 50, 'prev_price': 775, 'bands': [[17, 175], [19, 425], [21, 700], [32, 750]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [800, 0]), ({'density': 38, 'prev_price': 225, 'bands': [[10, 225], [20, 575], [29, 650], [38, 750]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 1, 'hov_free_min': 4, 'hov2_pct': 50}, [250, 250]), ({'density': 26, 'prev_price': 1050, 'bands': [[24, 125], [26, 275], [27, 750], [43, 925]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 4, 'hov_free_min': 3, 'hov2_pct': 50}, [1025, 0]), ({'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': 36, 'prev_price': 1025, 'bands': [[17, 50], [22, 550], [27, 725], [35, 975]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 4, 'hov_free_min': 3, 'hov2_pct': 70}, [1050, 0]), ({'density': 43, 'prev_price': 1150, 'bands': [[10, 375], [12, 575], [21, 625], [36, 875]], 'max_step': 50, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 2, 'hov2_pct': 70}, [1200, 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': 45, 'prev_price': 775, 'bands': [[16, 175], [22, 200], [29, 225], [35, 450]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [800, 800]), ({'density': 48, 'prev_price': 950, 'bands': [[12, 100], [14, 175], [38, 500], [42, 925]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 4, 'hov2_pct': 70}, [1000, 1000]), ({'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': 45, 'prev_price': 700, 'bands': [[16, 50], [22, 475], [23, 675], [32, 700]], 'max_step': 50, 'min_price': 50, 'max_price': 800, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [750, 750]), ({'density': 29, 'prev_price': 0, 'bands': [[16, 675], [29, 850], [33, 875], [34, 975]], 'max_step': 25, 'min_price': 50, 'max_price': 800, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [50, 0]), ({'density': 36, 'prev_price': 225, 'bands': [[10, 75], [18, 300], [27, 625], [34, 900]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 70}, [250, 0])], [({'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': 45, 'prev_price': 900, 'bands': [[22, 200], [24, 325], [33, 800], [41, 925]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 2, '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': 49, 'prev_price': 900, 'bands': [[16, 650], [20, 850], [23, 925], [34, 950]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [1000, 1000]), ({'density': 14, 'prev_price': 525, 'bands': [[13, 200], [14, 350], [19, 850], [27, 925]], 'max_step': 25, 'min_price': 50, 'max_price': 800, 'occupancy': 4, 'hov_free_min': 2, 'hov2_pct': 70}, [500, 0]), ({'density': 48, 'prev_price': 175, 'bands': [[19, 275], [28, 325], [31, 675], [39, 725]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 4, 'hov_free_min': 2, 'hov2_pct': 50}, [225, 0]), ({'density': 50, 'prev_price': 1050, 'bands': [[11, 75], [15, 725], [29, 750], [32, 875]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 4, 'hov_free_min': 4, 'hov2_pct': 70}, [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': 48, 'prev_price': 900, 'bands': [[24, 250], [29, 275], [32, 975], [41, 1000]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 3, 'hov_free_min': 2, 'hov2_pct': 50}, [950, 0]), ({'density': 40, 'prev_price': 925, 'bands': [[12, 225], [32, 250], [34, 300], [37, 650]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 2, 'hov2_pct': 50}, [1000, 1000]), ({'density': 33, 'prev_price': 25, 'bands': [[20, 75], [21, 225], [33, 375], [34, 800]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [50, 35]), ({'density': 36, 'prev_price': 325, 'bands': [[26, 150], [33, 550], [36, 650], [38, 850]], 'max_step': 100, 'min_price': 50, 'max_price': 1200, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [425, 425]), ({'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': 50, 'prev_price': 50, 'bands': [[10, 375], [12, 475], [23, 525], [32, 575]], 'max_step': 100, 'min_price': 50, 'max_price': 1200, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [150, 150]), ({'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': 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': 45, 'prev_price': 800, 'bands': [[20, 50], [22, 350], [32, 450], [44, 575]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 50}, [825, 410]), ({'density': 45, 'prev_price': 1000, 'bands': [[19, 100], [30, 150], [34, 500], [37, 875]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 4, 'hov_free_min': 3, 'hov2_pct': 70}, [1000, 0]), ({'density': 50, 'prev_price': 425, 'bands': [[11, 200], [33, 250], [36, 500], [42, 625]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 2, 'hov2_pct': 70}, [525, 525]), ({'density': 45, 'prev_price': 700, 'bands': [[18, 50], [20, 425], [29, 675], [34, 800]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 4, 'hov_free_min': 2, 'hov2_pct': 70}, [750, 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': 33, 'prev_price': 1025, 'bands': [[17, 350], [20, 600], [33, 650], [38, 825]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 2, 'hov_free_min': 2, 'hov2_pct': 50}, [800, 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    target = x['prev_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': 50, 'prev_price': 775, 'bands': [[17, 175], [19, 425], [21, 700], [32, 750]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [800, 0]), ({'density': 38, 'prev_price': 225, 'bands': [[10, 225], [20, 575], [29, 650], [38, 750]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 1, 'hov_free_min': 4, 'hov2_pct': 50}, [250, 250]), ({'density': 26, 'prev_price': 1050, 'bands': [[24, 125], [26, 275], [27, 750], [43, 925]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 4, 'hov_free_min': 3, 'hov2_pct': 50}, [1025, 0]), ({'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': 36, 'prev_price': 1025, 'bands': [[17, 50], [22, 550], [27, 725], [35, 975]], 'max_step': 25, 'min_price': 50, 'max_price': 1200, 'occupancy': 4, 'hov_free_min': 3, 'hov2_pct': 70}, [1050, 0]), ({'density': 43, 'prev_price': 1150, 'bands': [[10, 375], [12, 575], [21, 625], [36, 875]], 'max_step': 50, 'min_price': 50, 'max_price': 1200, 'occupancy': 2, 'hov_free_min': 2, 'hov2_pct': 70}, [1200, 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': 45, 'prev_price': 775, 'bands': [[16, 175], [22, 200], [29, 225], [35, 450]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [800, 800]), ({'density': 48, 'prev_price': 950, 'bands': [[12, 100], [14, 175], [38, 500], [42, 925]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 4, 'hov2_pct': 70}, [1000, 1000]), ({'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': 45, 'prev_price': 700, 'bands': [[16, 50], [22, 475], [23, 675], [32, 700]], 'max_step': 50, 'min_price': 50, 'max_price': 800, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [750, 750]), ({'density': 29, 'prev_price': 0, 'bands': [[16, 675], [29, 850], [33, 875], [34, 975]], 'max_step': 25, 'min_price': 50, 'max_price': 800, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 50}, [50, 0]), ({'density': 36, 'prev_price': 225, 'bands': [[10, 75], [18, 300], [27, 625], [34, 900]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 3, 'hov_free_min': 3, 'hov2_pct': 70}, [250, 0])], [({'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': 45, 'prev_price': 900, 'bands': [[22, 200], [24, 325], [33, 800], [41, 925]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 2, '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': 49, 'prev_price': 900, 'bands': [[16, 650], [20, 850], [23, 925], [34, 950]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [1000, 1000]), ({'density': 14, 'prev_price': 525, 'bands': [[13, 200], [14, 350], [19, 850], [27, 925]], 'max_step': 25, 'min_price': 50, 'max_price': 800, 'occupancy': 4, 'hov_free_min': 2, 'hov2_pct': 70}, [500, 0]), ({'density': 48, 'prev_price': 175, 'bands': [[19, 275], [28, 325], [31, 675], [39, 725]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 4, 'hov_free_min': 2, 'hov2_pct': 50}, [225, 0]), ({'density': 50, 'prev_price': 1050, 'bands': [[11, 75], [15, 725], [29, 750], [32, 875]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 4, 'hov_free_min': 4, 'hov2_pct': 70}, [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': 48, 'prev_price': 900, 'bands': [[24, 250], [29, 275], [32, 975], [41, 1000]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 3, 'hov_free_min': 2, 'hov2_pct': 50}, [950, 0]), ({'density': 40, 'prev_price': 925, 'bands': [[12, 225], [32, 250], [34, 300], [37, 650]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 2, 'hov2_pct': 50}, [1000, 1000]), ({'density': 33, 'prev_price': 25, 'bands': [[20, 75], [21, 225], [33, 375], [34, 800]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 70}, [50, 35]), ({'density': 36, 'prev_price': 325, 'bands': [[26, 150], [33, 550], [36, 650], [38, 850]], 'max_step': 100, 'min_price': 50, 'max_price': 1200, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 50}, [425, 425]), ({'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': 50, 'prev_price': 50, 'bands': [[10, 375], [12, 475], [23, 525], [32, 575]], 'max_step': 100, 'min_price': 50, 'max_price': 1200, 'occupancy': 1, 'hov_free_min': 3, 'hov2_pct': 70}, [150, 150]), ({'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': 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': 45, 'prev_price': 800, 'bands': [[20, 50], [22, 350], [32, 450], [44, 575]], 'max_step': 25, 'min_price': 50, 'max_price': 1000, 'occupancy': 2, 'hov_free_min': 3, 'hov2_pct': 50}, [825, 410]), ({'density': 45, 'prev_price': 1000, 'bands': [[19, 100], [30, 150], [34, 500], [37, 875]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 4, 'hov_free_min': 3, 'hov2_pct': 70}, [1000, 0]), ({'density': 50, 'prev_price': 425, 'bands': [[11, 200], [33, 250], [36, 500], [42, 625]], 'max_step': 100, 'min_price': 50, 'max_price': 1000, 'occupancy': 1, 'hov_free_min': 2, 'hov2_pct': 70}, [525, 525]), ({'density': 45, 'prev_price': 700, 'bands': [[18, 50], [20, 425], [29, 675], [34, 800]], 'max_step': 50, 'min_price': 50, 'max_price': 1000, 'occupancy': 4, 'hov_free_min': 2, 'hov2_pct': 70}, [750, 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': 33, 'prev_price': 1025, 'bands': [[17, 350], [20, 600], [33, 650], [38, 825]], 'max_step': 100, 'min_price': 50, 'max_price': 800, 'occupancy': 2, 'hov_free_min': 2, 'hov2_pct': 50}, [800, 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)

prompt:
Express lane dynamic price returns a wrong result when densities beyond the table hold the previous price.

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].

split: open-access


broken_source:
"""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)
    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': [[14, 410, 'tag'], [35, 525, 'tag'], [37, 333, 'tag'], [82, 525, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 1206, 'plate': 1057, 'invoices': 1}), ({'trips': [[92, 525, 'plate'], [25, 250, 'exempt'], [84, 525, 'plate'], [83, 175, 'tag'], [49, 410, 'plate'], [76, 250, 'plate'], [82, 250, 'plate'], [2, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 458, 'plate': 3848, 'invoices': 3}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[85, 410, 'exempt'], [7, 410, 'plate'], [31, 175, 'plate'], [7, 410, 'exempt'], [58, 175, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 149, 'plate': 1532, 'invoices': 2}), ({'trips': [[83, 175, 'plate'], [80, 250, 'plate'], [2, 250, 'plate'], [84, 525, 'tag'], [1, 175, 'plate'], [14, 175, 'plate'], [4, 333, 'plate'], [76, 410, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 499, 'plate': 3454, 'invoices': 2}), ({'trips': [[49, 333, 'tag'], [86, 175, 'plate'], [46, 410, 'exempt'], [64, 333, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 568, 'plate': 419, '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': [[53, 410, 'tag'], [9, 250, 'plate'], [81, 525, 'exempt'], [50, 525, 'plate'], [44, 525, 'plate'], [88, 333, 'exempt']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 2156, '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': [[5, 250, 'exempt'], [20, 333, 'tag'], [44, 333, 'plate'], [5, 175, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 484, 'plate': 650, 'invoices': 1}), ({'trips': [[37, 250, 'exempt'], [61, 525, 'tag'], [38, 410, 'plate'], [90, 333, 'plate'], [72, 250, 'plate'], [79, 410, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 447, 'plate': 2156, 'invoices': 2}), ({'trips': [[70, 333, 'plate'], [91, 525, 'tag'], [91, 410, 'tag'], [81, 175, 'plate'], [44, 175, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 945, 'plate': 1087, 'invoices': 1}), ({'trips': [[68, 175, 'plate'], [69, 175, 'plate'], [28, 175, 'exempt'], [45, 175, 'plate'], [80, 410, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 349, 'plate': 1111, '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': [[41, 333, 'plate'], [81, 250, 'plate'], [31, 525, 'plate'], [93, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 284, 'plate': 2463, 'invoices': 2}), ({'trips': [[78, 410, 'tag'], [76, 410, 'tag'], [1, 525, 'tag'], [57, 410, 'plate'], [79, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 1580, 'plate': 913, 'invoices': 1})], [({'trips': [[30, 175, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 0, 'plate': 0, 'invoices': 0}), ({'trips': [[47, 333, 'plate'], [14, 525, 'tag'], [23, 333, 'exempt'], [70, 525, 'exempt'], [30, 250, 'plate'], [50, 410, 'plate'], [93, 175, 'tag'], [34, 525, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 1043, 'plate': 1443, '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': [[8, 250, 'tag'], [67, 175, 'plate'], [78, 410, 'plate'], [94, 175, 'exempt'], [0, 333, 'tag'], [85, 175, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 683, 'plate': 882, 'invoices': 1}), ({'trips': [[75, 525, 'tag'], [36, 333, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 447, 'plate': 617, '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': [[72, 250, 'tag'], [80, 250, 'tag'], [50, 410, 'plate'], [26, 333, 'exempt'], [57, 250, 'tag'], [95, 250, 'tag'], [34, 525, 'plate'], [42, 333, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 1136, 'plate': 1570, 'invoices': 1}), ({'trips': [[66, 250, 'plate'], [47, 333, 'tag'], [83, 250, 'tag'], [80, 525, 'plate'], [46, 333, 'tag'], [94, 250, 'plate'], [40, 333, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 825, 'plate': 2285, 'invoices': 3})], [({'trips': [[68, 525, 'tag'], [24, 410, 'tag'], [73, 333, 'plate'], [7, 175, 'tag'], [24, 525, 'plate'], [28, 175, 'plate'], [56, 525, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 945, 'plate': 2705, 'invoices': 3}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[66, 175, 'plate'], [90, 410, 'plate'], [22, 175, 'tag'], [32, 410, 'tag'], [12, 175, 'plate'], [1, 333, 'tag'], [7, 410, 'exempt'], [87, 250, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 827, 'plate': 1741, 'invoices': 3}), ({'trips': [[64, 525, 'plate'], [1, 410, 'tag'], [9, 333, 'plate'], [95, 333, 'tag'], [5, 410, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 707, 'plate': 2303, 'invoices': 2}), ({'trips': [[35, 410, 'tag'], [33, 175, 'tag'], [41, 175, 'tag'], [2, 175, 'tag'], [75, 250, 'tag'], [8, 525, 'plate'], [7, 525, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 1541, 'plate': 1057, 'invoices': 1}), ({'trips': [[9, 525, 'tag'], [51, 525, 'exempt'], [55, 175, 'plate'], [71, 525, 'plate'], [83, 175, 'plate'], [84, 333, 'plate'], [9, 250, 'plate'], [31, 333, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 447, 'plate': 2692, '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': [[60, 333, 'exempt'], [43, 525, 'tag'], [18, 525, 'tag'], [30, 250, 'plate'], [73, 525, 'exempt'], [73, 333, 'exempt'], [83, 250, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 946, 'plate': 525, 'invoices': 1})], [({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[82, 525, 'plate'], [0, 525, 'tag'], [10, 175, 'exempt'], [72, 525, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 499, 'plate': 1514, 'invoices': 1}), ({'trips': [[32, 333, 'tag'], [38, 333, 'plate'], [80, 175, 'plate'], [48, 175, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 284, 'plate': 1655, 'invoices': 2}), ({'trips': [[73, 525, 'tag'], [84, 525, 'plate'], [90, 250, 'plate'], [15, 175, 'plate'], [29, 333, 'tag'], [61, 525, 'plate'], [71, 250, 'exempt'], [52, 175, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 816, 'plate': 2446, 'invoices': 3}), ({'trips': [[81, 250, 'plate'], [66, 525, 'plate'], [45, 333, 'tag'], [38, 333, 'plate'], [61, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 707, 'plate': 1687, 'invoices': 2}), ({'trips': [[93, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 349, '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': [[66, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 317, '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)

source:
"""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 - 1) // 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': [[14, 410, 'tag'], [35, 525, 'tag'], [37, 333, 'tag'], [82, 525, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 1206, 'plate': 1057, 'invoices': 1}), ({'trips': [[92, 525, 'plate'], [25, 250, 'exempt'], [84, 525, 'plate'], [83, 175, 'tag'], [49, 410, 'plate'], [76, 250, 'plate'], [82, 250, 'plate'], [2, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 458, 'plate': 3848, 'invoices': 3}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[85, 410, 'exempt'], [7, 410, 'plate'], [31, 175, 'plate'], [7, 410, 'exempt'], [58, 175, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 149, 'plate': 1532, 'invoices': 2}), ({'trips': [[83, 175, 'plate'], [80, 250, 'plate'], [2, 250, 'plate'], [84, 525, 'tag'], [1, 175, 'plate'], [14, 175, 'plate'], [4, 333, 'plate'], [76, 410, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 499, 'plate': 3454, 'invoices': 2}), ({'trips': [[49, 333, 'tag'], [86, 175, 'plate'], [46, 410, 'exempt'], [64, 333, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 568, 'plate': 419, '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': [[53, 410, 'tag'], [9, 250, 'plate'], [81, 525, 'exempt'], [50, 525, 'plate'], [44, 525, 'plate'], [88, 333, 'exempt']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 2156, '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': [[5, 250, 'exempt'], [20, 333, 'tag'], [44, 333, 'plate'], [5, 175, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 484, 'plate': 650, 'invoices': 1}), ({'trips': [[37, 250, 'exempt'], [61, 525, 'tag'], [38, 410, 'plate'], [90, 333, 'plate'], [72, 250, 'plate'], [79, 410, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 447, 'plate': 2156, 'invoices': 2}), ({'trips': [[70, 333, 'plate'], [91, 525, 'tag'], [91, 410, 'tag'], [81, 175, 'plate'], [44, 175, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 945, 'plate': 1087, 'invoices': 1}), ({'trips': [[68, 175, 'plate'], [69, 175, 'plate'], [28, 175, 'exempt'], [45, 175, 'plate'], [80, 410, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 349, 'plate': 1111, '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': [[41, 333, 'plate'], [81, 250, 'plate'], [31, 525, 'plate'], [93, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 284, 'plate': 2463, 'invoices': 2}), ({'trips': [[78, 410, 'tag'], [76, 410, 'tag'], [1, 525, 'tag'], [57, 410, 'plate'], [79, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 1580, 'plate': 913, 'invoices': 1})], [({'trips': [[30, 175, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 0, 'plate': 0, 'invoices': 0}), ({'trips': [[47, 333, 'plate'], [14, 525, 'tag'], [23, 333, 'exempt'], [70, 525, 'exempt'], [30, 250, 'plate'], [50, 410, 'plate'], [93, 175, 'tag'], [34, 525, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 1043, 'plate': 1443, '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': [[8, 250, 'tag'], [67, 175, 'plate'], [78, 410, 'plate'], [94, 175, 'exempt'], [0, 333, 'tag'], [85, 175, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 683, 'plate': 882, 'invoices': 1}), ({'trips': [[75, 525, 'tag'], [36, 333, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 447, 'plate': 617, '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': [[72, 250, 'tag'], [80, 250, 'tag'], [50, 410, 'plate'], [26, 333, 'exempt'], [57, 250, 'tag'], [95, 250, 'tag'], [34, 525, 'plate'], [42, 333, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 1136, 'plate': 1570, 'invoices': 1}), ({'trips': [[66, 250, 'plate'], [47, 333, 'tag'], [83, 250, 'tag'], [80, 525, 'plate'], [46, 333, 'tag'], [94, 250, 'plate'], [40, 333, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 825, 'plate': 2285, 'invoices': 3})], [({'trips': [[68, 525, 'tag'], [24, 410, 'tag'], [73, 333, 'plate'], [7, 175, 'tag'], [24, 525, 'plate'], [28, 175, 'plate'], [56, 525, 'plate']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 945, 'plate': 2705, 'invoices': 3}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[66, 175, 'plate'], [90, 410, 'plate'], [22, 175, 'tag'], [32, 410, 'tag'], [12, 175, 'plate'], [1, 333, 'tag'], [7, 410, 'exempt'], [87, 250, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 827, 'plate': 1741, 'invoices': 3}), ({'trips': [[64, 525, 'plate'], [1, 410, 'tag'], [9, 333, 'plate'], [95, 333, 'tag'], [5, 410, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 707, 'plate': 2303, 'invoices': 2}), ({'trips': [[35, 410, 'tag'], [33, 175, 'tag'], [41, 175, 'tag'], [2, 175, 'tag'], [75, 250, 'tag'], [8, 525, 'plate'], [7, 525, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 1541, 'plate': 1057, 'invoices': 1}), ({'trips': [[9, 525, 'tag'], [51, 525, 'exempt'], [55, 175, 'plate'], [71, 525, 'plate'], [83, 175, 'plate'], [84, 333, 'plate'], [9, 250, 'plate'], [31, 333, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 447, 'plate': 2692, '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': [[60, 333, 'exempt'], [43, 525, 'tag'], [18, 525, 'tag'], [30, 250, 'plate'], [73, 525, 'exempt'], [73, 333, 'exempt'], [83, 250, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 946, 'plate': 525, 'invoices': 1})], [({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[82, 525, 'plate'], [0, 525, 'tag'], [10, 175, 'exempt'], [72, 525, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 499, 'plate': 1514, 'invoices': 1}), ({'trips': [[32, 333, 'tag'], [38, 333, 'plate'], [80, 175, 'plate'], [48, 175, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 284, 'plate': 1655, 'invoices': 2}), ({'trips': [[73, 525, 'tag'], [84, 525, 'plate'], [90, 250, 'plate'], [15, 175, 'plate'], [29, 333, 'tag'], [61, 525, 'plate'], [71, 250, 'exempt'], [52, 175, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 816, 'plate': 2446, 'invoices': 3}), ({'trips': [[81, 250, 'plate'], [66, 525, 'plate'], [45, 333, 'tag'], [38, 333, 'plate'], [61, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 707, 'plate': 1687, 'invoices': 2}), ({'trips': [[93, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 349, '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': [[66, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 317, '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)

prompt:
Pay-by-plate invoice and tag discount returns a wrong result when invoice periods assume 1-based days.

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}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    tag = plate = 0
    periods = set()
    for day, base, method in x['trips']:
        if method == 'exempt':
            continue
        if method == 'tag':
            tag += base - base * x['tag_discount_pct'] // 100
        else:
            plate += base + base * x['plate_surcharge_pct'] // 100
            periods.add(day // x['cycle_days'])
    fees = len(periods) * x['invoice_fee']
    return {'tag': tag, 'plate': plate + fees, 'invoices': len(periods)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[84, 250, 'tag'], [82, 250, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 225, 'plate': 575, 'invoices': 1}), ({'trips': [[76, 250, 'tag'], [71, 525, 'tag'], [40, 250, 'tag'], [16, 525, 'plate'], [18, 250, 'plate'], [35, 333, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 1292, 'plate': 1370, 'invoices': 1}), ({'trips': [[74, 175, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 0, 'plate': 463, 'invoices': 1}), ({'trips': [[10, 250, 'plate'], [0, 250, 'plate'], [89, 410, 'tag'], [19, 410, 'tag'], [44, 250, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 911, 'plate': 1150, 'invoices': 1}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[36, 410, 'plate'], [12, 175, 'exempt'], [24, 333, 'plate'], [48, 250, 'tag'], [7, 525, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 225, 'plate': 1730, 'invoices': 2}), ({'trips': [[44, 410, 'exempt']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 0, 'plate': 0, 'invoices': 0})], [({'trips': [[51, 175, 'tag'], [42, 410, 'tag'], [70, 175, 'exempt'], [17, 175, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 685, 'plate': 0, 'invoices': 0}), ({'trips': [[55, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 473, 'plate': 0, 'invoices': 0}), ({'trips': [[64, 410, 'tag'], [0, 250, 'exempt'], [74, 250, 'exempt'], [12, 175, 'plate'], [4, 250, 'exempt'], [77, 410, 'tag'], [29, 250, 'plate'], [86, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 1170, 'plate': 932, 'invoices': 1}), ({'trips': [[44, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 300, 'plate': 0, 'invoices': 0}), ({'trips': [[80, 333, 'tag'], [37, 250, 'exempt'], [93, 525, 'tag'], [24, 175, 'plate'], [73, 525, 'tag'], [91, 250, 'plate'], [14, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 1546, 'plate': 1038, 'invoices': 2}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[48, 175, 'plate'], [37, 525, 'tag'], [81, 333, 'plate'], [42, 175, 'tag'], [11, 250, 'exempt']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 631, 'plate': 987, 'invoices': 2}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2})], [({'trips': [[20, 250, 'tag'], [55, 250, 'plate'], [77, 333, 'plate'], [83, 333, 'plate'], [95, 410, 'tag'], [27, 250, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 628, 'plate': 1910, 'invoices': 3}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[1, 410, 'tag'], [95, 250, 'exempt'], [59, 250, 'tag'], [51, 410, 'exempt'], [40, 333, 'plate'], [26, 410, 'plate'], [84, 333, 'plate'], [8, 250, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 775, 'plate': 2547, 'invoices': 3}), ({'trips': [[17, 525, 'tag'], [95, 175, 'plate'], [42, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 842, 'plate': 369, 'invoices': 1}), ({'trips': [[22, 250, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 225, 'plate': 0, 'invoices': 0}), ({'trips': [[22, 250, 'exempt'], [95, 525, 'exempt'], [7, 410, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 0, 'invoices': 0}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[89, 175, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 167, 'plate': 0, 'invoices': 0})], [({'trips': [[73, 250, 'plate'], [32, 410, 'tag'], [6, 333, 'plate'], [16, 250, 'plate'], [46, 250, 'tag'], [86, 175, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 752, 'plate': 1526, 'invoices': 2}), ({'trips': [[52, 410, 'exempt'], [6, 333, 'plate'], [26, 175, 'plate'], [18, 333, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 1663, 'invoices': 1}), ({'trips': [[8, 525, 'plate'], [27, 333, 'plate'], [72, 410, 'plate'], [15, 525, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 0, 'plate': 2644, 'invoices': 2}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[94, 525, 'exempt'], [50, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 447, 'plate': 0, 'invoices': 0}), ({'trips': [[41, 333, 'tag'], [76, 250, 'plate'], [33, 410, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 317, 'plate': 525, 'invoices': 1}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[43, 175, 'exempt'], [36, 175, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 0, 'plate': 0, 'invoices': 0})], [({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[72, 525, 'tag'], [18, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 998, 'plate': 0, 'invoices': 0}), ({'trips': [[24, 175, 'plate'], [4, 525, 'plate'], [22, 333, 'tag'], [63, 525, 'tag'], [10, 525, 'tag'], [0, 525, 'plate'], [6, 410, 'tag'], [39, 525, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 2088, 'plate': 1989, 'invoices': 1}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[82, 250, 'exempt'], [20, 175, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 149, 'plate': 0, 'invoices': 0}), ({'trips': [[88, 410, 'tag'], [89, 250, 'plate'], [5, 525, 'tag'], [38, 175, 'exempt'], [64, 525, 'plate'], [28, 175, 'tag'], [62, 333, 'exempt'], [9, 250, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 945, 'plate': 1683, 'invoices': 2}), ({'trips': [[82, 333, 'plate'], [35, 410, 'plate'], [24, 175, 'plate'], [34, 410, 'tag'], [60, 333, 'exempt'], [10, 250, 'tag'], [40, 175, 'plate'], [47, 250, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 594, 'plate': 2466, 'invoices': 3}), ({'trips': [[76, 175, 'exempt'], [69, 410, 'exempt'], [75, 175, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 167, 'plate': 0, 'invoices': 0})]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('fee oracle' + ' %d' % i, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    tag = plate = 0
    periods = set()
    for day, base, method in x['trips']:
        if method == 'exempt':
            continue
        if method == 'tag':
            tag += base - base * x['tag_discount_pct'] // 100
        else:
            plate += base + round(base * x['plate_surcharge_pct'] / 100)
            periods.add(day // x['cycle_days'])
    fees = len(periods) * x['invoice_fee']
    return {'tag': tag, 'plate': plate + fees, 'invoices': len(periods)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[84, 250, 'tag'], [82, 250, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 225, 'plate': 575, 'invoices': 1}), ({'trips': [[76, 250, 'tag'], [71, 525, 'tag'], [40, 250, 'tag'], [16, 525, 'plate'], [18, 250, 'plate'], [35, 333, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 1292, 'plate': 1370, 'invoices': 1}), ({'trips': [[74, 175, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 0, 'plate': 463, 'invoices': 1}), ({'trips': [[10, 250, 'plate'], [0, 250, 'plate'], [89, 410, 'tag'], [19, 410, 'tag'], [44, 250, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 911, 'plate': 1150, 'invoices': 1}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[36, 410, 'plate'], [12, 175, 'exempt'], [24, 333, 'plate'], [48, 250, 'tag'], [7, 525, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 225, 'plate': 1730, 'invoices': 2}), ({'trips': [[44, 410, 'exempt']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 0, 'plate': 0, 'invoices': 0})], [({'trips': [[51, 175, 'tag'], [42, 410, 'tag'], [70, 175, 'exempt'], [17, 175, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 685, 'plate': 0, 'invoices': 0}), ({'trips': [[55, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 473, 'plate': 0, 'invoices': 0}), ({'trips': [[64, 410, 'tag'], [0, 250, 'exempt'], [74, 250, 'exempt'], [12, 175, 'plate'], [4, 250, 'exempt'], [77, 410, 'tag'], [29, 250, 'plate'], [86, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 1170, 'plate': 932, 'invoices': 1}), ({'trips': [[44, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 300, 'plate': 0, 'invoices': 0}), ({'trips': [[80, 333, 'tag'], [37, 250, 'exempt'], [93, 525, 'tag'], [24, 175, 'plate'], [73, 525, 'tag'], [91, 250, 'plate'], [14, 333, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 1546, 'plate': 1038, 'invoices': 2}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[48, 175, 'plate'], [37, 525, 'tag'], [81, 333, 'plate'], [42, 175, 'tag'], [11, 250, 'exempt']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 631, 'plate': 987, 'invoices': 2}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2})], [({'trips': [[20, 250, 'tag'], [55, 250, 'plate'], [77, 333, 'plate'], [83, 333, 'plate'], [95, 410, 'tag'], [27, 250, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 628, 'plate': 1910, 'invoices': 3}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[1, 410, 'tag'], [95, 250, 'exempt'], [59, 250, 'tag'], [51, 410, 'exempt'], [40, 333, 'plate'], [26, 410, 'plate'], [84, 333, 'plate'], [8, 250, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 775, 'plate': 2547, 'invoices': 3}), ({'trips': [[17, 525, 'tag'], [95, 175, 'plate'], [42, 410, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 842, 'plate': 369, 'invoices': 1}), ({'trips': [[22, 250, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 225, 'plate': 0, 'invoices': 0}), ({'trips': [[22, 250, 'exempt'], [95, 525, 'exempt'], [7, 410, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 0, 'invoices': 0}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[89, 175, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 30}, {'tag': 167, 'plate': 0, 'invoices': 0})], [({'trips': [[73, 250, 'plate'], [32, 410, 'tag'], [6, 333, 'plate'], [16, 250, 'plate'], [46, 250, 'tag'], [86, 175, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 31}, {'tag': 752, 'plate': 1526, 'invoices': 2}), ({'trips': [[52, 410, 'exempt'], [6, 333, 'plate'], [26, 175, 'plate'], [18, 333, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 400, 'cycle_days': 31}, {'tag': 0, 'plate': 1663, 'invoices': 1}), ({'trips': [[8, 525, 'plate'], [27, 333, 'plate'], [72, 410, 'plate'], [15, 525, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 0, 'plate': 2644, 'invoices': 2}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[94, 525, 'exempt'], [50, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 447, 'plate': 0, 'invoices': 0}), ({'trips': [[41, 333, 'tag'], [76, 250, 'plate'], [33, 410, 'exempt']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 317, 'plate': 525, 'invoices': 1}), ({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[43, 175, 'exempt'], [36, 175, 'exempt']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 0, 'plate': 0, 'invoices': 0})], [({'trips': [[29, 250, 'plate'], [30, 250, 'plate'], [5, 333, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 284, 'plate': 1076, 'invoices': 2}), ({'trips': [[72, 525, 'tag'], [18, 525, 'tag']], 'plate_surcharge_pct': 35, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 998, 'plate': 0, 'invoices': 0}), ({'trips': [[24, 175, 'plate'], [4, 525, 'plate'], [22, 333, 'tag'], [63, 525, 'tag'], [10, 525, 'tag'], [0, 525, 'plate'], [6, 410, 'tag'], [39, 525, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 2088, 'plate': 1989, 'invoices': 1}), ({'trips': [[3, 410, 'exempt'], [4, 410, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 369, 'plate': 0, 'invoices': 0}), ({'trips': [[82, 250, 'exempt'], [20, 175, 'tag']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 149, 'plate': 0, 'invoices': 0}), ({'trips': [[88, 410, 'tag'], [89, 250, 'plate'], [5, 525, 'tag'], [38, 175, 'exempt'], [64, 525, 'plate'], [28, 175, 'tag'], [62, 333, 'exempt'], [9, 250, 'plate']], 'plate_surcharge_pct': 25, 'tag_discount_pct': 15, 'invoice_fee': 200, 'cycle_days': 30}, {'tag': 945, 'plate': 1683, 'invoices': 2}), ({'trips': [[82, 333, 'plate'], [35, 410, 'plate'], [24, 175, 'plate'], [34, 410, 'tag'], [60, 333, 'exempt'], [10, 250, 'tag'], [40, 175, 'plate'], [47, 250, 'plate']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 10, 'invoice_fee': 150, 'cycle_days': 31}, {'tag': 594, 'plate': 2466, 'invoices': 3}), ({'trips': [[76, 175, 'exempt'], [69, 410, 'exempt'], [75, 175, 'tag']], 'plate_surcharge_pct': 50, 'tag_discount_pct': 5, 'invoice_fee': 150, 'cycle_days': 30}, {'tag': 167, 'plate': 0, 'invoices': 0})]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('fee oracle' + ' %d' % i, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Pay-by-plate invoice and tag discount returns a wrong result when the plate surcharge is floored.

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}.

split: open-access