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

N = 1
observations = []
def solve(promo, ride, now_day):
    reason = None
    if now_day > promo['expires_day']:
        reason = 'expired'
    elif promo['uses_left'] <= 0:
        reason = 'exhausted'
    elif promo['first_ride_only'] and ride['rider_rides'] > 0:
        reason = 'not_first'
    elif ride['fare'] <= promo['min_fare']:
        reason = 'min_fare'
    disc = 0
    if reason is None:
        if promo['kind'] == 'pct':
            disc = ride['fare'] * promo['value'] // 100
            if promo['cap'] is not None:
                disc = min(disc, promo['cap'])
        else:
            disc = min(promo['value'], ride['fare'])
    credit = min(ride['credits'], ride['fare'] - disc)
    return {'discount': disc, 'credit_used': credit, 'due': ride['fare'] - disc - credit, 'reason': reason}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: minimum fare comparison',
   [{'cap': 0,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 1050,
     'uses_left': 1,
     'value': 500},
    {'credits': 5000, 'fare': 1050, 'rider_rides': 0}, 99],
   {'credit_used': 550, 'discount': 500, 'due': 0, 'reason': None}),
  ('partial repair probe: minimum fare comparison',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 1050,
     'uses_left': 1,
     'value': 500},
    {'credits': 0, 'fare': 1000, 'rider_rides': 0}, 100],
   {'credit_used': 0, 'discount': 0, 'due': 1000, 'reason': 'min_fare'}),
  ('second regression',
   [{'cap': 800,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 1050,
     'uses_left': 1,
     'value': 1000},
    {'credits': 0, 'fare': 1000, 'rider_rides': 5}, 100],
   {'credit_used': 0, 'discount': 0, 'due': 1000, 'reason': 'min_fare'}),
  ('normal control 1',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': True,
     'kind': 'pct',
     'min_fare': 0,
     'uses_left': 1,
     'value': 50},
    {'credits': 5000, 'fare': 1000, 'rider_rides': 1}, 101],
   {'credit_used': 1000, 'discount': 0, 'due': 0, 'reason': 'expired'}),
  ('normal control 2',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': True,
     'kind': 'flat',
     'min_fare': 0,
     'uses_left': 0,
     'value': 500},
    {'credits': 250, 'fare': 1099, 'rider_rides': 0}, 100],
   {'credit_used': 250, 'discount': 0, 'due': 849, 'reason': 'exhausted'}),
  ('normal control 3',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 0,
     'uses_left': 3,
     'value': 500},
    {'credits': 0, 'fare': 700, 'rider_rides': 1}, 99],
   {'credit_used': 0, 'discount': 500, 'due': 200, 'reason': None}),
  ('normal control 4',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 1000,
     'uses_left': 1,
     'value': 1000},
    {'credits': 5000, 'fare': 700, 'rider_rides': 5}, 99],
   {'credit_used': 700, 'discount': 0, 'due': 0, 'reason': 'min_fare'})],
 [('regression: minimum fare comparison',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 3,
     'value': 25},
    {'credits': 250, 'fare': 1050, 'rider_rides': 0}, 100],
   {'credit_used': 250, 'discount': 262, 'due': 538, 'reason': None}),
  ('partial repair probe: minimum fare comparison',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 1,
     'value': 10},
    {'credits': 0, 'fare': 1000, 'rider_rides': 5}, 100],
   {'credit_used': 0, 'discount': 0, 'due': 1000, 'reason': 'min_fare'}),
  ('second regression',
   [{'cap': 0,
     'expires_day': 100,
     'first_ride_only': True,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 3,
     'value': 25},
    {'credits': 0, 'fare': 1000, 'rider_rides': 0}, 100],
   {'credit_used': 0, 'discount': 0, 'due': 1000, 'reason': 'min_fare'}),
  ('normal control 1',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 0,
     'uses_left': 3,
     'value': 1000},
    {'credits': 0, 'fare': 1000, 'rider_rides': 0}, 99],
   {'credit_used': 0, 'discount': 1000, 'due': 0, 'reason': None}),
  ('normal control 2',
   [{'cap': 0,
     'expires_day': 100,
     'first_ride_only': True,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 0,
     'value': 25},
    {'credits': 5000, 'fare': 2167, 'rider_rides': 0}, 101],
   {'credit_used': 2167, 'discount': 0, 'due': 0, 'reason': 'expired'}),
  ('normal control 3',
   [{'cap': 0,
     'expires_day': 100,
     'first_ride_only': True,
     'kind': 'pct',
     'min_fare': 1000,
     'uses_left': 1,
     'value': 50},
    {'credits': 250, 'fare': 2346, 'rider_rides': 5}, 99],
   {'credit_used': 250, 'discount': 0, 'due': 2096, 'reason': 'not_first'}),
  ('normal control 4',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': True,
     'kind': 'pct',
     'min_fare': 0,
     'uses_left': 3,
     'value': 50},
    {'credits': 0, 'fare': 1099, 'rider_rides': 0}, 100],
   {'credit_used': 0, 'discount': 549, 'due': 550, 'reason': None})],
 [('regression: minimum fare comparison',
   [{'cap': 800,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1000,
     'uses_left': 3,
     'value': 10},
    {'credits': 250, 'fare': 1000, 'rider_rides': 5}, 100],
   {'credit_used': 250, 'discount': 100, 'due': 650, 'reason': None}),
  ('partial repair probe: minimum fare comparison',
   [{'cap': 0,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 1050,
     'uses_left': 3,
     'value': 500},
    {'credits': 0, 'fare': 1000, 'rider_rides': 5}, 99],
   {'credit_used': 0, 'discount': 0, 'due': 1000, 'reason': 'min_fare'}),
  ('second regression',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 3,
     'value': 10},
    {'credits': 250, 'fare': 1050, 'rider_rides': 0}, 99],
   {'credit_used': 250, 'discount': 105, 'due': 695, 'reason': None}),
  ('normal control 1',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 1050,
     'uses_left': 3,
     'value': 500},
    {'credits': 250, 'fare': 1099, 'rider_rides': 0}, 100],
   {'credit_used': 250, 'discount': 500, 'due': 349, 'reason': None}),
  ('normal control 2',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 0,
     'uses_left': 0,
     'value': 50},
    {'credits': 0, 'fare': 1050, 'rider_rides': 0}, 101],
   {'credit_used': 0, 'discount': 0, 'due': 1050, 'reason': 'expired'}),
  ('normal control 3',
   [{'cap': 800,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 0,
     'uses_left': 3,
     'value': 10},
    {'credits': 250, 'fare': 2400, 'rider_rides': 5}, 100],
   {'credit_used': 250, 'discount': 240, 'due': 1910, 'reason': None}),
  ('normal control 4',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 0,
     'value': 50},
    {'credits': 5000, 'fare': 1050, 'rider_rides': 0}, 100],
   {'credit_used': 1050, 'discount': 0, 'due': 0, 'reason': 'exhausted'})],
 [('regression: minimum fare comparison',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1000,
     'uses_left': 1,
     'value': 50},
    {'credits': 5000, 'fare': 1000, 'rider_rides': 0}, 99],
   {'credit_used': 500, 'discount': 500, 'due': 0, 'reason': None}),
  ('partial repair probe: minimum fare comparison',
   [{'cap': 800,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 3,
     'value': 25},
    {'credits': 250, 'fare': 1000, 'rider_rides': 0}, 99],
   {'credit_used': 250, 'discount': 0, 'due': 750, 'reason': 'min_fare'}),
  ('second regression',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 3,
     'value': 10},
    {'credits': 0, 'fare': 1000, 'rider_rides': 5}, 100],
   {'credit_used': 0, 'discount': 0, 'due': 1000, 'reason': 'min_fare'}),
  ('normal control 1',
   [{'cap': 800,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 0,
     'uses_left': 0,
     'value': 10},
    {'credits': 5000, 'fare': 1933, 'rider_rides': 0}, 101],
   {'credit_used': 1933, 'discount': 0, 'due': 0, 'reason': 'expired'}),
  ('normal control 2',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 1050,
     'uses_left': 0,
     'value': 500},
    {'credits': 0, 'fare': 1099, 'rider_rides': 5}, 99],
   {'credit_used': 0, 'discount': 0, 'due': 1099, 'reason': 'exhausted'}),
  ('normal control 3',
   [{'cap': 800,
     'expires_day': 100,
     'first_ride_only': True,
     'kind': 'flat',
     'min_fare': 0,
     'uses_left': 3,
     'value': 1000},
    {'credits': 0, 'fare': 2400, 'rider_rides': 0}, 99],
   {'credit_used': 0, 'discount': 1000, 'due': 1400, 'reason': None}),
  ('normal control 4',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 0,
     'value': 50},
    {'credits': 0, 'fare': 1050, 'rider_rides': 0}, 99],
   {'credit_used': 0, 'discount': 0, 'due': 1050, 'reason': 'exhausted'})],
 [('regression: minimum fare comparison',
   [{'cap': 800,
     'expires_day': 100,
     'first_ride_only': True,
     'kind': 'pct',
     'min_fare': 1000,
     'uses_left': 1,
     'value': 50},
    {'credits': 0, 'fare': 1000, 'rider_rides': 0}, 100],
   {'credit_used': 0, 'discount': 500, 'due': 500, 'reason': None}),
  ('partial repair probe: minimum fare comparison',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': True,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 3,
     'value': 25},
    {'credits': 5000, 'fare': 1000, 'rider_rides': 0}, 100],
   {'credit_used': 1000, 'discount': 0, 'due': 0, 'reason': 'min_fare'}),
  ('second regression',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1000,
     'uses_left': 3,
     'value': 10},
    {'credits': 5000, 'fare': 1000, 'rider_rides': 1}, 99],
   {'credit_used': 900, 'discount': 100, 'due': 0, 'reason': None}),
  ('normal control 1',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 0,
     'value': 10},
    {'credits': 0, 'fare': 700, 'rider_rides': 5}, 99],
   {'credit_used': 0, 'discount': 0, 'due': 700, 'reason': 'exhausted'}),
  ('normal control 2',
   [{'cap': 0,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 0,
     'value': 10},
    {'credits': 0, 'fare': 1099, 'rider_rides': 0}, 101],
   {'credit_used': 0, 'discount': 0, 'due': 1099, 'reason': 'expired'}),
  ('normal control 3',
   [{'cap': 0,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1000,
     'uses_left': 0,
     'value': 25},
    {'credits': 250, 'fare': 1099, 'rider_rides': 0}, 100],
   {'credit_used': 250, 'discount': 0, 'due': 849, 'reason': 'exhausted'}),
  ('normal control 4',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 1050,
     'uses_left': 1,
     'value': 2500},
    {'credits': 250, 'fare': 700, 'rider_rides': 0}, 101],
   {'credit_used': 250, 'discount': 0, 'due': 450, 'reason': 'expired'})]]
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(promo, ride, now_day):
    reason = None
    if now_day > promo['expires_day']:
        reason = 'expired'
    elif promo['uses_left'] <= 0:
        reason = 'exhausted'
    elif promo['first_ride_only'] and ride['rider_rides'] > 0:
        reason = 'not_first'
    elif ride['fare'] // 100 < promo['min_fare'] // 100:
        reason = 'min_fare'
    disc = 0
    if reason is None:
        if promo['kind'] == 'pct':
            disc = ride['fare'] * promo['value'] // 100
            if promo['cap'] is not None:
                disc = min(disc, promo['cap'])
        else:
            disc = min(promo['value'], ride['fare'])
    credit = min(ride['credits'], ride['fare'] - disc)
    return {'discount': disc, 'credit_used': credit, 'due': ride['fare'] - disc - credit, 'reason': reason}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: minimum fare comparison',
   [{'cap': 0,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 1050,
     'uses_left': 1,
     'value': 500},
    {'credits': 5000, 'fare': 1050, 'rider_rides': 0}, 99],
   {'credit_used': 550, 'discount': 500, 'due': 0, 'reason': None}),
  ('partial repair probe: minimum fare comparison',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 1050,
     'uses_left': 1,
     'value': 500},
    {'credits': 0, 'fare': 1000, 'rider_rides': 0}, 100],
   {'credit_used': 0, 'discount': 0, 'due': 1000, 'reason': 'min_fare'}),
  ('second regression',
   [{'cap': 800,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 1050,
     'uses_left': 1,
     'value': 1000},
    {'credits': 0, 'fare': 1000, 'rider_rides': 5}, 100],
   {'credit_used': 0, 'discount': 0, 'due': 1000, 'reason': 'min_fare'}),
  ('normal control 1',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': True,
     'kind': 'pct',
     'min_fare': 0,
     'uses_left': 1,
     'value': 50},
    {'credits': 5000, 'fare': 1000, 'rider_rides': 1}, 101],
   {'credit_used': 1000, 'discount': 0, 'due': 0, 'reason': 'expired'}),
  ('normal control 2',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': True,
     'kind': 'flat',
     'min_fare': 0,
     'uses_left': 0,
     'value': 500},
    {'credits': 250, 'fare': 1099, 'rider_rides': 0}, 100],
   {'credit_used': 250, 'discount': 0, 'due': 849, 'reason': 'exhausted'}),
  ('normal control 3',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 0,
     'uses_left': 3,
     'value': 500},
    {'credits': 0, 'fare': 700, 'rider_rides': 1}, 99],
   {'credit_used': 0, 'discount': 500, 'due': 200, 'reason': None}),
  ('normal control 4',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 1000,
     'uses_left': 1,
     'value': 1000},
    {'credits': 5000, 'fare': 700, 'rider_rides': 5}, 99],
   {'credit_used': 700, 'discount': 0, 'due': 0, 'reason': 'min_fare'})],
 [('regression: minimum fare comparison',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 3,
     'value': 25},
    {'credits': 250, 'fare': 1050, 'rider_rides': 0}, 100],
   {'credit_used': 250, 'discount': 262, 'due': 538, 'reason': None}),
  ('partial repair probe: minimum fare comparison',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 1,
     'value': 10},
    {'credits': 0, 'fare': 1000, 'rider_rides': 5}, 100],
   {'credit_used': 0, 'discount': 0, 'due': 1000, 'reason': 'min_fare'}),
  ('second regression',
   [{'cap': 0,
     'expires_day': 100,
     'first_ride_only': True,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 3,
     'value': 25},
    {'credits': 0, 'fare': 1000, 'rider_rides': 0}, 100],
   {'credit_used': 0, 'discount': 0, 'due': 1000, 'reason': 'min_fare'}),
  ('normal control 1',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 0,
     'uses_left': 3,
     'value': 1000},
    {'credits': 0, 'fare': 1000, 'rider_rides': 0}, 99],
   {'credit_used': 0, 'discount': 1000, 'due': 0, 'reason': None}),
  ('normal control 2',
   [{'cap': 0,
     'expires_day': 100,
     'first_ride_only': True,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 0,
     'value': 25},
    {'credits': 5000, 'fare': 2167, 'rider_rides': 0}, 101],
   {'credit_used': 2167, 'discount': 0, 'due': 0, 'reason': 'expired'}),
  ('normal control 3',
   [{'cap': 0,
     'expires_day': 100,
     'first_ride_only': True,
     'kind': 'pct',
     'min_fare': 1000,
     'uses_left': 1,
     'value': 50},
    {'credits': 250, 'fare': 2346, 'rider_rides': 5}, 99],
   {'credit_used': 250, 'discount': 0, 'due': 2096, 'reason': 'not_first'}),
  ('normal control 4',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': True,
     'kind': 'pct',
     'min_fare': 0,
     'uses_left': 3,
     'value': 50},
    {'credits': 0, 'fare': 1099, 'rider_rides': 0}, 100],
   {'credit_used': 0, 'discount': 549, 'due': 550, 'reason': None})],
 [('regression: minimum fare comparison',
   [{'cap': 800,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1000,
     'uses_left': 3,
     'value': 10},
    {'credits': 250, 'fare': 1000, 'rider_rides': 5}, 100],
   {'credit_used': 250, 'discount': 100, 'due': 650, 'reason': None}),
  ('partial repair probe: minimum fare comparison',
   [{'cap': 0,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 1050,
     'uses_left': 3,
     'value': 500},
    {'credits': 0, 'fare': 1000, 'rider_rides': 5}, 99],
   {'credit_used': 0, 'discount': 0, 'due': 1000, 'reason': 'min_fare'}),
  ('second regression',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 3,
     'value': 10},
    {'credits': 250, 'fare': 1050, 'rider_rides': 0}, 99],
   {'credit_used': 250, 'discount': 105, 'due': 695, 'reason': None}),
  ('normal control 1',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 1050,
     'uses_left': 3,
     'value': 500},
    {'credits': 250, 'fare': 1099, 'rider_rides': 0}, 100],
   {'credit_used': 250, 'discount': 500, 'due': 349, 'reason': None}),
  ('normal control 2',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 0,
     'uses_left': 0,
     'value': 50},
    {'credits': 0, 'fare': 1050, 'rider_rides': 0}, 101],
   {'credit_used': 0, 'discount': 0, 'due': 1050, 'reason': 'expired'}),
  ('normal control 3',
   [{'cap': 800,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 0,
     'uses_left': 3,
     'value': 10},
    {'credits': 250, 'fare': 2400, 'rider_rides': 5}, 100],
   {'credit_used': 250, 'discount': 240, 'due': 1910, 'reason': None}),
  ('normal control 4',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 0,
     'value': 50},
    {'credits': 5000, 'fare': 1050, 'rider_rides': 0}, 100],
   {'credit_used': 1050, 'discount': 0, 'due': 0, 'reason': 'exhausted'})],
 [('regression: minimum fare comparison',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1000,
     'uses_left': 1,
     'value': 50},
    {'credits': 5000, 'fare': 1000, 'rider_rides': 0}, 99],
   {'credit_used': 500, 'discount': 500, 'due': 0, 'reason': None}),
  ('partial repair probe: minimum fare comparison',
   [{'cap': 800,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 3,
     'value': 25},
    {'credits': 250, 'fare': 1000, 'rider_rides': 0}, 99],
   {'credit_used': 250, 'discount': 0, 'due': 750, 'reason': 'min_fare'}),
  ('second regression',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 3,
     'value': 10},
    {'credits': 0, 'fare': 1000, 'rider_rides': 5}, 100],
   {'credit_used': 0, 'discount': 0, 'due': 1000, 'reason': 'min_fare'}),
  ('normal control 1',
   [{'cap': 800,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 0,
     'uses_left': 0,
     'value': 10},
    {'credits': 5000, 'fare': 1933, 'rider_rides': 0}, 101],
   {'credit_used': 1933, 'discount': 0, 'due': 0, 'reason': 'expired'}),
  ('normal control 2',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 1050,
     'uses_left': 0,
     'value': 500},
    {'credits': 0, 'fare': 1099, 'rider_rides': 5}, 99],
   {'credit_used': 0, 'discount': 0, 'due': 1099, 'reason': 'exhausted'}),
  ('normal control 3',
   [{'cap': 800,
     'expires_day': 100,
     'first_ride_only': True,
     'kind': 'flat',
     'min_fare': 0,
     'uses_left': 3,
     'value': 1000},
    {'credits': 0, 'fare': 2400, 'rider_rides': 0}, 99],
   {'credit_used': 0, 'discount': 1000, 'due': 1400, 'reason': None}),
  ('normal control 4',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 0,
     'value': 50},
    {'credits': 0, 'fare': 1050, 'rider_rides': 0}, 99],
   {'credit_used': 0, 'discount': 0, 'due': 1050, 'reason': 'exhausted'})],
 [('regression: minimum fare comparison',
   [{'cap': 800,
     'expires_day': 100,
     'first_ride_only': True,
     'kind': 'pct',
     'min_fare': 1000,
     'uses_left': 1,
     'value': 50},
    {'credits': 0, 'fare': 1000, 'rider_rides': 0}, 100],
   {'credit_used': 0, 'discount': 500, 'due': 500, 'reason': None}),
  ('partial repair probe: minimum fare comparison',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': True,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 3,
     'value': 25},
    {'credits': 5000, 'fare': 1000, 'rider_rides': 0}, 100],
   {'credit_used': 1000, 'discount': 0, 'due': 0, 'reason': 'min_fare'}),
  ('second regression',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1000,
     'uses_left': 3,
     'value': 10},
    {'credits': 5000, 'fare': 1000, 'rider_rides': 1}, 99],
   {'credit_used': 900, 'discount': 100, 'due': 0, 'reason': None}),
  ('normal control 1',
   [{'cap': 300,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 0,
     'value': 10},
    {'credits': 0, 'fare': 700, 'rider_rides': 5}, 99],
   {'credit_used': 0, 'discount': 0, 'due': 700, 'reason': 'exhausted'}),
  ('normal control 2',
   [{'cap': 0,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1050,
     'uses_left': 0,
     'value': 10},
    {'credits': 0, 'fare': 1099, 'rider_rides': 0}, 101],
   {'credit_used': 0, 'discount': 0, 'due': 1099, 'reason': 'expired'}),
  ('normal control 3',
   [{'cap': 0,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'pct',
     'min_fare': 1000,
     'uses_left': 0,
     'value': 25},
    {'credits': 250, 'fare': 1099, 'rider_rides': 0}, 100],
   {'credit_used': 250, 'discount': 0, 'due': 849, 'reason': 'exhausted'}),
  ('normal control 4',
   [{'cap': None,
     'expires_day': 100,
     'first_ride_only': False,
     'kind': 'flat',
     'min_fare': 1050,
     'uses_left': 1,
     'value': 2500},
    {'credits': 250, 'fare': 700, 'rider_rides': 0}, 101],
   {'credit_used': 250, 'discount': 0, 'due': 450, 'reason': 'expired'})]]
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 10.00 ride fails a 10.00 minimum-spend promo.

Validate a promo in order: expired if now_day is after expires_day (the expiry day itself is valid), exhausted if no uses remain, not_first if first-ride-only and the rider has prior rides, min_fare if the fare (cents) is below min_fare. A valid pct promo takes value% of the fare (floored), capped at cap cents when cap is not None (a cap of 0 means a zero discount); a flat promo takes value but never more than the fare. Ride credits then cover up to the remaining fare. Return discount, credit used, amount due and reason.

split: open-access


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

N = 1
observations = []
def solve(quote, request_t, current_surge):
    elapsed = request_t - quote['t']
    valid = 0 <= elapsed <= 300
    used = min(quote['surge'], current_surge) if valid else current_surge
    price = (quote['core'] * used * 2 + 10) // 20
    return [price, 'locked' if valid else 'requoted']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: lock expiry instant', [{'core': 999, 'surge': 20, 't': 5000}, 5300, 20], [1998, 'requoted']),
  ('partial repair probe: lock expiry instant', [{'core': 2500, 'surge': 20, 't': 5000}, 5900, 15],
   [3750, 'requoted']),
  ('second regression', [{'core': 999, 'surge': 20, 't': 5000}, 5900, 20], [1998, 'requoted']),
  ('normal control 1', [{'core': 999, 'surge': 15, 't': 5000}, 5299, 20], [1499, 'locked']),
  ('normal control 2', [{'core': 2500, 'surge': 10, 't': 5000}, 5001, 25], [2500, 'locked']),
  ('normal control 3', [{'core': 999, 'surge': 20, 't': 5000}, 5299, 20], [1998, 'locked']),
  ('normal control 4', [{'core': 2500, 'surge': 15, 't': 5000}, 5001, 25], [3750, 'locked'])],
 [('regression: lock expiry instant', [{'core': 1111, 'surge': 10, 't': 5000}, 5300, 20], [2222, 'requoted']),
  ('partial repair probe: lock expiry instant', [{'core': 999, 'surge': 15, 't': 5000}, 5900, 15],
   [1499, 'requoted']),
  ('second regression', [{'core': 999, 'surge': 10, 't': 5000}, 5300, 10], [999, 'requoted']),
  ('normal control 1', [{'core': 999, 'surge': 20, 't': 5000}, 5120, 10], [999, 'locked']),
  ('normal control 2', [{'core': 1111, 'surge': 20, 't': 5000}, 5120, 20], [2222, 'locked']),
  ('normal control 3', [{'core': 2500, 'surge': 15, 't': 5000}, 4995, 15], [3750, 'requoted']),
  ('normal control 4', [{'core': 1111, 'surge': 10, 't': 5000}, 5120, 15], [1111, 'locked'])],
 [('regression: lock expiry instant', [{'core': 2500, 'surge': 20, 't': 5000}, 5300, 15], [3750, 'requoted']),
  ('partial repair probe: lock expiry instant', [{'core': 2500, 'surge': 10, 't': 5000}, 5900, 12],
   [3000, 'requoted']),
  ('second regression', [{'core': 1111, 'surge': 10, 't': 5000}, 5301, 25], [2778, 'requoted']),
  ('normal control 1', [{'core': 2500, 'surge': 10, 't': 5000}, 5000, 12], [2500, 'locked']),
  ('normal control 2', [{'core': 999, 'surge': 10, 't': 5000}, 5000, 25], [999, 'locked']),
  ('normal control 3', [{'core': 1111, 'surge': 20, 't': 5000}, 4995, 25], [2778, 'requoted']),
  ('normal control 4', [{'core': 2500, 'surge': 15, 't': 5000}, 5299, 20], [3750, 'locked'])],
 [('regression: lock expiry instant', [{'core': 1111, 'surge': 15, 't': 5000}, 5300, 12], [1333, 'requoted']),
  ('partial repair probe: lock expiry instant', [{'core': 999, 'surge': 20, 't': 5000}, 5900, 10],
   [999, 'requoted']),
  ('second regression', [{'core': 1111, 'surge': 15, 't': 5000}, 5301, 10], [1111, 'requoted']),
  ('normal control 1', [{'core': 999, 'surge': 15, 't': 5000}, 4995, 20], [1998, 'requoted']),
  ('normal control 2', [{'core': 2500, 'surge': 20, 't': 5000}, 5120, 10], [2500, 'locked']),
  ('normal control 3', [{'core': 1111, 'surge': 10, 't': 5000}, 5299, 10], [1111, 'locked']),
  ('normal control 4', [{'core': 1111, 'surge': 10, 't': 5000}, 5001, 12], [1111, 'locked'])],
 [('regression: lock expiry instant', [{'core': 999, 'surge': 15, 't': 5000}, 5300, 20], [1998, 'requoted']),
  ('partial repair probe: lock expiry instant', [{'core': 1111, 'surge': 20, 't': 5000}, 5900, 15],
   [1667, 'requoted']),
  ('second regression', [{'core': 999, 'surge': 20, 't': 5000}, 5900, 10], [999, 'requoted']),
  ('normal control 1', [{'core': 999, 'surge': 10, 't': 5000}, 5120, 20], [999, 'locked']),
  ('normal control 2', [{'core': 999, 'surge': 20, 't': 5000}, 5120, 25], [1998, 'locked']),
  ('normal control 3', [{'core': 999, 'surge': 15, 't': 5000}, 5120, 15], [1499, 'locked']),
  ('normal control 4', [{'core': 1111, 'surge': 20, 't': 5000}, 5001, 15], [1667, 'locked'])]]
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(quote, request_t, current_surge):
    elapsed = request_t - quote['t']
    valid = 0 <= elapsed < 300 * 1000
    used = min(quote['surge'], current_surge) if valid else current_surge
    price = (quote['core'] * used * 2 + 10) // 20
    return [price, 'locked' if valid else 'requoted']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: lock expiry instant', [{'core': 999, 'surge': 20, 't': 5000}, 5300, 20], [1998, 'requoted']),
  ('partial repair probe: lock expiry instant', [{'core': 2500, 'surge': 20, 't': 5000}, 5900, 15],
   [3750, 'requoted']),
  ('second regression', [{'core': 999, 'surge': 20, 't': 5000}, 5900, 20], [1998, 'requoted']),
  ('normal control 1', [{'core': 999, 'surge': 15, 't': 5000}, 5299, 20], [1499, 'locked']),
  ('normal control 2', [{'core': 2500, 'surge': 10, 't': 5000}, 5001, 25], [2500, 'locked']),
  ('normal control 3', [{'core': 999, 'surge': 20, 't': 5000}, 5299, 20], [1998, 'locked']),
  ('normal control 4', [{'core': 2500, 'surge': 15, 't': 5000}, 5001, 25], [3750, 'locked'])],
 [('regression: lock expiry instant', [{'core': 1111, 'surge': 10, 't': 5000}, 5300, 20], [2222, 'requoted']),
  ('partial repair probe: lock expiry instant', [{'core': 999, 'surge': 15, 't': 5000}, 5900, 15],
   [1499, 'requoted']),
  ('second regression', [{'core': 999, 'surge': 10, 't': 5000}, 5300, 10], [999, 'requoted']),
  ('normal control 1', [{'core': 999, 'surge': 20, 't': 5000}, 5120, 10], [999, 'locked']),
  ('normal control 2', [{'core': 1111, 'surge': 20, 't': 5000}, 5120, 20], [2222, 'locked']),
  ('normal control 3', [{'core': 2500, 'surge': 15, 't': 5000}, 4995, 15], [3750, 'requoted']),
  ('normal control 4', [{'core': 1111, 'surge': 10, 't': 5000}, 5120, 15], [1111, 'locked'])],
 [('regression: lock expiry instant', [{'core': 2500, 'surge': 20, 't': 5000}, 5300, 15], [3750, 'requoted']),
  ('partial repair probe: lock expiry instant', [{'core': 2500, 'surge': 10, 't': 5000}, 5900, 12],
   [3000, 'requoted']),
  ('second regression', [{'core': 1111, 'surge': 10, 't': 5000}, 5301, 25], [2778, 'requoted']),
  ('normal control 1', [{'core': 2500, 'surge': 10, 't': 5000}, 5000, 12], [2500, 'locked']),
  ('normal control 2', [{'core': 999, 'surge': 10, 't': 5000}, 5000, 25], [999, 'locked']),
  ('normal control 3', [{'core': 1111, 'surge': 20, 't': 5000}, 4995, 25], [2778, 'requoted']),
  ('normal control 4', [{'core': 2500, 'surge': 15, 't': 5000}, 5299, 20], [3750, 'locked'])],
 [('regression: lock expiry instant', [{'core': 1111, 'surge': 15, 't': 5000}, 5300, 12], [1333, 'requoted']),
  ('partial repair probe: lock expiry instant', [{'core': 999, 'surge': 20, 't': 5000}, 5900, 10],
   [999, 'requoted']),
  ('second regression', [{'core': 1111, 'surge': 15, 't': 5000}, 5301, 10], [1111, 'requoted']),
  ('normal control 1', [{'core': 999, 'surge': 15, 't': 5000}, 4995, 20], [1998, 'requoted']),
  ('normal control 2', [{'core': 2500, 'surge': 20, 't': 5000}, 5120, 10], [2500, 'locked']),
  ('normal control 3', [{'core': 1111, 'surge': 10, 't': 5000}, 5299, 10], [1111, 'locked']),
  ('normal control 4', [{'core': 1111, 'surge': 10, 't': 5000}, 5001, 12], [1111, 'locked'])],
 [('regression: lock expiry instant', [{'core': 999, 'surge': 15, 't': 5000}, 5300, 20], [1998, 'requoted']),
  ('partial repair probe: lock expiry instant', [{'core': 1111, 'surge': 20, 't': 5000}, 5900, 15],
   [1667, 'requoted']),
  ('second regression', [{'core': 999, 'surge': 20, 't': 5000}, 5900, 10], [999, 'requoted']),
  ('normal control 1', [{'core': 999, 'surge': 10, 't': 5000}, 5120, 20], [999, 'locked']),
  ('normal control 2', [{'core': 999, 'surge': 20, 't': 5000}, 5120, 25], [1998, 'locked']),
  ('normal control 3', [{'core': 999, 'surge': 15, 't': 5000}, 5120, 15], [1499, 'locked']),
  ('normal control 4', [{'core': 1111, 'surge': 20, 't': 5000}, 5001, 15], [1667, 'locked'])]]
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 request exactly five minutes after the quote still uses the locked surge.

A fare quote locks its surge for 300 seconds: requests with 0 <= elapsed < 300 seconds are locked (a request timestamped before the quote, from clock skew, is not). A locked request uses the lower of the quoted and current surge; otherwise the current surge. Price = core x surge / 10, half up. Return [price, locked|requoted].

split: open-access


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

N = 1
observations = []
def solve(quote, request_t, current_surge):
    elapsed = request_t - quote['t']
    valid = 0 <= elapsed < 300
    used = quote['surge'] if valid else current_surge
    price = (quote['core'] * used * 2 + 10) // 20
    return [price, 'locked' if valid else 'requoted']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: downward price protection', [{'core': 999, 'surge': 20, 't': 5000}, 5000, 12],
   [1199, 'locked']),
  ('partial repair probe: downward price protection', [{'core': 1111, 'surge': 15, 't': 5000}, 5120, 20],
   [1667, 'locked']),
  ('second regression', [{'core': 2500, 'surge': 10, 't': 5000}, 5000, 20], [2500, 'locked']),
  ('normal control 1', [{'core': 999, 'surge': 15, 't': 5000}, 5300, 12], [1199, 'requoted']),
  ('normal control 2', [{'core': 1111, 'surge': 15, 't': 5000}, 5301, 12], [1333, 'requoted']),
  ('normal control 3', [{'core': 2500, 'surge': 20, 't': 5000}, 5301, 10], [2500, 'requoted']),
  ('normal control 4', [{'core': 2500, 'surge': 15, 't': 5000}, 5301, 12], [3000, 'requoted'])],
 [('regression: downward price protection', [{'core': 2500, 'surge': 20, 't': 5000}, 5299, 10],
   [2500, 'locked']),
  ('partial repair probe: downward price protection', [{'core': 1111, 'surge': 15, 't': 5000}, 5000, 25],
   [1667, 'locked']),
  ('second regression', [{'core': 999, 'surge': 10, 't': 5000}, 5000, 15], [999, 'locked']),
  ('normal control 1', [{'core': 999, 'surge': 15, 't': 5000}, 5299, 15], [1499, 'locked']),
  ('normal control 2', [{'core': 999, 'surge': 20, 't': 5000}, 5900, 20], [1998, 'requoted']),
  ('normal control 3', [{'core': 2500, 'surge': 15, 't': 5000}, 4995, 15], [3750, 'requoted']),
  ('normal control 4', [{'core': 999, 'surge': 10, 't': 5000}, 5120, 10], [999, 'locked'])],
 [('regression: downward price protection', [{'core': 999, 'surge': 15, 't': 5000}, 5299, 10],
   [999, 'locked']),
  ('partial repair probe: downward price protection', [{'core': 1111, 'surge': 10, 't': 5000}, 5000, 15],
   [1111, 'locked']),
  ('second regression', [{'core': 1111, 'surge': 15, 't': 5000}, 5001, 20], [1667, 'locked']),
  ('normal control 1', [{'core': 2500, 'surge': 20, 't': 5000}, 5900, 25], [6250, 'requoted']),
  ('normal control 2', [{'core': 1111, 'surge': 20, 't': 5000}, 5300, 25], [2778, 'requoted']),
  ('normal control 3', [{'core': 999, 'surge': 20, 't': 5000}, 5900, 15], [1499, 'requoted']),
  ('normal control 4', [{'core': 1111, 'surge': 15, 't': 5000}, 5301, 20], [2222, 'requoted'])],
 [('regression: downward price protection', [{'core': 2500, 'surge': 20, 't': 5000}, 5001, 15],
   [3750, 'locked']),
  ('partial repair probe: downward price protection', [{'core': 999, 'surge': 20, 't': 5000}, 5001, 25],
   [1998, 'locked']),
  ('second regression', [{'core': 2500, 'surge': 10, 't': 5000}, 5299, 20], [2500, 'locked']),
  ('normal control 1', [{'core': 2500, 'surge': 15, 't': 5000}, 4995, 12], [3000, 'requoted']),
  ('normal control 2', [{'core': 1111, 'surge': 20, 't': 5000}, 5300, 20], [2222, 'requoted']),
  ('normal control 3', [{'core': 2500, 'surge': 15, 't': 5000}, 5900, 10], [2500, 'requoted']),
  ('normal control 4', [{'core': 2500, 'surge': 10, 't': 5000}, 5001, 10], [2500, 'locked'])],
 [('regression: downward price protection', [{'core': 999, 'surge': 15, 't': 5000}, 5299, 12],
   [1199, 'locked']),
  ('partial repair probe: downward price protection', [{'core': 999, 'surge': 20, 't': 5000}, 5120, 25],
   [1998, 'locked']),
  ('second regression', [{'core': 1111, 'surge': 15, 't': 5000}, 5001, 20], [1667, 'locked']),
  ('normal control 1', [{'core': 2500, 'surge': 10, 't': 5000}, 5301, 10], [2500, 'requoted']),
  ('normal control 2', [{'core': 999, 'surge': 20, 't': 5000}, 5300, 10], [999, 'requoted']),
  ('normal control 3', [{'core': 1111, 'surge': 20, 't': 5000}, 5900, 10], [1111, 'requoted']),
  ('normal control 4', [{'core': 2500, 'surge': 15, 't': 5000}, 5299, 15], [3750, 'locked'])]]
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(quote, request_t, current_surge):
    elapsed = request_t - quote['t']
    valid = 0 <= elapsed < 300
    used = max(quote['surge'], current_surge) if valid else current_surge
    price = (quote['core'] * used * 2 + 10) // 20
    return [price, 'locked' if valid else 'requoted']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: downward price protection', [{'core': 999, 'surge': 20, 't': 5000}, 5000, 12],
   [1199, 'locked']),
  ('partial repair probe: downward price protection', [{'core': 1111, 'surge': 15, 't': 5000}, 5120, 20],
   [1667, 'locked']),
  ('second regression', [{'core': 2500, 'surge': 10, 't': 5000}, 5000, 20], [2500, 'locked']),
  ('normal control 1', [{'core': 999, 'surge': 15, 't': 5000}, 5300, 12], [1199, 'requoted']),
  ('normal control 2', [{'core': 1111, 'surge': 15, 't': 5000}, 5301, 12], [1333, 'requoted']),
  ('normal control 3', [{'core': 2500, 'surge': 20, 't': 5000}, 5301, 10], [2500, 'requoted']),
  ('normal control 4', [{'core': 2500, 'surge': 15, 't': 5000}, 5301, 12], [3000, 'requoted'])],
 [('regression: downward price protection', [{'core': 2500, 'surge': 20, 't': 5000}, 5299, 10],
   [2500, 'locked']),
  ('partial repair probe: downward price protection', [{'core': 1111, 'surge': 15, 't': 5000}, 5000, 25],
   [1667, 'locked']),
  ('second regression', [{'core': 999, 'surge': 10, 't': 5000}, 5000, 15], [999, 'locked']),
  ('normal control 1', [{'core': 999, 'surge': 15, 't': 5000}, 5299, 15], [1499, 'locked']),
  ('normal control 2', [{'core': 999, 'surge': 20, 't': 5000}, 5900, 20], [1998, 'requoted']),
  ('normal control 3', [{'core': 2500, 'surge': 15, 't': 5000}, 4995, 15], [3750, 'requoted']),
  ('normal control 4', [{'core': 999, 'surge': 10, 't': 5000}, 5120, 10], [999, 'locked'])],
 [('regression: downward price protection', [{'core': 999, 'surge': 15, 't': 5000}, 5299, 10],
   [999, 'locked']),
  ('partial repair probe: downward price protection', [{'core': 1111, 'surge': 10, 't': 5000}, 5000, 15],
   [1111, 'locked']),
  ('second regression', [{'core': 1111, 'surge': 15, 't': 5000}, 5001, 20], [1667, 'locked']),
  ('normal control 1', [{'core': 2500, 'surge': 20, 't': 5000}, 5900, 25], [6250, 'requoted']),
  ('normal control 2', [{'core': 1111, 'surge': 20, 't': 5000}, 5300, 25], [2778, 'requoted']),
  ('normal control 3', [{'core': 999, 'surge': 20, 't': 5000}, 5900, 15], [1499, 'requoted']),
  ('normal control 4', [{'core': 1111, 'surge': 15, 't': 5000}, 5301, 20], [2222, 'requoted'])],
 [('regression: downward price protection', [{'core': 2500, 'surge': 20, 't': 5000}, 5001, 15],
   [3750, 'locked']),
  ('partial repair probe: downward price protection', [{'core': 999, 'surge': 20, 't': 5000}, 5001, 25],
   [1998, 'locked']),
  ('second regression', [{'core': 2500, 'surge': 10, 't': 5000}, 5299, 20], [2500, 'locked']),
  ('normal control 1', [{'core': 2500, 'surge': 15, 't': 5000}, 4995, 12], [3000, 'requoted']),
  ('normal control 2', [{'core': 1111, 'surge': 20, 't': 5000}, 5300, 20], [2222, 'requoted']),
  ('normal control 3', [{'core': 2500, 'surge': 15, 't': 5000}, 5900, 10], [2500, 'requoted']),
  ('normal control 4', [{'core': 2500, 'surge': 10, 't': 5000}, 5001, 10], [2500, 'locked'])],
 [('regression: downward price protection', [{'core': 999, 'surge': 15, 't': 5000}, 5299, 12],
   [1199, 'locked']),
  ('partial repair probe: downward price protection', [{'core': 999, 'surge': 20, 't': 5000}, 5120, 25],
   [1998, 'locked']),
  ('second regression', [{'core': 1111, 'surge': 15, 't': 5000}, 5001, 20], [1667, 'locked']),
  ('normal control 1', [{'core': 2500, 'surge': 10, 't': 5000}, 5301, 10], [2500, 'requoted']),
  ('normal control 2', [{'core': 999, 'surge': 20, 't': 5000}, 5300, 10], [999, 'requoted']),
  ('normal control 3', [{'core': 1111, 'surge': 20, 't': 5000}, 5900, 10], [1111, 'requoted']),
  ('normal control 4', [{'core': 2500, 'surge': 15, 't': 5000}, 5299, 15], [3750, 'locked'])]]
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:
Riders pay the quoted 2.0x after surge dropped to 1.2x.

A fare quote locks its surge for 300 seconds: requests with 0 <= elapsed < 300 seconds are locked (a request timestamped before the quote, from clock skew, is not). A locked request uses the lower of the quoted and current surge; otherwise the current surge. Price = core x surge / 10, half up. Return [price, locked|requoted].

split: open-access


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

N = 1
observations = []
def solve(quote, request_t, current_surge):
    elapsed = request_t - quote['t']
    valid = elapsed < 300
    used = min(quote['surge'], current_surge) if valid else current_surge
    price = (quote['core'] * used * 2 + 10) // 20
    return [price, 'locked' if valid else 'requoted']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: clock skew', [{'core': 999, 'surge': 15, 't': 5000}, 4995, 20], [1998, 'requoted']),
  ('partial repair probe: clock skew', [{'core': 1111, 'surge': 10, 't': 5000}, 4995, 25],
   [2778, 'requoted']),
  ('second regression', [{'core': 2500, 'surge': 15, 't': 5000}, 4995, 25], [6250, 'requoted']),
  ('normal control 1', [{'core': 999, 'surge': 10, 't': 5000}, 5000, 12], [999, 'locked']),
  ('normal control 2', [{'core': 2500, 'surge': 20, 't': 5000}, 5900, 15], [3750, 'requoted']),
  ('normal control 3', [{'core': 2500, 'surge': 10, 't': 5000}, 5000, 25], [2500, 'locked']),
  ('normal control 4', [{'core': 999, 'surge': 15, 't': 5000}, 5300, 12], [1199, 'requoted'])],
 [('regression: clock skew', [{'core': 1111, 'surge': 10, 't': 5000}, 4995, 12], [1333, 'requoted']),
  ('partial repair probe: clock skew', [{'core': 999, 'surge': 20, 't': 5000}, 4995, 20], [1998, 'requoted']),
  ('second regression', [{'core': 2500, 'surge': 10, 't': 5000}, 4995, 10], [2500, 'requoted']),
  ('normal control 1', [{'core': 999, 'surge': 10, 't': 5000}, 5300, 15], [1499, 'requoted']),
  ('normal control 2', [{'core': 1111, 'surge': 10, 't': 5000}, 5299, 12], [1111, 'locked']),
  ('normal control 3', [{'core': 2500, 'surge': 15, 't': 5000}, 5001, 10], [2500, 'locked']),
  ('normal control 4', [{'core': 1111, 'surge': 20, 't': 5000}, 5120, 12], [1333, 'locked'])],
 [('regression: clock skew', [{'core': 1111, 'surge': 15, 't': 5000}, 4995, 15], [1667, 'requoted']),
  ('partial repair probe: clock skew', [{'core': 999, 'surge': 15, 't': 5000}, 4995, 25], [2498, 'requoted']),
  ('second regression', [{'core': 1111, 'surge': 10, 't': 5000}, 4995, 20], [2222, 'requoted']),
  ('normal control 1', [{'core': 2500, 'surge': 10, 't': 5000}, 5299, 10], [2500, 'locked']),
  ('normal control 2', [{'core': 999, 'surge': 10, 't': 5000}, 5300, 20], [1998, 'requoted']),
  ('normal control 3', [{'core': 999, 'surge': 10, 't': 5000}, 5299, 20], [999, 'locked']),
  ('normal control 4', [{'core': 1111, 'surge': 20, 't': 5000}, 5900, 10], [1111, 'requoted'])],
 [('regression: clock skew', [{'core': 999, 'surge': 20, 't': 5000}, 4995, 25], [2498, 'requoted']),
  ('partial repair probe: clock skew', [{'core': 999, 'surge': 20, 't': 5000}, 4995, 10], [999, 'requoted']),
  ('second regression', [{'core': 1111, 'surge': 20, 't': 5000}, 4995, 25], [2778, 'requoted']),
  ('normal control 1', [{'core': 2500, 'surge': 15, 't': 5000}, 5001, 10], [2500, 'locked']),
  ('normal control 2', [{'core': 1111, 'surge': 15, 't': 5000}, 5120, 20], [1667, 'locked']),
  ('normal control 3', [{'core': 999, 'surge': 10, 't': 5000}, 5301, 12], [1199, 'requoted']),
  ('normal control 4', [{'core': 1111, 'surge': 15, 't': 5000}, 5000, 15], [1667, 'locked'])],
 [('regression: clock skew', [{'core': 1111, 'surge': 10, 't': 5000}, 4995, 20], [2222, 'requoted']),
  ('partial repair probe: clock skew', [{'core': 2500, 'surge': 10, 't': 5000}, 4995, 20],
   [5000, 'requoted']),
  ('second regression', [{'core': 999, 'surge': 15, 't': 5000}, 4995, 25], [2498, 'requoted']),
  ('normal control 1', [{'core': 999, 'surge': 15, 't': 5000}, 5299, 10], [999, 'locked']),
  ('normal control 2', [{'core': 1111, 'surge': 15, 't': 5000}, 5120, 12], [1333, 'locked']),
  ('normal control 3', [{'core': 1111, 'surge': 15, 't': 5000}, 5300, 20], [2222, 'requoted']),
  ('normal control 4', [{'core': 2500, 'surge': 10, 't': 5000}, 5299, 15], [2500, 'locked'])]]
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(quote, request_t, current_surge):
    elapsed = request_t - quote['t']
    valid = abs(elapsed) < 300
    used = min(quote['surge'], current_surge) if valid else current_surge
    price = (quote['core'] * used * 2 + 10) // 20
    return [price, 'locked' if valid else 'requoted']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: clock skew', [{'core': 999, 'surge': 15, 't': 5000}, 4995, 20], [1998, 'requoted']),
  ('partial repair probe: clock skew', [{'core': 1111, 'surge': 10, 't': 5000}, 4995, 25],
   [2778, 'requoted']),
  ('second regression', [{'core': 2500, 'surge': 15, 't': 5000}, 4995, 25], [6250, 'requoted']),
  ('normal control 1', [{'core': 999, 'surge': 10, 't': 5000}, 5000, 12], [999, 'locked']),
  ('normal control 2', [{'core': 2500, 'surge': 20, 't': 5000}, 5900, 15], [3750, 'requoted']),
  ('normal control 3', [{'core': 2500, 'surge': 10, 't': 5000}, 5000, 25], [2500, 'locked']),
  ('normal control 4', [{'core': 999, 'surge': 15, 't': 5000}, 5300, 12], [1199, 'requoted'])],
 [('regression: clock skew', [{'core': 1111, 'surge': 10, 't': 5000}, 4995, 12], [1333, 'requoted']),
  ('partial repair probe: clock skew', [{'core': 999, 'surge': 20, 't': 5000}, 4995, 20], [1998, 'requoted']),
  ('second regression', [{'core': 2500, 'surge': 10, 't': 5000}, 4995, 10], [2500, 'requoted']),
  ('normal control 1', [{'core': 999, 'surge': 10, 't': 5000}, 5300, 15], [1499, 'requoted']),
  ('normal control 2', [{'core': 1111, 'surge': 10, 't': 5000}, 5299, 12], [1111, 'locked']),
  ('normal control 3', [{'core': 2500, 'surge': 15, 't': 5000}, 5001, 10], [2500, 'locked']),
  ('normal control 4', [{'core': 1111, 'surge': 20, 't': 5000}, 5120, 12], [1333, 'locked'])],
 [('regression: clock skew', [{'core': 1111, 'surge': 15, 't': 5000}, 4995, 15], [1667, 'requoted']),
  ('partial repair probe: clock skew', [{'core': 999, 'surge': 15, 't': 5000}, 4995, 25], [2498, 'requoted']),
  ('second regression', [{'core': 1111, 'surge': 10, 't': 5000}, 4995, 20], [2222, 'requoted']),
  ('normal control 1', [{'core': 2500, 'surge': 10, 't': 5000}, 5299, 10], [2500, 'locked']),
  ('normal control 2', [{'core': 999, 'surge': 10, 't': 5000}, 5300, 20], [1998, 'requoted']),
  ('normal control 3', [{'core': 999, 'surge': 10, 't': 5000}, 5299, 20], [999, 'locked']),
  ('normal control 4', [{'core': 1111, 'surge': 20, 't': 5000}, 5900, 10], [1111, 'requoted'])],
 [('regression: clock skew', [{'core': 999, 'surge': 20, 't': 5000}, 4995, 25], [2498, 'requoted']),
  ('partial repair probe: clock skew', [{'core': 999, 'surge': 20, 't': 5000}, 4995, 10], [999, 'requoted']),
  ('second regression', [{'core': 1111, 'surge': 20, 't': 5000}, 4995, 25], [2778, 'requoted']),
  ('normal control 1', [{'core': 2500, 'surge': 15, 't': 5000}, 5001, 10], [2500, 'locked']),
  ('normal control 2', [{'core': 1111, 'surge': 15, 't': 5000}, 5120, 20], [1667, 'locked']),
  ('normal control 3', [{'core': 999, 'surge': 10, 't': 5000}, 5301, 12], [1199, 'requoted']),
  ('normal control 4', [{'core': 1111, 'surge': 15, 't': 5000}, 5000, 15], [1667, 'locked'])],
 [('regression: clock skew', [{'core': 1111, 'surge': 10, 't': 5000}, 4995, 20], [2222, 'requoted']),
  ('partial repair probe: clock skew', [{'core': 2500, 'surge': 10, 't': 5000}, 4995, 20],
   [5000, 'requoted']),
  ('second regression', [{'core': 999, 'surge': 15, 't': 5000}, 4995, 25], [2498, 'requoted']),
  ('normal control 1', [{'core': 999, 'surge': 15, 't': 5000}, 5299, 10], [999, 'locked']),
  ('normal control 2', [{'core': 1111, 'surge': 15, 't': 5000}, 5120, 12], [1333, 'locked']),
  ('normal control 3', [{'core': 1111, 'surge': 15, 't': 5000}, 5300, 20], [2222, 'requoted']),
  ('normal control 4', [{'core': 2500, 'surge': 10, 't': 5000}, 5299, 15], [2500, 'locked'])]]
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:
Replayed or skewed requests reuse quotes that were not yet issued.

A fare quote locks its surge for 300 seconds: requests with 0 <= elapsed < 300 seconds are locked (a request timestamped before the quote, from clock skew, is not). A locked request uses the lower of the quoted and current surge; otherwise the current surge. Price = core x surge / 10, half up. Return [price, locked|requoted].

split: open-access


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

N = 1
observations = []
def solve(table, pickup_zone, drop_zone, metered, tolls, surge, airport_fees):
    p, d = pickup_zone.upper(), drop_zone.upper()
    flat = table.get(p + '|' + d)
    if flat is not None:
        fare, kind = flat, 'flat'
    else:
        fare, kind = (metered * surge * 2 + 10) // 20, 'metered'
    fare += airport_fees.get(p, {}).get('pickup', 0) + airport_fees.get(d, {}).get('dropoff', 0)
    return [fare + tolls, kind]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'air', 3608, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4800, 'flat']),
  ('partial repair probe: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'SHUT', 4805, 600, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [600, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'SHUT', 5208, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [250, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'Dt', 1699, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [3398, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'SHUT', 3856, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [7712, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'DT', 1127, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2254, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'UNI', 2552, 600, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5704, 'metered'])],
 [('regression: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'Dt', 1073, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [0, 'flat']),
  ('partial repair probe: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'SHUT', 931, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [600, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'AIR', 3359, 600, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5400, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'AIR', 2443, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [3343, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'UNI', 923, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [1846, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'Dt', 3022, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [3272, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'UNI', 805, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [1208, 'metered'])],
 [('regression: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'air', 3515, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5400, 'flat']),
  ('partial repair probe: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'SHUT', 2597, 250, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [250, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'DT', 4747, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [0, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'air', 2328, 600, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5556, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'MID', 5158, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5158, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'AIR', 1806, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4109, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'MID', 1753, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [1753, 'metered'])],
 [('regression: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'Dt', 1321, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [250, 'flat']),
  ('partial repair probe: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'SHUT', 5412, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [250, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'air', 880, 600, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5400, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'MID', 3538, 250, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [7326, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'MID', 3425, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [6850, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'SHUT', 4765, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [7748, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'MID', 1553, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2830, 'metered'])],
 [('regression: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'AIR', 3392, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4800, 'flat']),
  ('partial repair probe: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'SHUT', 2417, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [250, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'air', 3231, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5400, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'Dt', 1302, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [1902, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'DT', 5689, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [11378, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'SHUT', 4147, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4897, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'SHUT', 1371, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [1971, 'metered'])]]
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(table, pickup_zone, drop_zone, metered, tolls, surge, airport_fees):
    p, d = pickup_zone.upper(), drop_zone.upper()
    flat = table.get(p + '|' + d) or table.get(d + '|' + p)
    if flat is not None:
        fare, kind = flat, 'flat'
    else:
        fare, kind = (metered * surge * 2 + 10) // 20, 'metered'
    fare += airport_fees.get(p, {}).get('pickup', 0) + airport_fees.get(d, {}).get('dropoff', 0)
    return [fare + tolls, kind]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'air', 3608, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4800, 'flat']),
  ('partial repair probe: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'SHUT', 4805, 600, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [600, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'SHUT', 5208, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [250, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'Dt', 1699, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [3398, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'SHUT', 3856, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [7712, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'DT', 1127, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2254, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'UNI', 2552, 600, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5704, 'metered'])],
 [('regression: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'Dt', 1073, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [0, 'flat']),
  ('partial repair probe: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'SHUT', 931, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [600, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'AIR', 3359, 600, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5400, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'AIR', 2443, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [3343, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'UNI', 923, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [1846, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'Dt', 3022, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [3272, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'UNI', 805, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [1208, 'metered'])],
 [('regression: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'air', 3515, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5400, 'flat']),
  ('partial repair probe: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'SHUT', 2597, 250, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [250, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'DT', 4747, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [0, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'air', 2328, 600, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5556, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'MID', 5158, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5158, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'AIR', 1806, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4109, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'MID', 1753, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [1753, 'metered'])],
 [('regression: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'Dt', 1321, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [250, 'flat']),
  ('partial repair probe: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'SHUT', 5412, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [250, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'air', 880, 600, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5400, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'MID', 3538, 250, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [7326, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'MID', 3425, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [6850, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'SHUT', 4765, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [7748, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'MID', 1553, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2830, 'metered'])],
 [('regression: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'AIR', 3392, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4800, 'flat']),
  ('partial repair probe: reverse direction lookup',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'SHUT', 2417, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [250, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'air', 3231, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5400, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'Dt', 1302, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [1902, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'DT', 5689, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [11378, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'SHUT', 4147, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4897, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'SHUT', 1371, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [1971, 'metered'])]]
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:
Downtown-to-airport trips are metered while airport-to-downtown is flat.

Zone names are case-insensitive (normalized upper case). A flat fare table keyed "A|B" applies in both directions; a flat fare (0 is a valid promotional flat) is never surged. Otherwise the metered fare is surged (tenths, half up). Airport fees apply separately: the pickup fee of the pickup zone and the dropoff fee of the dropoff zone. Tolls are added last. Return [fare, flat|metered].

split: open-access


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

N = 1
observations = []
def solve(table, pickup_zone, drop_zone, metered, tolls, surge, airport_fees):
    p, d = pickup_zone.upper(), drop_zone.upper()
    flat = table.get(p + '|' + d, table.get(d + '|' + p))
    if flat is not None:
        fare, kind = (flat * surge * 2 + 10) // 20, 'flat'
    else:
        fare, kind = (metered * surge * 2 + 10) // 20, 'metered'
    fare += airport_fees.get(p, {}).get('pickup', 0) + airport_fees.get(d, {}).get('dropoff', 0)
    return [fare + tolls, kind]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'Dt', 4020, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5250, 'flat']),
  ('partial repair probe: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'UNI', 1583, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4650, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'air', 3817, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4200, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'MID', 1392, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2688, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'SHUT', 2416, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [0, 'flat']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'UNI', 1886, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5000, 'flat']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'MID', 3959, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [3959, 'metered'])],
 [('regression: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'DT', 2394, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5000, 'flat']),
  ('partial repair probe: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'DT', 1758, 250, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5250, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'Dt', 5666, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5000, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'DT', 4719, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5319, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'Dt', 4427, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4427, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'air', 2639, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5050, 'flat']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'UNI', 1611, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [1611, 'metered'])],
 [('regression: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'AIR', 4755, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4800, 'flat']),
  ('partial repair probe: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'Dt', 4524, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5600, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'DT', 1236, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5600, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'air', 2551, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5050, 'flat']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'SHUT', 3196, 250, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [6642, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'air', 2794, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5400, 'flat']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'air', 4676, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5726, 'metered'])],
 [('regression: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'DT', 5371, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5250, 'flat']),
  ('partial repair probe: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'Dt', 3909, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5250, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'AIR', 2322, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4800, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'UNI', 5805, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [8708, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'MID', 3717, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [6176, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'UNI', 4021, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [8042, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'AIR', 1131, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2247, 'metered'])],
 [('regression: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'air', 2796, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5400, 'flat']),
  ('partial repair probe: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'Dt', 2621, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5000, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'DT', 1792, 250, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5250, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'MID', 2031, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [3647, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'MID', 4946, 250, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [10142, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'air', 3171, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5557, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'AIR', 4585, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5985, 'metered'])]]
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(table, pickup_zone, drop_zone, metered, tolls, surge, airport_fees):
    p, d = pickup_zone.upper(), drop_zone.upper()
    flat = table.get(p + '|' + d, table.get(d + '|' + p))
    if flat is not None:
        fare, kind = (flat * min(surge, 15) * 2 + 10) // 20, 'flat'
    else:
        fare, kind = (metered * surge * 2 + 10) // 20, 'metered'
    fare += airport_fees.get(p, {}).get('pickup', 0) + airport_fees.get(d, {}).get('dropoff', 0)
    return [fare + tolls, kind]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'Dt', 4020, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5250, 'flat']),
  ('partial repair probe: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'UNI', 1583, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4650, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'air', 3817, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4200, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'MID', 1392, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2688, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'SHUT', 2416, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [0, 'flat']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'UNI', 1886, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5000, 'flat']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'MID', 3959, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [3959, 'metered'])],
 [('regression: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'DT', 2394, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5000, 'flat']),
  ('partial repair probe: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'DT', 1758, 250, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5250, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'Dt', 5666, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5000, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'DT', 4719, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5319, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'Dt', 4427, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4427, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'air', 2639, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5050, 'flat']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'UNI', 1611, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [1611, 'metered'])],
 [('regression: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'AIR', 4755, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4800, 'flat']),
  ('partial repair probe: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'Dt', 4524, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5600, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'DT', 1236, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5600, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'air', 2551, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5050, 'flat']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'SHUT', 3196, 250, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [6642, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'air', 2794, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5400, 'flat']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'air', 4676, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5726, 'metered'])],
 [('regression: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'DT', 5371, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5250, 'flat']),
  ('partial repair probe: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'Dt', 3909, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5250, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'AIR', 2322, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4800, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'UNI', 5805, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [8708, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'MID', 3717, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [6176, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'UNI', 4021, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [8042, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'AIR', 1131, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2247, 'metered'])],
 [('regression: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'air', 2796, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5400, 'flat']),
  ('partial repair probe: surge on flat fares',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'Dt', 2621, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5000, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'DT', 1792, 250, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5250, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'MID', 2031, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [3647, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'MID', 4946, 250, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [10142, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'air', 3171, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5557, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'AIR', 4585, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5985, 'metered'])]]
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:
The advertised 45.00 airport flat becomes 90.00 during surge.

Zone names are case-insensitive (normalized upper case). A flat fare table keyed "A|B" applies in both directions; a flat fare (0 is a valid promotional flat) is never surged. Otherwise the metered fare is surged (tenths, half up). Airport fees apply separately: the pickup fee of the pickup zone and the dropoff fee of the dropoff zone. Tolls are added last. Return [fare, flat|metered].

split: open-access


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

N = 1
observations = []
def solve(table, pickup_zone, drop_zone, metered, tolls, surge, airport_fees):
    p, d = pickup_zone, drop_zone
    flat = table.get(p + '|' + d, table.get(d + '|' + p))
    if flat is not None:
        fare, kind = flat, 'flat'
    else:
        fare, kind = (metered * surge * 2 + 10) // 20, 'metered'
    fare += airport_fees.get(p, {}).get('pickup', 0) + airport_fees.get(d, {}).get('dropoff', 0)
    return [fare + tolls, kind]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'air', 2818, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5127, 'metered']),
  ('partial repair probe: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'air', 5170, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [6570, 'metered']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'air', 803, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2203, 'metered']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'MID', 2204, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2954, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'UNI', 5858, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [6458, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'UNI', 4561, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4650, 'flat']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'UNI', 2316, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4400, 'flat'])],
 [('regression: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'air', 1509, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4200, 'flat']),
  ('partial repair probe: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'air', 1624, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5400, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'MID', 3754, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [6381, 'metered']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'SHUT', 1127, 600, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2854, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'MID', 2529, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2779, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'SHUT', 1706, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2559, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'AIR', 3897, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4797, 'metered'])],
 [('regression: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'AIR', 5997, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4800, 'flat']),
  ('partial repair probe: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'air', 2722, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [3522, 'metered']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'AIR', 5836, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4800, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'DT', 3292, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [3542, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'DT', 5622, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5872, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'SHUT', 2719, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4079, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'MID', 3755, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5883, 'metered'])],
 [('regression: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'Dt', 3694, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5250, 'flat']),
  ('partial repair probe: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'air', 2965, 250, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [6980, 'metered']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'UNI', 2911, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4400, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'MID', 2503, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4005, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'MID', 2587, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4131, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'UNI', 2720, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4080, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'Dt', 3004, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [3254, 'metered'])],
 [('regression: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'air', 3508, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5050, 'flat']),
  ('partial repair probe: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'air', 5235, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5400, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'Dt', 3354, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5000, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'AIR', 1957, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4714, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'UNI', 2918, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2918, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'MID', 2209, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [3914, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'MID', 4348, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4348, 'metered'])]]
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(table, pickup_zone, drop_zone, metered, tolls, surge, airport_fees):
    p, d = pickup_zone.upper(), drop_zone
    flat = table.get(p + '|' + d, table.get(d + '|' + p))
    if flat is not None:
        fare, kind = flat, 'flat'
    else:
        fare, kind = (metered * surge * 2 + 10) // 20, 'metered'
    fare += airport_fees.get(p, {}).get('pickup', 0) + airport_fees.get(d, {}).get('dropoff', 0)
    return [fare + tolls, kind]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'air', 2818, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5127, 'metered']),
  ('partial repair probe: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'air', 5170, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [6570, 'metered']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'air', 803, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2203, 'metered']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'MID', 2204, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2954, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'UNI', 5858, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [6458, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'UNI', 4561, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4650, 'flat']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'UNI', 2316, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4400, 'flat'])],
 [('regression: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'air', 1509, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4200, 'flat']),
  ('partial repair probe: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'air', 1624, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5400, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'MID', 3754, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [6381, 'metered']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'SHUT', 1127, 600, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2854, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'MID', 2529, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2779, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'SHUT', 1706, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2559, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'MID', 'AIR', 3897, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4797, 'metered'])],
 [('regression: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'AIR', 5997, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4800, 'flat']),
  ('partial repair probe: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'air', 2722, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [3522, 'metered']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'AIR', 5836, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4800, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'DT', 3292, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [3542, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'DT', 5622, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5872, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'SHUT', 'SHUT', 2719, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4079, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'MID', 3755, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5883, 'metered'])],
 [('regression: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'Dt', 3694, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5250, 'flat']),
  ('partial repair probe: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'air', 2965, 250, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [6980, 'metered']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'air', 'UNI', 2911, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4400, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'MID', 2503, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4005, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'MID', 2587, 250, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4131, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'UNI', 'UNI', 2720, 0, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4080, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'Dt', 3004, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [3254, 'metered'])],
 [('regression: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'air', 3508, 250, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5050, 'flat']),
  ('partial repair probe: zone name normalization',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'air', 5235, 600, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5400, 'flat']),
  ('second regression',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'Dt', 3354, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [5000, 'flat']),
  ('normal control 1',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'AIR', 'AIR', 1957, 0, 20,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4714, 'metered']),
  ('normal control 2',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'UNI', 2918, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [2918, 'metered']),
  ('normal control 3',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'DT', 'MID', 2209, 600, 15,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [3914, 'metered']),
  ('normal control 4',
   [{'AIR|DT': 4500, 'AIR|UNI': 3900, 'DT|SHUT': 0}, 'Dt', 'MID', 4348, 0, 10,
    {'AIR': {'dropoff': 300, 'pickup': 500}}],
   [4348, 'metered'])]]
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 pickup reported as "air" is metered and skips the airport fee.

Zone names are case-insensitive (normalized upper case). A flat fare table keyed "A|B" applies in both directions; a flat fare (0 is a valid promotional flat) is never surged. Otherwise the metered fare is surged (tenths, half up). Airport fees apply separately: the pickup fee of the pickup zone and the dropoff fee of the dropoff zone. Tolls are added last. Return [fare, flat|metered].

split: open-access