broken_source:
"""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'] + parts['booking_fee']
    surged = half_up(core * surge, 10)
    disc = 0
    if promo:
        disc = min(surged * promo['pct'] // 100, promo['cap'])
    sub = surged - disc
    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: booking fee surged',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 1778, 'time': 866, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 4191, 'tax': 436, 'total': 5297}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1084, 'time': 371, 'tolls': 690}, 17,
    {'cap': 5, 'pct': 15}, 625],
   {'discount': 5, 'surged': 2899, 'tax': 196, 'total': 4025}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 2720, 'time': 873, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 5765, 'tax': 0, 'total': 6005}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 2506, 'time': 646, 'tolls': 0}, 12,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 3962, 'tax': 216, 'total': 4178}),
  ('normal control 2',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 1416, 'time': 612, 'tolls': 0}, 17,
    {'cap': 500, 'pct': 20}, 825],
   {'discount': 500, 'surged': 3703, 'tax': 264, 'total': 3967}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 709, 'time': 156, 'tolls': 0}, 25,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 2538, 'tax': 209, 'total': 2742}),
  ('normal control 4',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 2828, 'time': 171, 'tolls': 0}, 17, None,
    625],
   {'discount': 0, 'surged': 5523, 'tax': 345, 'total': 6368})],
 [('regression: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 1428, 'time': 657, 'tolls': 690}, 17,
    None, 825],
   {'discount': 0, 'surged': 3800, 'tax': 328, 'total': 4993}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 713, 'time': 323, 'tolls': 375}, 15, None,
    625],
   {'discount': 0, 'surged': 1779, 'tax': 122, 'total': 2451}),
  ('second regression',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 245, 'distance': 998, 'time': 460, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 2412, 'tax': 219, 'total': 3371}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 1810, 'time': 373, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 3650, 'tax': 365, 'total': 4510}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1451, 'time': 384, 'tolls': 0}, 10,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 2085, 'tax': 0, 'total': 2080}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 765, 'time': 379, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 970, 'surged': 1941, 'tax': 0, 'total': 1471}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1362, 'time': 592, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 3306, 'tax': 0, 'total': 3301})],
 [('regression: booking fee surged',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 175, 'distance': 1423, 'time': 494, 'tolls': 375}, 12,
    {'cap': 1000, 'pct': 50}, 625],
   {'discount': 1000, 'surged': 2600, 'tax': 111, 'total': 2761}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 879, 'time': 747, 'tolls': 375}, 17,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 3189, 'tax': 343, 'total': 4647}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 660, 'time': 472, 'tolls': 690}, 25,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 3455, 'tax': 185, 'total': 3830}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 2852, 'time': 398, 'tolls': 0}, 25,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 8500, 'tax': 850, 'total': 9845}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 706, 'time': 406, 'tolls': 0}, 10, None,
    1000],
   {'discount': 0, 'surged': 1362, 'tax': 136, 'total': 1498}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2282, 'time': 527, 'tolls': 0}, 10,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 2959, 'tax': 246, 'total': 2705}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 294, 'time': 652, 'tolls': 0}, 25,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 2740, 'tax': 224, 'total': 2464})],
 [('regression: booking fee surged',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 748, 'time': 320, 'tolls': 0}, 12, None,
    625],
   {'discount': 0, 'surged': 1582, 'tax': 110, 'total': 1867}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 336, 'time': 837, 'tolls': 375}, 25, None,
    1000],
   {'discount': 0, 'surged': 3308, 'tax': 331, 'total': 4014}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 1861, 'time': 607, 'tolls': 0}, 25,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 6795, 'tax': 404, 'total': 6874}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 251, 'time': 580, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 625],
   {'discount': 736, 'surged': 1472, 'tax': 46, 'total': 782}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2510, 'time': 135, 'tolls': 0}, 15, None,
    0],
   {'discount': 0, 'surged': 4193, 'tax': 0, 'total': 4193}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 1629, 'time': 264, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 3215, 'tax': 265, 'total': 3975}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1916, 'time': 473, 'tolls': 0}, 10,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 2539, 'tax': 154, 'total': 1693})],
 [('regression: booking fee surged',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 2485, 'time': 638, 'tolls': 0}, 12,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 3928, 'tax': 225, 'total': 4328}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2937, 'time': 390, 'tolls': 690}, 17,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 5911, 'tax': 491, 'total': 6092}),
  ('second regression',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2487, 'time': 507, 'tolls': 0}, 15,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 500, 'surged': 4716, 'tax': 0, 'total': 4391}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 2216, 'time': 595, 'tolls': 0}, 17,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 1000, 'surged': 5204, 'tax': 0, 'total': 4704}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2675, 'time': 665, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 5235, 'tax': 349, 'total': 4584}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 2698, 'time': 462, 'tolls': 0}, 17,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 5797, 'tax': 396, 'total': 5693}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1857, 'time': 629, 'tolls': 0}, 15,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 500, 'surged': 3954, 'tax': 0, 'total': 3454})]]
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)

source:
"""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'] + parts['tolls']
    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: booking fee surged',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 1778, 'time': 866, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 4191, 'tax': 436, 'total': 5297}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1084, 'time': 371, 'tolls': 690}, 17,
    {'cap': 5, 'pct': 15}, 625],
   {'discount': 5, 'surged': 2899, 'tax': 196, 'total': 4025}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 2720, 'time': 873, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 5765, 'tax': 0, 'total': 6005}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 2506, 'time': 646, 'tolls': 0}, 12,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 3962, 'tax': 216, 'total': 4178}),
  ('normal control 2',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 1416, 'time': 612, 'tolls': 0}, 17,
    {'cap': 500, 'pct': 20}, 825],
   {'discount': 500, 'surged': 3703, 'tax': 264, 'total': 3967}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 709, 'time': 156, 'tolls': 0}, 25,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 2538, 'tax': 209, 'total': 2742}),
  ('normal control 4',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 2828, 'time': 171, 'tolls': 0}, 17, None,
    625],
   {'discount': 0, 'surged': 5523, 'tax': 345, 'total': 6368})],
 [('regression: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 1428, 'time': 657, 'tolls': 690}, 17,
    None, 825],
   {'discount': 0, 'surged': 3800, 'tax': 328, 'total': 4993}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 713, 'time': 323, 'tolls': 375}, 15, None,
    625],
   {'discount': 0, 'surged': 1779, 'tax': 122, 'total': 2451}),
  ('second regression',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 245, 'distance': 998, 'time': 460, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 2412, 'tax': 219, 'total': 3371}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 1810, 'time': 373, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 3650, 'tax': 365, 'total': 4510}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1451, 'time': 384, 'tolls': 0}, 10,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 2085, 'tax': 0, 'total': 2080}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 765, 'time': 379, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 970, 'surged': 1941, 'tax': 0, 'total': 1471}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1362, 'time': 592, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 3306, 'tax': 0, 'total': 3301})],
 [('regression: booking fee surged',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 175, 'distance': 1423, 'time': 494, 'tolls': 375}, 12,
    {'cap': 1000, 'pct': 50}, 625],
   {'discount': 1000, 'surged': 2600, 'tax': 111, 'total': 2761}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 879, 'time': 747, 'tolls': 375}, 17,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 3189, 'tax': 343, 'total': 4647}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 660, 'time': 472, 'tolls': 690}, 25,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 3455, 'tax': 185, 'total': 3830}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 2852, 'time': 398, 'tolls': 0}, 25,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 8500, 'tax': 850, 'total': 9845}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 706, 'time': 406, 'tolls': 0}, 10, None,
    1000],
   {'discount': 0, 'surged': 1362, 'tax': 136, 'total': 1498}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2282, 'time': 527, 'tolls': 0}, 10,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 2959, 'tax': 246, 'total': 2705}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 294, 'time': 652, 'tolls': 0}, 25,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 2740, 'tax': 224, 'total': 2464})],
 [('regression: booking fee surged',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 748, 'time': 320, 'tolls': 0}, 12, None,
    625],
   {'discount': 0, 'surged': 1582, 'tax': 110, 'total': 1867}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 336, 'time': 837, 'tolls': 375}, 25, None,
    1000],
   {'discount': 0, 'surged': 3308, 'tax': 331, 'total': 4014}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 1861, 'time': 607, 'tolls': 0}, 25,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 6795, 'tax': 404, 'total': 6874}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 251, 'time': 580, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 625],
   {'discount': 736, 'surged': 1472, 'tax': 46, 'total': 782}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2510, 'time': 135, 'tolls': 0}, 15, None,
    0],
   {'discount': 0, 'surged': 4193, 'tax': 0, 'total': 4193}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 1629, 'time': 264, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 3215, 'tax': 265, 'total': 3975}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1916, 'time': 473, 'tolls': 0}, 10,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 2539, 'tax': 154, 'total': 1693})],
 [('regression: booking fee surged',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 2485, 'time': 638, 'tolls': 0}, 12,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 3928, 'tax': 225, 'total': 4328}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2937, 'time': 390, 'tolls': 690}, 17,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 5911, 'tax': 491, 'total': 6092}),
  ('second regression',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2487, 'time': 507, 'tolls': 0}, 15,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 500, 'surged': 4716, 'tax': 0, 'total': 4391}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 2216, 'time': 595, 'tolls': 0}, 17,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 1000, 'surged': 5204, 'tax': 0, 'total': 4704}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2675, 'time': 665, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 5235, 'tax': 349, 'total': 4584}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 2698, 'time': 462, 'tolls': 0}, 17,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 5797, 'tax': 396, 'total': 5693}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1857, 'time': 629, 'tolls': 0}, 15,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 500, 'surged': 3954, 'tax': 0, 'total': 3454})]]
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)

prompt:
At 2.5x surge the flat booking fee becomes 2.5 times larger.

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.

split: open-access


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

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(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)

prompt:
Percentage promos are larger than advertised because they include the fee.

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.

split: open-access


broken_source:
"""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 = surged * promo['pct'] // 100
    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 cap',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2070, 'time': 734, 'tolls': 375}, 10,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 3054, 'tax': 205, 'total': 2634}),
  ('partial repair probe: promo cap',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1506, 'time': 265, 'tolls': 375}, 10,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 1000, 'surged': 2021, 'tax': 0, 'total': 1641}),
  ('second regression',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 175, 'distance': 2171, 'time': 246, 'tolls': 375}, 17,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 4534, 'tax': 470, 'total': 6049}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 245, 'distance': 855, 'time': 216, 'tolls': 0}, 12, None,
    825],
   {'discount': 0, 'surged': 1465, 'tax': 141, 'total': 2351}),
  ('normal control 2',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 599, 'time': 617, 'tolls': 0}, 12, None,
    0],
   {'discount': 0, 'surged': 1759, 'tax': 0, 'total': 2259}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 2589, 'time': 635, 'tolls': 690}, 25,
    None, 825],
   {'discount': 0, 'surged': 8435, 'tax': 710, 'total': 10510}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 429, 'time': 564, 'tolls': 375}, 17,
    {'cap': 500, 'pct': 20}, 825],
   {'discount': 388, 'surged': 1943, 'tax': 143, 'total': 2248})],
 [('regression: promo cap',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2808, 'time': 350, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 5112, 'tax': 339, 'total': 4451}),
  ('partial repair probe: promo cap',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1187, 'time': 97, 'tolls': 0}, 25,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 1000, 'surged': 3585, 'tax': 0, 'total': 2585}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 218, 'time': 836, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 1956, 'tax': 0, 'total': 2126}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2595, 'time': 377, 'tolls': 375}, 25, None,
    0],
   {'discount': 0, 'surged': 8055, 'tax': 0, 'total': 8430}),
  ('normal control 2',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 359, 'time': 804, 'tolls': 0}, 10, None,
    625],
   {'discount': 0, 'surged': 1313, 'tax': 93, 'total': 2081}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 1650, 'time': 892, 'tolls': 690}, 17,
    None, 1000],
   {'discount': 0, 'surged': 4576, 'tax': 475, 'total': 6416}),
  ('normal control 4',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 2382, 'time': 551, 'tolls': 690}, 25,
    None, 825],
   {'discount': 0, 'surged': 7958, 'tax': 677, 'total': 10070})],
 [('regression: promo cap',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 2496, 'time': 616, 'tolls': 690}, 10,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 3362, 'tax': 215, 'total': 3512}),
  ('partial repair probe: promo cap',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2743, 'time': 287, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 4770, 'tax': 325, 'total': 4270}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2977, 'time': 212, 'tolls': 0}, 15,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 500, 'surged': 5159, 'tax': 0, 'total': 4659}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 530, 'time': 327, 'tolls': 690}, 10, None,
    625],
   {'discount': 0, 'surged': 1007, 'tax': 78, 'total': 2020}),
  ('normal control 2',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 175, 'distance': 693, 'time': 420, 'tolls': 375}, 25,
    None, 825],
   {'discount': 0, 'surged': 3408, 'tax': 296, 'total': 4754}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 403, 'time': 448, 'tolls': 0}, 15,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 330, 'surged': 1652, 'tax': 0, 'total': 1497}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 925, 'time': 819, 'tolls': 0}, 12, None,
    625],
   {'discount': 0, 'surged': 2273, 'tax': 157, 'total': 2675})],
 [('regression: promo cap',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 1887, 'time': 798, 'tolls': 0}, 17,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 4990, 'tax': 417, 'total': 4582}),
  ('partial repair probe: promo cap',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 2043, 'time': 744, 'tolls': 690}, 17,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 500, 'surged': 5163, 'tax': 0, 'total': 5528}),
  ('second regression',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 1583, 'time': 804, 'tolls': 0}, 25,
    {'cap': 500, 'pct': 20}, 825],
   {'discount': 500, 'surged': 6593, 'tax': 523, 'total': 7361}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 464, 'time': 114, 'tolls': 0}, 17,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 247, 'surged': 1238, 'tax': 0, 'total': 1166}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 504, 'time': 655, 'tolls': 375}, 25, None,
    0],
   {'discount': 0, 'surged': 3523, 'tax': 0, 'total': 4073}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 403, 'time': 175, 'tolls': 375}, 12,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 437, 'surged': 874, 'tax': 36, 'total': 1348}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2545, 'time': 164, 'tolls': 690}, 15, None,
    625],
   {'discount': 0, 'surged': 4439, 'tax': 277, 'total': 5406})],
 [('regression: promo cap',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 592, 'time': 318, 'tolls': 690}, 10,
    {'cap': 5, 'pct': 15}, 625],
   {'discount': 5, 'surged': 1160, 'tax': 72, 'total': 1917}),
  ('partial repair probe: promo cap',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2992, 'time': 342, 'tolls': 690}, 10,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 500, 'surged': 3484, 'tax': 0, 'total': 3674}),
  ('second regression',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 920, 'time': 542, 'tolls': 690}, 17,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 2740, 'tax': 242, 'total': 3347}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 1845, 'time': 397, 'tolls': 375}, 15,
    None, 1000],
   {'discount': 0, 'surged': 3588, 'tax': 359, 'total': 4822}),
  ('normal control 2',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 2544, 'time': 666, 'tolls': 690}, 10,
    None, 625],
   {'discount': 0, 'surged': 3360, 'tax': 210, 'total': 4760}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 275, 'time': 747, 'tolls': 690}, 25, None,
    1000],
   {'discount': 0, 'surged': 3180, 'tax': 343, 'total': 4458}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2045, 'time': 515, 'tolls': 0}, 15, None,
    0],
   {'discount': 0, 'surged': 4215, 'tax': 0, 'total': 4215})]]
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)

source:
"""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'] * 100)
    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 cap',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2070, 'time': 734, 'tolls': 375}, 10,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 3054, 'tax': 205, 'total': 2634}),
  ('partial repair probe: promo cap',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1506, 'time': 265, 'tolls': 375}, 10,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 1000, 'surged': 2021, 'tax': 0, 'total': 1641}),
  ('second regression',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 175, 'distance': 2171, 'time': 246, 'tolls': 375}, 17,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 4534, 'tax': 470, 'total': 6049}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 245, 'distance': 855, 'time': 216, 'tolls': 0}, 12, None,
    825],
   {'discount': 0, 'surged': 1465, 'tax': 141, 'total': 2351}),
  ('normal control 2',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 599, 'time': 617, 'tolls': 0}, 12, None,
    0],
   {'discount': 0, 'surged': 1759, 'tax': 0, 'total': 2259}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 2589, 'time': 635, 'tolls': 690}, 25,
    None, 825],
   {'discount': 0, 'surged': 8435, 'tax': 710, 'total': 10510}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 429, 'time': 564, 'tolls': 375}, 17,
    {'cap': 500, 'pct': 20}, 825],
   {'discount': 388, 'surged': 1943, 'tax': 143, 'total': 2248})],
 [('regression: promo cap',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2808, 'time': 350, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 5112, 'tax': 339, 'total': 4451}),
  ('partial repair probe: promo cap',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1187, 'time': 97, 'tolls': 0}, 25,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 1000, 'surged': 3585, 'tax': 0, 'total': 2585}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 218, 'time': 836, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 1956, 'tax': 0, 'total': 2126}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2595, 'time': 377, 'tolls': 375}, 25, None,
    0],
   {'discount': 0, 'surged': 8055, 'tax': 0, 'total': 8430}),
  ('normal control 2',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 359, 'time': 804, 'tolls': 0}, 10, None,
    625],
   {'discount': 0, 'surged': 1313, 'tax': 93, 'total': 2081}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 1650, 'time': 892, 'tolls': 690}, 17,
    None, 1000],
   {'discount': 0, 'surged': 4576, 'tax': 475, 'total': 6416}),
  ('normal control 4',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 2382, 'time': 551, 'tolls': 690}, 25,
    None, 825],
   {'discount': 0, 'surged': 7958, 'tax': 677, 'total': 10070})],
 [('regression: promo cap',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 2496, 'time': 616, 'tolls': 690}, 10,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 3362, 'tax': 215, 'total': 3512}),
  ('partial repair probe: promo cap',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2743, 'time': 287, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 4770, 'tax': 325, 'total': 4270}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2977, 'time': 212, 'tolls': 0}, 15,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 500, 'surged': 5159, 'tax': 0, 'total': 4659}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 530, 'time': 327, 'tolls': 690}, 10, None,
    625],
   {'discount': 0, 'surged': 1007, 'tax': 78, 'total': 2020}),
  ('normal control 2',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 175, 'distance': 693, 'time': 420, 'tolls': 375}, 25,
    None, 825],
   {'discount': 0, 'surged': 3408, 'tax': 296, 'total': 4754}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 403, 'time': 448, 'tolls': 0}, 15,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 330, 'surged': 1652, 'tax': 0, 'total': 1497}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 925, 'time': 819, 'tolls': 0}, 12, None,
    625],
   {'discount': 0, 'surged': 2273, 'tax': 157, 'total': 2675})],
 [('regression: promo cap',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 1887, 'time': 798, 'tolls': 0}, 17,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 4990, 'tax': 417, 'total': 4582}),
  ('partial repair probe: promo cap',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 2043, 'time': 744, 'tolls': 690}, 17,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 500, 'surged': 5163, 'tax': 0, 'total': 5528}),
  ('second regression',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 1583, 'time': 804, 'tolls': 0}, 25,
    {'cap': 500, 'pct': 20}, 825],
   {'discount': 500, 'surged': 6593, 'tax': 523, 'total': 7361}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 464, 'time': 114, 'tolls': 0}, 17,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 247, 'surged': 1238, 'tax': 0, 'total': 1166}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 504, 'time': 655, 'tolls': 375}, 25, None,
    0],
   {'discount': 0, 'surged': 3523, 'tax': 0, 'total': 4073}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 403, 'time': 175, 'tolls': 375}, 12,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 437, 'surged': 874, 'tax': 36, 'total': 1348}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2545, 'time': 164, 'tolls': 690}, 15, None,
    625],
   {'discount': 0, 'surged': 4439, 'tax': 277, 'total': 5406})],
 [('regression: promo cap',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 592, 'time': 318, 'tolls': 690}, 10,
    {'cap': 5, 'pct': 15}, 625],
   {'discount': 5, 'surged': 1160, 'tax': 72, 'total': 1917}),
  ('partial repair probe: promo cap',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2992, 'time': 342, 'tolls': 690}, 10,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 500, 'surged': 3484, 'tax': 0, 'total': 3674}),
  ('second regression',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 920, 'time': 542, 'tolls': 690}, 17,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 2740, 'tax': 242, 'total': 3347}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 1845, 'time': 397, 'tolls': 375}, 15,
    None, 1000],
   {'discount': 0, 'surged': 3588, 'tax': 359, 'total': 4822}),
  ('normal control 2',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 2544, 'time': 666, 'tolls': 690}, 10,
    None, 625],
   {'discount': 0, 'surged': 3360, 'tax': 210, 'total': 4760}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 275, 'time': 747, 'tolls': 690}, 25, None,
    1000],
   {'discount': 0, 'surged': 3180, 'tax': 343, 'total': 4458}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2045, 'time': 515, 'tolls': 0}, 15, None,
    0],
   {'discount': 0, 'surged': 4215, 'tax': 0, 'total': 4215})]]
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)

prompt:
A 50% promo takes 40.00 off an 80.00 ride despite a 10.00 cap.

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.

split: open-access


broken_source:
"""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 + parts['tolls'] + parts['airport_fee']) * 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: tax base pass-throughs',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 245, 'distance': 2406, 'time': 539, 'tolls': 375}, 17,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 5262, 'tax': 372, 'total': 5754}),
  ('partial repair probe: tax base pass-throughs',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 469, 'time': 618, 'tolls': 690}, 17,
    {'cap': 5, 'pct': 15}, 625],
   {'discount': 5, 'surged': 2273, 'tax': 142, 'total': 3600}),
  ('second regression',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 1550, 'time': 85, 'tolls': 375}, 15,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 2678, 'tax': 153, 'total': 2381}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2734, 'time': 279, 'tolls': 0}, 25,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 8158, 'tax': 766, 'total': 8424}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 2248, 'time': 508, 'tolls': 0}, 17,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 5110, 'tax': 479, 'total': 5264}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2650, 'time': 202, 'tolls': 0}, 10,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 3102, 'tax': 310, 'total': 3407}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2389, 'time': 840, 'tolls': 0}, 12, None,
    1000],
   {'discount': 0, 'surged': 4055, 'tax': 406, 'total': 4461})],
 [('regression: tax base pass-throughs',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 2245, 'time': 503, 'tolls': 375}, 17,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 5097, 'tax': 358, 'total': 5075}),
  ('partial repair probe: tax base pass-throughs',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 2032, 'time': 137, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 625],
   {'discount': 1000, 'surged': 3629, 'tax': 180, 'total': 3554}),
  ('second regression',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 493, 'time': 689, 'tolls': 690}, 15,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 2148, 'tax': 115, 'total': 2453}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2242, 'time': 356, 'tolls': 0}, 25, None,
    1000],
   {'discount': 0, 'surged': 6870, 'tax': 705, 'total': 7750}),
  ('normal control 2',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 2484, 'time': 239, 'tolls': 375}, 10,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 500, 'surged': 2873, 'tax': 0, 'total': 3423}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1450, 'time': 685, 'tolls': 690}, 10, None,
    0],
   {'discount': 0, 'surged': 2385, 'tax': 0, 'total': 3075}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1384, 'time': 605, 'tolls': 375}, 25,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 1000, 'surged': 5598, 'tax': 0, 'total': 5218})],
 [('regression: tax base pass-throughs',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 2864, 'time': 693, 'tolls': 690}, 25,
    None, 1000],
   {'discount': 0, 'surged': 9518, 'tax': 976, 'total': 11929}),
  ('partial repair probe: tax base pass-throughs',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 2979, 'time': 350, 'tolls': 375}, 10,
    None, 625],
   {'discount': 0, 'surged': 3579, 'tax': 224, 'total': 4678}),
  ('second regression',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1097, 'time': 564, 'tolls': 375}, 25, None,
    625],
   {'discount': 0, 'surged': 4528, 'tax': 283, 'total': 5186}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 766, 'time': 97, 'tolls': 0}, 17,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 1722, 'tax': 0, 'total': 1717}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 153, 'time': 253, 'tolls': 0}, 10,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 328, 'surged': 656, 'tax': 0, 'total': 328}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2516, 'time': 255, 'tolls': 0}, 17,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 5136, 'tax': 423, 'total': 5554}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2401, 'time': 633, 'tolls': 0}, 12,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 3821, 'tax': 300, 'total': 3296})],
 [('regression: tax base pass-throughs',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1429, 'time': 711, 'tolls': 375}, 12,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 2868, 'tax': 256, 'total': 3739}),
  ('partial repair probe: tax base pass-throughs',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 1495, 'time': 630, 'tolls': 375}, 25,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 5938, 'tax': 518, 'total': 6576}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2410, 'time': 738, 'tolls': 375}, 17, None,
    1000],
   {'discount': 0, 'surged': 5777, 'tax': 578, 'total': 6730}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 715, 'time': 669, 'tolls': 0}, 17, None,
    625],
   {'discount': 0, 'surged': 2608, 'tax': 178, 'total': 3031}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2721, 'time': 80, 'tolls': 0}, 10,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 2951, 'tax': 164, 'total': 2790}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 2525, 'time': 270, 'tolls': 0}, 10, None,
    0],
   {'discount': 0, 'surged': 3045, 'tax': 0, 'total': 3220}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1654, 'time': 354, 'tolls': 0}, 12,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 2710, 'tax': 223, 'total': 2928})],
 [('regression: tax base pass-throughs',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 334, 'time': 196, 'tolls': 0}, 12,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 408, 'surged': 816, 'tax': 48, 'total': 1131}),
  ('partial repair probe: tax base pass-throughs',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 2268, 'time': 551, 'tolls': 0}, 10,
    None, 625],
   {'discount': 0, 'surged': 2969, 'tax': 197, 'total': 3841}),
  ('second regression',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 2751, 'time': 391, 'tolls': 690}, 12,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 3950, 'tax': 227, 'total': 5042}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1613, 'time': 249, 'tolls': 375}, 25,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 5030, 'tax': 0, 'total': 5400}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 1014, 'time': 577, 'tolls': 0}, 15, None,
    825],
   {'discount': 0, 'surged': 2762, 'tax': 242, 'total': 3179}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 175, 'distance': 1130, 'time': 733, 'tolls': 0}, 25,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 5283, 'tax': 0, 'total': 5953}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 1904, 'time': 392, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 3819, 'tax': 0, 'total': 3989})]]
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)

source:
"""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 + parts['airport_fee']) * 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: tax base pass-throughs',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 245, 'distance': 2406, 'time': 539, 'tolls': 375}, 17,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 5262, 'tax': 372, 'total': 5754}),
  ('partial repair probe: tax base pass-throughs',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 469, 'time': 618, 'tolls': 690}, 17,
    {'cap': 5, 'pct': 15}, 625],
   {'discount': 5, 'surged': 2273, 'tax': 142, 'total': 3600}),
  ('second regression',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 1550, 'time': 85, 'tolls': 375}, 15,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 2678, 'tax': 153, 'total': 2381}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2734, 'time': 279, 'tolls': 0}, 25,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 8158, 'tax': 766, 'total': 8424}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 2248, 'time': 508, 'tolls': 0}, 17,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 5110, 'tax': 479, 'total': 5264}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2650, 'time': 202, 'tolls': 0}, 10,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 3102, 'tax': 310, 'total': 3407}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2389, 'time': 840, 'tolls': 0}, 12, None,
    1000],
   {'discount': 0, 'surged': 4055, 'tax': 406, 'total': 4461})],
 [('regression: tax base pass-throughs',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 2245, 'time': 503, 'tolls': 375}, 17,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 5097, 'tax': 358, 'total': 5075}),
  ('partial repair probe: tax base pass-throughs',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 2032, 'time': 137, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 625],
   {'discount': 1000, 'surged': 3629, 'tax': 180, 'total': 3554}),
  ('second regression',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 493, 'time': 689, 'tolls': 690}, 15,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 2148, 'tax': 115, 'total': 2453}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2242, 'time': 356, 'tolls': 0}, 25, None,
    1000],
   {'discount': 0, 'surged': 6870, 'tax': 705, 'total': 7750}),
  ('normal control 2',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 2484, 'time': 239, 'tolls': 375}, 10,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 500, 'surged': 2873, 'tax': 0, 'total': 3423}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1450, 'time': 685, 'tolls': 690}, 10, None,
    0],
   {'discount': 0, 'surged': 2385, 'tax': 0, 'total': 3075}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1384, 'time': 605, 'tolls': 375}, 25,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 1000, 'surged': 5598, 'tax': 0, 'total': 5218})],
 [('regression: tax base pass-throughs',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 2864, 'time': 693, 'tolls': 690}, 25,
    None, 1000],
   {'discount': 0, 'surged': 9518, 'tax': 976, 'total': 11929}),
  ('partial repair probe: tax base pass-throughs',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 2979, 'time': 350, 'tolls': 375}, 10,
    None, 625],
   {'discount': 0, 'surged': 3579, 'tax': 224, 'total': 4678}),
  ('second regression',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1097, 'time': 564, 'tolls': 375}, 25, None,
    625],
   {'discount': 0, 'surged': 4528, 'tax': 283, 'total': 5186}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 766, 'time': 97, 'tolls': 0}, 17,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 1722, 'tax': 0, 'total': 1717}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 153, 'time': 253, 'tolls': 0}, 10,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 328, 'surged': 656, 'tax': 0, 'total': 328}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2516, 'time': 255, 'tolls': 0}, 17,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 5136, 'tax': 423, 'total': 5554}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2401, 'time': 633, 'tolls': 0}, 12,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 3821, 'tax': 300, 'total': 3296})],
 [('regression: tax base pass-throughs',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1429, 'time': 711, 'tolls': 375}, 12,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 2868, 'tax': 256, 'total': 3739}),
  ('partial repair probe: tax base pass-throughs',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 1495, 'time': 630, 'tolls': 375}, 25,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 5938, 'tax': 518, 'total': 6576}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2410, 'time': 738, 'tolls': 375}, 17, None,
    1000],
   {'discount': 0, 'surged': 5777, 'tax': 578, 'total': 6730}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 715, 'time': 669, 'tolls': 0}, 17, None,
    625],
   {'discount': 0, 'surged': 2608, 'tax': 178, 'total': 3031}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2721, 'time': 80, 'tolls': 0}, 10,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 2951, 'tax': 164, 'total': 2790}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 2525, 'time': 270, 'tolls': 0}, 10, None,
    0],
   {'discount': 0, 'surged': 3045, 'tax': 0, 'total': 3220}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1654, 'time': 354, 'tolls': 0}, 12,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 2710, 'tax': 223, 'total': 2928})],
 [('regression: tax base pass-throughs',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 334, 'time': 196, 'tolls': 0}, 12,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 408, 'surged': 816, 'tax': 48, 'total': 1131}),
  ('partial repair probe: tax base pass-throughs',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 2268, 'time': 551, 'tolls': 0}, 10,
    None, 625],
   {'discount': 0, 'surged': 2969, 'tax': 197, 'total': 3841}),
  ('second regression',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 2751, 'time': 391, 'tolls': 690}, 12,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 3950, 'tax': 227, 'total': 5042}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1613, 'time': 249, 'tolls': 375}, 25,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 5030, 'tax': 0, 'total': 5400}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 1014, 'time': 577, 'tolls': 0}, 15, None,
    825],
   {'discount': 0, 'surged': 2762, 'tax': 242, 'total': 3179}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 175, 'distance': 1130, 'time': 733, 'tolls': 0}, 25,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 5283, 'tax': 0, 'total': 5953}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 1904, 'time': 392, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 3819, 'tax': 0, 'total': 3989})]]
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)

prompt:
Airport trips show tax on the pass-through fees.

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.

split: open-access


broken_source:
"""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 = 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: surge product rounding',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1133, 'time': 346, 'tolls': 690}, 25,
    {'cap': 1000, 'pct': 50}, 625],
   {'discount': 1000, 'surged': 4323, 'tax': 208, 'total': 4221}),
  ('partial repair probe: surge product rounding',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2672, 'time': 63, 'tolls': 0}, 25, None,
    625],
   {'discount': 0, 'surged': 7213, 'tax': 462, 'total': 7850}),
  ('second regression',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 915, 'time': 814, 'tolls': 375}, 12,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 451, 'surged': 2255, 'tax': 205, 'total': 2629}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1078, 'time': 847, 'tolls': 690}, 12,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 498, 'surged': 2490, 'tax': 199, 'total': 2881}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1178, 'time': 825, 'tolls': 0}, 17,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 3830, 'tax': 0, 'total': 4070}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 651, 'time': 574, 'tolls': 375}, 12,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 825, 'surged': 1650, 'tax': 83, 'total': 1283}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2422, 'time': 315, 'tolls': 375}, 10, None,
    825],
   {'discount': 0, 'surged': 2887, 'tax': 238, 'total': 3500})],
 [('regression: surge product rounding',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1959, 'time': 269, 'tolls': 0}, 17, None,
    625],
   {'discount': 0, 'surged': 4043, 'tax': 253, 'total': 4296}),
  ('partial repair probe: surge product rounding',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 227, 'time': 722, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 625],
   {'discount': 5, 'surged': 1799, 'tax': 123, 'total': 2092}),
  ('second regression',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 670, 'time': 311, 'tolls': 0}, 25,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 3078, 'tax': 258, 'total': 3336}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 2869, 'time': 310, 'tolls': 0}, 10,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 3329, 'tax': 289, 'total': 4288}),
  ('normal control 2',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 175, 'distance': 2735, 'time': 367, 'tolls': 690}, 12,
    {'cap': 500, 'pct': 20}, 825],
   {'discount': 500, 'surged': 4022, 'tax': 305, 'total': 5192}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 1129, 'time': 187, 'tolls': 0}, 12, None,
    625],
   {'discount': 0, 'surged': 1759, 'tax': 125, 'total': 2129}),
  ('normal control 4',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 2184, 'time': 136, 'tolls': 0}, 17,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 1000, 'surged': 4199, 'tax': 0, 'total': 3699})],
 [('regression: surge product rounding',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 245, 'distance': 1137, 'time': 394, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 625],
   {'discount': 1000, 'surged': 2522, 'tax': 110, 'total': 2377}),
  ('partial repair probe: surge product rounding',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1239, 'time': 362, 'tolls': 375}, 15,
    None, 625],
   {'discount': 0, 'surged': 2777, 'tax': 189, 'total': 3586}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 2998, 'time': 169, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 625],
   {'discount': 5, 'surged': 5126, 'tax': 331, 'total': 5627}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 978, 'time': 114, 'tolls': 690}, 25, None,
    825],
   {'discount': 0, 'surged': 3105, 'tax': 256, 'total': 4051}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2383, 'time': 160, 'tolls': 0}, 17,
    {'cap': 5, 'pct': 15}, 625],
   {'discount': 5, 'surged': 4578, 'tax': 286, 'total': 4859}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 1266, 'time': 570, 'tolls': 0}, 17,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 3376, 'tax': 0, 'total': 3546}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 2592, 'time': 644, 'tolls': 0}, 10,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 3386, 'tax': 313, 'total': 3444})],
 [('regression: surge product rounding',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 343, 'time': 325, 'tolls': 0}, 12,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 196, 'surged': 982, 'tax': 49, 'total': 835}),
  ('partial repair probe: surge product rounding',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 401, 'time': 180, 'tolls': 375}, 15,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 623, 'surged': 1247, 'tax': 87, 'total': 1831}),
  ('second regression',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 1525, 'time': 734, 'tolls': 690}, 15,
    None, 625],
   {'discount': 0, 'surged': 3614, 'tax': 237, 'total': 5216}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1417, 'time': 611, 'tolls': 375}, 25,
    {'cap': 500, 'pct': 20}, 825],
   {'discount': 500, 'surged': 5695, 'tax': 449, 'total': 6264}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2189, 'time': 343, 'tolls': 375}, 10,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 2782, 'tax': 147, 'total': 2304}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 986, 'time': 383, 'tolls': 375}, 10,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 1519, 'tax': 0, 'total': 2064}),
  ('normal control 4',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 556, 'time': 727, 'tolls': 375}, 10,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 286, 'surged': 1433, 'tax': 83, 'total': 2280})],
 [('regression: surge product rounding',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 1239, 'time': 898, 'tolls': 690}, 15,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 3431, 'tax': 0, 'total': 4361}),
  ('partial repair probe: surge product rounding',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 449, 'time': 856, 'tolls': 690}, 15,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 1000, 'surged': 2183, 'tax': 0, 'total': 2548}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 253, 'time': 50, 'tolls': 375}, 15,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 415, 'surged': 830, 'tax': 59, 'total': 1024}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 288, 'time': 608, 'tolls': 690}, 12,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 1375, 'tax': 0, 'total': 2560}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1188, 'time': 261, 'tolls': 0}, 10,
    {'cap': 500, 'pct': 20}, 825],
   {'discount': 339, 'surged': 1699, 'tax': 112, 'total': 1472}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 239, 'time': 770, 'tolls': 375}, 17,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 394, 'surged': 1970, 'tax': 0, 'total': 1951}),
  ('normal control 4',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 245, 'distance': 1284, 'time': 494, 'tolls': 690}, 10,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 964, 'surged': 1928, 'tax': 0, 'total': 2399})]]
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)

source:
"""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 = round(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: surge product rounding',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1133, 'time': 346, 'tolls': 690}, 25,
    {'cap': 1000, 'pct': 50}, 625],
   {'discount': 1000, 'surged': 4323, 'tax': 208, 'total': 4221}),
  ('partial repair probe: surge product rounding',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2672, 'time': 63, 'tolls': 0}, 25, None,
    625],
   {'discount': 0, 'surged': 7213, 'tax': 462, 'total': 7850}),
  ('second regression',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 915, 'time': 814, 'tolls': 375}, 12,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 451, 'surged': 2255, 'tax': 205, 'total': 2629}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1078, 'time': 847, 'tolls': 690}, 12,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 498, 'surged': 2490, 'tax': 199, 'total': 2881}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1178, 'time': 825, 'tolls': 0}, 17,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 3830, 'tax': 0, 'total': 4070}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 651, 'time': 574, 'tolls': 375}, 12,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 825, 'surged': 1650, 'tax': 83, 'total': 1283}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2422, 'time': 315, 'tolls': 375}, 10, None,
    825],
   {'discount': 0, 'surged': 2887, 'tax': 238, 'total': 3500})],
 [('regression: surge product rounding',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1959, 'time': 269, 'tolls': 0}, 17, None,
    625],
   {'discount': 0, 'surged': 4043, 'tax': 253, 'total': 4296}),
  ('partial repair probe: surge product rounding',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 227, 'time': 722, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 625],
   {'discount': 5, 'surged': 1799, 'tax': 123, 'total': 2092}),
  ('second regression',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 670, 'time': 311, 'tolls': 0}, 25,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 3078, 'tax': 258, 'total': 3336}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 2869, 'time': 310, 'tolls': 0}, 10,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 3329, 'tax': 289, 'total': 4288}),
  ('normal control 2',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 175, 'distance': 2735, 'time': 367, 'tolls': 690}, 12,
    {'cap': 500, 'pct': 20}, 825],
   {'discount': 500, 'surged': 4022, 'tax': 305, 'total': 5192}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 1129, 'time': 187, 'tolls': 0}, 12, None,
    625],
   {'discount': 0, 'surged': 1759, 'tax': 125, 'total': 2129}),
  ('normal control 4',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 2184, 'time': 136, 'tolls': 0}, 17,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 1000, 'surged': 4199, 'tax': 0, 'total': 3699})],
 [('regression: surge product rounding',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 245, 'distance': 1137, 'time': 394, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 625],
   {'discount': 1000, 'surged': 2522, 'tax': 110, 'total': 2377}),
  ('partial repair probe: surge product rounding',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1239, 'time': 362, 'tolls': 375}, 15,
    None, 625],
   {'discount': 0, 'surged': 2777, 'tax': 189, 'total': 3586}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 2998, 'time': 169, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 625],
   {'discount': 5, 'surged': 5126, 'tax': 331, 'total': 5627}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 978, 'time': 114, 'tolls': 690}, 25, None,
    825],
   {'discount': 0, 'surged': 3105, 'tax': 256, 'total': 4051}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2383, 'time': 160, 'tolls': 0}, 17,
    {'cap': 5, 'pct': 15}, 625],
   {'discount': 5, 'surged': 4578, 'tax': 286, 'total': 4859}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 1266, 'time': 570, 'tolls': 0}, 17,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 3376, 'tax': 0, 'total': 3546}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 2592, 'time': 644, 'tolls': 0}, 10,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 3386, 'tax': 313, 'total': 3444})],
 [('regression: surge product rounding',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 343, 'time': 325, 'tolls': 0}, 12,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 196, 'surged': 982, 'tax': 49, 'total': 835}),
  ('partial repair probe: surge product rounding',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 401, 'time': 180, 'tolls': 375}, 15,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 623, 'surged': 1247, 'tax': 87, 'total': 1831}),
  ('second regression',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 1525, 'time': 734, 'tolls': 690}, 15,
    None, 625],
   {'discount': 0, 'surged': 3614, 'tax': 237, 'total': 5216}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1417, 'time': 611, 'tolls': 375}, 25,
    {'cap': 500, 'pct': 20}, 825],
   {'discount': 500, 'surged': 5695, 'tax': 449, 'total': 6264}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2189, 'time': 343, 'tolls': 375}, 10,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 2782, 'tax': 147, 'total': 2304}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 986, 'time': 383, 'tolls': 375}, 10,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 1519, 'tax': 0, 'total': 2064}),
  ('normal control 4',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 556, 'time': 727, 'tolls': 375}, 10,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 286, 'surged': 1433, 'tax': 83, 'total': 2280})],
 [('regression: surge product rounding',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 1239, 'time': 898, 'tolls': 690}, 15,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 3431, 'tax': 0, 'total': 4361}),
  ('partial repair probe: surge product rounding',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 449, 'time': 856, 'tolls': 690}, 15,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 1000, 'surged': 2183, 'tax': 0, 'total': 2548}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 253, 'time': 50, 'tolls': 375}, 15,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 415, 'surged': 830, 'tax': 59, 'total': 1024}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 288, 'time': 608, 'tolls': 690}, 12,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 1375, 'tax': 0, 'total': 2560}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1188, 'time': 261, 'tolls': 0}, 10,
    {'cap': 500, 'pct': 20}, 825],
   {'discount': 339, 'surged': 1699, 'tax': 112, 'total': 1472}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 239, 'time': 770, 'tolls': 375}, 17,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 394, 'surged': 1970, 'tax': 0, 'total': 1951}),
  ('normal control 4',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 245, 'distance': 1284, 'time': 494, 'tolls': 690}, 10,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 964, 'surged': 1928, 'tax': 0, 'total': 2399})]]
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)

prompt:
A 1.5x fare on 12.35 shows 18.52 instead of 18.53.

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.

split: open-access