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

N = 1
observations = []
def solve(plays):
    bonus = 0
    for kind, yards, td in plays:
        if td and yards >= 50:
            bonus += 30
        elif td and yards > 40:
            bonus += 20
        if kind != 'pass' and yards >= 20:
            bonus += 5
    tds = sum(1 for _, _, td in plays if td)
    if tds >= 3:
        bonus += 20
    return bonus
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: forty-yard boundary', [[['pass', 40, True], ['rec', 50, True]]], 55),
  ('partial repair probe: forty-yard boundary',
   [[['rec', 49, True], ['rec', 40, False], ['rush', 49, False], ['rush', 19, True]]], 35),
  ('second regression', [[['pass', 49, True]]], 20),
  ('normal control 1',
   [[['rec', 20, False], ['rush', 46, False], ['rec', 39, True], ['pass', 5, False], ['rec', 5, False],
     ['rec', 5, True]]],
   15),
  ('normal control 2',
   [[['rush', 41, False], ['pass', 49, False], ['rush', 41, False], ['rush', 19, False], ['rec', -1, True]]],
   10),
  ('normal control 3', [[['rush', 19, True], ['pass', 59, False], ['rec', 5, True], ['pass', 50, False]]], 0),
  ('normal control 4',
   [[['pass', 41, False], ['pass', 39, False], ['pass', 51, False], ['pass', 41, False], ['rush', 5, False],
     ['rec', 50, False]]],
   5)],
 [('regression: forty-yard boundary',
   [[['rush', 49, True], ['rush', 40, True], ['rec', 40, True], ['pass', 20, False]]], 95),
  ('partial repair probe: forty-yard boundary',
   [[['rec', -3, False], ['rec', 39, False], ['pass', 50, True], ['rush', 49, True], ['pass', 50, False],
     ['rec', 51, False]]],
   65),
  ('second regression', [[['rec', 20, False], ['pass', 40, True], ['rush', 49, False], ['pass', 49, False]]],
   30),
  ('normal control 1', [[['rush', 19, True]]], 0), ('normal control 2', [[['rush', 51, True]]], 35),
  ('normal control 3', [[['rec', 50, False]]], 5),
  ('normal control 4',
   [[['pass', 49, False], ['rec', 19, True], ['rec', 51, True], ['pass', 41, False], ['pass', 39, False],
     ['rush', 19, True]]],
   55)],
 [('regression: forty-yard boundary',
   [[['pass', 51, True], ['pass', -3, False], ['rec', 40, True], ['rush', 20, False], ['rec', 5, True]]],
   80),
  ('partial repair probe: forty-yard boundary',
   [[['rush', 47, True], ['rush', 19, True], ['rec', 39, False], ['rush', 49, True], ['rush', 5, False]]],
   75),
  ('second regression', [[['rec', 49, True], ['rec', -3, False], ['rush', 49, True], ['rec', 19, True]]], 70),
  ('normal control 1', [[['pass', 50, False], ['rec', -3, True]]], 0),
  ('normal control 2', [[['rec', 50, True], ['rec', 38, True]]], 40),
  ('normal control 3', [[['rec', 23, False]]], 5), ('normal control 4', [[['pass', 19, False]]], 0)],
 [('regression: forty-yard boundary',
   [[['pass', 51, False], ['rush', 40, False], ['rec', 50, False], ['rush', 51, False], ['rec', 40, True],
     ['pass', 39, False]]],
   40),
  ('partial repair probe: forty-yard boundary', [[['rec', 49, True], ['rush', 49, False]]], 30),
  ('second regression', [[['rush', 20, False], ['rush', 31, True], ['rec', 41, True], ['rec', 49, True]]],
   80),
  ('normal control 1', [[['pass', 40, False], ['pass', 19, False]]], 0),
  ('normal control 2', [[['rec', 41, False]]], 5),
  ('normal control 3', [[['pass', 19, False], ['pass', 51, False]]], 0),
  ('normal control 4', [[['rec', 40, False], ['pass', 39, False], ['pass', 50, True]]], 35)],
 [('regression: forty-yard boundary',
   [[['rec', 20, False], ['pass', 49, True], ['rush', 5, False], ['pass', 41, True], ['rush', 40, True],
     ['rec', -3, True]]],
   90),
  ('partial repair probe: forty-yard boundary', [[['rec', 39, False], ['pass', 49, True]]], 25),
  ('second regression',
   [[['rush', 50, False], ['rec', 19, True], ['pass', 23, False], ['rush', 39, False], ['pass', 49, True],
     ['rec', 20, False]]],
   35),
  ('normal control 1', [[['pass', 31, False]]], 0),
  ('normal control 2', [[['rec', 5, True], ['pass', -3, False]]], 0),
  ('normal control 3', [[['pass', 39, False]]], 0), ('normal control 4', [[['rush', 20, False]]], 5)]]
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(plays):
    bonus = 0
    for kind, yards, td in plays:
        if td and yards >= 50:
            bonus += 30
        elif td and 40 <= yards < 49:
            bonus += 20
        if kind != 'pass' and yards >= 20:
            bonus += 5
    tds = sum(1 for _, _, td in plays if td)
    if tds >= 3:
        bonus += 20
    return bonus
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: forty-yard boundary', [[['pass', 40, True], ['rec', 50, True]]], 55),
  ('partial repair probe: forty-yard boundary',
   [[['rec', 49, True], ['rec', 40, False], ['rush', 49, False], ['rush', 19, True]]], 35),
  ('second regression', [[['pass', 49, True]]], 20),
  ('normal control 1',
   [[['rec', 20, False], ['rush', 46, False], ['rec', 39, True], ['pass', 5, False], ['rec', 5, False],
     ['rec', 5, True]]],
   15),
  ('normal control 2',
   [[['rush', 41, False], ['pass', 49, False], ['rush', 41, False], ['rush', 19, False], ['rec', -1, True]]],
   10),
  ('normal control 3', [[['rush', 19, True], ['pass', 59, False], ['rec', 5, True], ['pass', 50, False]]], 0),
  ('normal control 4',
   [[['pass', 41, False], ['pass', 39, False], ['pass', 51, False], ['pass', 41, False], ['rush', 5, False],
     ['rec', 50, False]]],
   5)],
 [('regression: forty-yard boundary',
   [[['rush', 49, True], ['rush', 40, True], ['rec', 40, True], ['pass', 20, False]]], 95),
  ('partial repair probe: forty-yard boundary',
   [[['rec', -3, False], ['rec', 39, False], ['pass', 50, True], ['rush', 49, True], ['pass', 50, False],
     ['rec', 51, False]]],
   65),
  ('second regression', [[['rec', 20, False], ['pass', 40, True], ['rush', 49, False], ['pass', 49, False]]],
   30),
  ('normal control 1', [[['rush', 19, True]]], 0), ('normal control 2', [[['rush', 51, True]]], 35),
  ('normal control 3', [[['rec', 50, False]]], 5),
  ('normal control 4',
   [[['pass', 49, False], ['rec', 19, True], ['rec', 51, True], ['pass', 41, False], ['pass', 39, False],
     ['rush', 19, True]]],
   55)],
 [('regression: forty-yard boundary',
   [[['pass', 51, True], ['pass', -3, False], ['rec', 40, True], ['rush', 20, False], ['rec', 5, True]]],
   80),
  ('partial repair probe: forty-yard boundary',
   [[['rush', 47, True], ['rush', 19, True], ['rec', 39, False], ['rush', 49, True], ['rush', 5, False]]],
   75),
  ('second regression', [[['rec', 49, True], ['rec', -3, False], ['rush', 49, True], ['rec', 19, True]]], 70),
  ('normal control 1', [[['pass', 50, False], ['rec', -3, True]]], 0),
  ('normal control 2', [[['rec', 50, True], ['rec', 38, True]]], 40),
  ('normal control 3', [[['rec', 23, False]]], 5), ('normal control 4', [[['pass', 19, False]]], 0)],
 [('regression: forty-yard boundary',
   [[['pass', 51, False], ['rush', 40, False], ['rec', 50, False], ['rush', 51, False], ['rec', 40, True],
     ['pass', 39, False]]],
   40),
  ('partial repair probe: forty-yard boundary', [[['rec', 49, True], ['rush', 49, False]]], 30),
  ('second regression', [[['rush', 20, False], ['rush', 31, True], ['rec', 41, True], ['rec', 49, True]]],
   80),
  ('normal control 1', [[['pass', 40, False], ['pass', 19, False]]], 0),
  ('normal control 2', [[['rec', 41, False]]], 5),
  ('normal control 3', [[['pass', 19, False], ['pass', 51, False]]], 0),
  ('normal control 4', [[['rec', 40, False], ['pass', 39, False], ['pass', 50, True]]], 35)],
 [('regression: forty-yard boundary',
   [[['rec', 20, False], ['pass', 49, True], ['rush', 5, False], ['pass', 41, True], ['rush', 40, True],
     ['rec', -3, True]]],
   90),
  ('partial repair probe: forty-yard boundary', [[['rec', 39, False], ['pass', 49, True]]], 25),
  ('second regression',
   [[['rush', 50, False], ['rec', 19, True], ['pass', 23, False], ['rush', 39, False], ['pass', 49, True],
     ['rec', 20, False]]],
   35),
  ('normal control 1', [[['pass', 31, False]]], 0),
  ('normal control 2', [[['rec', 5, True], ['pass', -3, False]]], 0),
  ('normal control 3', [[['pass', 39, False]]], 0), ('normal control 4', [[['rush', 20, False]]], 5)]]
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 40-yard touchdown run scores no long-TD bonus.

Per-play bonus tenths for one player: a touchdown of 50+ yards earns 3, a touchdown of 40-49 yards earns 2 (exclusive tiers); every rushing or receiving play (not passing) of 20+ yards earns 0.5 whether or not it scored; three or more touchdowns in the game earn 2 once.

split: open-access


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

N = 1
observations = []
def solve(plays):
    bonus = 0
    for kind, yards, td in plays:
        if td and yards >= 50:
            bonus += 30
        elif td and yards >= 40:
            bonus += 20
        if yards >= 20:
            bonus += 5
    tds = sum(1 for _, _, td in plays if td)
    if tds >= 3:
        bonus += 20
    return bonus
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: big play type filter',
   [[['rush', 40, True], ['rec', 50, False], ['rec', 51, True], ['rec', 51, True], ['rec', 40, False],
     ['pass', 41, False]]],
   125),
  ('partial repair probe: big play type filter', [[['rec', 20, True], ['rec', 41, True]]], 30),
  ('second regression', [[['pass', 50, True], ['rush', 41, False]]], 35),
  ('normal control 1', [[['pass', 19, False]]], 0), ('normal control 2', [[['rush', 19, False]]], 0),
  ('normal control 3', [[['rec', -3, False], ['rush', 20, False], ['rush', 51, False], ['rush', 40, False]]],
   15),
  ('normal control 4', [[['rush', 49, False], ['rec', 5, True], ['rec', -3, True]]], 5)],
 [('regression: big play type filter', [[['pass', 39, True]]], 0),
  ('partial repair probe: big play type filter',
   [[['rec', 19, False], ['rec', -3, False], ['rec', 50, True], ['pass', 51, False], ['rec', 5, False],
     ['pass', 49, True]]],
   55),
  ('second regression', [[['pass', 41, False]]], 0),
  ('normal control 1', [[['rec', 5, True], ['pass', -3, True]]], 0),
  ('normal control 2', [[['pass', -5, True], ['rush', 19, True], ['pass', 4, False]]], 0),
  ('normal control 3', [[['rush', 39, True]]], 5), ('normal control 4', [[['rec', 5, True]]], 0)],
 [('regression: big play type filter',
   [[['rush', 61, False], ['rec', 51, False], ['pass', 41, True], ['rush', 20, True]]], 35),
  ('partial repair probe: big play type filter', [[['rec', 20, False], ['rec', 41, False]]], 10),
  ('second regression',
   [[['rush', 5, False], ['rush', 5, True], ['rec', 41, False], ['pass', 41, False], ['rush', 50, True]]],
   40),
  ('normal control 1', [[['rush', 40, False]]], 5), ('normal control 2', [[['pass', 19, False]]], 0),
  ('normal control 3',
   [[['rec', 5, False], ['rush', 41, True], ['rush', 40, True], ['rush', 49, False], ['rush', 40, True]]],
   100),
  ('normal control 4', [[['rush', 40, True]]], 25)],
 [('regression: big play type filter', [[['rec', 40, False], ['rec', 51, True], ['pass', 40, False]]], 40),
  ('partial repair probe: big play type filter',
   [[['pass', 23, False], ['rush', 13, True], ['pass', 77, True], ['rec', 41, True]]], 75),
  ('second regression', [[['pass', 20, True], ['rush', 41, True]]], 25),
  ('normal control 1', [[['pass', 5, True], ['rec', 19, False]]], 0),
  ('normal control 2', [[['rush', 40, False], ['rush', 39, True]]], 10),
  ('normal control 3', [[['pass', 5, False], ['rec', 5, True]]], 0),
  ('normal control 4',
   [[['rush', 19, False], ['rush', -3, False], ['rush', 5, False], ['rush', 40, True], ['rush', 5, True]]],
   25)],
 [('regression: big play type filter', [[['pass', 39, True], ['rec', 19, False]]], 0),
  ('partial repair probe: big play type filter',
   [[['pass', 19, False], ['rush', 5, True], ['rush', 40, True], ['rush', 5, True], ['rec', 39, False],
     ['rec', 19, False]]],
   50),
  ('second regression', [[['pass', 41, False], ['rush', 10, True], ['rush', 20, False]]], 5),
  ('normal control 1', [[['rush', 51, False]]], 5),
  ('normal control 2',
   [[['rec', -3, False], ['rush', 51, True], ['rush', -3, False], ['rush', -3, True], ['rush', 19, True]]],
   55),
  ('normal control 3', [[['rec', 19, False], ['rush', 5, False]]], 0),
  ('normal control 4', [[['rush', 39, False], ['rush', 51, False], ['rush', 48, False], ['rec', 5, True]]],
   15)]]
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(plays):
    bonus = 0
    for kind, yards, td in plays:
        if td and yards >= 50:
            bonus += 30
        elif td and yards >= 40:
            bonus += 20
        if kind == 'rush' and yards >= 20:
            bonus += 5
    tds = sum(1 for _, _, td in plays if td)
    if tds >= 3:
        bonus += 20
    return bonus
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: big play type filter',
   [[['rush', 40, True], ['rec', 50, False], ['rec', 51, True], ['rec', 51, True], ['rec', 40, False],
     ['pass', 41, False]]],
   125),
  ('partial repair probe: big play type filter', [[['rec', 20, True], ['rec', 41, True]]], 30),
  ('second regression', [[['pass', 50, True], ['rush', 41, False]]], 35),
  ('normal control 1', [[['pass', 19, False]]], 0), ('normal control 2', [[['rush', 19, False]]], 0),
  ('normal control 3', [[['rec', -3, False], ['rush', 20, False], ['rush', 51, False], ['rush', 40, False]]],
   15),
  ('normal control 4', [[['rush', 49, False], ['rec', 5, True], ['rec', -3, True]]], 5)],
 [('regression: big play type filter', [[['pass', 39, True]]], 0),
  ('partial repair probe: big play type filter',
   [[['rec', 19, False], ['rec', -3, False], ['rec', 50, True], ['pass', 51, False], ['rec', 5, False],
     ['pass', 49, True]]],
   55),
  ('second regression', [[['pass', 41, False]]], 0),
  ('normal control 1', [[['rec', 5, True], ['pass', -3, True]]], 0),
  ('normal control 2', [[['pass', -5, True], ['rush', 19, True], ['pass', 4, False]]], 0),
  ('normal control 3', [[['rush', 39, True]]], 5), ('normal control 4', [[['rec', 5, True]]], 0)],
 [('regression: big play type filter',
   [[['rush', 61, False], ['rec', 51, False], ['pass', 41, True], ['rush', 20, True]]], 35),
  ('partial repair probe: big play type filter', [[['rec', 20, False], ['rec', 41, False]]], 10),
  ('second regression',
   [[['rush', 5, False], ['rush', 5, True], ['rec', 41, False], ['pass', 41, False], ['rush', 50, True]]],
   40),
  ('normal control 1', [[['rush', 40, False]]], 5), ('normal control 2', [[['pass', 19, False]]], 0),
  ('normal control 3',
   [[['rec', 5, False], ['rush', 41, True], ['rush', 40, True], ['rush', 49, False], ['rush', 40, True]]],
   100),
  ('normal control 4', [[['rush', 40, True]]], 25)],
 [('regression: big play type filter', [[['rec', 40, False], ['rec', 51, True], ['pass', 40, False]]], 40),
  ('partial repair probe: big play type filter',
   [[['pass', 23, False], ['rush', 13, True], ['pass', 77, True], ['rec', 41, True]]], 75),
  ('second regression', [[['pass', 20, True], ['rush', 41, True]]], 25),
  ('normal control 1', [[['pass', 5, True], ['rec', 19, False]]], 0),
  ('normal control 2', [[['rush', 40, False], ['rush', 39, True]]], 10),
  ('normal control 3', [[['pass', 5, False], ['rec', 5, True]]], 0),
  ('normal control 4',
   [[['rush', 19, False], ['rush', -3, False], ['rush', 5, False], ['rush', 40, True], ['rush', 5, True]]],
   25)],
 [('regression: big play type filter', [[['pass', 39, True], ['rec', 19, False]]], 0),
  ('partial repair probe: big play type filter',
   [[['pass', 19, False], ['rush', 5, True], ['rush', 40, True], ['rush', 5, True], ['rec', 39, False],
     ['rec', 19, False]]],
   50),
  ('second regression', [[['pass', 41, False], ['rush', 10, True], ['rush', 20, False]]], 5),
  ('normal control 1', [[['rush', 51, False]]], 5),
  ('normal control 2',
   [[['rec', -3, False], ['rush', 51, True], ['rush', -3, False], ['rush', -3, True], ['rush', 19, True]]],
   55),
  ('normal control 3', [[['rec', 19, False], ['rush', 5, False]]], 0),
  ('normal control 4', [[['rush', 39, False], ['rush', 51, False], ['rush', 48, False], ['rec', 5, True]]],
   15)]]
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 quarterback earns 0.5 for every 20-yard completion.

Per-play bonus tenths for one player: a touchdown of 50+ yards earns 3, a touchdown of 40-49 yards earns 2 (exclusive tiers); every rushing or receiving play (not passing) of 20+ yards earns 0.5 whether or not it scored; three or more touchdowns in the game earn 2 once.

split: open-access


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

N = 1
observations = []
def solve(plays):
    bonus = 0
    for kind, yards, td in plays:
        if yards >= 50:
            bonus += 30
        elif td and yards >= 40:
            bonus += 20
        if kind != 'pass' and yards >= 20:
            bonus += 5
    tds = sum(1 for _, _, td in plays if td)
    if tds >= 3:
        bonus += 20
    return bonus
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: touchdown requirement',
   [[['pass', 44, False], ['rec', 51, False], ['pass', 20, False], ['rec', 5, False]]], 5),
  ('partial repair probe: touchdown requirement',
   [[['pass', 50, True], ['rush', 66, True], ['rush', 41, False], ['rush', 19, False], ['rec', 51, False],
     ['pass', -3, False]]],
   75),
  ('second regression', [[['rec', 19, True], ['rush', 80, False]]], 5),
  ('normal control 1',
   [[['pass', 41, False], ['rush', 20, True], ['rush', -3, True], ['rec', 50, True], ['pass', 20, False]]],
   60),
  ('normal control 2', [[['rec', 39, True]]], 5),
  ('normal control 3', [[['pass', 50, True], ['pass', 19, True], ['rush', 40, False]]], 35),
  ('normal control 4',
   [[['rec', 20, False], ['rush', 5, False], ['rec', 5, True], ['rush', 41, True], ['rec', 51, True]]], 85)],
 [('regression: touchdown requirement', [[['rush', 41, True], ['pass', 51, False]]], 25),
  ('partial repair probe: touchdown requirement',
   [[['rec', 50, False], ['rec', 19, False], ['pass', 49, False]]], 5),
  ('second regression', [[['pass', -3, False], ['pass', 51, False]]], 0),
  ('normal control 1', [[['rush', 5, False], ['pass', 19, False], ['rec', 41, False], ['rush', 49, True]]],
   30),
  ('normal control 2', [[['rec', 51, True]]], 35),
  ('normal control 3', [[['rec', -4, True], ['rec', 20, False], ['rec', 5, True]]], 5),
  ('normal control 4', [[['pass', 41, False], ['pass', 40, False], ['rec', -3, True], ['pass', 19, True]]],
   0)],
 [('regression: touchdown requirement', [[['rush', 51, False], ['pass', 41, True]]], 25),
  ('partial repair probe: touchdown requirement', [[['rec', 51, False]]], 5),
  ('second regression', [[['rush', 40, True], ['rec', 19, False], ['rush', 20, True], ['rush', 50, False]]],
   35),
  ('normal control 1',
   [[['rush', 51, True], ['rec', 40, False], ['rush', 5, True], ['pass', 7, True], ['pass', 49, False]]],
   60),
  ('normal control 2', [[['rec', 19, False]]], 0),
  ('normal control 3', [[['pass', 50, True], ['rec', 50, True], ['rec', 41, True], ['rush', 41, True]]], 135),
  ('normal control 4', [[['rec', -3, False], ['rush', -3, False]]], 0)],
 [('regression: touchdown requirement',
   [[['pass', 5, False], ['rec', 41, False], ['rec', -3, True], ['rec', 40, False], ['pass', 51, False]]],
   10),
  ('partial repair probe: touchdown requirement', [[['rec', 51, False]]], 5),
  ('second regression', [[['rec', 5, False], ['rush', 39, False], ['pass', 51, False]]], 5),
  ('normal control 1', [[['rush', 5, True], ['pass', 5, False], ['rec', 5, True]]], 0),
  ('normal control 2', [[['rush', 33, False], ['pass', 5, False], ['rec', 40, False]]], 10),
  ('normal control 3',
   [[['rec', 41, True], ['rush', 20, False], ['pass', 40, False], ['rec', 39, False], ['rush', 5, False],
     ['rush', 19, False]]],
   35),
  ('normal control 4', [[['pass', 39, True], ['pass', 40, False]]], 0)],
 [('regression: touchdown requirement',
   [[['pass', 39, False], ['pass', 41, True], ['rush', 40, True], ['rec', 50, False], ['rush', 39, False],
     ['rush', 39, True]]],
   80),
  ('partial repair probe: touchdown requirement',
   [[['rush', 19, True], ['pass', 41, False], ['rush', 5, True], ['pass', 50, True], ['rush', 49, True],
     ['rec', 50, False]]],
   80),
  ('second regression', [[['rec', 49, True], ['rush', 19, False], ['rec', 50, False], ['rush', 20, False]]],
   35),
  ('normal control 1', [[['rush', 5, False], ['rush', 32, False], ['pass', 19, False], ['pass', 40, False]]],
   5),
  ('normal control 2',
   [[['rec', 50, True], ['rush', 5, False], ['rec', 5, True], ['rush', -3, True], ['rec', 5, False],
     ['rush', 40, False]]],
   60),
  ('normal control 3',
   [[['pass', 5, False], ['rush', 20, False], ['rush', -3, False], ['rush', 49, False], ['pass', 41, False]]],
   10),
  ('normal control 4', [[['rush', 53, True], ['rec', 19, False], ['pass', -3, True]]], 35)]]
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(plays):
    bonus = 0
    for kind, yards, td in plays:
        if (td or kind == 'rec') and yards >= 50:
            bonus += 30
        elif td and yards >= 40:
            bonus += 20
        if kind != 'pass' and yards >= 20:
            bonus += 5
    tds = sum(1 for _, _, td in plays if td)
    if tds >= 3:
        bonus += 20
    return bonus
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: touchdown requirement',
   [[['pass', 44, False], ['rec', 51, False], ['pass', 20, False], ['rec', 5, False]]], 5),
  ('partial repair probe: touchdown requirement',
   [[['pass', 50, True], ['rush', 66, True], ['rush', 41, False], ['rush', 19, False], ['rec', 51, False],
     ['pass', -3, False]]],
   75),
  ('second regression', [[['rec', 19, True], ['rush', 80, False]]], 5),
  ('normal control 1',
   [[['pass', 41, False], ['rush', 20, True], ['rush', -3, True], ['rec', 50, True], ['pass', 20, False]]],
   60),
  ('normal control 2', [[['rec', 39, True]]], 5),
  ('normal control 3', [[['pass', 50, True], ['pass', 19, True], ['rush', 40, False]]], 35),
  ('normal control 4',
   [[['rec', 20, False], ['rush', 5, False], ['rec', 5, True], ['rush', 41, True], ['rec', 51, True]]], 85)],
 [('regression: touchdown requirement', [[['rush', 41, True], ['pass', 51, False]]], 25),
  ('partial repair probe: touchdown requirement',
   [[['rec', 50, False], ['rec', 19, False], ['pass', 49, False]]], 5),
  ('second regression', [[['pass', -3, False], ['pass', 51, False]]], 0),
  ('normal control 1', [[['rush', 5, False], ['pass', 19, False], ['rec', 41, False], ['rush', 49, True]]],
   30),
  ('normal control 2', [[['rec', 51, True]]], 35),
  ('normal control 3', [[['rec', -4, True], ['rec', 20, False], ['rec', 5, True]]], 5),
  ('normal control 4', [[['pass', 41, False], ['pass', 40, False], ['rec', -3, True], ['pass', 19, True]]],
   0)],
 [('regression: touchdown requirement', [[['rush', 51, False], ['pass', 41, True]]], 25),
  ('partial repair probe: touchdown requirement', [[['rec', 51, False]]], 5),
  ('second regression', [[['rush', 40, True], ['rec', 19, False], ['rush', 20, True], ['rush', 50, False]]],
   35),
  ('normal control 1',
   [[['rush', 51, True], ['rec', 40, False], ['rush', 5, True], ['pass', 7, True], ['pass', 49, False]]],
   60),
  ('normal control 2', [[['rec', 19, False]]], 0),
  ('normal control 3', [[['pass', 50, True], ['rec', 50, True], ['rec', 41, True], ['rush', 41, True]]], 135),
  ('normal control 4', [[['rec', -3, False], ['rush', -3, False]]], 0)],
 [('regression: touchdown requirement',
   [[['pass', 5, False], ['rec', 41, False], ['rec', -3, True], ['rec', 40, False], ['pass', 51, False]]],
   10),
  ('partial repair probe: touchdown requirement', [[['rec', 51, False]]], 5),
  ('second regression', [[['rec', 5, False], ['rush', 39, False], ['pass', 51, False]]], 5),
  ('normal control 1', [[['rush', 5, True], ['pass', 5, False], ['rec', 5, True]]], 0),
  ('normal control 2', [[['rush', 33, False], ['pass', 5, False], ['rec', 40, False]]], 10),
  ('normal control 3',
   [[['rec', 41, True], ['rush', 20, False], ['pass', 40, False], ['rec', 39, False], ['rush', 5, False],
     ['rush', 19, False]]],
   35),
  ('normal control 4', [[['pass', 39, True], ['pass', 40, False]]], 0)],
 [('regression: touchdown requirement',
   [[['pass', 39, False], ['pass', 41, True], ['rush', 40, True], ['rec', 50, False], ['rush', 39, False],
     ['rush', 39, True]]],
   80),
  ('partial repair probe: touchdown requirement',
   [[['rush', 19, True], ['pass', 41, False], ['rush', 5, True], ['pass', 50, True], ['rush', 49, True],
     ['rec', 50, False]]],
   80),
  ('second regression', [[['rec', 49, True], ['rush', 19, False], ['rec', 50, False], ['rush', 20, False]]],
   35),
  ('normal control 1', [[['rush', 5, False], ['rush', 32, False], ['pass', 19, False], ['pass', 40, False]]],
   5),
  ('normal control 2',
   [[['rec', 50, True], ['rush', 5, False], ['rec', 5, True], ['rush', -3, True], ['rec', 5, False],
     ['rush', 40, False]]],
   60),
  ('normal control 3',
   [[['pass', 5, False], ['rush', 20, False], ['rush', -3, False], ['rush', 49, False], ['pass', 41, False]]],
   10),
  ('normal control 4', [[['rush', 53, True], ['rec', 19, False], ['pass', -3, True]]], 35)]]
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 55-yard run tackled at the 5 earns the 50+ touchdown bonus.

Per-play bonus tenths for one player: a touchdown of 50+ yards earns 3, a touchdown of 40-49 yards earns 2 (exclusive tiers); every rushing or receiving play (not passing) of 20+ yards earns 0.5 whether or not it scored; three or more touchdowns in the game earn 2 once.

split: open-access


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

N = 1
observations = []
def solve(trip, rate):
    def half_up(num, den):
        return (num * 2 + den) // (den * 2)
    dist = half_up(trip['meters'] * rate['per_km'], 1000)
    tm = half_up(trip['seconds'] * rate['per_min'], 60)
    sub = rate['base'] + dist + tm
    fare = max(sub + rate['booking_fee'], rate['minimum'])
    return {'distance': dist, 'time': tm, 'fare': fare}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: minimum before booking fee',
   [{'meters': 0, 'seconds': 30},
    {'base': 250, 'booking_fee': 250, 'minimum': 1000, 'per_km': 125, 'per_min': 35}],
   {'distance': 0, 'fare': 1250, 'time': 18}),
  ('partial repair probe: minimum before booking fee',
   [{'meters': 4, 'seconds': 30},
    {'base': 150, 'booking_fee': 250, 'minimum': 500, 'per_km': 95, 'per_min': 30}],
   {'distance': 0, 'fare': 750, 'time': 15}),
  ('second regression',
   [{'meters': 0, 'seconds': 30},
    {'base': 0, 'booking_fee': 175, 'minimum': 700, 'per_km': 110, 'per_min': 30}],
   {'distance': 0, 'fare': 875, 'time': 15}),
  ('normal control 1',
   [{'meters': 2500, 'seconds': 30},
    {'base': 250, 'booking_fee': 0, 'minimum': 1000, 'per_km': 125, 'per_min': 15}],
   {'distance': 313, 'fare': 1000, 'time': 8}),
  ('normal control 2',
   [{'meters': 0, 'seconds': 61},
    {'base': 0, 'booking_fee': 0, 'minimum': 700, 'per_km': 125, 'per_min': 15}],
   {'distance': 0, 'fare': 700, 'time': 15}),
  ('normal control 3',
   [{'meters': 500, 'seconds': 0},
    {'base': 0, 'booking_fee': 0, 'minimum': 500, 'per_km': 250, 'per_min': 30}],
   {'distance': 125, 'fare': 500, 'time': 0}),
  ('normal control 4',
   [{'meters': 0, 'seconds': 61},
    {'base': 250, 'booking_fee': 0, 'minimum': 500, 'per_km': 110, 'per_min': 35}],
   {'distance': 0, 'fare': 500, 'time': 36})],
 [('regression: minimum before booking fee',
   [{'meters': 2500, 'seconds': 90},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 125, 'per_min': 15}],
   {'distance': 313, 'fare': 950, 'time': 23}),
  ('partial repair probe: minimum before booking fee',
   [{'meters': 0, 'seconds': 0},
    {'base': 250, 'booking_fee': 175, 'minimum': 1000, 'per_km': 95, 'per_min': 35}],
   {'distance': 0, 'fare': 1175, 'time': 0}),
  ('second regression',
   [{'meters': 0, 'seconds': 90},
    {'base': 250, 'booking_fee': 175, 'minimum': 1000, 'per_km': 110, 'per_min': 30}],
   {'distance': 0, 'fare': 1175, 'time': 45}),
  ('normal control 1',
   [{'meters': 15327, 'seconds': 30},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 125, 'per_min': 30}],
   {'distance': 1916, 'fare': 2181, 'time': 15}),
  ('normal control 2',
   [{'meters': 500, 'seconds': 1882},
    {'base': 0, 'booking_fee': 0, 'minimum': 500, 'per_km': 250, 'per_min': 25}],
   {'distance': 125, 'fare': 909, 'time': 784}),
  ('normal control 3',
   [{'meters': 500, 'seconds': 61},
    {'base': 250, 'booking_fee': 0, 'minimum': 700, 'per_km': 95, 'per_min': 30}],
   {'distance': 48, 'fare': 700, 'time': 31}),
  ('normal control 4',
   [{'meters': 500, 'seconds': 0},
    {'base': 250, 'booking_fee': 0, 'minimum': 700, 'per_km': 95, 'per_min': 35}],
   {'distance': 48, 'fare': 700, 'time': 0})],
 [('regression: minimum before booking fee',
   [{'meters': 1004, 'seconds': 0},
    {'base': 0, 'booking_fee': 175, 'minimum': 500, 'per_km': 250, 'per_min': 15}],
   {'distance': 251, 'fare': 675, 'time': 0}),
  ('partial repair probe: minimum before booking fee',
   [{'meters': 4, 'seconds': 0},
    {'base': 150, 'booking_fee': 250, 'minimum': 700, 'per_km': 110, 'per_min': 30}],
   {'distance': 0, 'fare': 950, 'time': 0}),
  ('second regression',
   [{'meters': 12, 'seconds': 90},
    {'base': 250, 'booking_fee': 250, 'minimum': 700, 'per_km': 110, 'per_min': 30}],
   {'distance': 1, 'fare': 950, 'time': 45}),
  ('normal control 1',
   [{'meters': 0, 'seconds': 61},
    {'base': 250, 'booking_fee': 0, 'minimum': 500, 'per_km': 110, 'per_min': 15}],
   {'distance': 0, 'fare': 500, 'time': 15}),
  ('normal control 2',
   [{'meters': 6354, 'seconds': 30},
    {'base': 0, 'booking_fee': 0, 'minimum': 500, 'per_km': 110, 'per_min': 35}],
   {'distance': 699, 'fare': 717, 'time': 18}),
  ('normal control 3',
   [{'meters': 4, 'seconds': 61},
    {'base': 250, 'booking_fee': 0, 'minimum': 500, 'per_km': 95, 'per_min': 35}],
   {'distance': 0, 'fare': 500, 'time': 36}),
  ('normal control 4',
   [{'meters': 23665, 'seconds': 30},
    {'base': 0, 'booking_fee': 175, 'minimum': 500, 'per_km': 110, 'per_min': 15}],
   {'distance': 2603, 'fare': 2786, 'time': 8})],
 [('regression: minimum before booking fee',
   [{'meters': 500, 'seconds': 30},
    {'base': 150, 'booking_fee': 175, 'minimum': 1000, 'per_km': 110, 'per_min': 15}],
   {'distance': 55, 'fare': 1175, 'time': 8}),
  ('partial repair probe: minimum before booking fee',
   [{'meters': 0, 'seconds': 1374},
    {'base': 0, 'booking_fee': 175, 'minimum': 700, 'per_km': 110, 'per_min': 15}],
   {'distance': 0, 'fare': 875, 'time': 344}),
  ('second regression',
   [{'meters': 500, 'seconds': 30},
    {'base': 0, 'booking_fee': 175, 'minimum': 500, 'per_km': 110, 'per_min': 35}],
   {'distance': 55, 'fare': 675, 'time': 18}),
  ('normal control 1',
   [{'meters': 1004, 'seconds': 61},
    {'base': 0, 'booking_fee': 0, 'minimum': 500, 'per_km': 95, 'per_min': 15}],
   {'distance': 95, 'fare': 500, 'time': 15}),
  ('normal control 2',
   [{'meters': 0, 'seconds': 30},
    {'base': 150, 'booking_fee': 0, 'minimum': 1000, 'per_km': 125, 'per_min': 30}],
   {'distance': 0, 'fare': 1000, 'time': 15}),
  ('normal control 3',
   [{'meters': 12, 'seconds': 61},
    {'base': 150, 'booking_fee': 0, 'minimum': 500, 'per_km': 110, 'per_min': 15}],
   {'distance': 1, 'fare': 500, 'time': 15}),
  ('normal control 4',
   [{'meters': 24766, 'seconds': 30},
    {'base': 250, 'booking_fee': 250, 'minimum': 1000, 'per_km': 250, 'per_min': 30}],
   {'distance': 6192, 'fare': 6707, 'time': 15})],
 [('regression: minimum before booking fee',
   [{'meters': 500, 'seconds': 61},
    {'base': 150, 'booking_fee': 250, 'minimum': 500, 'per_km': 125, 'per_min': 35}],
   {'distance': 63, 'fare': 750, 'time': 36}),
  ('partial repair probe: minimum before booking fee',
   [{'meters': 500, 'seconds': 90},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 110, 'per_min': 35}],
   {'distance': 55, 'fare': 950, 'time': 53}),
  ('second regression',
   [{'meters': 2500, 'seconds': 30},
    {'base': 0, 'booking_fee': 175, 'minimum': 700, 'per_km': 250, 'per_min': 15}],
   {'distance': 625, 'fare': 875, 'time': 8}),
  ('normal control 1',
   [{'meters': 4, 'seconds': 2383},
    {'base': 250, 'booking_fee': 0, 'minimum': 700, 'per_km': 250, 'per_min': 35}],
   {'distance': 1, 'fare': 1641, 'time': 1390}),
  ('normal control 2',
   [{'meters': 0, 'seconds': 1117},
    {'base': 250, 'booking_fee': 250, 'minimum': 700, 'per_km': 125, 'per_min': 30}],
   {'distance': 0, 'fare': 1059, 'time': 559}),
  ('normal control 3',
   [{'meters': 0, 'seconds': 30}, {'base': 0, 'booking_fee': 0, 'minimum': 700, 'per_km': 95, 'per_min': 35}],
   {'distance': 0, 'fare': 700, 'time': 18}),
  ('normal control 4',
   [{'meters': 12, 'seconds': 30},
    {'base': 150, 'booking_fee': 0, 'minimum': 500, 'per_km': 110, 'per_min': 15}],
   {'distance': 1, 'fare': 500, 'time': 8})]]
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(trip, rate):
    def half_up(num, den):
        return (num * 2 + den) // (den * 2)
    dist = half_up(trip['meters'] * rate['per_km'], 1000)
    tm = half_up(trip['seconds'] * rate['per_min'], 60)
    sub = rate['base'] + dist + tm
    fare = max(sub, rate['minimum']) + (rate['booking_fee'] if sub >= rate['minimum'] else 0)
    return {'distance': dist, 'time': tm, 'fare': fare}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: minimum before booking fee',
   [{'meters': 0, 'seconds': 30},
    {'base': 250, 'booking_fee': 250, 'minimum': 1000, 'per_km': 125, 'per_min': 35}],
   {'distance': 0, 'fare': 1250, 'time': 18}),
  ('partial repair probe: minimum before booking fee',
   [{'meters': 4, 'seconds': 30},
    {'base': 150, 'booking_fee': 250, 'minimum': 500, 'per_km': 95, 'per_min': 30}],
   {'distance': 0, 'fare': 750, 'time': 15}),
  ('second regression',
   [{'meters': 0, 'seconds': 30},
    {'base': 0, 'booking_fee': 175, 'minimum': 700, 'per_km': 110, 'per_min': 30}],
   {'distance': 0, 'fare': 875, 'time': 15}),
  ('normal control 1',
   [{'meters': 2500, 'seconds': 30},
    {'base': 250, 'booking_fee': 0, 'minimum': 1000, 'per_km': 125, 'per_min': 15}],
   {'distance': 313, 'fare': 1000, 'time': 8}),
  ('normal control 2',
   [{'meters': 0, 'seconds': 61},
    {'base': 0, 'booking_fee': 0, 'minimum': 700, 'per_km': 125, 'per_min': 15}],
   {'distance': 0, 'fare': 700, 'time': 15}),
  ('normal control 3',
   [{'meters': 500, 'seconds': 0},
    {'base': 0, 'booking_fee': 0, 'minimum': 500, 'per_km': 250, 'per_min': 30}],
   {'distance': 125, 'fare': 500, 'time': 0}),
  ('normal control 4',
   [{'meters': 0, 'seconds': 61},
    {'base': 250, 'booking_fee': 0, 'minimum': 500, 'per_km': 110, 'per_min': 35}],
   {'distance': 0, 'fare': 500, 'time': 36})],
 [('regression: minimum before booking fee',
   [{'meters': 2500, 'seconds': 90},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 125, 'per_min': 15}],
   {'distance': 313, 'fare': 950, 'time': 23}),
  ('partial repair probe: minimum before booking fee',
   [{'meters': 0, 'seconds': 0},
    {'base': 250, 'booking_fee': 175, 'minimum': 1000, 'per_km': 95, 'per_min': 35}],
   {'distance': 0, 'fare': 1175, 'time': 0}),
  ('second regression',
   [{'meters': 0, 'seconds': 90},
    {'base': 250, 'booking_fee': 175, 'minimum': 1000, 'per_km': 110, 'per_min': 30}],
   {'distance': 0, 'fare': 1175, 'time': 45}),
  ('normal control 1',
   [{'meters': 15327, 'seconds': 30},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 125, 'per_min': 30}],
   {'distance': 1916, 'fare': 2181, 'time': 15}),
  ('normal control 2',
   [{'meters': 500, 'seconds': 1882},
    {'base': 0, 'booking_fee': 0, 'minimum': 500, 'per_km': 250, 'per_min': 25}],
   {'distance': 125, 'fare': 909, 'time': 784}),
  ('normal control 3',
   [{'meters': 500, 'seconds': 61},
    {'base': 250, 'booking_fee': 0, 'minimum': 700, 'per_km': 95, 'per_min': 30}],
   {'distance': 48, 'fare': 700, 'time': 31}),
  ('normal control 4',
   [{'meters': 500, 'seconds': 0},
    {'base': 250, 'booking_fee': 0, 'minimum': 700, 'per_km': 95, 'per_min': 35}],
   {'distance': 48, 'fare': 700, 'time': 0})],
 [('regression: minimum before booking fee',
   [{'meters': 1004, 'seconds': 0},
    {'base': 0, 'booking_fee': 175, 'minimum': 500, 'per_km': 250, 'per_min': 15}],
   {'distance': 251, 'fare': 675, 'time': 0}),
  ('partial repair probe: minimum before booking fee',
   [{'meters': 4, 'seconds': 0},
    {'base': 150, 'booking_fee': 250, 'minimum': 700, 'per_km': 110, 'per_min': 30}],
   {'distance': 0, 'fare': 950, 'time': 0}),
  ('second regression',
   [{'meters': 12, 'seconds': 90},
    {'base': 250, 'booking_fee': 250, 'minimum': 700, 'per_km': 110, 'per_min': 30}],
   {'distance': 1, 'fare': 950, 'time': 45}),
  ('normal control 1',
   [{'meters': 0, 'seconds': 61},
    {'base': 250, 'booking_fee': 0, 'minimum': 500, 'per_km': 110, 'per_min': 15}],
   {'distance': 0, 'fare': 500, 'time': 15}),
  ('normal control 2',
   [{'meters': 6354, 'seconds': 30},
    {'base': 0, 'booking_fee': 0, 'minimum': 500, 'per_km': 110, 'per_min': 35}],
   {'distance': 699, 'fare': 717, 'time': 18}),
  ('normal control 3',
   [{'meters': 4, 'seconds': 61},
    {'base': 250, 'booking_fee': 0, 'minimum': 500, 'per_km': 95, 'per_min': 35}],
   {'distance': 0, 'fare': 500, 'time': 36}),
  ('normal control 4',
   [{'meters': 23665, 'seconds': 30},
    {'base': 0, 'booking_fee': 175, 'minimum': 500, 'per_km': 110, 'per_min': 15}],
   {'distance': 2603, 'fare': 2786, 'time': 8})],
 [('regression: minimum before booking fee',
   [{'meters': 500, 'seconds': 30},
    {'base': 150, 'booking_fee': 175, 'minimum': 1000, 'per_km': 110, 'per_min': 15}],
   {'distance': 55, 'fare': 1175, 'time': 8}),
  ('partial repair probe: minimum before booking fee',
   [{'meters': 0, 'seconds': 1374},
    {'base': 0, 'booking_fee': 175, 'minimum': 700, 'per_km': 110, 'per_min': 15}],
   {'distance': 0, 'fare': 875, 'time': 344}),
  ('second regression',
   [{'meters': 500, 'seconds': 30},
    {'base': 0, 'booking_fee': 175, 'minimum': 500, 'per_km': 110, 'per_min': 35}],
   {'distance': 55, 'fare': 675, 'time': 18}),
  ('normal control 1',
   [{'meters': 1004, 'seconds': 61},
    {'base': 0, 'booking_fee': 0, 'minimum': 500, 'per_km': 95, 'per_min': 15}],
   {'distance': 95, 'fare': 500, 'time': 15}),
  ('normal control 2',
   [{'meters': 0, 'seconds': 30},
    {'base': 150, 'booking_fee': 0, 'minimum': 1000, 'per_km': 125, 'per_min': 30}],
   {'distance': 0, 'fare': 1000, 'time': 15}),
  ('normal control 3',
   [{'meters': 12, 'seconds': 61},
    {'base': 150, 'booking_fee': 0, 'minimum': 500, 'per_km': 110, 'per_min': 15}],
   {'distance': 1, 'fare': 500, 'time': 15}),
  ('normal control 4',
   [{'meters': 24766, 'seconds': 30},
    {'base': 250, 'booking_fee': 250, 'minimum': 1000, 'per_km': 250, 'per_min': 30}],
   {'distance': 6192, 'fare': 6707, 'time': 15})],
 [('regression: minimum before booking fee',
   [{'meters': 500, 'seconds': 61},
    {'base': 150, 'booking_fee': 250, 'minimum': 500, 'per_km': 125, 'per_min': 35}],
   {'distance': 63, 'fare': 750, 'time': 36}),
  ('partial repair probe: minimum before booking fee',
   [{'meters': 500, 'seconds': 90},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 110, 'per_min': 35}],
   {'distance': 55, 'fare': 950, 'time': 53}),
  ('second regression',
   [{'meters': 2500, 'seconds': 30},
    {'base': 0, 'booking_fee': 175, 'minimum': 700, 'per_km': 250, 'per_min': 15}],
   {'distance': 625, 'fare': 875, 'time': 8}),
  ('normal control 1',
   [{'meters': 4, 'seconds': 2383},
    {'base': 250, 'booking_fee': 0, 'minimum': 700, 'per_km': 250, 'per_min': 35}],
   {'distance': 1, 'fare': 1641, 'time': 1390}),
  ('normal control 2',
   [{'meters': 0, 'seconds': 1117},
    {'base': 250, 'booking_fee': 250, 'minimum': 700, 'per_km': 125, 'per_min': 30}],
   {'distance': 0, 'fare': 1059, 'time': 559}),
  ('normal control 3',
   [{'meters': 0, 'seconds': 30}, {'base': 0, 'booking_fee': 0, 'minimum': 700, 'per_km': 95, 'per_min': 35}],
   {'distance': 0, 'fare': 700, 'time': 18}),
  ('normal control 4',
   [{'meters': 12, 'seconds': 30},
    {'base': 150, 'booking_fee': 0, 'minimum': 500, 'per_km': 110, 'per_min': 15}],
   {'distance': 1, 'fare': 500, 'time': 8})]]
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:
Short trips charged exactly the minimum fare, missing the booking fee.

All money is integer cents. Distance charge = meters x per_km / 1000 and time charge = seconds x per_min / 60, each rounded half up to a cent on its own. Subtotal = base + distance + time. The minimum fare applies to that subtotal only; the booking fee is added after the minimum. Return the distance charge, time charge and fare.

split: open-access


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

N = 1
observations = []
def solve(trip, rate):
    def half_up(num, den):
        return (num * 2 + den) // (den * 2)
    dist = trip['meters'] * rate['per_km'] // 1000
    tm = half_up(trip['seconds'] * rate['per_min'], 60)
    sub = rate['base'] + dist + tm
    fare = max(sub, rate['minimum']) + rate['booking_fee']
    return {'distance': dist, 'time': tm, 'fare': fare}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: distance cent rounding',
   [{'meters': 13218, 'seconds': 30},
    {'base': 150, 'booking_fee': 0, 'minimum': 1000, 'per_km': 250, 'per_min': 25}],
   {'distance': 3305, 'fare': 3468, 'time': 13}),
  ('partial repair probe: distance cent rounding',
   [{'meters': 2500, 'seconds': 0},
    {'base': 150, 'booking_fee': 175, 'minimum': 700, 'per_km': 125, 'per_min': 35}],
   {'distance': 313, 'fare': 875, 'time': 0}),
  ('second regression',
   [{'meters': 5073, 'seconds': 440},
    {'base': 250, 'booking_fee': 175, 'minimum': 500, 'per_km': 95, 'per_min': 30}],
   {'distance': 482, 'fare': 1127, 'time': 220}),
  ('normal control 1',
   [{'meters': 12, 'seconds': 0},
    {'base': 250, 'booking_fee': 0, 'minimum': 1000, 'per_km': 250, 'per_min': 30}],
   {'distance': 3, 'fare': 1000, 'time': 0}),
  ('normal control 2',
   [{'meters': 1004, 'seconds': 1448},
    {'base': 0, 'booking_fee': 250, 'minimum': 1000, 'per_km': 250, 'per_min': 35}],
   {'distance': 251, 'fare': 1346, 'time': 845}),
  ('normal control 3',
   [{'meters': 4, 'seconds': 1514},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 250, 'per_min': 25}],
   {'distance': 1, 'fare': 950, 'time': 631}),
  ('normal control 4',
   [{'meters': 12, 'seconds': 2021},
    {'base': 250, 'booking_fee': 250, 'minimum': 1000, 'per_km': 110, 'per_min': 15}],
   {'distance': 1, 'fare': 1250, 'time': 505})],
 [('regression: distance cent rounding',
   [{'meters': 23462, 'seconds': 61},
    {'base': 250, 'booking_fee': 0, 'minimum': 1000, 'per_km': 125, 'per_min': 35}],
   {'distance': 2933, 'fare': 3219, 'time': 36}),
  ('partial repair probe: distance cent rounding',
   [{'meters': 2500, 'seconds': 61},
    {'base': 250, 'booking_fee': 0, 'minimum': 500, 'per_km': 125, 'per_min': 25}],
   {'distance': 313, 'fare': 588, 'time': 25}),
  ('second regression',
   [{'meters': 1004, 'seconds': 30},
    {'base': 150, 'booking_fee': 175, 'minimum': 500, 'per_km': 125, 'per_min': 35}],
   {'distance': 126, 'fare': 675, 'time': 18}),
  ('normal control 1',
   [{'meters': 1004, 'seconds': 61},
    {'base': 0, 'booking_fee': 175, 'minimum': 700, 'per_km': 95, 'per_min': 30}],
   {'distance': 95, 'fare': 875, 'time': 31}),
  ('normal control 2',
   [{'meters': 12, 'seconds': 61},
    {'base': 250, 'booking_fee': 175, 'minimum': 500, 'per_km': 95, 'per_min': 25}],
   {'distance': 1, 'fare': 675, 'time': 25}),
  ('normal control 3',
   [{'meters': 9283, 'seconds': 2669},
    {'base': 250, 'booking_fee': 0, 'minimum': 700, 'per_km': 125, 'per_min': 25}],
   {'distance': 1160, 'fare': 2522, 'time': 1112}),
  ('normal control 4',
   [{'meters': 4, 'seconds': 1599},
    {'base': 0, 'booking_fee': 0, 'minimum': 1000, 'per_km': 95, 'per_min': 35}],
   {'distance': 0, 'fare': 1000, 'time': 933})],
 [('regression: distance cent rounding',
   [{'meters': 2500, 'seconds': 30},
    {'base': 150, 'booking_fee': 175, 'minimum': 500, 'per_km': 125, 'per_min': 35}],
   {'distance': 313, 'fare': 675, 'time': 18}),
  ('partial repair probe: distance cent rounding',
   [{'meters': 4, 'seconds': 30},
    {'base': 250, 'booking_fee': 175, 'minimum': 500, 'per_km': 125, 'per_min': 25}],
   {'distance': 1, 'fare': 675, 'time': 13}),
  ('second regression',
   [{'meters': 16236, 'seconds': 0},
    {'base': 150, 'booking_fee': 0, 'minimum': 1000, 'per_km': 125, 'per_min': 15}],
   {'distance': 2030, 'fare': 2180, 'time': 0}),
  ('normal control 1',
   [{'meters': 0, 'seconds': 90},
    {'base': 150, 'booking_fee': 175, 'minimum': 700, 'per_km': 95, 'per_min': 25}],
   {'distance': 0, 'fare': 875, 'time': 38}),
  ('normal control 2',
   [{'meters': 4, 'seconds': 30},
    {'base': 150, 'booking_fee': 175, 'minimum': 1000, 'per_km': 95, 'per_min': 35}],
   {'distance': 0, 'fare': 1175, 'time': 18}),
  ('normal control 3',
   [{'meters': 12, 'seconds': 30},
    {'base': 150, 'booking_fee': 0, 'minimum': 500, 'per_km': 110, 'per_min': 35}],
   {'distance': 1, 'fare': 500, 'time': 18}),
  ('normal control 4',
   [{'meters': 1004, 'seconds': 90},
    {'base': 150, 'booking_fee': 0, 'minimum': 500, 'per_km': 110, 'per_min': 15}],
   {'distance': 110, 'fare': 500, 'time': 23})],
 [('regression: distance cent rounding',
   [{'meters': 2500, 'seconds': 90},
    {'base': 150, 'booking_fee': 250, 'minimum': 1000, 'per_km': 125, 'per_min': 25}],
   {'distance': 313, 'fare': 1250, 'time': 38}),
  ('partial repair probe: distance cent rounding',
   [{'meters': 13716, 'seconds': 61},
    {'base': 0, 'booking_fee': 250, 'minimum': 500, 'per_km': 125, 'per_min': 30}],
   {'distance': 1715, 'fare': 1996, 'time': 31}),
  ('second regression',
   [{'meters': 12, 'seconds': 0},
    {'base': 150, 'booking_fee': 0, 'minimum': 700, 'per_km': 125, 'per_min': 30}],
   {'distance': 2, 'fare': 700, 'time': 0}),
  ('normal control 1',
   [{'meters': 12, 'seconds': 1415},
    {'base': 150, 'booking_fee': 175, 'minimum': 500, 'per_km': 110, 'per_min': 15}],
   {'distance': 1, 'fare': 680, 'time': 354}),
  ('normal control 2',
   [{'meters': 500, 'seconds': 30},
    {'base': 150, 'booking_fee': 250, 'minimum': 700, 'per_km': 110, 'per_min': 30}],
   {'distance': 55, 'fare': 950, 'time': 15}),
  ('normal control 3',
   [{'meters': 12, 'seconds': 90},
    {'base': 150, 'booking_fee': 175, 'minimum': 1000, 'per_km': 110, 'per_min': 35}],
   {'distance': 1, 'fare': 1175, 'time': 53}),
  ('normal control 4',
   [{'meters': 17013, 'seconds': 61},
    {'base': 250, 'booking_fee': 175, 'minimum': 1000, 'per_km': 110, 'per_min': 25}],
   {'distance': 1871, 'fare': 2321, 'time': 25})],
 [('regression: distance cent rounding',
   [{'meters': 500, 'seconds': 1926},
    {'base': 250, 'booking_fee': 0, 'minimum': 700, 'per_km': 125, 'per_min': 30}],
   {'distance': 63, 'fare': 1276, 'time': 963}),
  ('partial repair probe: distance cent rounding',
   [{'meters': 4, 'seconds': 90},
    {'base': 0, 'booking_fee': 0, 'minimum': 700, 'per_km': 125, 'per_min': 25}],
   {'distance': 1, 'fare': 700, 'time': 38}),
  ('second regression',
   [{'meters': 11469, 'seconds': 811},
    {'base': 0, 'booking_fee': 250, 'minimum': 1000, 'per_km': 125, 'per_min': 30}],
   {'distance': 1434, 'fare': 2090, 'time': 406}),
  ('normal control 1',
   [{'meters': 12570, 'seconds': 61},
    {'base': 0, 'booking_fee': 0, 'minimum': 500, 'per_km': 125, 'per_min': 15}],
   {'distance': 1571, 'fare': 1586, 'time': 15}),
  ('normal control 2',
   [{'meters': 1004, 'seconds': 90},
    {'base': 250, 'booking_fee': 175, 'minimum': 700, 'per_km': 250, 'per_min': 30}],
   {'distance': 251, 'fare': 875, 'time': 45}),
  ('normal control 3',
   [{'meters': 0, 'seconds': 2350},
    {'base': 150, 'booking_fee': 0, 'minimum': 700, 'per_km': 125, 'per_min': 25}],
   {'distance': 0, 'fare': 1129, 'time': 979}),
  ('normal control 4',
   [{'meters': 1004, 'seconds': 0},
    {'base': 250, 'booking_fee': 250, 'minimum': 700, 'per_km': 95, 'per_min': 25}],
   {'distance': 95, 'fare': 950, 'time': 0})]]
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(trip, rate):
    def half_up(num, den):
        return (num * 2 + den) // (den * 2)
    dist = round(trip['meters'] * rate['per_km'] / 1000)
    tm = half_up(trip['seconds'] * rate['per_min'], 60)
    sub = rate['base'] + dist + tm
    fare = max(sub, rate['minimum']) + rate['booking_fee']
    return {'distance': dist, 'time': tm, 'fare': fare}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: distance cent rounding',
   [{'meters': 13218, 'seconds': 30},
    {'base': 150, 'booking_fee': 0, 'minimum': 1000, 'per_km': 250, 'per_min': 25}],
   {'distance': 3305, 'fare': 3468, 'time': 13}),
  ('partial repair probe: distance cent rounding',
   [{'meters': 2500, 'seconds': 0},
    {'base': 150, 'booking_fee': 175, 'minimum': 700, 'per_km': 125, 'per_min': 35}],
   {'distance': 313, 'fare': 875, 'time': 0}),
  ('second regression',
   [{'meters': 5073, 'seconds': 440},
    {'base': 250, 'booking_fee': 175, 'minimum': 500, 'per_km': 95, 'per_min': 30}],
   {'distance': 482, 'fare': 1127, 'time': 220}),
  ('normal control 1',
   [{'meters': 12, 'seconds': 0},
    {'base': 250, 'booking_fee': 0, 'minimum': 1000, 'per_km': 250, 'per_min': 30}],
   {'distance': 3, 'fare': 1000, 'time': 0}),
  ('normal control 2',
   [{'meters': 1004, 'seconds': 1448},
    {'base': 0, 'booking_fee': 250, 'minimum': 1000, 'per_km': 250, 'per_min': 35}],
   {'distance': 251, 'fare': 1346, 'time': 845}),
  ('normal control 3',
   [{'meters': 4, 'seconds': 1514},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 250, 'per_min': 25}],
   {'distance': 1, 'fare': 950, 'time': 631}),
  ('normal control 4',
   [{'meters': 12, 'seconds': 2021},
    {'base': 250, 'booking_fee': 250, 'minimum': 1000, 'per_km': 110, 'per_min': 15}],
   {'distance': 1, 'fare': 1250, 'time': 505})],
 [('regression: distance cent rounding',
   [{'meters': 23462, 'seconds': 61},
    {'base': 250, 'booking_fee': 0, 'minimum': 1000, 'per_km': 125, 'per_min': 35}],
   {'distance': 2933, 'fare': 3219, 'time': 36}),
  ('partial repair probe: distance cent rounding',
   [{'meters': 2500, 'seconds': 61},
    {'base': 250, 'booking_fee': 0, 'minimum': 500, 'per_km': 125, 'per_min': 25}],
   {'distance': 313, 'fare': 588, 'time': 25}),
  ('second regression',
   [{'meters': 1004, 'seconds': 30},
    {'base': 150, 'booking_fee': 175, 'minimum': 500, 'per_km': 125, 'per_min': 35}],
   {'distance': 126, 'fare': 675, 'time': 18}),
  ('normal control 1',
   [{'meters': 1004, 'seconds': 61},
    {'base': 0, 'booking_fee': 175, 'minimum': 700, 'per_km': 95, 'per_min': 30}],
   {'distance': 95, 'fare': 875, 'time': 31}),
  ('normal control 2',
   [{'meters': 12, 'seconds': 61},
    {'base': 250, 'booking_fee': 175, 'minimum': 500, 'per_km': 95, 'per_min': 25}],
   {'distance': 1, 'fare': 675, 'time': 25}),
  ('normal control 3',
   [{'meters': 9283, 'seconds': 2669},
    {'base': 250, 'booking_fee': 0, 'minimum': 700, 'per_km': 125, 'per_min': 25}],
   {'distance': 1160, 'fare': 2522, 'time': 1112}),
  ('normal control 4',
   [{'meters': 4, 'seconds': 1599},
    {'base': 0, 'booking_fee': 0, 'minimum': 1000, 'per_km': 95, 'per_min': 35}],
   {'distance': 0, 'fare': 1000, 'time': 933})],
 [('regression: distance cent rounding',
   [{'meters': 2500, 'seconds': 30},
    {'base': 150, 'booking_fee': 175, 'minimum': 500, 'per_km': 125, 'per_min': 35}],
   {'distance': 313, 'fare': 675, 'time': 18}),
  ('partial repair probe: distance cent rounding',
   [{'meters': 4, 'seconds': 30},
    {'base': 250, 'booking_fee': 175, 'minimum': 500, 'per_km': 125, 'per_min': 25}],
   {'distance': 1, 'fare': 675, 'time': 13}),
  ('second regression',
   [{'meters': 16236, 'seconds': 0},
    {'base': 150, 'booking_fee': 0, 'minimum': 1000, 'per_km': 125, 'per_min': 15}],
   {'distance': 2030, 'fare': 2180, 'time': 0}),
  ('normal control 1',
   [{'meters': 0, 'seconds': 90},
    {'base': 150, 'booking_fee': 175, 'minimum': 700, 'per_km': 95, 'per_min': 25}],
   {'distance': 0, 'fare': 875, 'time': 38}),
  ('normal control 2',
   [{'meters': 4, 'seconds': 30},
    {'base': 150, 'booking_fee': 175, 'minimum': 1000, 'per_km': 95, 'per_min': 35}],
   {'distance': 0, 'fare': 1175, 'time': 18}),
  ('normal control 3',
   [{'meters': 12, 'seconds': 30},
    {'base': 150, 'booking_fee': 0, 'minimum': 500, 'per_km': 110, 'per_min': 35}],
   {'distance': 1, 'fare': 500, 'time': 18}),
  ('normal control 4',
   [{'meters': 1004, 'seconds': 90},
    {'base': 150, 'booking_fee': 0, 'minimum': 500, 'per_km': 110, 'per_min': 15}],
   {'distance': 110, 'fare': 500, 'time': 23})],
 [('regression: distance cent rounding',
   [{'meters': 2500, 'seconds': 90},
    {'base': 150, 'booking_fee': 250, 'minimum': 1000, 'per_km': 125, 'per_min': 25}],
   {'distance': 313, 'fare': 1250, 'time': 38}),
  ('partial repair probe: distance cent rounding',
   [{'meters': 13716, 'seconds': 61},
    {'base': 0, 'booking_fee': 250, 'minimum': 500, 'per_km': 125, 'per_min': 30}],
   {'distance': 1715, 'fare': 1996, 'time': 31}),
  ('second regression',
   [{'meters': 12, 'seconds': 0},
    {'base': 150, 'booking_fee': 0, 'minimum': 700, 'per_km': 125, 'per_min': 30}],
   {'distance': 2, 'fare': 700, 'time': 0}),
  ('normal control 1',
   [{'meters': 12, 'seconds': 1415},
    {'base': 150, 'booking_fee': 175, 'minimum': 500, 'per_km': 110, 'per_min': 15}],
   {'distance': 1, 'fare': 680, 'time': 354}),
  ('normal control 2',
   [{'meters': 500, 'seconds': 30},
    {'base': 150, 'booking_fee': 250, 'minimum': 700, 'per_km': 110, 'per_min': 30}],
   {'distance': 55, 'fare': 950, 'time': 15}),
  ('normal control 3',
   [{'meters': 12, 'seconds': 90},
    {'base': 150, 'booking_fee': 175, 'minimum': 1000, 'per_km': 110, 'per_min': 35}],
   {'distance': 1, 'fare': 1175, 'time': 53}),
  ('normal control 4',
   [{'meters': 17013, 'seconds': 61},
    {'base': 250, 'booking_fee': 175, 'minimum': 1000, 'per_km': 110, 'per_min': 25}],
   {'distance': 1871, 'fare': 2321, 'time': 25})],
 [('regression: distance cent rounding',
   [{'meters': 500, 'seconds': 1926},
    {'base': 250, 'booking_fee': 0, 'minimum': 700, 'per_km': 125, 'per_min': 30}],
   {'distance': 63, 'fare': 1276, 'time': 963}),
  ('partial repair probe: distance cent rounding',
   [{'meters': 4, 'seconds': 90},
    {'base': 0, 'booking_fee': 0, 'minimum': 700, 'per_km': 125, 'per_min': 25}],
   {'distance': 1, 'fare': 700, 'time': 38}),
  ('second regression',
   [{'meters': 11469, 'seconds': 811},
    {'base': 0, 'booking_fee': 250, 'minimum': 1000, 'per_km': 125, 'per_min': 30}],
   {'distance': 1434, 'fare': 2090, 'time': 406}),
  ('normal control 1',
   [{'meters': 12570, 'seconds': 61},
    {'base': 0, 'booking_fee': 0, 'minimum': 500, 'per_km': 125, 'per_min': 15}],
   {'distance': 1571, 'fare': 1586, 'time': 15}),
  ('normal control 2',
   [{'meters': 1004, 'seconds': 90},
    {'base': 250, 'booking_fee': 175, 'minimum': 700, 'per_km': 250, 'per_min': 30}],
   {'distance': 251, 'fare': 875, 'time': 45}),
  ('normal control 3',
   [{'meters': 0, 'seconds': 2350},
    {'base': 150, 'booking_fee': 0, 'minimum': 700, 'per_km': 125, 'per_min': 25}],
   {'distance': 0, 'fare': 1129, 'time': 979}),
  ('normal control 4',
   [{'meters': 1004, 'seconds': 0},
    {'base': 250, 'booking_fee': 250, 'minimum': 700, 'per_km': 95, 'per_min': 25}],
   {'distance': 95, 'fare': 950, 'time': 0})]]
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:
Distance charges ending in half a cent or more lose a cent.

All money is integer cents. Distance charge = meters x per_km / 1000 and time charge = seconds x per_min / 60, each rounded half up to a cent on its own. Subtotal = base + distance + time. The minimum fare applies to that subtotal only; the booking fee is added after the minimum. Return the distance charge, time charge and fare.

split: open-access


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

N = 1
observations = []
def solve(trip, rate):
    def half_up(num, den):
        return (num * 2 + den) // (den * 2)
    dist = half_up(trip['meters'] * rate['per_km'], 1000)
    tm = half_up(trip['seconds'] * rate['per_min'], 3600)
    sub = rate['base'] + dist + tm
    fare = max(sub, rate['minimum']) + rate['booking_fee']
    return {'distance': dist, 'time': tm, 'fare': fare}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: per-minute proration',
   [{'meters': 500, 'seconds': 61},
    {'base': 0, 'booking_fee': 0, 'minimum': 500, 'per_km': 250, 'per_min': 30}],
   {'distance': 125, 'fare': 500, 'time': 31}),
  ('partial repair probe: per-minute proration',
   [{'meters': 12, 'seconds': 1229},
    {'base': 0, 'booking_fee': 250, 'minimum': 1000, 'per_km': 125, 'per_min': 15}],
   {'distance': 2, 'fare': 1250, 'time': 307}),
  ('second regression',
   [{'meters': 0, 'seconds': 2352},
    {'base': 150, 'booking_fee': 250, 'minimum': 1000, 'per_km': 110, 'per_min': 25}],
   {'distance': 0, 'fare': 1380, 'time': 980}),
  ('normal control 1',
   [{'meters': 0, 'seconds': 0},
    {'base': 250, 'booking_fee': 250, 'minimum': 500, 'per_km': 110, 'per_min': 30}],
   {'distance': 0, 'fare': 750, 'time': 0}),
  ('normal control 2',
   [{'meters': 15062, 'seconds': 0},
    {'base': 0, 'booking_fee': 0, 'minimum': 500, 'per_km': 125, 'per_min': 30}],
   {'distance': 1883, 'fare': 1883, 'time': 0}),
  ('normal control 3',
   [{'meters': 12, 'seconds': 0},
    {'base': 0, 'booking_fee': 175, 'minimum': 1000, 'per_km': 250, 'per_min': 15}],
   {'distance': 3, 'fare': 1175, 'time': 0}),
  ('normal control 4',
   [{'meters': 500, 'seconds': 0},
    {'base': 150, 'booking_fee': 175, 'minimum': 1000, 'per_km': 125, 'per_min': 30}],
   {'distance': 63, 'fare': 1175, 'time': 0})],
 [('regression: per-minute proration',
   [{'meters': 500, 'seconds': 61},
    {'base': 0, 'booking_fee': 0, 'minimum': 1000, 'per_km': 250, 'per_min': 30}],
   {'distance': 125, 'fare': 1000, 'time': 31}),
  ('partial repair probe: per-minute proration',
   [{'meters': 12, 'seconds': 826},
    {'base': 250, 'booking_fee': 0, 'minimum': 1000, 'per_km': 95, 'per_min': 35}],
   {'distance': 1, 'fare': 1000, 'time': 482}),
  ('second regression',
   [{'meters': 1004, 'seconds': 90},
    {'base': 0, 'booking_fee': 175, 'minimum': 1000, 'per_km': 125, 'per_min': 25}],
   {'distance': 126, 'fare': 1175, 'time': 38}),
  ('normal control 1',
   [{'meters': 500, 'seconds': 0},
    {'base': 0, 'booking_fee': 250, 'minimum': 500, 'per_km': 250, 'per_min': 30}],
   {'distance': 125, 'fare': 750, 'time': 0}),
  ('normal control 2',
   [{'meters': 18143, 'seconds': 0},
    {'base': 250, 'booking_fee': 0, 'minimum': 1000, 'per_km': 125, 'per_min': 15}],
   {'distance': 2268, 'fare': 2518, 'time': 0}),
  ('normal control 3',
   [{'meters': 12, 'seconds': 0},
    {'base': 0, 'booking_fee': 175, 'minimum': 1000, 'per_km': 110, 'per_min': 35}],
   {'distance': 1, 'fare': 1175, 'time': 0}),
  ('normal control 4',
   [{'meters': 2500, 'seconds': 0},
    {'base': 250, 'booking_fee': 250, 'minimum': 500, 'per_km': 95, 'per_min': 15}],
   {'distance': 238, 'fare': 750, 'time': 0})],
 [('regression: per-minute proration',
   [{'meters': 12, 'seconds': 61},
    {'base': 250, 'booking_fee': 175, 'minimum': 500, 'per_km': 110, 'per_min': 15}],
   {'distance': 1, 'fare': 675, 'time': 15}),
  ('partial repair probe: per-minute proration',
   [{'meters': 500, 'seconds': 90},
    {'base': 150, 'booking_fee': 175, 'minimum': 500, 'per_km': 125, 'per_min': 30}],
   {'distance': 63, 'fare': 675, 'time': 45}),
  ('second regression',
   [{'meters': 0, 'seconds': 30},
    {'base': 150, 'booking_fee': 250, 'minimum': 500, 'per_km': 95, 'per_min': 25}],
   {'distance': 0, 'fare': 750, 'time': 13}),
  ('normal control 1',
   [{'meters': 0, 'seconds': 0},
    {'base': 0, 'booking_fee': 175, 'minimum': 500, 'per_km': 250, 'per_min': 15}],
   {'distance': 0, 'fare': 675, 'time': 0}),
  ('normal control 2',
   [{'meters': 4, 'seconds': 0},
    {'base': 0, 'booking_fee': 175, 'minimum': 1000, 'per_km': 250, 'per_min': 15}],
   {'distance': 1, 'fare': 1175, 'time': 0}),
  ('normal control 3',
   [{'meters': 4, 'seconds': 0},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 250, 'per_min': 15}],
   {'distance': 1, 'fare': 950, 'time': 0}),
  ('normal control 4',
   [{'meters': 4, 'seconds': 0},
    {'base': 250, 'booking_fee': 175, 'minimum': 700, 'per_km': 250, 'per_min': 30}],
   {'distance': 1, 'fare': 875, 'time': 0})],
 [('regression: per-minute proration',
   [{'meters': 3247, 'seconds': 2905},
    {'base': 250, 'booking_fee': 0, 'minimum': 500, 'per_km': 110, 'per_min': 25}],
   {'distance': 357, 'fare': 1817, 'time': 1210}),
  ('partial repair probe: per-minute proration',
   [{'meters': 16003, 'seconds': 1892},
    {'base': 250, 'booking_fee': 250, 'minimum': 700, 'per_km': 250, 'per_min': 25}],
   {'distance': 4001, 'fare': 5289, 'time': 788}),
  ('second regression',
   [{'meters': 3374, 'seconds': 61},
    {'base': 250, 'booking_fee': 250, 'minimum': 700, 'per_km': 125, 'per_min': 25}],
   {'distance': 422, 'fare': 950, 'time': 25}),
  ('normal control 1',
   [{'meters': 500, 'seconds': 0},
    {'base': 250, 'booking_fee': 175, 'minimum': 1000, 'per_km': 125, 'per_min': 25}],
   {'distance': 63, 'fare': 1175, 'time': 0}),
  ('normal control 2',
   [{'meters': 4, 'seconds': 0},
    {'base': 150, 'booking_fee': 175, 'minimum': 700, 'per_km': 125, 'per_min': 25}],
   {'distance': 1, 'fare': 875, 'time': 0}),
  ('normal control 3',
   [{'meters': 1004, 'seconds': 0},
    {'base': 250, 'booking_fee': 250, 'minimum': 700, 'per_km': 250, 'per_min': 30}],
   {'distance': 251, 'fare': 950, 'time': 0}),
  ('normal control 4',
   [{'meters': 2500, 'seconds': 0},
    {'base': 250, 'booking_fee': 250, 'minimum': 700, 'per_km': 110, 'per_min': 35}],
   {'distance': 275, 'fare': 950, 'time': 0})],
 [('regression: per-minute proration',
   [{'meters': 4, 'seconds': 30},
    {'base': 150, 'booking_fee': 175, 'minimum': 500, 'per_km': 110, 'per_min': 15}],
   {'distance': 0, 'fare': 675, 'time': 8}),
  ('partial repair probe: per-minute proration',
   [{'meters': 1004, 'seconds': 30},
    {'base': 0, 'booking_fee': 0, 'minimum': 700, 'per_km': 95, 'per_min': 30}],
   {'distance': 95, 'fare': 700, 'time': 15}),
  ('second regression',
   [{'meters': 500, 'seconds': 1245},
    {'base': 250, 'booking_fee': 175, 'minimum': 1000, 'per_km': 110, 'per_min': 30}],
   {'distance': 55, 'fare': 1175, 'time': 623}),
  ('normal control 1',
   [{'meters': 2500, 'seconds': 0},
    {'base': 250, 'booking_fee': 175, 'minimum': 700, 'per_km': 250, 'per_min': 30}],
   {'distance': 625, 'fare': 1050, 'time': 0}),
  ('normal control 2',
   [{'meters': 20828, 'seconds': 0},
    {'base': 250, 'booking_fee': 0, 'minimum': 700, 'per_km': 125, 'per_min': 25}],
   {'distance': 2604, 'fare': 2854, 'time': 0}),
  ('normal control 3',
   [{'meters': 0, 'seconds': 0},
    {'base': 0, 'booking_fee': 175, 'minimum': 700, 'per_km': 250, 'per_min': 25}],
   {'distance': 0, 'fare': 875, 'time': 0}),
  ('normal control 4',
   [{'meters': 2500, 'seconds': 0},
    {'base': 150, 'booking_fee': 250, 'minimum': 1000, 'per_km': 250, 'per_min': 15}],
   {'distance': 625, 'fare': 1250, 'time': 0})]]
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(trip, rate):
    def half_up(num, den):
        return (num * 2 + den) // (den * 2)
    dist = half_up(trip['meters'] * rate['per_km'], 1000)
    tm = -(-trip['seconds'] // 60) * rate['per_min']
    sub = rate['base'] + dist + tm
    fare = max(sub, rate['minimum']) + rate['booking_fee']
    return {'distance': dist, 'time': tm, 'fare': fare}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: per-minute proration',
   [{'meters': 500, 'seconds': 61},
    {'base': 0, 'booking_fee': 0, 'minimum': 500, 'per_km': 250, 'per_min': 30}],
   {'distance': 125, 'fare': 500, 'time': 31}),
  ('partial repair probe: per-minute proration',
   [{'meters': 12, 'seconds': 1229},
    {'base': 0, 'booking_fee': 250, 'minimum': 1000, 'per_km': 125, 'per_min': 15}],
   {'distance': 2, 'fare': 1250, 'time': 307}),
  ('second regression',
   [{'meters': 0, 'seconds': 2352},
    {'base': 150, 'booking_fee': 250, 'minimum': 1000, 'per_km': 110, 'per_min': 25}],
   {'distance': 0, 'fare': 1380, 'time': 980}),
  ('normal control 1',
   [{'meters': 0, 'seconds': 0},
    {'base': 250, 'booking_fee': 250, 'minimum': 500, 'per_km': 110, 'per_min': 30}],
   {'distance': 0, 'fare': 750, 'time': 0}),
  ('normal control 2',
   [{'meters': 15062, 'seconds': 0},
    {'base': 0, 'booking_fee': 0, 'minimum': 500, 'per_km': 125, 'per_min': 30}],
   {'distance': 1883, 'fare': 1883, 'time': 0}),
  ('normal control 3',
   [{'meters': 12, 'seconds': 0},
    {'base': 0, 'booking_fee': 175, 'minimum': 1000, 'per_km': 250, 'per_min': 15}],
   {'distance': 3, 'fare': 1175, 'time': 0}),
  ('normal control 4',
   [{'meters': 500, 'seconds': 0},
    {'base': 150, 'booking_fee': 175, 'minimum': 1000, 'per_km': 125, 'per_min': 30}],
   {'distance': 63, 'fare': 1175, 'time': 0})],
 [('regression: per-minute proration',
   [{'meters': 500, 'seconds': 61},
    {'base': 0, 'booking_fee': 0, 'minimum': 1000, 'per_km': 250, 'per_min': 30}],
   {'distance': 125, 'fare': 1000, 'time': 31}),
  ('partial repair probe: per-minute proration',
   [{'meters': 12, 'seconds': 826},
    {'base': 250, 'booking_fee': 0, 'minimum': 1000, 'per_km': 95, 'per_min': 35}],
   {'distance': 1, 'fare': 1000, 'time': 482}),
  ('second regression',
   [{'meters': 1004, 'seconds': 90},
    {'base': 0, 'booking_fee': 175, 'minimum': 1000, 'per_km': 125, 'per_min': 25}],
   {'distance': 126, 'fare': 1175, 'time': 38}),
  ('normal control 1',
   [{'meters': 500, 'seconds': 0},
    {'base': 0, 'booking_fee': 250, 'minimum': 500, 'per_km': 250, 'per_min': 30}],
   {'distance': 125, 'fare': 750, 'time': 0}),
  ('normal control 2',
   [{'meters': 18143, 'seconds': 0},
    {'base': 250, 'booking_fee': 0, 'minimum': 1000, 'per_km': 125, 'per_min': 15}],
   {'distance': 2268, 'fare': 2518, 'time': 0}),
  ('normal control 3',
   [{'meters': 12, 'seconds': 0},
    {'base': 0, 'booking_fee': 175, 'minimum': 1000, 'per_km': 110, 'per_min': 35}],
   {'distance': 1, 'fare': 1175, 'time': 0}),
  ('normal control 4',
   [{'meters': 2500, 'seconds': 0},
    {'base': 250, 'booking_fee': 250, 'minimum': 500, 'per_km': 95, 'per_min': 15}],
   {'distance': 238, 'fare': 750, 'time': 0})],
 [('regression: per-minute proration',
   [{'meters': 12, 'seconds': 61},
    {'base': 250, 'booking_fee': 175, 'minimum': 500, 'per_km': 110, 'per_min': 15}],
   {'distance': 1, 'fare': 675, 'time': 15}),
  ('partial repair probe: per-minute proration',
   [{'meters': 500, 'seconds': 90},
    {'base': 150, 'booking_fee': 175, 'minimum': 500, 'per_km': 125, 'per_min': 30}],
   {'distance': 63, 'fare': 675, 'time': 45}),
  ('second regression',
   [{'meters': 0, 'seconds': 30},
    {'base': 150, 'booking_fee': 250, 'minimum': 500, 'per_km': 95, 'per_min': 25}],
   {'distance': 0, 'fare': 750, 'time': 13}),
  ('normal control 1',
   [{'meters': 0, 'seconds': 0},
    {'base': 0, 'booking_fee': 175, 'minimum': 500, 'per_km': 250, 'per_min': 15}],
   {'distance': 0, 'fare': 675, 'time': 0}),
  ('normal control 2',
   [{'meters': 4, 'seconds': 0},
    {'base': 0, 'booking_fee': 175, 'minimum': 1000, 'per_km': 250, 'per_min': 15}],
   {'distance': 1, 'fare': 1175, 'time': 0}),
  ('normal control 3',
   [{'meters': 4, 'seconds': 0},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 250, 'per_min': 15}],
   {'distance': 1, 'fare': 950, 'time': 0}),
  ('normal control 4',
   [{'meters': 4, 'seconds': 0},
    {'base': 250, 'booking_fee': 175, 'minimum': 700, 'per_km': 250, 'per_min': 30}],
   {'distance': 1, 'fare': 875, 'time': 0})],
 [('regression: per-minute proration',
   [{'meters': 3247, 'seconds': 2905},
    {'base': 250, 'booking_fee': 0, 'minimum': 500, 'per_km': 110, 'per_min': 25}],
   {'distance': 357, 'fare': 1817, 'time': 1210}),
  ('partial repair probe: per-minute proration',
   [{'meters': 16003, 'seconds': 1892},
    {'base': 250, 'booking_fee': 250, 'minimum': 700, 'per_km': 250, 'per_min': 25}],
   {'distance': 4001, 'fare': 5289, 'time': 788}),
  ('second regression',
   [{'meters': 3374, 'seconds': 61},
    {'base': 250, 'booking_fee': 250, 'minimum': 700, 'per_km': 125, 'per_min': 25}],
   {'distance': 422, 'fare': 950, 'time': 25}),
  ('normal control 1',
   [{'meters': 500, 'seconds': 0},
    {'base': 250, 'booking_fee': 175, 'minimum': 1000, 'per_km': 125, 'per_min': 25}],
   {'distance': 63, 'fare': 1175, 'time': 0}),
  ('normal control 2',
   [{'meters': 4, 'seconds': 0},
    {'base': 150, 'booking_fee': 175, 'minimum': 700, 'per_km': 125, 'per_min': 25}],
   {'distance': 1, 'fare': 875, 'time': 0}),
  ('normal control 3',
   [{'meters': 1004, 'seconds': 0},
    {'base': 250, 'booking_fee': 250, 'minimum': 700, 'per_km': 250, 'per_min': 30}],
   {'distance': 251, 'fare': 950, 'time': 0}),
  ('normal control 4',
   [{'meters': 2500, 'seconds': 0},
    {'base': 250, 'booking_fee': 250, 'minimum': 700, 'per_km': 110, 'per_min': 35}],
   {'distance': 275, 'fare': 950, 'time': 0})],
 [('regression: per-minute proration',
   [{'meters': 4, 'seconds': 30},
    {'base': 150, 'booking_fee': 175, 'minimum': 500, 'per_km': 110, 'per_min': 15}],
   {'distance': 0, 'fare': 675, 'time': 8}),
  ('partial repair probe: per-minute proration',
   [{'meters': 1004, 'seconds': 30},
    {'base': 0, 'booking_fee': 0, 'minimum': 700, 'per_km': 95, 'per_min': 30}],
   {'distance': 95, 'fare': 700, 'time': 15}),
  ('second regression',
   [{'meters': 500, 'seconds': 1245},
    {'base': 250, 'booking_fee': 175, 'minimum': 1000, 'per_km': 110, 'per_min': 30}],
   {'distance': 55, 'fare': 1175, 'time': 623}),
  ('normal control 1',
   [{'meters': 2500, 'seconds': 0},
    {'base': 250, 'booking_fee': 175, 'minimum': 700, 'per_km': 250, 'per_min': 30}],
   {'distance': 625, 'fare': 1050, 'time': 0}),
  ('normal control 2',
   [{'meters': 20828, 'seconds': 0},
    {'base': 250, 'booking_fee': 0, 'minimum': 700, 'per_km': 125, 'per_min': 25}],
   {'distance': 2604, 'fare': 2854, 'time': 0}),
  ('normal control 3',
   [{'meters': 0, 'seconds': 0},
    {'base': 0, 'booking_fee': 175, 'minimum': 700, 'per_km': 250, 'per_min': 25}],
   {'distance': 0, 'fare': 875, 'time': 0}),
  ('normal control 4',
   [{'meters': 2500, 'seconds': 0},
    {'base': 150, 'booking_fee': 250, 'minimum': 1000, 'per_km': 250, 'per_min': 15}],
   {'distance': 625, 'fare': 1250, 'time': 0})]]
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:
Time charges come out 60 times too small.

All money is integer cents. Distance charge = meters x per_km / 1000 and time charge = seconds x per_min / 60, each rounded half up to a cent on its own. Subtotal = base + distance + time. The minimum fare applies to that subtotal only; the booking fee is added after the minimum. Return the distance charge, time charge and fare.

split: open-access


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

N = 1
observations = []
def solve(trip, rate):
    def half_up(num, den):
        return (num * 2 + den) // (den * 2)
    dist = half_up(trip['meters'] * rate['per_km'], 1000)
    tm = half_up(trip['seconds'] * rate['per_min'], 60)
    sub = dist + tm
    fare = max(sub, rate['minimum']) + rate['base'] + rate['booking_fee']
    return {'distance': dist, 'time': tm, 'fare': fare}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: base inside minimum',
   [{'meters': 4, 'seconds': 1629},
    {'base': 250, 'booking_fee': 250, 'minimum': 1000, 'per_km': 95, 'per_min': 25}],
   {'distance': 0, 'fare': 1250, 'time': 679}),
  ('partial repair probe: base inside minimum',
   [{'meters': 2500, 'seconds': 0},
    {'base': 150, 'booking_fee': 250, 'minimum': 700, 'per_km': 95, 'per_min': 30}],
   {'distance': 238, 'fare': 950, 'time': 0}),
  ('second regression',
   [{'meters': 0, 'seconds': 61},
    {'base': 150, 'booking_fee': 250, 'minimum': 500, 'per_km': 250, 'per_min': 35}],
   {'distance': 0, 'fare': 750, 'time': 36}),
  ('normal control 1',
   [{'meters': 14115, 'seconds': 90},
    {'base': 250, 'booking_fee': 0, 'minimum': 1000, 'per_km': 125, 'per_min': 30}],
   {'distance': 1764, 'fare': 2059, 'time': 45}),
  ('normal control 2',
   [{'meters': 500, 'seconds': 121},
    {'base': 0, 'booking_fee': 0, 'minimum': 700, 'per_km': 250, 'per_min': 35}],
   {'distance': 125, 'fare': 700, 'time': 71}),
  ('normal control 3',
   [{'meters': 0, 'seconds': 61},
    {'base': 0, 'booking_fee': 0, 'minimum': 1000, 'per_km': 250, 'per_min': 35}],
   {'distance': 0, 'fare': 1000, 'time': 36}),
  ('normal control 4',
   [{'meters': 6825, 'seconds': 61},
    {'base': 250, 'booking_fee': 250, 'minimum': 1000, 'per_km': 250, 'per_min': 30}],
   {'distance': 1706, 'fare': 2237, 'time': 31})],
 [('regression: base inside minimum',
   [{'meters': 4, 'seconds': 61},
    {'base': 250, 'booking_fee': 250, 'minimum': 500, 'per_km': 95, 'per_min': 35}],
   {'distance': 0, 'fare': 750, 'time': 36}),
  ('partial repair probe: base inside minimum',
   [{'meters': 0, 'seconds': 61},
    {'base': 150, 'booking_fee': 175, 'minimum': 1000, 'per_km': 110, 'per_min': 35}],
   {'distance': 0, 'fare': 1175, 'time': 36}),
  ('second regression',
   [{'meters': 4, 'seconds': 0},
    {'base': 150, 'booking_fee': 250, 'minimum': 700, 'per_km': 125, 'per_min': 35}],
   {'distance': 1, 'fare': 950, 'time': 0}),
  ('normal control 1',
   [{'meters': 21815, 'seconds': 61},
    {'base': 250, 'booking_fee': 0, 'minimum': 1000, 'per_km': 125, 'per_min': 25}],
   {'distance': 2727, 'fare': 3002, 'time': 25}),
  ('normal control 2',
   [{'meters': 500, 'seconds': 0},
    {'base': 0, 'booking_fee': 0, 'minimum': 500, 'per_km': 250, 'per_min': 25}],
   {'distance': 125, 'fare': 500, 'time': 0}),
  ('normal control 3',
   [{'meters': 0, 'seconds': 90},
    {'base': 0, 'booking_fee': 250, 'minimum': 500, 'per_km': 110, 'per_min': 30}],
   {'distance': 0, 'fare': 750, 'time': 45}),
  ('normal control 4',
   [{'meters': 12, 'seconds': 90},
    {'base': 0, 'booking_fee': 175, 'minimum': 700, 'per_km': 250, 'per_min': 30}],
   {'distance': 3, 'fare': 875, 'time': 45})],
 [('regression: base inside minimum',
   [{'meters': 0, 'seconds': 90},
    {'base': 150, 'booking_fee': 250, 'minimum': 500, 'per_km': 110, 'per_min': 25}],
   {'distance': 0, 'fare': 750, 'time': 38}),
  ('partial repair probe: base inside minimum',
   [{'meters': 4, 'seconds': 61},
    {'base': 250, 'booking_fee': 0, 'minimum': 700, 'per_km': 110, 'per_min': 30}],
   {'distance': 0, 'fare': 700, 'time': 31}),
  ('second regression',
   [{'meters': 12, 'seconds': 214},
    {'base': 250, 'booking_fee': 175, 'minimum': 700, 'per_km': 95, 'per_min': 25}],
   {'distance': 1, 'fare': 875, 'time': 89}),
  ('normal control 1',
   [{'meters': 0, 'seconds': 30},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 110, 'per_min': 15}],
   {'distance': 0, 'fare': 950, 'time': 8}),
  ('normal control 2',
   [{'meters': 11380, 'seconds': 30},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 250, 'per_min': 35}],
   {'distance': 2845, 'fare': 3113, 'time': 18}),
  ('normal control 3',
   [{'meters': 14883, 'seconds': 245},
    {'base': 150, 'booking_fee': 175, 'minimum': 500, 'per_km': 125, 'per_min': 30}],
   {'distance': 1860, 'fare': 2308, 'time': 123}),
  ('normal control 4',
   [{'meters': 17188, 'seconds': 0},
    {'base': 250, 'booking_fee': 250, 'minimum': 500, 'per_km': 95, 'per_min': 35}],
   {'distance': 1633, 'fare': 2133, 'time': 0})],
 [('regression: base inside minimum',
   [{'meters': 4, 'seconds': 61},
    {'base': 250, 'booking_fee': 175, 'minimum': 1000, 'per_km': 95, 'per_min': 30}],
   {'distance': 0, 'fare': 1175, 'time': 31}),
  ('partial repair probe: base inside minimum',
   [{'meters': 0, 'seconds': 30},
    {'base': 250, 'booking_fee': 250, 'minimum': 700, 'per_km': 95, 'per_min': 25}],
   {'distance': 0, 'fare': 950, 'time': 13}),
  ('second regression',
   [{'meters': 1004, 'seconds': 90},
    {'base': 150, 'booking_fee': 0, 'minimum': 500, 'per_km': 110, 'per_min': 25}],
   {'distance': 110, 'fare': 500, 'time': 38}),
  ('normal control 1',
   [{'meters': 500, 'seconds': 30},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 125, 'per_min': 15}],
   {'distance': 63, 'fare': 950, 'time': 8}),
  ('normal control 2',
   [{'meters': 12, 'seconds': 0}, {'base': 0, 'booking_fee': 0, 'minimum': 700, 'per_km': 95, 'per_min': 15}],
   {'distance': 1, 'fare': 700, 'time': 0}),
  ('normal control 3',
   [{'meters': 4, 'seconds': 0},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 250, 'per_min': 35}],
   {'distance': 1, 'fare': 950, 'time': 0}),
  ('normal control 4',
   [{'meters': 2500, 'seconds': 0},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 250, 'per_min': 35}],
   {'distance': 625, 'fare': 950, 'time': 0})],
 [('regression: base inside minimum',
   [{'meters': 500, 'seconds': 30},
    {'base': 250, 'booking_fee': 250, 'minimum': 1000, 'per_km': 110, 'per_min': 30}],
   {'distance': 55, 'fare': 1250, 'time': 15}),
  ('partial repair probe: base inside minimum',
   [{'meters': 2500, 'seconds': 30},
    {'base': 250, 'booking_fee': 0, 'minimum': 500, 'per_km': 125, 'per_min': 25}],
   {'distance': 313, 'fare': 576, 'time': 13}),
  ('second regression',
   [{'meters': 500, 'seconds': 61},
    {'base': 250, 'booking_fee': 175, 'minimum': 700, 'per_km': 250, 'per_min': 15}],
   {'distance': 125, 'fare': 875, 'time': 15}),
  ('normal control 1',
   [{'meters': 500, 'seconds': 1622},
    {'base': 250, 'booking_fee': 175, 'minimum': 500, 'per_km': 250, 'per_min': 15}],
   {'distance': 125, 'fare': 956, 'time': 406}),
  ('normal control 2',
   [{'meters': 500, 'seconds': 90},
    {'base': 0, 'booking_fee': 250, 'minimum': 500, 'per_km': 95, 'per_min': 15}],
   {'distance': 48, 'fare': 750, 'time': 23}),
  ('normal control 3',
   [{'meters': 15947, 'seconds': 61},
    {'base': 250, 'booking_fee': 0, 'minimum': 700, 'per_km': 125, 'per_min': 15}],
   {'distance': 1993, 'fare': 2258, 'time': 15}),
  ('normal control 4',
   [{'meters': 2500, 'seconds': 2303},
    {'base': 150, 'booking_fee': 250, 'minimum': 1000, 'per_km': 125, 'per_min': 25}],
   {'distance': 313, 'fare': 1673, 'time': 960})]]
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(trip, rate):
    def half_up(num, den):
        return (num * 2 + den) // (den * 2)
    dist = half_up(trip['meters'] * rate['per_km'], 1000)
    tm = half_up(trip['seconds'] * rate['per_min'], 60)
    sub = rate['base'] + dist + tm
    fare = max(sub, rate['minimum'] + rate['base']) + rate['booking_fee']
    return {'distance': dist, 'time': tm, 'fare': fare}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: base inside minimum',
   [{'meters': 4, 'seconds': 1629},
    {'base': 250, 'booking_fee': 250, 'minimum': 1000, 'per_km': 95, 'per_min': 25}],
   {'distance': 0, 'fare': 1250, 'time': 679}),
  ('partial repair probe: base inside minimum',
   [{'meters': 2500, 'seconds': 0},
    {'base': 150, 'booking_fee': 250, 'minimum': 700, 'per_km': 95, 'per_min': 30}],
   {'distance': 238, 'fare': 950, 'time': 0}),
  ('second regression',
   [{'meters': 0, 'seconds': 61},
    {'base': 150, 'booking_fee': 250, 'minimum': 500, 'per_km': 250, 'per_min': 35}],
   {'distance': 0, 'fare': 750, 'time': 36}),
  ('normal control 1',
   [{'meters': 14115, 'seconds': 90},
    {'base': 250, 'booking_fee': 0, 'minimum': 1000, 'per_km': 125, 'per_min': 30}],
   {'distance': 1764, 'fare': 2059, 'time': 45}),
  ('normal control 2',
   [{'meters': 500, 'seconds': 121},
    {'base': 0, 'booking_fee': 0, 'minimum': 700, 'per_km': 250, 'per_min': 35}],
   {'distance': 125, 'fare': 700, 'time': 71}),
  ('normal control 3',
   [{'meters': 0, 'seconds': 61},
    {'base': 0, 'booking_fee': 0, 'minimum': 1000, 'per_km': 250, 'per_min': 35}],
   {'distance': 0, 'fare': 1000, 'time': 36}),
  ('normal control 4',
   [{'meters': 6825, 'seconds': 61},
    {'base': 250, 'booking_fee': 250, 'minimum': 1000, 'per_km': 250, 'per_min': 30}],
   {'distance': 1706, 'fare': 2237, 'time': 31})],
 [('regression: base inside minimum',
   [{'meters': 4, 'seconds': 61},
    {'base': 250, 'booking_fee': 250, 'minimum': 500, 'per_km': 95, 'per_min': 35}],
   {'distance': 0, 'fare': 750, 'time': 36}),
  ('partial repair probe: base inside minimum',
   [{'meters': 0, 'seconds': 61},
    {'base': 150, 'booking_fee': 175, 'minimum': 1000, 'per_km': 110, 'per_min': 35}],
   {'distance': 0, 'fare': 1175, 'time': 36}),
  ('second regression',
   [{'meters': 4, 'seconds': 0},
    {'base': 150, 'booking_fee': 250, 'minimum': 700, 'per_km': 125, 'per_min': 35}],
   {'distance': 1, 'fare': 950, 'time': 0}),
  ('normal control 1',
   [{'meters': 21815, 'seconds': 61},
    {'base': 250, 'booking_fee': 0, 'minimum': 1000, 'per_km': 125, 'per_min': 25}],
   {'distance': 2727, 'fare': 3002, 'time': 25}),
  ('normal control 2',
   [{'meters': 500, 'seconds': 0},
    {'base': 0, 'booking_fee': 0, 'minimum': 500, 'per_km': 250, 'per_min': 25}],
   {'distance': 125, 'fare': 500, 'time': 0}),
  ('normal control 3',
   [{'meters': 0, 'seconds': 90},
    {'base': 0, 'booking_fee': 250, 'minimum': 500, 'per_km': 110, 'per_min': 30}],
   {'distance': 0, 'fare': 750, 'time': 45}),
  ('normal control 4',
   [{'meters': 12, 'seconds': 90},
    {'base': 0, 'booking_fee': 175, 'minimum': 700, 'per_km': 250, 'per_min': 30}],
   {'distance': 3, 'fare': 875, 'time': 45})],
 [('regression: base inside minimum',
   [{'meters': 0, 'seconds': 90},
    {'base': 150, 'booking_fee': 250, 'minimum': 500, 'per_km': 110, 'per_min': 25}],
   {'distance': 0, 'fare': 750, 'time': 38}),
  ('partial repair probe: base inside minimum',
   [{'meters': 4, 'seconds': 61},
    {'base': 250, 'booking_fee': 0, 'minimum': 700, 'per_km': 110, 'per_min': 30}],
   {'distance': 0, 'fare': 700, 'time': 31}),
  ('second regression',
   [{'meters': 12, 'seconds': 214},
    {'base': 250, 'booking_fee': 175, 'minimum': 700, 'per_km': 95, 'per_min': 25}],
   {'distance': 1, 'fare': 875, 'time': 89}),
  ('normal control 1',
   [{'meters': 0, 'seconds': 30},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 110, 'per_min': 15}],
   {'distance': 0, 'fare': 950, 'time': 8}),
  ('normal control 2',
   [{'meters': 11380, 'seconds': 30},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 250, 'per_min': 35}],
   {'distance': 2845, 'fare': 3113, 'time': 18}),
  ('normal control 3',
   [{'meters': 14883, 'seconds': 245},
    {'base': 150, 'booking_fee': 175, 'minimum': 500, 'per_km': 125, 'per_min': 30}],
   {'distance': 1860, 'fare': 2308, 'time': 123}),
  ('normal control 4',
   [{'meters': 17188, 'seconds': 0},
    {'base': 250, 'booking_fee': 250, 'minimum': 500, 'per_km': 95, 'per_min': 35}],
   {'distance': 1633, 'fare': 2133, 'time': 0})],
 [('regression: base inside minimum',
   [{'meters': 4, 'seconds': 61},
    {'base': 250, 'booking_fee': 175, 'minimum': 1000, 'per_km': 95, 'per_min': 30}],
   {'distance': 0, 'fare': 1175, 'time': 31}),
  ('partial repair probe: base inside minimum',
   [{'meters': 0, 'seconds': 30},
    {'base': 250, 'booking_fee': 250, 'minimum': 700, 'per_km': 95, 'per_min': 25}],
   {'distance': 0, 'fare': 950, 'time': 13}),
  ('second regression',
   [{'meters': 1004, 'seconds': 90},
    {'base': 150, 'booking_fee': 0, 'minimum': 500, 'per_km': 110, 'per_min': 25}],
   {'distance': 110, 'fare': 500, 'time': 38}),
  ('normal control 1',
   [{'meters': 500, 'seconds': 30},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 125, 'per_min': 15}],
   {'distance': 63, 'fare': 950, 'time': 8}),
  ('normal control 2',
   [{'meters': 12, 'seconds': 0}, {'base': 0, 'booking_fee': 0, 'minimum': 700, 'per_km': 95, 'per_min': 15}],
   {'distance': 1, 'fare': 700, 'time': 0}),
  ('normal control 3',
   [{'meters': 4, 'seconds': 0},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 250, 'per_min': 35}],
   {'distance': 1, 'fare': 950, 'time': 0}),
  ('normal control 4',
   [{'meters': 2500, 'seconds': 0},
    {'base': 0, 'booking_fee': 250, 'minimum': 700, 'per_km': 250, 'per_min': 35}],
   {'distance': 625, 'fare': 950, 'time': 0})],
 [('regression: base inside minimum',
   [{'meters': 500, 'seconds': 30},
    {'base': 250, 'booking_fee': 250, 'minimum': 1000, 'per_km': 110, 'per_min': 30}],
   {'distance': 55, 'fare': 1250, 'time': 15}),
  ('partial repair probe: base inside minimum',
   [{'meters': 2500, 'seconds': 30},
    {'base': 250, 'booking_fee': 0, 'minimum': 500, 'per_km': 125, 'per_min': 25}],
   {'distance': 313, 'fare': 576, 'time': 13}),
  ('second regression',
   [{'meters': 500, 'seconds': 61},
    {'base': 250, 'booking_fee': 175, 'minimum': 700, 'per_km': 250, 'per_min': 15}],
   {'distance': 125, 'fare': 875, 'time': 15}),
  ('normal control 1',
   [{'meters': 500, 'seconds': 1622},
    {'base': 250, 'booking_fee': 175, 'minimum': 500, 'per_km': 250, 'per_min': 15}],
   {'distance': 125, 'fare': 956, 'time': 406}),
  ('normal control 2',
   [{'meters': 500, 'seconds': 90},
    {'base': 0, 'booking_fee': 250, 'minimum': 500, 'per_km': 95, 'per_min': 15}],
   {'distance': 48, 'fare': 750, 'time': 23}),
  ('normal control 3',
   [{'meters': 15947, 'seconds': 61},
    {'base': 250, 'booking_fee': 0, 'minimum': 700, 'per_km': 125, 'per_min': 15}],
   {'distance': 1993, 'fare': 2258, 'time': 15}),
  ('normal control 4',
   [{'meters': 2500, 'seconds': 2303},
    {'base': 150, 'booking_fee': 250, 'minimum': 1000, 'per_km': 125, 'per_min': 25}],
   {'distance': 313, 'fare': 1673, 'time': 960})]]
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 minimum-fare trip is charged the minimum plus the base fare.

All money is integer cents. Distance charge = meters x per_km / 1000 and time charge = seconds x per_min / 60, each rounded half up to a cent on its own. Subtotal = base + distance + time. The minimum fare applies to that subtotal only; the booking fee is added after the minimum. Return the distance charge, time charge and fare.

split: open-access


prompt:
Surge creeps up slowly during a demand spike and collapses instantly afterwards.

Each interval gives [open requests, idle drivers]. The raw multiplier (tenths) is 30 when the exact ratio requests/drivers >= 3, 20 when >= 2, 15 when >= 1.5, 12 when >= 1.2, else 10; with zero drivers it is 30 if any request is open, else 10. The published multiplier rises immediately to the raw value but falls by at most 2 tenths per interval, starting from prev. Return the published multiplier per interval.

split: open-access


prompt:
A quiet zone with no drivers and no riders publishes 3.0x.

Each interval gives [open requests, idle drivers]. The raw multiplier (tenths) is 30 when the exact ratio requests/drivers >= 3, 20 when >= 2, 15 when >= 1.5, 12 when >= 1.2, else 10; with zero drivers it is 30 if any request is open, else 10. The published multiplier rises immediately to the raw value but falls by at most 2 tenths per interval, starting from prev. Return the published multiplier per interval.

split: open-access


prompt:
Exactly 20 requests for 10 drivers publishes 1.5x instead of 2.0x.

Each interval gives [open requests, idle drivers]. The raw multiplier (tenths) is 30 when the exact ratio requests/drivers >= 3, 20 when >= 2, 15 when >= 1.5, 12 when >= 1.2, else 10; with zero drivers it is 30 if any request is open, else 10. The published multiplier rises immediately to the raw value but falls by at most 2 tenths per interval, starting from prev. Return the published multiplier per interval.

split: open-access


prompt:
A 1.9 ratio is treated as 1.0 and no surge is published.

Each interval gives [open requests, idle drivers]. The raw multiplier (tenths) is 30 when the exact ratio requests/drivers >= 3, 20 when >= 2, 15 when >= 1.5, 12 when >= 1.2, else 10; with zero drivers it is 30 if any request is open, else 10. The published multiplier rises immediately to the raw value but falls by at most 2 tenths per interval, starting from prev. Return the published multiplier per interval.

split: open-access