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

N = 1
observations = []
def solve(fare_cents, fare_ccy, pay_ccy, method, fx, cash_step):
    amt = fare_cents
    if pay_ccy != fare_ccy:
        num, den = fx[fare_ccy + pay_ccy]
        amt = (amt * num * 2 + den) // (2 * den)
    if method == 'cash':
        step = cash_step.get(fare_ccy, 1)
        amt = (amt * 2 + step) // (2 * step) * step
    return amt
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: cash step currency',
   [2502, 'SEK', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   225),
  ('partial repair probe: cash step currency',
   [1234, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('second regression',
   [1003, 'SEK', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   90),
  ('normal control 1',
   [1234, 'SEK', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   111),
  ('normal control 2',
   [1003, 'CHF', 'CHF', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 3',
   [4194, 'EUR', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   4194),
  ('normal control 4',
   [1999, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1999)],
 [('regression: cash step currency',
   [1003, 'CHF', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1043),
  ('partial repair probe: cash step currency',
   [2502, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2502),
  ('second regression',
   [1003, 'EUR', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   11500),
  ('normal control 1',
   [3395, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   38941),
  ('normal control 2',
   [2795, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2795),
  ('normal control 3',
   [1234, 'CHF', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1283),
  ('normal control 4',
   [2502, 'SEK', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2500)],
 [('regression: cash step currency',
   [2387, 'CHF', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2482),
  ('partial repair probe: cash step currency',
   [1003, 'CHF', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1043),
  ('second regression',
   [2017, 'EUR', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   23100),
  ('normal control 1',
   [873, 'EUR', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   873),
  ('normal control 2',
   [1003, 'SEK', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 3',
   [1003, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 4',
   [1234, 'CHF', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1283)],
 [('regression: cash step currency',
   [2502, 'EUR', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   28700),
  ('partial repair probe: cash step currency',
   [1234, 'CHF', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1283),
  ('second regression',
   [2502, 'SEK', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   225),
  ('normal control 1',
   [2110, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   24202),
  ('normal control 2',
   [1999, 'CHF', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2079),
  ('normal control 3',
   [1999, 'EUR', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   22929),
  ('normal control 4',
   [852, 'EUR', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   9772)],
 [('regression: cash step currency',
   [2502, 'EUR', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   28700),
  ('partial repair probe: cash step currency',
   [1234, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('second regression',
   [2502, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2502),
  ('normal control 1',
   [1234, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 2',
   [1999, 'CHF', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2079),
  ('normal control 3',
   [2203, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2203),
  ('normal control 4',
   [1999, 'SEK', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2000)]]
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(fare_cents, fare_ccy, pay_ccy, method, fx, cash_step):
    amt = fare_cents
    if pay_ccy != fare_ccy:
        num, den = fx[fare_ccy + pay_ccy]
        amt = (amt * num * 2 + den) // (2 * den)
    if method == 'cash':
        step = cash_step.get(pay_ccy, 5)
        amt = (amt * 2 + step) // (2 * step) * step
    return amt
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: cash step currency',
   [2502, 'SEK', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   225),
  ('partial repair probe: cash step currency',
   [1234, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('second regression',
   [1003, 'SEK', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   90),
  ('normal control 1',
   [1234, 'SEK', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   111),
  ('normal control 2',
   [1003, 'CHF', 'CHF', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 3',
   [4194, 'EUR', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   4194),
  ('normal control 4',
   [1999, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1999)],
 [('regression: cash step currency',
   [1003, 'CHF', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1043),
  ('partial repair probe: cash step currency',
   [2502, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2502),
  ('second regression',
   [1003, 'EUR', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   11500),
  ('normal control 1',
   [3395, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   38941),
  ('normal control 2',
   [2795, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2795),
  ('normal control 3',
   [1234, 'CHF', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1283),
  ('normal control 4',
   [2502, 'SEK', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2500)],
 [('regression: cash step currency',
   [2387, 'CHF', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2482),
  ('partial repair probe: cash step currency',
   [1003, 'CHF', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1043),
  ('second regression',
   [2017, 'EUR', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   23100),
  ('normal control 1',
   [873, 'EUR', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   873),
  ('normal control 2',
   [1003, 'SEK', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 3',
   [1003, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 4',
   [1234, 'CHF', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1283)],
 [('regression: cash step currency',
   [2502, 'EUR', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   28700),
  ('partial repair probe: cash step currency',
   [1234, 'CHF', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1283),
  ('second regression',
   [2502, 'SEK', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   225),
  ('normal control 1',
   [2110, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   24202),
  ('normal control 2',
   [1999, 'CHF', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2079),
  ('normal control 3',
   [1999, 'EUR', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   22929),
  ('normal control 4',
   [852, 'EUR', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   9772)],
 [('regression: cash step currency',
   [2502, 'EUR', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   28700),
  ('partial repair probe: cash step currency',
   [1234, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('second regression',
   [2502, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2502),
  ('normal control 1',
   [1234, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 2',
   [1999, 'CHF', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2079),
  ('normal control 3',
   [2203, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2203),
  ('normal control 4',
   [1999, 'SEK', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2000)]]
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 CHF fare paid in euro cash is rounded to 5 cents.

Convert a fare to the payment currency with the directed rate fx[FROM+TO] = [num, den] (half up), then, for cash payments only, round half up to the payment currency cash step (CHF 5 centimes, SEK 100 ore, others 1). Card and wallet payments are not cash-rounded. Return the amount in minor units of the payment currency.

split: open-access


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

N = 1
observations = []
def solve(fare_cents, fare_ccy, pay_ccy, method, fx, cash_step):
    amt = fare_cents
    if pay_ccy != fare_ccy:
        den, num = fx[pay_ccy + fare_ccy]
        amt = (amt * num * 2 + den) // (2 * den)
    if method == 'cash':
        step = cash_step.get(pay_ccy, 1)
        amt = (amt * 2 + step) // (2 * step) * step
    return amt
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: fx pair direction',
   [1999, 'SEK', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   180),
  ('partial repair probe: fx pair direction',
   [1234, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   14154),
  ('second regression',
   [1999, 'EUR', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   22929),
  ('normal control 1',
   [2502, 'EUR', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2502),
  ('normal control 2',
   [1234, 'SEK', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1200),
  ('normal control 3',
   [1234, 'SEK', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 4',
   [2502, 'SEK', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2500)],
 [('regression: fx pair direction',
   [1999, 'EUR', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1880),
  ('partial repair probe: fx pair direction',
   [1003, 'CHF', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1043),
  ('second regression',
   [1234, 'EUR', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1160),
  ('normal control 1',
   [747, 'SEK', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   747),
  ('normal control 2',
   [1234, 'SEK', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 3',
   [1003, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 4',
   [1003, 'SEK', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003)],
 [('regression: fx pair direction',
   [1234, 'EUR', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1160),
  ('partial repair probe: fx pair direction',
   [2502, 'EUR', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   28700),
  ('second regression',
   [1003, 'EUR', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   11504),
  ('normal control 1',
   [2502, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2502),
  ('normal control 2',
   [1234, 'SEK', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 3',
   [1003, 'SEK', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 4',
   [1003, 'CHF', 'CHF', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003)],
 [('regression: fx pair direction',
   [1999, 'EUR', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   22900),
  ('partial repair probe: fx pair direction',
   [1003, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   11504),
  ('second regression',
   [1003, 'EUR', 'CHF', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   943),
  ('normal control 1',
   [1003, 'CHF', 'CHF', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 2',
   [1234, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 3',
   [1003, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 4',
   [1003, 'CHF', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1005)],
 [('regression: fx pair direction',
   [3496, 'EUR', 'CHF', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   3286),
  ('partial repair probe: fx pair direction',
   [1999, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   22929),
  ('second regression',
   [1003, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   11504),
  ('normal control 1',
   [2502, 'EUR', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2502),
  ('normal control 2',
   [1999, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1999),
  ('normal control 3',
   [1999, 'SEK', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2000),
  ('normal control 4',
   [1003, 'CHF', 'CHF', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003)]]
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(fare_cents, fare_ccy, pay_ccy, method, fx, cash_step):
    amt = fare_cents
    if pay_ccy != fare_ccy:
        num, den = fx[pay_ccy + fare_ccy]
        amt = (amt * num * 2 + den) // (2 * den)
    if method == 'cash':
        step = cash_step.get(pay_ccy, 1)
        amt = (amt * 2 + step) // (2 * step) * step
    return amt
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: fx pair direction',
   [1999, 'SEK', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   180),
  ('partial repair probe: fx pair direction',
   [1234, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   14154),
  ('second regression',
   [1999, 'EUR', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   22929),
  ('normal control 1',
   [2502, 'EUR', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2502),
  ('normal control 2',
   [1234, 'SEK', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1200),
  ('normal control 3',
   [1234, 'SEK', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 4',
   [2502, 'SEK', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2500)],
 [('regression: fx pair direction',
   [1999, 'EUR', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1880),
  ('partial repair probe: fx pair direction',
   [1003, 'CHF', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1043),
  ('second regression',
   [1234, 'EUR', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1160),
  ('normal control 1',
   [747, 'SEK', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   747),
  ('normal control 2',
   [1234, 'SEK', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 3',
   [1003, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 4',
   [1003, 'SEK', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003)],
 [('regression: fx pair direction',
   [1234, 'EUR', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1160),
  ('partial repair probe: fx pair direction',
   [2502, 'EUR', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   28700),
  ('second regression',
   [1003, 'EUR', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   11504),
  ('normal control 1',
   [2502, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2502),
  ('normal control 2',
   [1234, 'SEK', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 3',
   [1003, 'SEK', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 4',
   [1003, 'CHF', 'CHF', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003)],
 [('regression: fx pair direction',
   [1999, 'EUR', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   22900),
  ('partial repair probe: fx pair direction',
   [1003, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   11504),
  ('second regression',
   [1003, 'EUR', 'CHF', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   943),
  ('normal control 1',
   [1003, 'CHF', 'CHF', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 2',
   [1234, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 3',
   [1003, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 4',
   [1003, 'CHF', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1005)],
 [('regression: fx pair direction',
   [3496, 'EUR', 'CHF', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   3286),
  ('partial repair probe: fx pair direction',
   [1999, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   22929),
  ('second regression',
   [1003, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   11504),
  ('normal control 1',
   [2502, 'EUR', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2502),
  ('normal control 2',
   [1999, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1999),
  ('normal control 3',
   [1999, 'SEK', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2000),
  ('normal control 4',
   [1003, 'CHF', 'CHF', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003)]]
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:
Converted fares are off by the bid/ask spread.

Convert a fare to the payment currency with the directed rate fx[FROM+TO] = [num, den] (half up), then, for cash payments only, round half up to the payment currency cash step (CHF 5 centimes, SEK 100 ore, others 1). Card and wallet payments are not cash-rounded. Return the amount in minor units of the payment currency.

split: open-access


prompt:
Surge spreads several hops from a hotspot depending on zone name order.

Smooth zone multipliers (tenths): each zone publishes the max of its own raw multiplier and each neighbor's raw multiplier minus 5, clamped to [10, 30]. Adjacency is symmetric even when listed once; neighbors without a raw multiplier are ignored; all reads use raw values, never already-smoothed ones. Return zone -> published multiplier.

split: open-access


prompt:
Calm zones next to a hotspot publish the full hotspot multiplier.

Smooth zone multipliers (tenths): each zone publishes the max of its own raw multiplier and each neighbor's raw multiplier minus 5, clamped to [10, 30]. Adjacency is symmetric even when listed once; neighbors without a raw multiplier are ignored; all reads use raw values, never already-smoothed ones. Return zone -> published multiplier.

split: open-access


prompt:
A raw 3.5x zone publishes 3.5x.

Smooth zone multipliers (tenths): each zone publishes the max of its own raw multiplier and each neighbor's raw multiplier minus 5, clamped to [10, 30]. Adjacency is symmetric even when listed once; neighbors without a raw multiplier are ignored; all reads use raw values, never already-smoothed ones. Return zone -> published multiplier.

split: open-access


prompt:
Zone B smooths from A but A never smooths from B.

Smooth zone multipliers (tenths): each zone publishes the max of its own raw multiplier and each neighbor's raw multiplier minus 5, clamped to [10, 30]. Adjacency is symmetric even when listed once; neighbors without a raw multiplier are ignored; all reads use raw values, never already-smoothed ones. Return zone -> published multiplier.

split: open-access


prompt:
Riders get refunds for routes only slightly longer than optimal.

Refund for inefficient routes: only when actual distance is more than 20% longer than optimal (actual*5 > optimal*6). Refund the whole extra distance at per_km (half up); refunds under 200 cents are not issued; the refund never takes the charge below the minimum fare. Return refund cents.

split: open-access


prompt:
A computed 2.00 refund is never issued.

Refund for inefficient routes: only when actual distance is more than 20% longer than optimal (actual*5 > optimal*6). Refund the whole extra distance at per_km (half up); refunds under 200 cents are not issued; the refund never takes the charge below the minimum fare. Return refund cents.

split: open-access


prompt:
A short inefficient trip is refunded to almost nothing.

Refund for inefficient routes: only when actual distance is more than 20% longer than optimal (actual*5 > optimal*6). Refund the whole extra distance at per_km (half up); refunds under 200 cents are not issued; the refund never takes the charge below the minimum fare. Return refund cents.

split: open-access


prompt:
Highway segments are charged twice.

A single-tariff taximeter bills each segment [seconds, meters] by distance when its speed is at least v m/s (meters >= v*seconds, so a zero-duration movement bills distance) and by time otherwise, never both. Charges accumulate exactly (per_km per 1000 m, per_hour per 3600 s) and the total is rounded half up to a cent once, then the flag fall is added.

split: open-access


prompt:
Traffic moving at exactly 5 m/s is billed on the clock.

A single-tariff taximeter bills each segment [seconds, meters] by distance when its speed is at least v m/s (meters >= v*seconds, so a zero-duration movement bills distance) and by time otherwise, never both. Charges accumulate exactly (per_km per 1000 m, per_hour per 3600 s) and the total is rounded half up to a cent once, then the flag fall is added.

split: open-access


prompt:
Trips with many short segments drift from the exact tariff.

A single-tariff taximeter bills each segment [seconds, meters] by distance when its speed is at least v m/s (meters >= v*seconds, so a zero-duration movement bills distance) and by time otherwise, never both. Charges accumulate exactly (per_km per 1000 m, per_hour per 3600 s) and the total is rounded half up to a cent once, then the flag fall is added.

split: open-access


prompt:
The meter drops fractional cents instead of rounding.

A single-tariff taximeter bills each segment [seconds, meters] by distance when its speed is at least v m/s (meters >= v*seconds, so a zero-duration movement bills distance) and by time otherwise, never both. Charges accumulate exactly (per_km per 1000 m, per_hour per 3600 s) and the total is rounded half up to a cent once, then the flag fall is added.

split: open-access


prompt:
Waiting in traffic costs sixty times the tariff.

A single-tariff taximeter bills each segment [seconds, meters] by distance when its speed is at least v m/s (meters >= v*seconds, so a zero-duration movement bills distance) and by time otherwise, never both. Charges accumulate exactly (per_km per 1000 m, per_hour per 3600 s) and the total is rounded half up to a cent once, then the flag fall is added.

split: open-access


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

N = 1
observations = []
def solve(fare, member, now):
    active = member['active'] and now <= member['expires']
    surge = fare['surge']
    surge = min(surge, 20)
    surged = (fare['core'] * surge * 2 + 10) // 20
    disc = 0
    if active and surge <= 15:
        disc = surged // 10
    return surged - disc + fare['fees']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: member-only surge cap',
   [{'core': 2555, 'fees': 250, 'surge': 25}, {'active': False, 'expires': 100}, 100], 6638),
  ('partial repair probe: member-only surge cap',
   [{'core': 999, 'fees': 245, 'surge': 30}, {'active': False, 'expires': 100}, 101], 3242),
  ('second regression', [{'core': 1234, 'fees': 199, 'surge': 30}, {'active': True, 'expires': 100}, 101],
   3901),
  ('normal control 1', [{'core': 999, 'fees': 199, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   2197),
  ('normal control 2', [{'core': 999, 'fees': 199, 'surge': 12}, {'active': True, 'expires': 100}, 100],
   1279),
  ('normal control 3', [{'core': 1234, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 100], 2468),
  ('normal control 4', [{'core': 1000, 'fees': 0, 'surge': 17}, {'active': True, 'expires': 100}, 101],
   1700)],
 [('regression: member-only surge cap',
   [{'core': 1234, 'fees': 245, 'surge': 30}, {'active': True, 'expires': 100}, 101], 3947),
  ('partial repair probe: member-only surge cap',
   [{'core': 1234, 'fees': 199, 'surge': 30}, {'active': True, 'expires': 100}, 101], 3901),
  ('second regression', [{'core': 1000, 'fees': 245, 'surge': 25}, {'active': False, 'expires': 100}, 99],
   2745),
  ('normal control 1', [{'core': 999, 'fees': 0, 'surge': 17}, {'active': True, 'expires': 100}, 99], 1698),
  ('normal control 2', [{'core': 1234, 'fees': 0, 'surge': 10}, {'active': True, 'expires': 100}, 99], 1111),
  ('normal control 3', [{'core': 1234, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 100], 2468),
  ('normal control 4', [{'core': 999, 'fees': 199, 'surge': 17}, {'active': True, 'expires': 100}, 100],
   1897)],
 [('regression: member-only surge cap',
   [{'core': 1000, 'fees': 199, 'surge': 25}, {'active': True, 'expires': 100}, 101], 2699),
  ('partial repair probe: member-only surge cap',
   [{'core': 1000, 'fees': 199, 'surge': 30}, {'active': True, 'expires': 100}, 101], 3199),
  ('second regression', [{'core': 999, 'fees': 250, 'surge': 25}, {'active': False, 'expires': 100}, 100],
   2748),
  ('normal control 1', [{'core': 1000, 'fees': 250, 'surge': 10}, {'active': False, 'expires': 100}, 100],
   1250),
  ('normal control 2', [{'core': 1000, 'fees': 250, 'surge': 20}, {'active': True, 'expires': 100}, 101],
   2250),
  ('normal control 3', [{'core': 1234, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 100], 2468),
  ('normal control 4', [{'core': 999, 'fees': 245, 'surge': 17}, {'active': True, 'expires': 100}, 99],
   1943)],
 [('regression: member-only surge cap',
   [{'core': 1000, 'fees': 250, 'surge': 30}, {'active': False, 'expires': 100}, 99], 3250),
  ('partial repair probe: member-only surge cap',
   [{'core': 999, 'fees': 199, 'surge': 30}, {'active': False, 'expires': 100}, 99], 3196),
  ('second regression', [{'core': 1000, 'fees': 199, 'surge': 30}, {'active': True, 'expires': 100}, 101],
   3199),
  ('normal control 1', [{'core': 999, 'fees': 245, 'surge': 25}, {'active': True, 'expires': 100}, 100],
   2243),
  ('normal control 2', [{'core': 1234, 'fees': 245, 'surge': 17}, {'active': True, 'expires': 100}, 101],
   2343),
  ('normal control 3', [{'core': 1000, 'fees': 0, 'surge': 10}, {'active': True, 'expires': 100}, 100], 900),
  ('normal control 4', [{'core': 1000, 'fees': 199, 'surge': 15}, {'active': True, 'expires': 100}, 100],
   1549)],
 [('regression: member-only surge cap',
   [{'core': 1234, 'fees': 245, 'surge': 25}, {'active': False, 'expires': 100}, 100], 3330),
  ('partial repair probe: member-only surge cap',
   [{'core': 1234, 'fees': 199, 'surge': 30}, {'active': False, 'expires': 100}, 100], 3901),
  ('second regression', [{'core': 2555, 'fees': 0, 'surge': 25}, {'active': False, 'expires': 100}, 100],
   6388),
  ('normal control 1', [{'core': 1234, 'fees': 250, 'surge': 17}, {'active': True, 'expires': 100}, 100],
   2348),
  ('normal control 2', [{'core': 999, 'fees': 199, 'surge': 17}, {'active': True, 'expires': 100}, 100],
   1897),
  ('normal control 3', [{'core': 1234, 'fees': 250, 'surge': 12}, {'active': True, 'expires': 100}, 100],
   1583),
  ('normal control 4', [{'core': 2555, 'fees': 245, 'surge': 15}, {'active': True, 'expires': 100}, 101],
   4078)]]
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(fare, member, now):
    active = member['active'] and now <= member['expires']
    surge = fare['surge']
    if active or fare['surge'] > 25:
        surge = min(surge, 20)
    surged = (fare['core'] * surge * 2 + 10) // 20
    disc = 0
    if active and surge <= 15:
        disc = surged // 10
    return surged - disc + fare['fees']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: member-only surge cap',
   [{'core': 2555, 'fees': 250, 'surge': 25}, {'active': False, 'expires': 100}, 100], 6638),
  ('partial repair probe: member-only surge cap',
   [{'core': 999, 'fees': 245, 'surge': 30}, {'active': False, 'expires': 100}, 101], 3242),
  ('second regression', [{'core': 1234, 'fees': 199, 'surge': 30}, {'active': True, 'expires': 100}, 101],
   3901),
  ('normal control 1', [{'core': 999, 'fees': 199, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   2197),
  ('normal control 2', [{'core': 999, 'fees': 199, 'surge': 12}, {'active': True, 'expires': 100}, 100],
   1279),
  ('normal control 3', [{'core': 1234, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 100], 2468),
  ('normal control 4', [{'core': 1000, 'fees': 0, 'surge': 17}, {'active': True, 'expires': 100}, 101],
   1700)],
 [('regression: member-only surge cap',
   [{'core': 1234, 'fees': 245, 'surge': 30}, {'active': True, 'expires': 100}, 101], 3947),
  ('partial repair probe: member-only surge cap',
   [{'core': 1234, 'fees': 199, 'surge': 30}, {'active': True, 'expires': 100}, 101], 3901),
  ('second regression', [{'core': 1000, 'fees': 245, 'surge': 25}, {'active': False, 'expires': 100}, 99],
   2745),
  ('normal control 1', [{'core': 999, 'fees': 0, 'surge': 17}, {'active': True, 'expires': 100}, 99], 1698),
  ('normal control 2', [{'core': 1234, 'fees': 0, 'surge': 10}, {'active': True, 'expires': 100}, 99], 1111),
  ('normal control 3', [{'core': 1234, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 100], 2468),
  ('normal control 4', [{'core': 999, 'fees': 199, 'surge': 17}, {'active': True, 'expires': 100}, 100],
   1897)],
 [('regression: member-only surge cap',
   [{'core': 1000, 'fees': 199, 'surge': 25}, {'active': True, 'expires': 100}, 101], 2699),
  ('partial repair probe: member-only surge cap',
   [{'core': 1000, 'fees': 199, 'surge': 30}, {'active': True, 'expires': 100}, 101], 3199),
  ('second regression', [{'core': 999, 'fees': 250, 'surge': 25}, {'active': False, 'expires': 100}, 100],
   2748),
  ('normal control 1', [{'core': 1000, 'fees': 250, 'surge': 10}, {'active': False, 'expires': 100}, 100],
   1250),
  ('normal control 2', [{'core': 1000, 'fees': 250, 'surge': 20}, {'active': True, 'expires': 100}, 101],
   2250),
  ('normal control 3', [{'core': 1234, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 100], 2468),
  ('normal control 4', [{'core': 999, 'fees': 245, 'surge': 17}, {'active': True, 'expires': 100}, 99],
   1943)],
 [('regression: member-only surge cap',
   [{'core': 1000, 'fees': 250, 'surge': 30}, {'active': False, 'expires': 100}, 99], 3250),
  ('partial repair probe: member-only surge cap',
   [{'core': 999, 'fees': 199, 'surge': 30}, {'active': False, 'expires': 100}, 99], 3196),
  ('second regression', [{'core': 1000, 'fees': 199, 'surge': 30}, {'active': True, 'expires': 100}, 101],
   3199),
  ('normal control 1', [{'core': 999, 'fees': 245, 'surge': 25}, {'active': True, 'expires': 100}, 100],
   2243),
  ('normal control 2', [{'core': 1234, 'fees': 245, 'surge': 17}, {'active': True, 'expires': 100}, 101],
   2343),
  ('normal control 3', [{'core': 1000, 'fees': 0, 'surge': 10}, {'active': True, 'expires': 100}, 100], 900),
  ('normal control 4', [{'core': 1000, 'fees': 199, 'surge': 15}, {'active': True, 'expires': 100}, 100],
   1549)],
 [('regression: member-only surge cap',
   [{'core': 1234, 'fees': 245, 'surge': 25}, {'active': False, 'expires': 100}, 100], 3330),
  ('partial repair probe: member-only surge cap',
   [{'core': 1234, 'fees': 199, 'surge': 30}, {'active': False, 'expires': 100}, 100], 3901),
  ('second regression', [{'core': 2555, 'fees': 0, 'surge': 25}, {'active': False, 'expires': 100}, 100],
   6388),
  ('normal control 1', [{'core': 1234, 'fees': 250, 'surge': 17}, {'active': True, 'expires': 100}, 100],
   2348),
  ('normal control 2', [{'core': 999, 'fees': 199, 'surge': 17}, {'active': True, 'expires': 100}, 100],
   1897),
  ('normal control 3', [{'core': 1234, 'fees': 250, 'surge': 12}, {'active': True, 'expires': 100}, 100],
   1583),
  ('normal control 4', [{'core': 2555, 'fees': 245, 'surge': 15}, {'active': True, 'expires': 100}, 101],
   4078)]]
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:
Non-members pay 2.0x during a 2.5x surge.

Membership is active if the flag is set and today is on or before the expiry day. Active members have surge capped at 2.0x (20 tenths) and, when the (capped) surge is at most 1.5x, get 10% off the surged fare (floored); fees are never discounted. Return the amount due in cents.

split: open-access


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

N = 1
observations = []
def solve(fare, member, now):
    active = member['active'] and now <= member['expires']
    surge = fare['surge']
    if active:
        surge = min(surge, 20)
    surged = (fare['core'] * surge * 2 + 10) // 20
    disc = 0
    if active and surge < 15:
        disc = surged // 10
    return surged - disc + fare['fees']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: discount surge boundary',
   [{'core': 1234, 'fees': 199, 'surge': 15}, {'active': True, 'expires': 100}, 99], 1865),
  ('partial repair probe: discount surge boundary',
   [{'core': 1000, 'fees': 199, 'surge': 17}, {'active': True, 'expires': 100}, 99], 1899),
  ('second regression', [{'core': 999, 'fees': 199, 'surge': 17}, {'active': True, 'expires': 100}, 100],
   1897),
  ('normal control 1', [{'core': 1000, 'fees': 0, 'surge': 25}, {'active': False, 'expires': 100}, 99], 2500),
  ('normal control 2', [{'core': 2555, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 101], 7665),
  ('normal control 3', [{'core': 999, 'fees': 0, 'surge': 17}, {'active': False, 'expires': 100}, 99], 1698),
  ('normal control 4', [{'core': 1000, 'fees': 250, 'surge': 30}, {'active': True, 'expires': 100}, 101],
   3250)],
 [('regression: discount surge boundary',
   [{'core': 2555, 'fees': 199, 'surge': 15}, {'active': True, 'expires': 100}, 100], 3649),
  ('partial repair probe: discount surge boundary',
   [{'core': 1234, 'fees': 199, 'surge': 17}, {'active': True, 'expires': 100}, 100], 2297),
  ('second regression', [{'core': 1000, 'fees': 199, 'surge': 15}, {'active': True, 'expires': 100}, 100],
   1549),
  ('normal control 1', [{'core': 999, 'fees': 245, 'surge': 12}, {'active': True, 'expires': 100}, 100],
   1325),
  ('normal control 2', [{'core': 1234, 'fees': 0, 'surge': 12}, {'active': True, 'expires': 100}, 100], 1333),
  ('normal control 3', [{'core': 1234, 'fees': 199, 'surge': 12}, {'active': False, 'expires': 100}, 101],
   1680),
  ('normal control 4', [{'core': 999, 'fees': 245, 'surge': 25}, {'active': True, 'expires': 100}, 99],
   2243)],
 [('regression: discount surge boundary',
   [{'core': 999, 'fees': 199, 'surge': 15}, {'active': True, 'expires': 100}, 100], 1549),
  ('partial repair probe: discount surge boundary',
   [{'core': 1000, 'fees': 245, 'surge': 17}, {'active': True, 'expires': 100}, 100], 1945),
  ('second regression', [{'core': 1234, 'fees': 250, 'surge': 17}, {'active': True, 'expires': 100}, 100],
   2348),
  ('normal control 1', [{'core': 1234, 'fees': 0, 'surge': 10}, {'active': True, 'expires': 100}, 99], 1111),
  ('normal control 2', [{'core': 1000, 'fees': 250, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   2250),
  ('normal control 3', [{'core': 1234, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 99], 2468),
  ('normal control 4', [{'core': 1000, 'fees': 0, 'surge': 30}, {'active': False, 'expires': 100}, 100],
   3000)],
 [('regression: discount surge boundary',
   [{'core': 1000, 'fees': 0, 'surge': 15}, {'active': True, 'expires': 100}, 100], 1350),
  ('partial repair probe: discount surge boundary',
   [{'core': 999, 'fees': 245, 'surge': 17}, {'active': True, 'expires': 100}, 100], 1943),
  ('second regression', [{'core': 1234, 'fees': 199, 'surge': 15}, {'active': True, 'expires': 100}, 100],
   1865),
  ('normal control 1', [{'core': 2555, 'fees': 250, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   5360),
  ('normal control 2', [{'core': 999, 'fees': 0, 'surge': 20}, {'active': True, 'expires': 100}, 100], 1998),
  ('normal control 3', [{'core': 2555, 'fees': 250, 'surge': 20}, {'active': True, 'expires': 100}, 99],
   5360),
  ('normal control 4', [{'core': 1000, 'fees': 245, 'surge': 12}, {'active': False, 'expires': 100}, 100],
   1445)],
 [('regression: discount surge boundary',
   [{'core': 1234, 'fees': 245, 'surge': 15}, {'active': True, 'expires': 100}, 100], 1911),
  ('partial repair probe: discount surge boundary',
   [{'core': 2555, 'fees': 199, 'surge': 17}, {'active': True, 'expires': 100}, 99], 4543),
  ('second regression', [{'core': 1000, 'fees': 250, 'surge': 17}, {'active': True, 'expires': 100}, 100],
   1950),
  ('normal control 1', [{'core': 1000, 'fees': 0, 'surge': 20}, {'active': True, 'expires': 100}, 100], 2000),
  ('normal control 2', [{'core': 999, 'fees': 0, 'surge': 25}, {'active': True, 'expires': 100}, 99], 1998),
  ('normal control 3', [{'core': 999, 'fees': 199, 'surge': 20}, {'active': True, 'expires': 100}, 100],
   2197),
  ('normal control 4', [{'core': 1000, 'fees': 250, 'surge': 12}, {'active': True, 'expires': 100}, 101],
   1450)]]
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(fare, member, now):
    active = member['active'] and now <= member['expires']
    surge = fare['surge']
    if active:
        surge = min(surge, 20)
    surged = (fare['core'] * surge * 2 + 10) // 20
    disc = 0
    if active and fare['surge'] < 20:
        disc = surged // 10
    return surged - disc + fare['fees']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: discount surge boundary',
   [{'core': 1234, 'fees': 199, 'surge': 15}, {'active': True, 'expires': 100}, 99], 1865),
  ('partial repair probe: discount surge boundary',
   [{'core': 1000, 'fees': 199, 'surge': 17}, {'active': True, 'expires': 100}, 99], 1899),
  ('second regression', [{'core': 999, 'fees': 199, 'surge': 17}, {'active': True, 'expires': 100}, 100],
   1897),
  ('normal control 1', [{'core': 1000, 'fees': 0, 'surge': 25}, {'active': False, 'expires': 100}, 99], 2500),
  ('normal control 2', [{'core': 2555, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 101], 7665),
  ('normal control 3', [{'core': 999, 'fees': 0, 'surge': 17}, {'active': False, 'expires': 100}, 99], 1698),
  ('normal control 4', [{'core': 1000, 'fees': 250, 'surge': 30}, {'active': True, 'expires': 100}, 101],
   3250)],
 [('regression: discount surge boundary',
   [{'core': 2555, 'fees': 199, 'surge': 15}, {'active': True, 'expires': 100}, 100], 3649),
  ('partial repair probe: discount surge boundary',
   [{'core': 1234, 'fees': 199, 'surge': 17}, {'active': True, 'expires': 100}, 100], 2297),
  ('second regression', [{'core': 1000, 'fees': 199, 'surge': 15}, {'active': True, 'expires': 100}, 100],
   1549),
  ('normal control 1', [{'core': 999, 'fees': 245, 'surge': 12}, {'active': True, 'expires': 100}, 100],
   1325),
  ('normal control 2', [{'core': 1234, 'fees': 0, 'surge': 12}, {'active': True, 'expires': 100}, 100], 1333),
  ('normal control 3', [{'core': 1234, 'fees': 199, 'surge': 12}, {'active': False, 'expires': 100}, 101],
   1680),
  ('normal control 4', [{'core': 999, 'fees': 245, 'surge': 25}, {'active': True, 'expires': 100}, 99],
   2243)],
 [('regression: discount surge boundary',
   [{'core': 999, 'fees': 199, 'surge': 15}, {'active': True, 'expires': 100}, 100], 1549),
  ('partial repair probe: discount surge boundary',
   [{'core': 1000, 'fees': 245, 'surge': 17}, {'active': True, 'expires': 100}, 100], 1945),
  ('second regression', [{'core': 1234, 'fees': 250, 'surge': 17}, {'active': True, 'expires': 100}, 100],
   2348),
  ('normal control 1', [{'core': 1234, 'fees': 0, 'surge': 10}, {'active': True, 'expires': 100}, 99], 1111),
  ('normal control 2', [{'core': 1000, 'fees': 250, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   2250),
  ('normal control 3', [{'core': 1234, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 99], 2468),
  ('normal control 4', [{'core': 1000, 'fees': 0, 'surge': 30}, {'active': False, 'expires': 100}, 100],
   3000)],
 [('regression: discount surge boundary',
   [{'core': 1000, 'fees': 0, 'surge': 15}, {'active': True, 'expires': 100}, 100], 1350),
  ('partial repair probe: discount surge boundary',
   [{'core': 999, 'fees': 245, 'surge': 17}, {'active': True, 'expires': 100}, 100], 1943),
  ('second regression', [{'core': 1234, 'fees': 199, 'surge': 15}, {'active': True, 'expires': 100}, 100],
   1865),
  ('normal control 1', [{'core': 2555, 'fees': 250, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   5360),
  ('normal control 2', [{'core': 999, 'fees': 0, 'surge': 20}, {'active': True, 'expires': 100}, 100], 1998),
  ('normal control 3', [{'core': 2555, 'fees': 250, 'surge': 20}, {'active': True, 'expires': 100}, 99],
   5360),
  ('normal control 4', [{'core': 1000, 'fees': 245, 'surge': 12}, {'active': False, 'expires': 100}, 100],
   1445)],
 [('regression: discount surge boundary',
   [{'core': 1234, 'fees': 245, 'surge': 15}, {'active': True, 'expires': 100}, 100], 1911),
  ('partial repair probe: discount surge boundary',
   [{'core': 2555, 'fees': 199, 'surge': 17}, {'active': True, 'expires': 100}, 99], 4543),
  ('second regression', [{'core': 1000, 'fees': 250, 'surge': 17}, {'active': True, 'expires': 100}, 100],
   1950),
  ('normal control 1', [{'core': 1000, 'fees': 0, 'surge': 20}, {'active': True, 'expires': 100}, 100], 2000),
  ('normal control 2', [{'core': 999, 'fees': 0, 'surge': 25}, {'active': True, 'expires': 100}, 99], 1998),
  ('normal control 3', [{'core': 999, 'fees': 199, 'surge': 20}, {'active': True, 'expires': 100}, 100],
   2197),
  ('normal control 4', [{'core': 1000, 'fees': 250, 'surge': 12}, {'active': True, 'expires': 100}, 101],
   1450)]]
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:
Members lose the 10% discount at 1.5x surge.

Membership is active if the flag is set and today is on or before the expiry day. Active members have surge capped at 2.0x (20 tenths) and, when the (capped) surge is at most 1.5x, get 10% off the surged fare (floored); fees are never discounted. Return the amount due in cents.

split: open-access


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

N = 1
observations = []
def solve(fare, member, now):
    active = member['active'] and now <= member['expires']
    surge = fare['surge']
    if active:
        surge = min(surge, 20)
    surged = (fare['core'] * surge * 2 + 10) // 20
    disc = 0
    if active and surge <= 15:
        disc = (surged + fare['fees']) // 10
    return surged - disc + fare['fees']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: fees excluded from discount',
   [{'core': 1234, 'fees': 245, 'surge': 12}, {'active': True, 'expires': 100}, 100], 1578),
  ('partial repair probe: fees excluded from discount',
   [{'core': 2555, 'fees': 245, 'surge': 10}, {'active': True, 'expires': 100}, 100], 2545),
  ('second regression', [{'core': 1234, 'fees': 245, 'surge': 12}, {'active': True, 'expires': 100}, 99],
   1578),
  ('normal control 1', [{'core': 1234, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 101], 3702),
  ('normal control 2', [{'core': 999, 'fees': 250, 'surge': 25}, {'active': False, 'expires': 100}, 100],
   2748),
  ('normal control 3', [{'core': 1234, 'fees': 0, 'surge': 12}, {'active': False, 'expires': 100}, 101],
   1481),
  ('normal control 4', [{'core': 1000, 'fees': 199, 'surge': 17}, {'active': False, 'expires': 100}, 99],
   1899)],
 [('regression: fees excluded from discount',
   [{'core': 2555, 'fees': 199, 'surge': 15}, {'active': True, 'expires': 100}, 100], 3649),
  ('partial repair probe: fees excluded from discount',
   [{'core': 999, 'fees': 245, 'surge': 12}, {'active': True, 'expires': 100}, 99], 1325),
  ('second regression', [{'core': 2555, 'fees': 245, 'surge': 15}, {'active': True, 'expires': 100}, 100],
   3695),
  ('normal control 1', [{'core': 2555, 'fees': 250, 'surge': 12}, {'active': False, 'expires': 100}, 100],
   3316),
  ('normal control 2', [{'core': 2555, 'fees': 245, 'surge': 20}, {'active': True, 'expires': 100}, 100],
   5355),
  ('normal control 3', [{'core': 2555, 'fees': 0, 'surge': 15}, {'active': True, 'expires': 100}, 99], 3450),
  ('normal control 4', [{'core': 1000, 'fees': 245, 'surge': 17}, {'active': True, 'expires': 100}, 100],
   1945)],
 [('regression: fees excluded from discount',
   [{'core': 1000, 'fees': 245, 'surge': 15}, {'active': True, 'expires': 100}, 99], 1595),
  ('partial repair probe: fees excluded from discount',
   [{'core': 999, 'fees': 245, 'surge': 10}, {'active': True, 'expires': 100}, 99], 1145),
  ('second regression', [{'core': 999, 'fees': 245, 'surge': 15}, {'active': True, 'expires': 100}, 99],
   1595),
  ('normal control 1', [{'core': 1234, 'fees': 0, 'surge': 12}, {'active': False, 'expires': 100}, 100],
   1481),
  ('normal control 2', [{'core': 1234, 'fees': 250, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   2718),
  ('normal control 3', [{'core': 999, 'fees': 250, 'surge': 25}, {'active': False, 'expires': 100}, 100],
   2748),
  ('normal control 4', [{'core': 1234, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   2468)],
 [('regression: fees excluded from discount',
   [{'core': 2555, 'fees': 245, 'surge': 10}, {'active': True, 'expires': 100}, 100], 2545),
  ('partial repair probe: fees excluded from discount',
   [{'core': 2555, 'fees': 245, 'surge': 12}, {'active': True, 'expires': 100}, 99], 3005),
  ('second regression', [{'core': 999, 'fees': 250, 'surge': 10}, {'active': True, 'expires': 100}, 100],
   1150),
  ('normal control 1', [{'core': 1000, 'fees': 0, 'surge': 17}, {'active': True, 'expires': 100}, 100], 1700),
  ('normal control 2', [{'core': 1234, 'fees': 199, 'surge': 17}, {'active': True, 'expires': 100}, 101],
   2297),
  ('normal control 3', [{'core': 2555, 'fees': 245, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   5355),
  ('normal control 4', [{'core': 2555, 'fees': 245, 'surge': 20}, {'active': True, 'expires': 100}, 100],
   5355)],
 [('regression: fees excluded from discount',
   [{'core': 999, 'fees': 245, 'surge': 12}, {'active': True, 'expires': 100}, 100], 1325),
  ('partial repair probe: fees excluded from discount',
   [{'core': 2555, 'fees': 199, 'surge': 12}, {'active': True, 'expires': 100}, 99], 2959),
  ('second regression', [{'core': 1000, 'fees': 245, 'surge': 10}, {'active': True, 'expires': 100}, 100],
   1145),
  ('normal control 1', [{'core': 1000, 'fees': 0, 'surge': 15}, {'active': True, 'expires': 100}, 100], 1350),
  ('normal control 2', [{'core': 1000, 'fees': 250, 'surge': 17}, {'active': True, 'expires': 100}, 100],
   1950),
  ('normal control 3', [{'core': 1234, 'fees': 245, 'surge': 25}, {'active': False, 'expires': 100}, 100],
   3330),
  ('normal control 4', [{'core': 999, 'fees': 0, 'surge': 15}, {'active': False, 'expires': 100}, 99], 1499)]]
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(fare, member, now):
    active = member['active'] and now <= member['expires']
    surge = fare['surge']
    if active:
        surge = min(surge, 20)
    surged = (fare['core'] * surge * 2 + 10) // 20
    disc = 0
    if active and surge <= 15:
        disc = (surged + fare['fees']) // 10 - fare['fees'] // 10
    return surged - disc + fare['fees']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: fees excluded from discount',
   [{'core': 1234, 'fees': 245, 'surge': 12}, {'active': True, 'expires': 100}, 100], 1578),
  ('partial repair probe: fees excluded from discount',
   [{'core': 2555, 'fees': 245, 'surge': 10}, {'active': True, 'expires': 100}, 100], 2545),
  ('second regression', [{'core': 1234, 'fees': 245, 'surge': 12}, {'active': True, 'expires': 100}, 99],
   1578),
  ('normal control 1', [{'core': 1234, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 101], 3702),
  ('normal control 2', [{'core': 999, 'fees': 250, 'surge': 25}, {'active': False, 'expires': 100}, 100],
   2748),
  ('normal control 3', [{'core': 1234, 'fees': 0, 'surge': 12}, {'active': False, 'expires': 100}, 101],
   1481),
  ('normal control 4', [{'core': 1000, 'fees': 199, 'surge': 17}, {'active': False, 'expires': 100}, 99],
   1899)],
 [('regression: fees excluded from discount',
   [{'core': 2555, 'fees': 199, 'surge': 15}, {'active': True, 'expires': 100}, 100], 3649),
  ('partial repair probe: fees excluded from discount',
   [{'core': 999, 'fees': 245, 'surge': 12}, {'active': True, 'expires': 100}, 99], 1325),
  ('second regression', [{'core': 2555, 'fees': 245, 'surge': 15}, {'active': True, 'expires': 100}, 100],
   3695),
  ('normal control 1', [{'core': 2555, 'fees': 250, 'surge': 12}, {'active': False, 'expires': 100}, 100],
   3316),
  ('normal control 2', [{'core': 2555, 'fees': 245, 'surge': 20}, {'active': True, 'expires': 100}, 100],
   5355),
  ('normal control 3', [{'core': 2555, 'fees': 0, 'surge': 15}, {'active': True, 'expires': 100}, 99], 3450),
  ('normal control 4', [{'core': 1000, 'fees': 245, 'surge': 17}, {'active': True, 'expires': 100}, 100],
   1945)],
 [('regression: fees excluded from discount',
   [{'core': 1000, 'fees': 245, 'surge': 15}, {'active': True, 'expires': 100}, 99], 1595),
  ('partial repair probe: fees excluded from discount',
   [{'core': 999, 'fees': 245, 'surge': 10}, {'active': True, 'expires': 100}, 99], 1145),
  ('second regression', [{'core': 999, 'fees': 245, 'surge': 15}, {'active': True, 'expires': 100}, 99],
   1595),
  ('normal control 1', [{'core': 1234, 'fees': 0, 'surge': 12}, {'active': False, 'expires': 100}, 100],
   1481),
  ('normal control 2', [{'core': 1234, 'fees': 250, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   2718),
  ('normal control 3', [{'core': 999, 'fees': 250, 'surge': 25}, {'active': False, 'expires': 100}, 100],
   2748),
  ('normal control 4', [{'core': 1234, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   2468)],
 [('regression: fees excluded from discount',
   [{'core': 2555, 'fees': 245, 'surge': 10}, {'active': True, 'expires': 100}, 100], 2545),
  ('partial repair probe: fees excluded from discount',
   [{'core': 2555, 'fees': 245, 'surge': 12}, {'active': True, 'expires': 100}, 99], 3005),
  ('second regression', [{'core': 999, 'fees': 250, 'surge': 10}, {'active': True, 'expires': 100}, 100],
   1150),
  ('normal control 1', [{'core': 1000, 'fees': 0, 'surge': 17}, {'active': True, 'expires': 100}, 100], 1700),
  ('normal control 2', [{'core': 1234, 'fees': 199, 'surge': 17}, {'active': True, 'expires': 100}, 101],
   2297),
  ('normal control 3', [{'core': 2555, 'fees': 245, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   5355),
  ('normal control 4', [{'core': 2555, 'fees': 245, 'surge': 20}, {'active': True, 'expires': 100}, 100],
   5355)],
 [('regression: fees excluded from discount',
   [{'core': 999, 'fees': 245, 'surge': 12}, {'active': True, 'expires': 100}, 100], 1325),
  ('partial repair probe: fees excluded from discount',
   [{'core': 2555, 'fees': 199, 'surge': 12}, {'active': True, 'expires': 100}, 99], 2959),
  ('second regression', [{'core': 1000, 'fees': 245, 'surge': 10}, {'active': True, 'expires': 100}, 100],
   1145),
  ('normal control 1', [{'core': 1000, 'fees': 0, 'surge': 15}, {'active': True, 'expires': 100}, 100], 1350),
  ('normal control 2', [{'core': 1000, 'fees': 250, 'surge': 17}, {'active': True, 'expires': 100}, 100],
   1950),
  ('normal control 3', [{'core': 1234, 'fees': 245, 'surge': 25}, {'active': False, 'expires': 100}, 100],
   3330),
  ('normal control 4', [{'core': 999, 'fees': 0, 'surge': 15}, {'active': False, 'expires': 100}, 99], 1499)]]
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:
Members get 10% off the booking fee as well.

Membership is active if the flag is set and today is on or before the expiry day. Active members have surge capped at 2.0x (20 tenths) and, when the (capped) surge is at most 1.5x, get 10% off the surged fare (floored); fees are never discounted. Return the amount due in cents.

split: open-access


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

N = 1
observations = []
def solve(fare, member, now):
    active = member['active']
    surge = fare['surge']
    if active:
        surge = min(surge, 20)
    surged = (fare['core'] * surge * 2 + 10) // 20
    disc = 0
    if active and surge <= 15:
        disc = surged // 10
    return surged - disc + fare['fees']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: membership expiry',
   [{'core': 2555, 'fees': 245, 'surge': 10}, {'active': True, 'expires': 100}, 101], 2800),
  ('partial repair probe: membership expiry',
   [{'core': 2555, 'fees': 0, 'surge': 25}, {'active': True, 'expires': 100}, 100], 5110),
  ('second regression', [{'core': 1234, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   2468),
  ('normal control 1', [{'core': 2555, 'fees': 199, 'surge': 20}, {'active': True, 'expires': 100}, 100],
   5309),
  ('normal control 2', [{'core': 999, 'fees': 250, 'surge': 20}, {'active': True, 'expires': 100}, 100],
   2248),
  ('normal control 3', [{'core': 2555, 'fees': 199, 'surge': 30}, {'active': False, 'expires': 100}, 100],
   7864),
  ('normal control 4', [{'core': 2555, 'fees': 199, 'surge': 10}, {'active': False, 'expires': 100}, 100],
   2754)],
 [('regression: membership expiry',
   [{'core': 1000, 'fees': 0, 'surge': 25}, {'active': True, 'expires': 100}, 101], 2500),
  ('partial repair probe: membership expiry',
   [{'core': 2555, 'fees': 199, 'surge': 15}, {'active': True, 'expires': 100}, 100], 3649),
  ('second regression', [{'core': 1234, 'fees': 199, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   2667),
  ('normal control 1', [{'core': 1234, 'fees': 250, 'surge': 30}, {'active': False, 'expires': 100}, 101],
   3952),
  ('normal control 2', [{'core': 1000, 'fees': 0, 'surge': 17}, {'active': True, 'expires': 100}, 100], 1700),
  ('normal control 3', [{'core': 1000, 'fees': 250, 'surge': 15}, {'active': False, 'expires': 100}, 100],
   1750),
  ('normal control 4', [{'core': 1234, 'fees': 0, 'surge': 30}, {'active': False, 'expires': 100}, 101],
   3702)],
 [('regression: membership expiry',
   [{'core': 1234, 'fees': 0, 'surge': 12}, {'active': True, 'expires': 100}, 101], 1481),
  ('partial repair probe: membership expiry',
   [{'core': 1234, 'fees': 250, 'surge': 30}, {'active': True, 'expires': 100}, 100], 2718),
  ('second regression', [{'core': 2555, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   5110),
  ('normal control 1', [{'core': 1234, 'fees': 250, 'surge': 20}, {'active': False, 'expires': 100}, 100],
   2718),
  ('normal control 2', [{'core': 999, 'fees': 199, 'surge': 20}, {'active': True, 'expires': 100}, 100],
   2197),
  ('normal control 3', [{'core': 2555, 'fees': 0, 'surge': 17}, {'active': True, 'expires': 100}, 100], 4344),
  ('normal control 4', [{'core': 2555, 'fees': 250, 'surge': 12}, {'active': False, 'expires': 100}, 100],
   3316)],
 [('regression: membership expiry',
   [{'core': 1234, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 101], 3702),
  ('partial repair probe: membership expiry',
   [{'core': 2555, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 100], 5110),
  ('second regression', [{'core': 999, 'fees': 250, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   2248),
  ('normal control 1', [{'core': 1234, 'fees': 199, 'surge': 12}, {'active': True, 'expires': 100}, 99],
   1532),
  ('normal control 2', [{'core': 2555, 'fees': 0, 'surge': 17}, {'active': True, 'expires': 100}, 100], 4344),
  ('normal control 3', [{'core': 2555, 'fees': 0, 'surge': 15}, {'active': False, 'expires': 100}, 101],
   3833),
  ('normal control 4', [{'core': 1234, 'fees': 199, 'surge': 10}, {'active': True, 'expires': 100}, 99],
   1310)],
 [('regression: membership expiry',
   [{'core': 999, 'fees': 0, 'surge': 12}, {'active': True, 'expires': 100}, 101], 1199),
  ('partial repair probe: membership expiry',
   [{'core': 1000, 'fees': 250, 'surge': 10}, {'active': True, 'expires': 100}, 100], 1150),
  ('second regression', [{'core': 2555, 'fees': 245, 'surge': 10}, {'active': True, 'expires': 100}, 100],
   2545),
  ('normal control 1', [{'core': 1234, 'fees': 0, 'surge': 17}, {'active': False, 'expires': 100}, 101],
   2098),
  ('normal control 2', [{'core': 1000, 'fees': 250, 'surge': 17}, {'active': False, 'expires': 100}, 101],
   1950),
  ('normal control 3', [{'core': 2555, 'fees': 250, 'surge': 15}, {'active': False, 'expires': 100}, 101],
   4083),
  ('normal control 4', [{'core': 1000, 'fees': 199, 'surge': 12}, {'active': True, 'expires': 100}, 99],
   1279)]]
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(fare, member, now):
    active = member['active'] and now < member['expires']
    surge = fare['surge']
    if active:
        surge = min(surge, 20)
    surged = (fare['core'] * surge * 2 + 10) // 20
    disc = 0
    if active and surge <= 15:
        disc = surged // 10
    return surged - disc + fare['fees']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: membership expiry',
   [{'core': 2555, 'fees': 245, 'surge': 10}, {'active': True, 'expires': 100}, 101], 2800),
  ('partial repair probe: membership expiry',
   [{'core': 2555, 'fees': 0, 'surge': 25}, {'active': True, 'expires': 100}, 100], 5110),
  ('second regression', [{'core': 1234, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   2468),
  ('normal control 1', [{'core': 2555, 'fees': 199, 'surge': 20}, {'active': True, 'expires': 100}, 100],
   5309),
  ('normal control 2', [{'core': 999, 'fees': 250, 'surge': 20}, {'active': True, 'expires': 100}, 100],
   2248),
  ('normal control 3', [{'core': 2555, 'fees': 199, 'surge': 30}, {'active': False, 'expires': 100}, 100],
   7864),
  ('normal control 4', [{'core': 2555, 'fees': 199, 'surge': 10}, {'active': False, 'expires': 100}, 100],
   2754)],
 [('regression: membership expiry',
   [{'core': 1000, 'fees': 0, 'surge': 25}, {'active': True, 'expires': 100}, 101], 2500),
  ('partial repair probe: membership expiry',
   [{'core': 2555, 'fees': 199, 'surge': 15}, {'active': True, 'expires': 100}, 100], 3649),
  ('second regression', [{'core': 1234, 'fees': 199, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   2667),
  ('normal control 1', [{'core': 1234, 'fees': 250, 'surge': 30}, {'active': False, 'expires': 100}, 101],
   3952),
  ('normal control 2', [{'core': 1000, 'fees': 0, 'surge': 17}, {'active': True, 'expires': 100}, 100], 1700),
  ('normal control 3', [{'core': 1000, 'fees': 250, 'surge': 15}, {'active': False, 'expires': 100}, 100],
   1750),
  ('normal control 4', [{'core': 1234, 'fees': 0, 'surge': 30}, {'active': False, 'expires': 100}, 101],
   3702)],
 [('regression: membership expiry',
   [{'core': 1234, 'fees': 0, 'surge': 12}, {'active': True, 'expires': 100}, 101], 1481),
  ('partial repair probe: membership expiry',
   [{'core': 1234, 'fees': 250, 'surge': 30}, {'active': True, 'expires': 100}, 100], 2718),
  ('second regression', [{'core': 2555, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   5110),
  ('normal control 1', [{'core': 1234, 'fees': 250, 'surge': 20}, {'active': False, 'expires': 100}, 100],
   2718),
  ('normal control 2', [{'core': 999, 'fees': 199, 'surge': 20}, {'active': True, 'expires': 100}, 100],
   2197),
  ('normal control 3', [{'core': 2555, 'fees': 0, 'surge': 17}, {'active': True, 'expires': 100}, 100], 4344),
  ('normal control 4', [{'core': 2555, 'fees': 250, 'surge': 12}, {'active': False, 'expires': 100}, 100],
   3316)],
 [('regression: membership expiry',
   [{'core': 1234, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 101], 3702),
  ('partial repair probe: membership expiry',
   [{'core': 2555, 'fees': 0, 'surge': 30}, {'active': True, 'expires': 100}, 100], 5110),
  ('second regression', [{'core': 999, 'fees': 250, 'surge': 30}, {'active': True, 'expires': 100}, 100],
   2248),
  ('normal control 1', [{'core': 1234, 'fees': 199, 'surge': 12}, {'active': True, 'expires': 100}, 99],
   1532),
  ('normal control 2', [{'core': 2555, 'fees': 0, 'surge': 17}, {'active': True, 'expires': 100}, 100], 4344),
  ('normal control 3', [{'core': 2555, 'fees': 0, 'surge': 15}, {'active': False, 'expires': 100}, 101],
   3833),
  ('normal control 4', [{'core': 1234, 'fees': 199, 'surge': 10}, {'active': True, 'expires': 100}, 99],
   1310)],
 [('regression: membership expiry',
   [{'core': 999, 'fees': 0, 'surge': 12}, {'active': True, 'expires': 100}, 101], 1199),
  ('partial repair probe: membership expiry',
   [{'core': 1000, 'fees': 250, 'surge': 10}, {'active': True, 'expires': 100}, 100], 1150),
  ('second regression', [{'core': 2555, 'fees': 245, 'surge': 10}, {'active': True, 'expires': 100}, 100],
   2545),
  ('normal control 1', [{'core': 1234, 'fees': 0, 'surge': 17}, {'active': False, 'expires': 100}, 101],
   2098),
  ('normal control 2', [{'core': 1000, 'fees': 250, 'surge': 17}, {'active': False, 'expires': 100}, 101],
   1950),
  ('normal control 3', [{'core': 2555, 'fees': 250, 'surge': 15}, {'active': False, 'expires': 100}, 101],
   4083),
  ('normal control 4', [{'core': 1000, 'fees': 199, 'surge': 12}, {'active': True, 'expires': 100}, 99],
   1279)]]
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:
Former members keep the surge cap after lapsing.

Membership is active if the flag is set and today is on or before the expiry day. Active members have surge capped at 2.0x (20 tenths) and, when the (capped) surge is at most 1.5x, get 10% off the surged fare (floored); fees are never discounted. Return the amount due in cents.

split: open-access


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

N = 1
observations = []
def solve(booked_price, metered, driver_no_show, reservation_fee):
    if driver_no_show:
        return {'charge': reservation_fee, 'refund_fee': False}
    return {'charge': min(booked_price, metered) + reservation_fee, 'refund_fee': False}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: no-show refund', [4100, 3400, True, 200], {'charge': 0, 'refund_fee': True}),
  ('partial repair probe: no-show refund', [2500, 3400, True, 200], {'charge': 0, 'refund_fee': True}),
  ('second regression', [3200, 4100, True, 200], {'charge': 0, 'refund_fee': True}),
  ('normal control 1', [4100, 3400, False, 300], {'charge': 3700, 'refund_fee': False}),
  ('normal control 2', [4100, 4099, False, 200], {'charge': 4299, 'refund_fee': False}),
  ('normal control 3', [4100, 4101, False, 200], {'charge': 4300, 'refund_fee': False}),
  ('normal control 4', [2500, 2499, False, 200], {'charge': 2699, 'refund_fee': False})],
 [('regression: no-show refund', [4100, 3400, True, 200], {'charge': 0, 'refund_fee': True}),
  ('partial repair probe: no-show refund', [2500, 3400, True, 300], {'charge': 0, 'refund_fee': True}),
  ('second regression', [2500, 3400, True, 200], {'charge': 0, 'refund_fee': True}),
  ('normal control 1', [2500, 1800, False, 200], {'charge': 2000, 'refund_fee': False}),
  ('normal control 2', [4100, 3400, False, 300], {'charge': 3700, 'refund_fee': False}),
  ('normal control 3', [3200, 3199, False, 200], {'charge': 3399, 'refund_fee': False}),
  ('normal control 4', [4100, 4101, False, 300], {'charge': 4400, 'refund_fee': False})],
 [('regression: no-show refund', [3200, 3201, True, 200], {'charge': 0, 'refund_fee': True}),
  ('partial repair probe: no-show refund', [4100, 4099, True, 300], {'charge': 0, 'refund_fee': True}),
  ('second regression', [3200, 3199, True, 300], {'charge': 0, 'refund_fee': True}),
  ('normal control 1', [3200, 3199, False, 200], {'charge': 3399, 'refund_fee': False}),
  ('normal control 2', [3200, 2500, False, 200], {'charge': 2700, 'refund_fee': False}),
  ('normal control 3', [2500, 1800, False, 200], {'charge': 2000, 'refund_fee': False}),
  ('normal control 4', [3200, 3201, False, 200], {'charge': 3400, 'refund_fee': False})],
 [('regression: no-show refund', [4100, 4099, True, 300], {'charge': 0, 'refund_fee': True}),
  ('partial repair probe: no-show refund', [4100, 5000, True, 300], {'charge': 0, 'refund_fee': True}),
  ('second regression', [2500, 1800, True, 300], {'charge': 0, 'refund_fee': True}),
  ('normal control 1', [2500, 1800, False, 200], {'charge': 2000, 'refund_fee': False}),
  ('normal control 2', [4100, 3400, False, 200], {'charge': 3600, 'refund_fee': False}),
  ('normal control 3', [3200, 3201, False, 300], {'charge': 3500, 'refund_fee': False}),
  ('normal control 4', [2500, 2501, False, 300], {'charge': 2800, 'refund_fee': False})],
 [('regression: no-show refund', [4100, 4100, True, 200], {'charge': 0, 'refund_fee': True}),
  ('partial repair probe: no-show refund', [4100, 4101, True, 300], {'charge': 0, 'refund_fee': True}),
  ('second regression', [3200, 3199, True, 300], {'charge': 0, 'refund_fee': True}),
  ('normal control 1', [2500, 3400, False, 300], {'charge': 2800, 'refund_fee': False}),
  ('normal control 2', [3200, 3199, False, 200], {'charge': 3399, 'refund_fee': False}),
  ('normal control 3', [3200, 2500, False, 200], {'charge': 2700, 'refund_fee': False}),
  ('normal control 4', [2500, 3400, False, 200], {'charge': 2700, 'refund_fee': False})]]
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(booked_price, metered, driver_no_show, reservation_fee):
    if driver_no_show:
        return {'charge': 0, 'refund_fee': False}
    return {'charge': min(booked_price, metered) + reservation_fee, 'refund_fee': False}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: no-show refund', [4100, 3400, True, 200], {'charge': 0, 'refund_fee': True}),
  ('partial repair probe: no-show refund', [2500, 3400, True, 200], {'charge': 0, 'refund_fee': True}),
  ('second regression', [3200, 4100, True, 200], {'charge': 0, 'refund_fee': True}),
  ('normal control 1', [4100, 3400, False, 300], {'charge': 3700, 'refund_fee': False}),
  ('normal control 2', [4100, 4099, False, 200], {'charge': 4299, 'refund_fee': False}),
  ('normal control 3', [4100, 4101, False, 200], {'charge': 4300, 'refund_fee': False}),
  ('normal control 4', [2500, 2499, False, 200], {'charge': 2699, 'refund_fee': False})],
 [('regression: no-show refund', [4100, 3400, True, 200], {'charge': 0, 'refund_fee': True}),
  ('partial repair probe: no-show refund', [2500, 3400, True, 300], {'charge': 0, 'refund_fee': True}),
  ('second regression', [2500, 3400, True, 200], {'charge': 0, 'refund_fee': True}),
  ('normal control 1', [2500, 1800, False, 200], {'charge': 2000, 'refund_fee': False}),
  ('normal control 2', [4100, 3400, False, 300], {'charge': 3700, 'refund_fee': False}),
  ('normal control 3', [3200, 3199, False, 200], {'charge': 3399, 'refund_fee': False}),
  ('normal control 4', [4100, 4101, False, 300], {'charge': 4400, 'refund_fee': False})],
 [('regression: no-show refund', [3200, 3201, True, 200], {'charge': 0, 'refund_fee': True}),
  ('partial repair probe: no-show refund', [4100, 4099, True, 300], {'charge': 0, 'refund_fee': True}),
  ('second regression', [3200, 3199, True, 300], {'charge': 0, 'refund_fee': True}),
  ('normal control 1', [3200, 3199, False, 200], {'charge': 3399, 'refund_fee': False}),
  ('normal control 2', [3200, 2500, False, 200], {'charge': 2700, 'refund_fee': False}),
  ('normal control 3', [2500, 1800, False, 200], {'charge': 2000, 'refund_fee': False}),
  ('normal control 4', [3200, 3201, False, 200], {'charge': 3400, 'refund_fee': False})],
 [('regression: no-show refund', [4100, 4099, True, 300], {'charge': 0, 'refund_fee': True}),
  ('partial repair probe: no-show refund', [4100, 5000, True, 300], {'charge': 0, 'refund_fee': True}),
  ('second regression', [2500, 1800, True, 300], {'charge': 0, 'refund_fee': True}),
  ('normal control 1', [2500, 1800, False, 200], {'charge': 2000, 'refund_fee': False}),
  ('normal control 2', [4100, 3400, False, 200], {'charge': 3600, 'refund_fee': False}),
  ('normal control 3', [3200, 3201, False, 300], {'charge': 3500, 'refund_fee': False}),
  ('normal control 4', [2500, 2501, False, 300], {'charge': 2800, 'refund_fee': False})],
 [('regression: no-show refund', [4100, 4100, True, 200], {'charge': 0, 'refund_fee': True}),
  ('partial repair probe: no-show refund', [4100, 4101, True, 300], {'charge': 0, 'refund_fee': True}),
  ('second regression', [3200, 3199, True, 300], {'charge': 0, 'refund_fee': True}),
  ('normal control 1', [2500, 3400, False, 300], {'charge': 2800, 'refund_fee': False}),
  ('normal control 2', [3200, 3199, False, 200], {'charge': 3399, 'refund_fee': False}),
  ('normal control 3', [3200, 2500, False, 200], {'charge': 2700, 'refund_fee': False}),
  ('normal control 4', [2500, 3400, False, 200], {'charge': 2700, 'refund_fee': False})]]
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 stood up by the driver still pay the reservation fee.

Scheduled rides guarantee the booked price: the rider pays the lower of booked and metered fare plus the reservation fee. If the driver never shows, nothing is charged and the reservation fee is refunded. Return charge cents and whether the fee is refunded.

split: open-access


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

N = 1
observations = []
def solve(booked_price, metered, driver_no_show, reservation_fee):
    if driver_no_show:
        return {'charge': 0, 'refund_fee': True}
    return {'charge': booked_price + reservation_fee, 'refund_fee': False}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: price guarantee direction', [3200, 3199, False, 300], {'charge': 3499, 'refund_fee': False}),
  ('partial repair probe: price guarantee direction', [3200, 4100, False, 300],
   {'charge': 3500, 'refund_fee': False}),
  ('second regression', [3200, 3201, False, 300], {'charge': 3500, 'refund_fee': False}),
  ('normal control 1', [2500, 2500, False, 200], {'charge': 2700, 'refund_fee': False}),
  ('normal control 2', [3200, 3199, True, 200], {'charge': 0, 'refund_fee': True}),
  ('normal control 3', [4100, 5000, True, 200], {'charge': 0, 'refund_fee': True}),
  ('normal control 4', [4100, 5000, True, 300], {'charge': 0, 'refund_fee': True})],
 [('regression: price guarantee direction', [4100, 4099, False, 200], {'charge': 4299, 'refund_fee': False}),
  ('partial repair probe: price guarantee direction', [4100, 5000, False, 200],
   {'charge': 4300, 'refund_fee': False}),
  ('second regression', [3200, 4100, False, 200], {'charge': 3400, 'refund_fee': False}),
  ('normal control 1', [3200, 3199, True, 200], {'charge': 0, 'refund_fee': True}),
  ('normal control 2', [4100, 4100, False, 300], {'charge': 4400, 'refund_fee': False}),
  ('normal control 3', [2500, 2500, False, 300], {'charge': 2800, 'refund_fee': False}),
  ('normal control 4', [2500, 3400, True, 300], {'charge': 0, 'refund_fee': True})],
 [('regression: price guarantee direction', [2500, 2499, False, 300], {'charge': 2799, 'refund_fee': False}),
  ('partial repair probe: price guarantee direction', [3200, 3201, False, 300],
   {'charge': 3500, 'refund_fee': False}),
  ('second regression', [2500, 3400, False, 300], {'charge': 2800, 'refund_fee': False}),
  ('normal control 1', [3200, 3199, True, 200], {'charge': 0, 'refund_fee': True}),
  ('normal control 2', [4100, 3400, True, 200], {'charge': 0, 'refund_fee': True}),
  ('normal control 3', [3200, 3200, False, 300], {'charge': 3500, 'refund_fee': False}),
  ('normal control 4', [3200, 3200, True, 300], {'charge': 0, 'refund_fee': True})],
 [('regression: price guarantee direction', [2500, 1800, False, 300], {'charge': 2100, 'refund_fee': False}),
  ('partial repair probe: price guarantee direction', [2500, 2499, False, 300],
   {'charge': 2799, 'refund_fee': False}),
  ('second regression', [3200, 2500, False, 200], {'charge': 2700, 'refund_fee': False}),
  ('normal control 1', [4100, 4099, True, 300], {'charge': 0, 'refund_fee': True}),
  ('normal control 2', [2500, 2500, False, 300], {'charge': 2800, 'refund_fee': False}),
  ('normal control 3', [4100, 4101, True, 300], {'charge': 0, 'refund_fee': True}),
  ('normal control 4', [2500, 2500, False, 200], {'charge': 2700, 'refund_fee': False})],
 [('regression: price guarantee direction', [2500, 1800, False, 300], {'charge': 2100, 'refund_fee': False}),
  ('partial repair probe: price guarantee direction', [3200, 2500, False, 200],
   {'charge': 2700, 'refund_fee': False}),
  ('second regression', [3200, 4100, False, 200], {'charge': 3400, 'refund_fee': False}),
  ('normal control 1', [2500, 2501, True, 300], {'charge': 0, 'refund_fee': True}),
  ('normal control 2', [4100, 4100, False, 300], {'charge': 4400, 'refund_fee': False}),
  ('normal control 3', [2500, 2501, True, 200], {'charge': 0, 'refund_fee': True}),
  ('normal control 4', [3200, 3200, False, 200], {'charge': 3400, 'refund_fee': False})]]
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(booked_price, metered, driver_no_show, reservation_fee):
    if driver_no_show:
        return {'charge': 0, 'refund_fee': True}
    return {'charge': max(booked_price, metered) + reservation_fee, 'refund_fee': False}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: price guarantee direction', [3200, 3199, False, 300], {'charge': 3499, 'refund_fee': False}),
  ('partial repair probe: price guarantee direction', [3200, 4100, False, 300],
   {'charge': 3500, 'refund_fee': False}),
  ('second regression', [3200, 3201, False, 300], {'charge': 3500, 'refund_fee': False}),
  ('normal control 1', [2500, 2500, False, 200], {'charge': 2700, 'refund_fee': False}),
  ('normal control 2', [3200, 3199, True, 200], {'charge': 0, 'refund_fee': True}),
  ('normal control 3', [4100, 5000, True, 200], {'charge': 0, 'refund_fee': True}),
  ('normal control 4', [4100, 5000, True, 300], {'charge': 0, 'refund_fee': True})],
 [('regression: price guarantee direction', [4100, 4099, False, 200], {'charge': 4299, 'refund_fee': False}),
  ('partial repair probe: price guarantee direction', [4100, 5000, False, 200],
   {'charge': 4300, 'refund_fee': False}),
  ('second regression', [3200, 4100, False, 200], {'charge': 3400, 'refund_fee': False}),
  ('normal control 1', [3200, 3199, True, 200], {'charge': 0, 'refund_fee': True}),
  ('normal control 2', [4100, 4100, False, 300], {'charge': 4400, 'refund_fee': False}),
  ('normal control 3', [2500, 2500, False, 300], {'charge': 2800, 'refund_fee': False}),
  ('normal control 4', [2500, 3400, True, 300], {'charge': 0, 'refund_fee': True})],
 [('regression: price guarantee direction', [2500, 2499, False, 300], {'charge': 2799, 'refund_fee': False}),
  ('partial repair probe: price guarantee direction', [3200, 3201, False, 300],
   {'charge': 3500, 'refund_fee': False}),
  ('second regression', [2500, 3400, False, 300], {'charge': 2800, 'refund_fee': False}),
  ('normal control 1', [3200, 3199, True, 200], {'charge': 0, 'refund_fee': True}),
  ('normal control 2', [4100, 3400, True, 200], {'charge': 0, 'refund_fee': True}),
  ('normal control 3', [3200, 3200, False, 300], {'charge': 3500, 'refund_fee': False}),
  ('normal control 4', [3200, 3200, True, 300], {'charge': 0, 'refund_fee': True})],
 [('regression: price guarantee direction', [2500, 1800, False, 300], {'charge': 2100, 'refund_fee': False}),
  ('partial repair probe: price guarantee direction', [2500, 2499, False, 300],
   {'charge': 2799, 'refund_fee': False}),
  ('second regression', [3200, 2500, False, 200], {'charge': 2700, 'refund_fee': False}),
  ('normal control 1', [4100, 4099, True, 300], {'charge': 0, 'refund_fee': True}),
  ('normal control 2', [2500, 2500, False, 300], {'charge': 2800, 'refund_fee': False}),
  ('normal control 3', [4100, 4101, True, 300], {'charge': 0, 'refund_fee': True}),
  ('normal control 4', [2500, 2500, False, 200], {'charge': 2700, 'refund_fee': False})],
 [('regression: price guarantee direction', [2500, 1800, False, 300], {'charge': 2100, 'refund_fee': False}),
  ('partial repair probe: price guarantee direction', [3200, 2500, False, 200],
   {'charge': 2700, 'refund_fee': False}),
  ('second regression', [3200, 4100, False, 200], {'charge': 3400, 'refund_fee': False}),
  ('normal control 1', [2500, 2501, True, 300], {'charge': 0, 'refund_fee': True}),
  ('normal control 2', [4100, 4100, False, 300], {'charge': 4400, 'refund_fee': False}),
  ('normal control 3', [2500, 2501, True, 200], {'charge': 0, 'refund_fee': True}),
  ('normal control 4', [3200, 3200, False, 200], {'charge': 3400, 'refund_fee': False})]]
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 traffic-free scheduled ride still costs the booked price.

Scheduled rides guarantee the booked price: the rider pays the lower of booked and metered fare plus the reservation fee. If the driver never shows, nothing is charged and the reservation fee is refunded. Return charge cents and whether the fee is refunded.

split: open-access