FA-85386 / Ride-hailing fare and surge pricing / Open access
Promo percentage applied to the booking fee · case 01
Percentage promos are larger than advertised because they include the fee.
ROOT CAUSE
The discount base includes the booking fee.
VERIFIED REPAIR
Discount only the surged fare.
Unsuccessful approach: Discounting the pre-surge fare shrinks the promo during surge.
Case contract
Cents throughout. Surge (tenths) multiplies only base+distance+time, rounded half up. A percentage promo discounts the surged amount (floor), capped at promo cap cents. The booking fee is added after the discount. Tax (basis points, rounded half up) applies to surged - discount + booking fee; tolls and airport fees are passed through untaxed and unsurged.
Why this case matters
Ride-hailing prices are computed per trip at scale; ordering, unit and boundary slips become systematic over- or under-charging.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(parts, surge, promo, tax_bp):
def half_up(num, den):
return (num * 2 + den) // (den * 2)
core = parts['base'] + parts['distance'] + parts['time']
surged = half_up(core * surge, 10)
disc = 0
if promo:
disc = min((surged + parts['booking_fee']) * promo['pct'] // 100, promo['cap'])
sub = surged - disc + parts['booking_fee']
tax = half_up(sub * tax_bp, 10000)
total = sub + tax + parts['tolls'] + parts['airport_fee']
return {'surged': surged, 'discount': disc, 'tax': tax, 'total': total}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: promo base',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 997, 'time': 241, 'tolls': 0}, 15,
{'cap': 500, 'pct': 20}, 0],
{'discount': 416, 'surged': 2082, 'tax': 0, 'total': 2341}),
('partial repair probe: promo base',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1174, 'time': 192, 'tolls': 690}, 15,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 1000, 'surged': 2424, 'tax': 0, 'total': 2359}),
('second regression',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 968, 'time': 734, 'tolls': 0}, 15,
{'cap': 500, 'pct': 20}, 625],
{'discount': 500, 'surged': 2778, 'tax': 142, 'total': 2420}),
('normal control 1',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1973, 'time': 171, 'tolls': 690}, 17,
{'cap': 5, 'pct': 15}, 825],
{'discount': 5, 'surged': 4070, 'tax': 356, 'total': 5356}),
('normal control 2',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2993, 'time': 725, 'tolls': 375}, 25,
None, 0],
{'discount': 0, 'surged': 9670, 'tax': 0, 'total': 10220}),
('normal control 3',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 1154, 'time': 617, 'tolls': 0}, 17, None,
1000],
{'discount': 0, 'surged': 3266, 'tax': 344, 'total': 3785}),
('normal control 4',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 1221, 'time': 768, 'tolls': 690}, 15,
None, 1000],
{'discount': 0, 'surged': 3359, 'tax': 336, 'total': 4885})],
[('regression: promo base',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 516, 'time': 674, 'tolls': 0}, 10,
{'cap': 500, 'pct': 20}, 0],
{'discount': 268, 'surged': 1340, 'tax': 0, 'total': 1247}),
('partial repair probe: promo base',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 682, 'time': 249, 'tolls': 0}, 25,
{'cap': 1000, 'pct': 50}, 1000],
{'discount': 1000, 'surged': 2953, 'tax': 213, 'total': 2341}),
('second regression',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 671, 'time': 774, 'tolls': 690}, 15,
{'cap': 1000, 'pct': 50}, 825],
{'discount': 1000, 'surged': 2393, 'tax': 115, 'total': 2198}),
('normal control 1',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 730, 'time': 288, 'tolls': 375}, 17, None,
0],
{'discount': 0, 'surged': 1986, 'tax': 0, 'total': 2361}),
('normal control 2',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2138, 'time': 530, 'tolls': 375}, 15,
None, 625],
{'discount': 0, 'surged': 4227, 'tax': 275, 'total': 5052}),
('normal control 3',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 1816, 'time': 118, 'tolls': 0}, 15,
{'cap': 5, 'pct': 15}, 825],
{'discount': 5, 'surged': 3276, 'tax': 290, 'total': 4306}),
('normal control 4',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 2778, 'time': 103, 'tolls': 0}, 17,
{'cap': 1000, 'pct': 50}, 625],
{'discount': 1000, 'surged': 5153, 'tax': 275, 'total': 4673})],
[('regression: promo base',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 253, 'time': 403, 'tolls': 0}, 15,
{'cap': 500, 'pct': 20}, 1000],
{'discount': 241, 'surged': 1209, 'tax': 114, 'total': 1257}),
('partial repair probe: promo base',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 1108, 'time': 532, 'tolls': 375}, 25,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 1000, 'surged': 4475, 'tax': 0, 'total': 4025}),
('second regression',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 750, 'time': 709, 'tolls': 0}, 17,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 1000, 'surged': 2905, 'tax': 0, 'total': 2080}),
('normal control 1',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 2269, 'time': 623, 'tolls': 690}, 17,
{'cap': 5, 'pct': 15}, 625],
{'discount': 5, 'surged': 5171, 'tax': 338, 'total': 6439}),
('normal control 2',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 847, 'time': 274, 'tolls': 0}, 15,
{'cap': 5, 'pct': 15}, 625],
{'discount': 5, 'surged': 1907, 'tax': 119, 'total': 2021}),
('normal control 3',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 1522, 'time': 555, 'tolls': 690}, 25,
{'cap': 5, 'pct': 15}, 1000],
{'discount': 5, 'surged': 5568, 'tax': 556, 'total': 7309}),
('normal control 4',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1887, 'time': 217, 'tolls': 690}, 10, None,
0],
{'discount': 0, 'surged': 2254, 'tax': 0, 'total': 2944})],
[('regression: promo base',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 410, 'time': 874, 'tolls': 0}, 17,
{'cap': 500, 'pct': 20}, 625],
{'discount': 487, 'surged': 2438, 'tax': 137, 'total': 2333}),
('partial repair probe: promo base',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1510, 'time': 277, 'tolls': 690}, 15,
{'cap': 500, 'pct': 20}, 1000],
{'discount': 500, 'surged': 3056, 'tax': 256, 'total': 3502}),
('second regression',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 1334, 'time': 485, 'tolls': 690}, 25,
{'cap': 1000, 'pct': 50}, 1000],
{'discount': 1000, 'surged': 4923, 'tax': 410, 'total': 5698}),
('normal control 1',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 2365, 'time': 516, 'tolls': 0}, 10,
{'cap': 5, 'pct': 15}, 625],
{'discount': 5, 'surged': 3131, 'tax': 206, 'total': 3507}),
('normal control 2',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 2432, 'time': 337, 'tolls': 375}, 10,
{'cap': 1000, 'pct': 50}, 825],
{'discount': 1000, 'surged': 3019, 'tax': 181, 'total': 2750}),
('normal control 3',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2663, 'time': 244, 'tolls': 375}, 17,
{'cap': 500, 'pct': 20}, 625],
{'discount': 500, 'surged': 5197, 'tax': 305, 'total': 5552}),
('normal control 4',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1527, 'time': 355, 'tolls': 0}, 10,
{'cap': 5, 'pct': 15}, 0],
{'discount': 5, 'surged': 2132, 'tax': 0, 'total': 2127})],
[('regression: promo base',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 678, 'time': 178, 'tolls': 0}, 12,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 603, 'surged': 1207, 'tax': 0, 'total': 1279}),
('partial repair probe: promo base',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 487, 'time': 307, 'tolls': 0}, 12,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 626, 'surged': 1253, 'tax': 0, 'total': 1372}),
('second regression',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 598, 'time': 531, 'tolls': 690}, 12,
{'cap': 1000, 'pct': 50}, 1000],
{'discount': 767, 'surged': 1535, 'tax': 101, 'total': 1804}),
('normal control 1',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2692, 'time': 466, 'tolls': 690}, 25, None,
825],
{'discount': 0, 'surged': 8270, 'tax': 682, 'total': 9642}),
('normal control 2',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 2757, 'time': 257, 'tolls': 0}, 12,
{'cap': 500, 'pct': 20}, 0],
{'discount': 500, 'surged': 3917, 'tax': 0, 'total': 3662}),
('normal control 3',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 2803, 'time': 828, 'tolls': 0}, 15,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 1000, 'surged': 5822, 'tax': 0, 'total': 5567}),
('normal control 4',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2004, 'time': 876, 'tolls': 690}, 25,
{'cap': 1000, 'pct': 50}, 625],
{'discount': 1000, 'surged': 7575, 'tax': 422, 'total': 7862})]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: promo base | {'discount': 451, 'surged': 2082, 'tax': 0, 'total': 2306} | {'discount': 416, 'surged': 2082, 'tax': 0, 'total': 2341} | Failed |
| partial repair probe: promo base | {'discount': 1000, 'surged': 2424, 'tax': 0, 'total': 2359} | {'discount': 1000, 'surged': 2424, 'tax': 0, 'total': 2359} | Passed |
| second regression | {'discount': 500, 'surged': 2778, 'tax': 142, 'total': 2420} | {'discount': 500, 'surged': 2778, 'tax': 142, 'total': 2420} | Passed |
| normal control 1 | {'discount': 5, 'surged': 4070, 'tax': 356, 'total': 5356} | {'discount': 5, 'surged': 4070, 'tax': 356, 'total': 5356} | Passed |
| normal control 2 | {'discount': 0, 'surged': 9670, 'tax': 0, 'total': 10220} | {'discount': 0, 'surged': 9670, 'tax': 0, 'total': 10220} | Passed |
| normal control 3 | {'discount': 0, 'surged': 3266, 'tax': 344, 'total': 3785} | {'discount': 0, 'surged': 3266, 'tax': 344, 'total': 3785} | Passed |
| normal control 4 | {'discount': 0, 'surged': 3359, 'tax': 336, 'total': 4885} | {'discount': 0, 'surged': 3359, 'tax': 336, 'total': 4885} | Passed |
SHA-256 / 1c354c2c511d64507ff3420d3e204be251891137a0a3c6ce056ef037b3867838
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(parts, surge, promo, tax_bp):
def half_up(num, den):
return (num * 2 + den) // (den * 2)
core = parts['base'] + parts['distance'] + parts['time']
surged = half_up(core * surge, 10)
disc = 0
if promo:
disc = min(core * promo['pct'] // 100, promo['cap'])
sub = surged - disc + parts['booking_fee']
tax = half_up(sub * tax_bp, 10000)
total = sub + tax + parts['tolls'] + parts['airport_fee']
return {'surged': surged, 'discount': disc, 'tax': tax, 'total': total}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: promo base',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 997, 'time': 241, 'tolls': 0}, 15,
{'cap': 500, 'pct': 20}, 0],
{'discount': 416, 'surged': 2082, 'tax': 0, 'total': 2341}),
('partial repair probe: promo base',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1174, 'time': 192, 'tolls': 690}, 15,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 1000, 'surged': 2424, 'tax': 0, 'total': 2359}),
('second regression',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 968, 'time': 734, 'tolls': 0}, 15,
{'cap': 500, 'pct': 20}, 625],
{'discount': 500, 'surged': 2778, 'tax': 142, 'total': 2420}),
('normal control 1',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1973, 'time': 171, 'tolls': 690}, 17,
{'cap': 5, 'pct': 15}, 825],
{'discount': 5, 'surged': 4070, 'tax': 356, 'total': 5356}),
('normal control 2',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2993, 'time': 725, 'tolls': 375}, 25,
None, 0],
{'discount': 0, 'surged': 9670, 'tax': 0, 'total': 10220}),
('normal control 3',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 1154, 'time': 617, 'tolls': 0}, 17, None,
1000],
{'discount': 0, 'surged': 3266, 'tax': 344, 'total': 3785}),
('normal control 4',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 1221, 'time': 768, 'tolls': 690}, 15,
None, 1000],
{'discount': 0, 'surged': 3359, 'tax': 336, 'total': 4885})],
[('regression: promo base',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 516, 'time': 674, 'tolls': 0}, 10,
{'cap': 500, 'pct': 20}, 0],
{'discount': 268, 'surged': 1340, 'tax': 0, 'total': 1247}),
('partial repair probe: promo base',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 682, 'time': 249, 'tolls': 0}, 25,
{'cap': 1000, 'pct': 50}, 1000],
{'discount': 1000, 'surged': 2953, 'tax': 213, 'total': 2341}),
('second regression',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 671, 'time': 774, 'tolls': 690}, 15,
{'cap': 1000, 'pct': 50}, 825],
{'discount': 1000, 'surged': 2393, 'tax': 115, 'total': 2198}),
('normal control 1',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 730, 'time': 288, 'tolls': 375}, 17, None,
0],
{'discount': 0, 'surged': 1986, 'tax': 0, 'total': 2361}),
('normal control 2',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2138, 'time': 530, 'tolls': 375}, 15,
None, 625],
{'discount': 0, 'surged': 4227, 'tax': 275, 'total': 5052}),
('normal control 3',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 1816, 'time': 118, 'tolls': 0}, 15,
{'cap': 5, 'pct': 15}, 825],
{'discount': 5, 'surged': 3276, 'tax': 290, 'total': 4306}),
('normal control 4',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 2778, 'time': 103, 'tolls': 0}, 17,
{'cap': 1000, 'pct': 50}, 625],
{'discount': 1000, 'surged': 5153, 'tax': 275, 'total': 4673})],
[('regression: promo base',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 253, 'time': 403, 'tolls': 0}, 15,
{'cap': 500, 'pct': 20}, 1000],
{'discount': 241, 'surged': 1209, 'tax': 114, 'total': 1257}),
('partial repair probe: promo base',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 1108, 'time': 532, 'tolls': 375}, 25,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 1000, 'surged': 4475, 'tax': 0, 'total': 4025}),
('second regression',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 750, 'time': 709, 'tolls': 0}, 17,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 1000, 'surged': 2905, 'tax': 0, 'total': 2080}),
('normal control 1',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 2269, 'time': 623, 'tolls': 690}, 17,
{'cap': 5, 'pct': 15}, 625],
{'discount': 5, 'surged': 5171, 'tax': 338, 'total': 6439}),
('normal control 2',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 847, 'time': 274, 'tolls': 0}, 15,
{'cap': 5, 'pct': 15}, 625],
{'discount': 5, 'surged': 1907, 'tax': 119, 'total': 2021}),
('normal control 3',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 1522, 'time': 555, 'tolls': 690}, 25,
{'cap': 5, 'pct': 15}, 1000],
{'discount': 5, 'surged': 5568, 'tax': 556, 'total': 7309}),
('normal control 4',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1887, 'time': 217, 'tolls': 690}, 10, None,
0],
{'discount': 0, 'surged': 2254, 'tax': 0, 'total': 2944})],
[('regression: promo base',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 410, 'time': 874, 'tolls': 0}, 17,
{'cap': 500, 'pct': 20}, 625],
{'discount': 487, 'surged': 2438, 'tax': 137, 'total': 2333}),
('partial repair probe: promo base',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1510, 'time': 277, 'tolls': 690}, 15,
{'cap': 500, 'pct': 20}, 1000],
{'discount': 500, 'surged': 3056, 'tax': 256, 'total': 3502}),
('second regression',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 1334, 'time': 485, 'tolls': 690}, 25,
{'cap': 1000, 'pct': 50}, 1000],
{'discount': 1000, 'surged': 4923, 'tax': 410, 'total': 5698}),
('normal control 1',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 2365, 'time': 516, 'tolls': 0}, 10,
{'cap': 5, 'pct': 15}, 625],
{'discount': 5, 'surged': 3131, 'tax': 206, 'total': 3507}),
('normal control 2',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 2432, 'time': 337, 'tolls': 375}, 10,
{'cap': 1000, 'pct': 50}, 825],
{'discount': 1000, 'surged': 3019, 'tax': 181, 'total': 2750}),
('normal control 3',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2663, 'time': 244, 'tolls': 375}, 17,
{'cap': 500, 'pct': 20}, 625],
{'discount': 500, 'surged': 5197, 'tax': 305, 'total': 5552}),
('normal control 4',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1527, 'time': 355, 'tolls': 0}, 10,
{'cap': 5, 'pct': 15}, 0],
{'discount': 5, 'surged': 2132, 'tax': 0, 'total': 2127})],
[('regression: promo base',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 678, 'time': 178, 'tolls': 0}, 12,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 603, 'surged': 1207, 'tax': 0, 'total': 1279}),
('partial repair probe: promo base',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 487, 'time': 307, 'tolls': 0}, 12,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 626, 'surged': 1253, 'tax': 0, 'total': 1372}),
('second regression',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 598, 'time': 531, 'tolls': 690}, 12,
{'cap': 1000, 'pct': 50}, 1000],
{'discount': 767, 'surged': 1535, 'tax': 101, 'total': 1804}),
('normal control 1',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2692, 'time': 466, 'tolls': 690}, 25, None,
825],
{'discount': 0, 'surged': 8270, 'tax': 682, 'total': 9642}),
('normal control 2',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 2757, 'time': 257, 'tolls': 0}, 12,
{'cap': 500, 'pct': 20}, 0],
{'discount': 500, 'surged': 3917, 'tax': 0, 'total': 3662}),
('normal control 3',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 2803, 'time': 828, 'tolls': 0}, 15,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 1000, 'surged': 5822, 'tax': 0, 'total': 5567}),
('normal control 4',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2004, 'time': 876, 'tolls': 690}, 25,
{'cap': 1000, 'pct': 50}, 625],
{'discount': 1000, 'surged': 7575, 'tax': 422, 'total': 7862})]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: promo base | {'discount': 277, 'surged': 2082, 'tax': 0, 'total': 2480} | {'discount': 416, 'surged': 2082, 'tax': 0, 'total': 2341} | Failed |
| partial repair probe: promo base | {'discount': 808, 'surged': 2424, 'tax': 0, 'total': 2551} | {'discount': 1000, 'surged': 2424, 'tax': 0, 'total': 2359} | Failed |
| second regression | {'discount': 370, 'surged': 2778, 'tax': 151, 'total': 2559} | {'discount': 500, 'surged': 2778, 'tax': 142, 'total': 2420} | Failed |
| normal control 1 | {'discount': 5, 'surged': 4070, 'tax': 356, 'total': 5356} | {'discount': 5, 'surged': 4070, 'tax': 356, 'total': 5356} | Passed |
| normal control 2 | {'discount': 0, 'surged': 9670, 'tax': 0, 'total': 10220} | {'discount': 0, 'surged': 9670, 'tax': 0, 'total': 10220} | Passed |
| normal control 3 | {'discount': 0, 'surged': 3266, 'tax': 344, 'total': 3785} | {'discount': 0, 'surged': 3266, 'tax': 344, 'total': 3785} | Passed |
| normal control 4 | {'discount': 0, 'surged': 3359, 'tax': 336, 'total': 4885} | {'discount': 0, 'surged': 3359, 'tax': 336, 'total': 4885} | Passed |
SHA-256 / 926f78b99284ebb94977fbf7aeca0997f37dcd53a1cff24bee0a01057c81ade6
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(parts, surge, promo, tax_bp):
def half_up(num, den):
return (num * 2 + den) // (den * 2)
core = parts['base'] + parts['distance'] + parts['time']
surged = half_up(core * surge, 10)
disc = 0
if promo:
disc = min(surged * promo['pct'] // 100, promo['cap'])
sub = surged - disc + parts['booking_fee']
tax = half_up(sub * tax_bp, 10000)
total = sub + tax + parts['tolls'] + parts['airport_fee']
return {'surged': surged, 'discount': disc, 'tax': tax, 'total': total}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: promo base',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 997, 'time': 241, 'tolls': 0}, 15,
{'cap': 500, 'pct': 20}, 0],
{'discount': 416, 'surged': 2082, 'tax': 0, 'total': 2341}),
('partial repair probe: promo base',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1174, 'time': 192, 'tolls': 690}, 15,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 1000, 'surged': 2424, 'tax': 0, 'total': 2359}),
('second regression',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 968, 'time': 734, 'tolls': 0}, 15,
{'cap': 500, 'pct': 20}, 625],
{'discount': 500, 'surged': 2778, 'tax': 142, 'total': 2420}),
('normal control 1',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1973, 'time': 171, 'tolls': 690}, 17,
{'cap': 5, 'pct': 15}, 825],
{'discount': 5, 'surged': 4070, 'tax': 356, 'total': 5356}),
('normal control 2',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2993, 'time': 725, 'tolls': 375}, 25,
None, 0],
{'discount': 0, 'surged': 9670, 'tax': 0, 'total': 10220}),
('normal control 3',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 1154, 'time': 617, 'tolls': 0}, 17, None,
1000],
{'discount': 0, 'surged': 3266, 'tax': 344, 'total': 3785}),
('normal control 4',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 1221, 'time': 768, 'tolls': 690}, 15,
None, 1000],
{'discount': 0, 'surged': 3359, 'tax': 336, 'total': 4885})],
[('regression: promo base',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 516, 'time': 674, 'tolls': 0}, 10,
{'cap': 500, 'pct': 20}, 0],
{'discount': 268, 'surged': 1340, 'tax': 0, 'total': 1247}),
('partial repair probe: promo base',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 682, 'time': 249, 'tolls': 0}, 25,
{'cap': 1000, 'pct': 50}, 1000],
{'discount': 1000, 'surged': 2953, 'tax': 213, 'total': 2341}),
('second regression',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 671, 'time': 774, 'tolls': 690}, 15,
{'cap': 1000, 'pct': 50}, 825],
{'discount': 1000, 'surged': 2393, 'tax': 115, 'total': 2198}),
('normal control 1',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 730, 'time': 288, 'tolls': 375}, 17, None,
0],
{'discount': 0, 'surged': 1986, 'tax': 0, 'total': 2361}),
('normal control 2',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2138, 'time': 530, 'tolls': 375}, 15,
None, 625],
{'discount': 0, 'surged': 4227, 'tax': 275, 'total': 5052}),
('normal control 3',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 1816, 'time': 118, 'tolls': 0}, 15,
{'cap': 5, 'pct': 15}, 825],
{'discount': 5, 'surged': 3276, 'tax': 290, 'total': 4306}),
('normal control 4',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 2778, 'time': 103, 'tolls': 0}, 17,
{'cap': 1000, 'pct': 50}, 625],
{'discount': 1000, 'surged': 5153, 'tax': 275, 'total': 4673})],
[('regression: promo base',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 253, 'time': 403, 'tolls': 0}, 15,
{'cap': 500, 'pct': 20}, 1000],
{'discount': 241, 'surged': 1209, 'tax': 114, 'total': 1257}),
('partial repair probe: promo base',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 1108, 'time': 532, 'tolls': 375}, 25,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 1000, 'surged': 4475, 'tax': 0, 'total': 4025}),
('second regression',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 750, 'time': 709, 'tolls': 0}, 17,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 1000, 'surged': 2905, 'tax': 0, 'total': 2080}),
('normal control 1',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 2269, 'time': 623, 'tolls': 690}, 17,
{'cap': 5, 'pct': 15}, 625],
{'discount': 5, 'surged': 5171, 'tax': 338, 'total': 6439}),
('normal control 2',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 847, 'time': 274, 'tolls': 0}, 15,
{'cap': 5, 'pct': 15}, 625],
{'discount': 5, 'surged': 1907, 'tax': 119, 'total': 2021}),
('normal control 3',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 1522, 'time': 555, 'tolls': 690}, 25,
{'cap': 5, 'pct': 15}, 1000],
{'discount': 5, 'surged': 5568, 'tax': 556, 'total': 7309}),
('normal control 4',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1887, 'time': 217, 'tolls': 690}, 10, None,
0],
{'discount': 0, 'surged': 2254, 'tax': 0, 'total': 2944})],
[('regression: promo base',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 410, 'time': 874, 'tolls': 0}, 17,
{'cap': 500, 'pct': 20}, 625],
{'discount': 487, 'surged': 2438, 'tax': 137, 'total': 2333}),
('partial repair probe: promo base',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1510, 'time': 277, 'tolls': 690}, 15,
{'cap': 500, 'pct': 20}, 1000],
{'discount': 500, 'surged': 3056, 'tax': 256, 'total': 3502}),
('second regression',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 1334, 'time': 485, 'tolls': 690}, 25,
{'cap': 1000, 'pct': 50}, 1000],
{'discount': 1000, 'surged': 4923, 'tax': 410, 'total': 5698}),
('normal control 1',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 2365, 'time': 516, 'tolls': 0}, 10,
{'cap': 5, 'pct': 15}, 625],
{'discount': 5, 'surged': 3131, 'tax': 206, 'total': 3507}),
('normal control 2',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 2432, 'time': 337, 'tolls': 375}, 10,
{'cap': 1000, 'pct': 50}, 825],
{'discount': 1000, 'surged': 3019, 'tax': 181, 'total': 2750}),
('normal control 3',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2663, 'time': 244, 'tolls': 375}, 17,
{'cap': 500, 'pct': 20}, 625],
{'discount': 500, 'surged': 5197, 'tax': 305, 'total': 5552}),
('normal control 4',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1527, 'time': 355, 'tolls': 0}, 10,
{'cap': 5, 'pct': 15}, 0],
{'discount': 5, 'surged': 2132, 'tax': 0, 'total': 2127})],
[('regression: promo base',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 678, 'time': 178, 'tolls': 0}, 12,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 603, 'surged': 1207, 'tax': 0, 'total': 1279}),
('partial repair probe: promo base',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 487, 'time': 307, 'tolls': 0}, 12,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 626, 'surged': 1253, 'tax': 0, 'total': 1372}),
('second regression',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 598, 'time': 531, 'tolls': 690}, 12,
{'cap': 1000, 'pct': 50}, 1000],
{'discount': 767, 'surged': 1535, 'tax': 101, 'total': 1804}),
('normal control 1',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2692, 'time': 466, 'tolls': 690}, 25, None,
825],
{'discount': 0, 'surged': 8270, 'tax': 682, 'total': 9642}),
('normal control 2',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 2757, 'time': 257, 'tolls': 0}, 12,
{'cap': 500, 'pct': 20}, 0],
{'discount': 500, 'surged': 3917, 'tax': 0, 'total': 3662}),
('normal control 3',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 2803, 'time': 828, 'tolls': 0}, 15,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 1000, 'surged': 5822, 'tax': 0, 'total': 5567}),
('normal control 4',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2004, 'time': 876, 'tolls': 690}, 25,
{'cap': 1000, 'pct': 50}, 625],
{'discount': 1000, 'surged': 7575, 'tax': 422, 'total': 7862})]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: promo base | {'discount': 416, 'surged': 2082, 'tax': 0, 'total': 2341} | {'discount': 416, 'surged': 2082, 'tax': 0, 'total': 2341} | Passed |
| partial repair probe: promo base | {'discount': 1000, 'surged': 2424, 'tax': 0, 'total': 2359} | {'discount': 1000, 'surged': 2424, 'tax': 0, 'total': 2359} | Passed |
| second regression | {'discount': 500, 'surged': 2778, 'tax': 142, 'total': 2420} | {'discount': 500, 'surged': 2778, 'tax': 142, 'total': 2420} | Passed |
| normal control 1 | {'discount': 5, 'surged': 4070, 'tax': 356, 'total': 5356} | {'discount': 5, 'surged': 4070, 'tax': 356, 'total': 5356} | Passed |
| normal control 2 | {'discount': 0, 'surged': 9670, 'tax': 0, 'total': 10220} | {'discount': 0, 'surged': 9670, 'tax': 0, 'total': 10220} | Passed |
| normal control 3 | {'discount': 0, 'surged': 3266, 'tax': 344, 'total': 3785} | {'discount': 0, 'surged': 3266, 'tax': 344, 'total': 3785} | Passed |
| normal control 4 | {'discount': 0, 'surged': 3359, 'tax': 336, 'total': 4885} | {'discount': 0, 'surged': 3359, 'tax': 336, 'total': 4885} | Passed |
SHA-256 / eb9696acdf634d233221bd13a4677568e33682bcecff7497e4b56f6e84296726
Verification & scope
A deterministic toy pricing contract stipulated for this example; it does not reproduce the pricing of any real ride-hailing operator or regulator. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:50:39.891935+00:00.
Case digest / 575da66b291bff773f3cbfbf0b81d42001ef5b73b137173d1c6269c761cdb80c