broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(spell):
    whole, _, part = spell['overs'].partition('.')
    balls = int(whole) * 6 + int(part or 0)
    wk = list(spell['wickets'])
    pts = 25 * len(wk)
    pts += 8 * sum(1 for d in wk if d in ('bowled', 'lbw'))
    if len(wk) >= 5:
        pts += 16
    elif len(wk) >= 4:
        pts += 8
    elif len(wk) >= 3:
        pts += 4
    pts += 12 * spell['maidens']
    if balls >= 12:
        econ = Fraction(spell['runs'] * 6, balls)
        if econ < 5:
            pts += 6
        elif econ < 6:
            pts += 4
        elif econ <= 7:
            pts += 2
        elif econ < 10:
            pass
        elif econ <= 11:
            pts -= 2
        elif econ <= 12:
            pts -= 4
        else:
            pts -= 6
    return {'balls': balls, 'points': pts}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: run-out credit', [{'maidens': 1, 'overs': '1.5', 'runs': 11, 'wickets': ['run out', 'lbw']}],
   {'balls': 11, 'points': 45}),
  ('partial repair probe: run-out credit',
   [{'maidens': 0, 'overs': '0.4', 'runs': 9, 'wickets': ['caught', 'run out', 'stumped', 'lbw']}],
   {'balls': 4, 'points': 87}),
  ('second regression', [{'maidens': 0, 'overs': '0.4', 'runs': 4, 'wickets': ['stumped']}],
   {'balls': 4, 'points': 25}),
  ('normal control 1',
   [{'maidens': 1, 'overs': '1.5', 'runs': 12, 'wickets': ['bowled', 'bowled', 'caught', 'bowled']}],
   {'balls': 11, 'points': 144}),
  ('normal control 2', [{'maidens': 1, 'overs': '2', 'runs': 24, 'wickets': []}], {'balls': 12, 'points': 8}),
  ('normal control 3',
   [{'maidens': 1, 'overs': '2.0', 'runs': 12, 'wickets': ['caught', 'bowled', 'caught']}],
   {'balls': 12, 'points': 101}),
  ('normal control 4', [{'maidens': 0, 'overs': '0.4', 'runs': 8, 'wickets': []}],
   {'balls': 4, 'points': 0})],
 [('regression: run-out credit', [{'maidens': 0, 'overs': '1.5', 'runs': 20, 'wickets': ['run out']}],
   {'balls': 11, 'points': 0}),
  ('partial repair probe: run-out credit',
   [{'maidens': 1, 'overs': '2.0', 'runs': 9, 'wickets': ['stumped', 'lbw', 'stumped', 'caught', 'lbw']}],
   {'balls': 12, 'points': 175}),
  ('second regression',
   [{'maidens': 1, 'overs': '1.5', 'runs': 16, 'wickets': ['lbw', 'stumped', 'lbw', 'stumped', 'lbw']}],
   {'balls': 11, 'points': 177}),
  ('normal control 1', [{'maidens': 1, 'overs': '2.0', 'runs': 14, 'wickets': []}],
   {'balls': 12, 'points': 14}),
  ('normal control 2',
   [{'maidens': 1, 'overs': '1.5', 'runs': 22, 'wickets': ['caught', 'caught', 'caught', 'lbw', 'caught']}],
   {'balls': 11, 'points': 161}),
  ('normal control 3',
   [{'maidens': 0, 'overs': '1.5', 'runs': 22, 'wickets': ['caught', 'caught', 'bowled']}],
   {'balls': 11, 'points': 87}),
  ('normal control 4', [{'maidens': 0, 'overs': '1.5', 'runs': 10, 'wickets': []}],
   {'balls': 11, 'points': 0})],
 [('regression: run-out credit',
   [{'maidens': 0, 'overs': '2', 'runs': 24, 'wickets': ['caught', 'run out', 'run out', 'caught']}],
   {'balls': 12, 'points': 46}),
  ('partial repair probe: run-out credit',
   [{'maidens': 1, 'overs': '2.0', 'runs': 24, 'wickets': ['lbw', 'run out', 'caught', 'lbw', 'stumped']}],
   {'balls': 12, 'points': 132}),
  ('second regression',
   [{'maidens': 1,
     'overs': '2.3',
     'runs': 45,
     'wickets': ['stumped', 'run out', 'bowled', 'run out', 'run out']}],
   {'balls': 15, 'points': 64}),
  ('normal control 1',
   [{'maidens': 1, 'overs': '2.3', 'runs': 17, 'wickets': ['lbw', 'bowled', 'caught', 'bowled', 'caught']}],
   {'balls': 15, 'points': 179}),
  ('normal control 2', [{'maidens': 0, 'overs': '2', 'runs': 12, 'wickets': []}], {'balls': 12, 'points': 2}),
  ('normal control 3', [{'maidens': 0, 'overs': '2.3', 'runs': 8, 'wickets': []}],
   {'balls': 15, 'points': 6}),
  ('normal control 4', [{'maidens': 0, 'overs': '2', 'runs': 34, 'wickets': []}],
   {'balls': 12, 'points': -6})],
 [('regression: run-out credit',
   [{'maidens': 1, 'overs': '2.0', 'runs': 24, 'wickets': ['run out', 'bowled']}],
   {'balls': 12, 'points': 41}),
  ('partial repair probe: run-out credit',
   [{'maidens': 1, 'overs': '4', 'runs': 48, 'wickets': ['stumped', 'caught']}],
   {'balls': 24, 'points': 58}),
  ('second regression',
   [{'maidens': 0, 'overs': '4', 'runs': 58, 'wickets': ['stumped', 'stumped', 'caught', 'lbw']}],
   {'balls': 24, 'points': 110}),
  ('normal control 1',
   [{'maidens': 0, 'overs': '2.0', 'runs': 24, 'wickets': ['lbw', 'caught', 'caught', 'caught', 'lbw']}],
   {'balls': 12, 'points': 153}),
  ('normal control 2', [{'maidens': 0, 'overs': '0.4', 'runs': 8, 'wickets': []}], {'balls': 4, 'points': 0}),
  ('normal control 3',
   [{'maidens': 1, 'overs': '1.6', 'runs': 24, 'wickets': ['lbw', 'lbw', 'bowled', 'caught', 'bowled']}],
   {'balls': 12, 'points': 181}),
  ('normal control 4', [{'maidens': 0, 'overs': '0.4', 'runs': 2, 'wickets': ['caught']}],
   {'balls': 4, 'points': 25})],
 [('regression: run-out credit',
   [{'maidens': 1, 'overs': '2.0', 'runs': 24, 'wickets': ['run out', 'run out', 'bowled']}],
   {'balls': 12, 'points': 41}),
  ('partial repair probe: run-out credit',
   [{'maidens': 0, 'overs': '1.5', 'runs': 12, 'wickets': ['stumped', 'stumped']}],
   {'balls': 11, 'points': 50}),
  ('second regression',
   [{'maidens': 1,
     'overs': '3.4',
     'runs': 47,
     'wickets': ['caught', 'caught', 'run out', 'stumped', 'run out']}],
   {'balls': 22, 'points': 85}),
  ('normal control 1', [{'maidens': 1, 'overs': '2', 'runs': 14, 'wickets': []}],
   {'balls': 12, 'points': 14}),
  ('normal control 2',
   [{'maidens': 1, 'overs': '0.4', 'runs': 6, 'wickets': ['bowled', 'lbw', 'lbw', 'caught']}],
   {'balls': 4, 'points': 144}),
  ('normal control 3', [{'maidens': 1, 'overs': '2.3', 'runs': 30, 'wickets': ['lbw', 'bowled']}],
   {'balls': 15, 'points': 74}),
  ('normal control 4', [{'maidens': 0, 'overs': '2', 'runs': 14, 'wickets': ['caught', 'caught', 'bowled']}],
   {'balls': 12, 'points': 89})]]
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
from fractions import Fraction
N = 1
observations = []
def solve(spell):
    whole, _, part = spell['overs'].partition('.')
    balls = int(whole) * 6 + int(part or 0)
    wk = [d for d in spell['wickets'] if d not in ('run out', 'stumped')]
    pts = 25 * len(wk)
    pts += 8 * sum(1 for d in wk if d in ('bowled', 'lbw'))
    if len(wk) >= 5:
        pts += 16
    elif len(wk) >= 4:
        pts += 8
    elif len(wk) >= 3:
        pts += 4
    pts += 12 * spell['maidens']
    if balls >= 12:
        econ = Fraction(spell['runs'] * 6, balls)
        if econ < 5:
            pts += 6
        elif econ < 6:
            pts += 4
        elif econ <= 7:
            pts += 2
        elif econ < 10:
            pass
        elif econ <= 11:
            pts -= 2
        elif econ <= 12:
            pts -= 4
        else:
            pts -= 6
    return {'balls': balls, 'points': pts}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: run-out credit', [{'maidens': 1, 'overs': '1.5', 'runs': 11, 'wickets': ['run out', 'lbw']}],
   {'balls': 11, 'points': 45}),
  ('partial repair probe: run-out credit',
   [{'maidens': 0, 'overs': '0.4', 'runs': 9, 'wickets': ['caught', 'run out', 'stumped', 'lbw']}],
   {'balls': 4, 'points': 87}),
  ('second regression', [{'maidens': 0, 'overs': '0.4', 'runs': 4, 'wickets': ['stumped']}],
   {'balls': 4, 'points': 25}),
  ('normal control 1',
   [{'maidens': 1, 'overs': '1.5', 'runs': 12, 'wickets': ['bowled', 'bowled', 'caught', 'bowled']}],
   {'balls': 11, 'points': 144}),
  ('normal control 2', [{'maidens': 1, 'overs': '2', 'runs': 24, 'wickets': []}], {'balls': 12, 'points': 8}),
  ('normal control 3',
   [{'maidens': 1, 'overs': '2.0', 'runs': 12, 'wickets': ['caught', 'bowled', 'caught']}],
   {'balls': 12, 'points': 101}),
  ('normal control 4', [{'maidens': 0, 'overs': '0.4', 'runs': 8, 'wickets': []}],
   {'balls': 4, 'points': 0})],
 [('regression: run-out credit', [{'maidens': 0, 'overs': '1.5', 'runs': 20, 'wickets': ['run out']}],
   {'balls': 11, 'points': 0}),
  ('partial repair probe: run-out credit',
   [{'maidens': 1, 'overs': '2.0', 'runs': 9, 'wickets': ['stumped', 'lbw', 'stumped', 'caught', 'lbw']}],
   {'balls': 12, 'points': 175}),
  ('second regression',
   [{'maidens': 1, 'overs': '1.5', 'runs': 16, 'wickets': ['lbw', 'stumped', 'lbw', 'stumped', 'lbw']}],
   {'balls': 11, 'points': 177}),
  ('normal control 1', [{'maidens': 1, 'overs': '2.0', 'runs': 14, 'wickets': []}],
   {'balls': 12, 'points': 14}),
  ('normal control 2',
   [{'maidens': 1, 'overs': '1.5', 'runs': 22, 'wickets': ['caught', 'caught', 'caught', 'lbw', 'caught']}],
   {'balls': 11, 'points': 161}),
  ('normal control 3',
   [{'maidens': 0, 'overs': '1.5', 'runs': 22, 'wickets': ['caught', 'caught', 'bowled']}],
   {'balls': 11, 'points': 87}),
  ('normal control 4', [{'maidens': 0, 'overs': '1.5', 'runs': 10, 'wickets': []}],
   {'balls': 11, 'points': 0})],
 [('regression: run-out credit',
   [{'maidens': 0, 'overs': '2', 'runs': 24, 'wickets': ['caught', 'run out', 'run out', 'caught']}],
   {'balls': 12, 'points': 46}),
  ('partial repair probe: run-out credit',
   [{'maidens': 1, 'overs': '2.0', 'runs': 24, 'wickets': ['lbw', 'run out', 'caught', 'lbw', 'stumped']}],
   {'balls': 12, 'points': 132}),
  ('second regression',
   [{'maidens': 1,
     'overs': '2.3',
     'runs': 45,
     'wickets': ['stumped', 'run out', 'bowled', 'run out', 'run out']}],
   {'balls': 15, 'points': 64}),
  ('normal control 1',
   [{'maidens': 1, 'overs': '2.3', 'runs': 17, 'wickets': ['lbw', 'bowled', 'caught', 'bowled', 'caught']}],
   {'balls': 15, 'points': 179}),
  ('normal control 2', [{'maidens': 0, 'overs': '2', 'runs': 12, 'wickets': []}], {'balls': 12, 'points': 2}),
  ('normal control 3', [{'maidens': 0, 'overs': '2.3', 'runs': 8, 'wickets': []}],
   {'balls': 15, 'points': 6}),
  ('normal control 4', [{'maidens': 0, 'overs': '2', 'runs': 34, 'wickets': []}],
   {'balls': 12, 'points': -6})],
 [('regression: run-out credit',
   [{'maidens': 1, 'overs': '2.0', 'runs': 24, 'wickets': ['run out', 'bowled']}],
   {'balls': 12, 'points': 41}),
  ('partial repair probe: run-out credit',
   [{'maidens': 1, 'overs': '4', 'runs': 48, 'wickets': ['stumped', 'caught']}],
   {'balls': 24, 'points': 58}),
  ('second regression',
   [{'maidens': 0, 'overs': '4', 'runs': 58, 'wickets': ['stumped', 'stumped', 'caught', 'lbw']}],
   {'balls': 24, 'points': 110}),
  ('normal control 1',
   [{'maidens': 0, 'overs': '2.0', 'runs': 24, 'wickets': ['lbw', 'caught', 'caught', 'caught', 'lbw']}],
   {'balls': 12, 'points': 153}),
  ('normal control 2', [{'maidens': 0, 'overs': '0.4', 'runs': 8, 'wickets': []}], {'balls': 4, 'points': 0}),
  ('normal control 3',
   [{'maidens': 1, 'overs': '1.6', 'runs': 24, 'wickets': ['lbw', 'lbw', 'bowled', 'caught', 'bowled']}],
   {'balls': 12, 'points': 181}),
  ('normal control 4', [{'maidens': 0, 'overs': '0.4', 'runs': 2, 'wickets': ['caught']}],
   {'balls': 4, 'points': 25})],
 [('regression: run-out credit',
   [{'maidens': 1, 'overs': '2.0', 'runs': 24, 'wickets': ['run out', 'run out', 'bowled']}],
   {'balls': 12, 'points': 41}),
  ('partial repair probe: run-out credit',
   [{'maidens': 0, 'overs': '1.5', 'runs': 12, 'wickets': ['stumped', 'stumped']}],
   {'balls': 11, 'points': 50}),
  ('second regression',
   [{'maidens': 1,
     'overs': '3.4',
     'runs': 47,
     'wickets': ['caught', 'caught', 'run out', 'stumped', 'run out']}],
   {'balls': 22, 'points': 85}),
  ('normal control 1', [{'maidens': 1, 'overs': '2', 'runs': 14, 'wickets': []}],
   {'balls': 12, 'points': 14}),
  ('normal control 2',
   [{'maidens': 1, 'overs': '0.4', 'runs': 6, 'wickets': ['bowled', 'lbw', 'lbw', 'caught']}],
   {'balls': 4, 'points': 144}),
  ('normal control 3', [{'maidens': 1, 'overs': '2.3', 'runs': 30, 'wickets': ['lbw', 'bowled']}],
   {'balls': 15, 'points': 74}),
  ('normal control 4', [{'maidens': 0, 'overs': '2', 'runs': 14, 'wickets': ['caught', 'caught', 'bowled']}],
   {'balls': 12, 'points': 89})]]
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 bowler earns 25 points for a run out effected by a fielder.

Score a T20 bowling spell. Overs use cricket notation ("3.4" = 3 overs and 4 balls, 6 balls per over). Each wicket credited to the bowler scores 25 (run outs are not credited); bowled and lbw earn +8 each; haul bonus for 3/4/5+ credited wickets is 4/8/16 (highest only); maiden +12. Economy (exact runs per 6 balls) applies from 2 full overs (12 balls): <5 +6, <6 +4, <=7 +2, <10 0, <=11 -2, <=12 -4, else -6.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(spell):
    whole, _, part = spell['overs'].partition('.')
    balls = int(whole) * 6 + int(part or 0)
    wk = [d for d in spell['wickets'] if d != 'run out']
    pts = 25 * len(wk)
    pts += 8 * sum(1 for d in wk if d in ('bowled', 'lbw', 'stumped'))
    if len(wk) >= 5:
        pts += 16
    elif len(wk) >= 4:
        pts += 8
    elif len(wk) >= 3:
        pts += 4
    pts += 12 * spell['maidens']
    if balls >= 12:
        econ = Fraction(spell['runs'] * 6, balls)
        if econ < 5:
            pts += 6
        elif econ < 6:
            pts += 4
        elif econ <= 7:
            pts += 2
        elif econ < 10:
            pass
        elif econ <= 11:
            pts -= 2
        elif econ <= 12:
            pts -= 4
        else:
            pts -= 6
    return {'balls': balls, 'points': pts}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: bowled lbw bonus set',
   [{'maidens': 0, 'overs': '0.4', 'runs': 7, 'wickets': ['caught', 'stumped', 'stumped', 'caught']}],
   {'balls': 4, 'points': 108}),
  ('partial repair probe: bowled lbw bonus set',
   [{'maidens': 0, 'overs': '0.4', 'runs': 4, 'wickets': ['stumped', 'caught', 'bowled', 'lbw']}],
   {'balls': 4, 'points': 124}),
  ('second regression', [{'maidens': 1, 'overs': '2', 'runs': 12, 'wickets': ['stumped']}],
   {'balls': 12, 'points': 39}),
  ('normal control 1', [{'maidens': 0, 'overs': '3.4', 'runs': 27, 'wickets': ['caught', 'caught']}],
   {'balls': 22, 'points': 50}),
  ('normal control 2', [{'maidens': 1, 'overs': '2', 'runs': 24, 'wickets': ['caught']}],
   {'balls': 12, 'points': 33}),
  ('normal control 3', [{'maidens': 0, 'overs': '2', 'runs': 30, 'wickets': []}],
   {'balls': 12, 'points': -6}),
  ('normal control 4', [{'maidens': 0, 'overs': '2', 'runs': 14, 'wickets': []}],
   {'balls': 12, 'points': 2})],
 [('regression: bowled lbw bonus set',
   [{'maidens': 0,
     'overs': '2.0',
     'runs': 0,
     'wickets': ['caught', 'run out', 'bowled', 'stumped', 'caught']}],
   {'balls': 12, 'points': 122}),
  ('partial repair probe: bowled lbw bonus set',
   [{'maidens': 0, 'overs': '2.3', 'runs': 30, 'wickets': ['bowled', 'lbw', 'stumped', 'caught']}],
   {'balls': 15, 'points': 120}),
  ('second regression', [{'maidens': 1, 'overs': '1.5', 'runs': 22, 'wickets': ['run out', 'stumped']}],
   {'balls': 11, 'points': 37}),
  ('normal control 1', [{'maidens': 1, 'overs': '2.3', 'runs': 17, 'wickets': []}],
   {'balls': 15, 'points': 14}),
  ('normal control 2', [{'maidens': 0, 'overs': '2', 'runs': 24, 'wickets': ['bowled']}],
   {'balls': 12, 'points': 29}),
  ('normal control 3', [{'maidens': 0, 'overs': '2', 'runs': 33, 'wickets': []}],
   {'balls': 12, 'points': -6}),
  ('normal control 4', [{'maidens': 1, 'overs': '2.3', 'runs': 21, 'wickets': ['run out']}],
   {'balls': 15, 'points': 12})],
 [('regression: bowled lbw bonus set',
   [{'maidens': 1, 'overs': '2.0', 'runs': 14, 'wickets': ['run out', 'stumped', 'lbw', 'bowled']}],
   {'balls': 12, 'points': 109}),
  ('partial repair probe: bowled lbw bonus set',
   [{'maidens': 1, 'overs': '4', 'runs': 48, 'wickets': ['lbw']}], {'balls': 24, 'points': 41}),
  ('second regression', [{'maidens': 1, 'overs': '2', 'runs': 32, 'wickets': ['stumped']}],
   {'balls': 12, 'points': 31}),
  ('normal control 1', [{'maidens': 1, 'overs': '0.4', 'runs': 8, 'wickets': []}],
   {'balls': 4, 'points': 12}),
  ('normal control 2', [{'maidens': 0, 'overs': '4', 'runs': 28, 'wickets': []}], {'balls': 24, 'points': 2}),
  ('normal control 3', [{'maidens': 0, 'overs': '2.3', 'runs': 17, 'wickets': ['bowled', 'caught']}],
   {'balls': 15, 'points': 60}),
  ('normal control 4', [{'maidens': 1, 'overs': '0.4', 'runs': 4, 'wickets': ['bowled', 'caught']}],
   {'balls': 4, 'points': 70})],
 [('regression: bowled lbw bonus set',
   [{'maidens': 0,
     'overs': '2',
     'runs': 12,
     'wickets': ['run out', 'caught', 'caught', 'caught', 'stumped']}],
   {'balls': 12, 'points': 110}),
  ('partial repair probe: bowled lbw bonus set',
   [{'maidens': 1, 'overs': '2', 'runs': 12, 'wickets': ['caught', 'caught', 'stumped', 'lbw', 'lbw']}],
   {'balls': 12, 'points': 171}),
  ('second regression', [{'maidens': 0, 'overs': '1.6', 'runs': 26, 'wickets': ['lbw', 'stumped']}],
   {'balls': 12, 'points': 52}),
  ('normal control 1', [{'maidens': 0, 'overs': '1.5', 'runs': 11, 'wickets': []}],
   {'balls': 11, 'points': 0}),
  ('normal control 2', [{'maidens': 1, 'overs': '2.3', 'runs': 30, 'wickets': ['caught', 'caught']}],
   {'balls': 15, 'points': 58}),
  ('normal control 3', [{'maidens': 0, 'overs': '2', 'runs': 14, 'wickets': ['caught']}],
   {'balls': 12, 'points': 27}),
  ('normal control 4', [{'maidens': 1, 'overs': '1.6', 'runs': 14, 'wickets': ['caught']}],
   {'balls': 12, 'points': 39})],
 [('regression: bowled lbw bonus set',
   [{'maidens': 1, 'overs': '3.4', 'runs': 25, 'wickets': ['stumped', 'stumped', 'bowled', 'run out']}],
   {'balls': 22, 'points': 101}),
  ('partial repair probe: bowled lbw bonus set',
   [{'maidens': 1, 'overs': '4', 'runs': 13, 'wickets': ['lbw']}], {'balls': 24, 'points': 51}),
  ('second regression', [{'maidens': 0, 'overs': '0.4', 'runs': 9, 'wickets': ['lbw', 'caught']}],
   {'balls': 4, 'points': 58}),
  ('normal control 1', [{'maidens': 1, 'overs': '0.4', 'runs': 4, 'wickets': []}],
   {'balls': 4, 'points': 12}),
  ('normal control 2', [{'maidens': 1, 'overs': '1.6', 'runs': 14, 'wickets': []}],
   {'balls': 12, 'points': 14}),
  ('normal control 3', [{'maidens': 0, 'overs': '2.3', 'runs': 23, 'wickets': ['caught']}],
   {'balls': 15, 'points': 25}),
  ('normal control 4', [{'maidens': 1, 'overs': '1.6', 'runs': 29, 'wickets': []}],
   {'balls': 12, 'points': 6})]]
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
from fractions import Fraction
N = 1
observations = []
def solve(spell):
    whole, _, part = spell['overs'].partition('.')
    balls = int(whole) * 6 + int(part or 0)
    wk = [d for d in spell['wickets'] if d != 'run out']
    pts = 25 * len(wk)
    pts += 8 * sum(1 for d in wk if d == 'bowled')
    if len(wk) >= 5:
        pts += 16
    elif len(wk) >= 4:
        pts += 8
    elif len(wk) >= 3:
        pts += 4
    pts += 12 * spell['maidens']
    if balls >= 12:
        econ = Fraction(spell['runs'] * 6, balls)
        if econ < 5:
            pts += 6
        elif econ < 6:
            pts += 4
        elif econ <= 7:
            pts += 2
        elif econ < 10:
            pass
        elif econ <= 11:
            pts -= 2
        elif econ <= 12:
            pts -= 4
        else:
            pts -= 6
    return {'balls': balls, 'points': pts}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: bowled lbw bonus set',
   [{'maidens': 0, 'overs': '0.4', 'runs': 7, 'wickets': ['caught', 'stumped', 'stumped', 'caught']}],
   {'balls': 4, 'points': 108}),
  ('partial repair probe: bowled lbw bonus set',
   [{'maidens': 0, 'overs': '0.4', 'runs': 4, 'wickets': ['stumped', 'caught', 'bowled', 'lbw']}],
   {'balls': 4, 'points': 124}),
  ('second regression', [{'maidens': 1, 'overs': '2', 'runs': 12, 'wickets': ['stumped']}],
   {'balls': 12, 'points': 39}),
  ('normal control 1', [{'maidens': 0, 'overs': '3.4', 'runs': 27, 'wickets': ['caught', 'caught']}],
   {'balls': 22, 'points': 50}),
  ('normal control 2', [{'maidens': 1, 'overs': '2', 'runs': 24, 'wickets': ['caught']}],
   {'balls': 12, 'points': 33}),
  ('normal control 3', [{'maidens': 0, 'overs': '2', 'runs': 30, 'wickets': []}],
   {'balls': 12, 'points': -6}),
  ('normal control 4', [{'maidens': 0, 'overs': '2', 'runs': 14, 'wickets': []}],
   {'balls': 12, 'points': 2})],
 [('regression: bowled lbw bonus set',
   [{'maidens': 0,
     'overs': '2.0',
     'runs': 0,
     'wickets': ['caught', 'run out', 'bowled', 'stumped', 'caught']}],
   {'balls': 12, 'points': 122}),
  ('partial repair probe: bowled lbw bonus set',
   [{'maidens': 0, 'overs': '2.3', 'runs': 30, 'wickets': ['bowled', 'lbw', 'stumped', 'caught']}],
   {'balls': 15, 'points': 120}),
  ('second regression', [{'maidens': 1, 'overs': '1.5', 'runs': 22, 'wickets': ['run out', 'stumped']}],
   {'balls': 11, 'points': 37}),
  ('normal control 1', [{'maidens': 1, 'overs': '2.3', 'runs': 17, 'wickets': []}],
   {'balls': 15, 'points': 14}),
  ('normal control 2', [{'maidens': 0, 'overs': '2', 'runs': 24, 'wickets': ['bowled']}],
   {'balls': 12, 'points': 29}),
  ('normal control 3', [{'maidens': 0, 'overs': '2', 'runs': 33, 'wickets': []}],
   {'balls': 12, 'points': -6}),
  ('normal control 4', [{'maidens': 1, 'overs': '2.3', 'runs': 21, 'wickets': ['run out']}],
   {'balls': 15, 'points': 12})],
 [('regression: bowled lbw bonus set',
   [{'maidens': 1, 'overs': '2.0', 'runs': 14, 'wickets': ['run out', 'stumped', 'lbw', 'bowled']}],
   {'balls': 12, 'points': 109}),
  ('partial repair probe: bowled lbw bonus set',
   [{'maidens': 1, 'overs': '4', 'runs': 48, 'wickets': ['lbw']}], {'balls': 24, 'points': 41}),
  ('second regression', [{'maidens': 1, 'overs': '2', 'runs': 32, 'wickets': ['stumped']}],
   {'balls': 12, 'points': 31}),
  ('normal control 1', [{'maidens': 1, 'overs': '0.4', 'runs': 8, 'wickets': []}],
   {'balls': 4, 'points': 12}),
  ('normal control 2', [{'maidens': 0, 'overs': '4', 'runs': 28, 'wickets': []}], {'balls': 24, 'points': 2}),
  ('normal control 3', [{'maidens': 0, 'overs': '2.3', 'runs': 17, 'wickets': ['bowled', 'caught']}],
   {'balls': 15, 'points': 60}),
  ('normal control 4', [{'maidens': 1, 'overs': '0.4', 'runs': 4, 'wickets': ['bowled', 'caught']}],
   {'balls': 4, 'points': 70})],
 [('regression: bowled lbw bonus set',
   [{'maidens': 0,
     'overs': '2',
     'runs': 12,
     'wickets': ['run out', 'caught', 'caught', 'caught', 'stumped']}],
   {'balls': 12, 'points': 110}),
  ('partial repair probe: bowled lbw bonus set',
   [{'maidens': 1, 'overs': '2', 'runs': 12, 'wickets': ['caught', 'caught', 'stumped', 'lbw', 'lbw']}],
   {'balls': 12, 'points': 171}),
  ('second regression', [{'maidens': 0, 'overs': '1.6', 'runs': 26, 'wickets': ['lbw', 'stumped']}],
   {'balls': 12, 'points': 52}),
  ('normal control 1', [{'maidens': 0, 'overs': '1.5', 'runs': 11, 'wickets': []}],
   {'balls': 11, 'points': 0}),
  ('normal control 2', [{'maidens': 1, 'overs': '2.3', 'runs': 30, 'wickets': ['caught', 'caught']}],
   {'balls': 15, 'points': 58}),
  ('normal control 3', [{'maidens': 0, 'overs': '2', 'runs': 14, 'wickets': ['caught']}],
   {'balls': 12, 'points': 27}),
  ('normal control 4', [{'maidens': 1, 'overs': '1.6', 'runs': 14, 'wickets': ['caught']}],
   {'balls': 12, 'points': 39})],
 [('regression: bowled lbw bonus set',
   [{'maidens': 1, 'overs': '3.4', 'runs': 25, 'wickets': ['stumped', 'stumped', 'bowled', 'run out']}],
   {'balls': 22, 'points': 101}),
  ('partial repair probe: bowled lbw bonus set',
   [{'maidens': 1, 'overs': '4', 'runs': 13, 'wickets': ['lbw']}], {'balls': 24, 'points': 51}),
  ('second regression', [{'maidens': 0, 'overs': '0.4', 'runs': 9, 'wickets': ['lbw', 'caught']}],
   {'balls': 4, 'points': 58}),
  ('normal control 1', [{'maidens': 1, 'overs': '0.4', 'runs': 4, 'wickets': []}],
   {'balls': 4, 'points': 12}),
  ('normal control 2', [{'maidens': 1, 'overs': '1.6', 'runs': 14, 'wickets': []}],
   {'balls': 12, 'points': 14}),
  ('normal control 3', [{'maidens': 0, 'overs': '2.3', 'runs': 23, 'wickets': ['caught']}],
   {'balls': 15, 'points': 25}),
  ('normal control 4', [{'maidens': 1, 'overs': '1.6', 'runs': 29, 'wickets': []}],
   {'balls': 12, 'points': 6})]]
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:
Spinners collect 8 extra points for every stumping.

Score a T20 bowling spell. Overs use cricket notation ("3.4" = 3 overs and 4 balls, 6 balls per over). Each wicket credited to the bowler scores 25 (run outs are not credited); bowled and lbw earn +8 each; haul bonus for 3/4/5+ credited wickets is 4/8/16 (highest only); maiden +12. Economy (exact runs per 6 balls) applies from 2 full overs (12 balls): <5 +6, <6 +4, <=7 +2, <10 0, <=11 -2, <=12 -4, else -6.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(spell):
    whole, _, part = spell['overs'].partition('.')
    balls = int(whole) * 6 + int(part or 0)
    wk = [d for d in spell['wickets'] if d != 'run out']
    pts = 25 * len(wk)
    pts += 8 * sum(1 for d in wk if d in ('bowled', 'lbw'))
    if len(wk) >= 5:
        pts += 16
    elif len(wk) >= 4:
        pts += 8
    elif len(wk) >= 3:
        pts += 4
    pts += 12 * spell['maidens']
    if balls >= 2:
        econ = Fraction(spell['runs'] * 6, balls)
        if econ < 5:
            pts += 6
        elif econ < 6:
            pts += 4
        elif econ <= 7:
            pts += 2
        elif econ < 10:
            pass
        elif econ <= 11:
            pts -= 2
        elif econ <= 12:
            pts -= 4
        else:
            pts -= 6
    return {'balls': balls, 'points': pts}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: economy minimum overs unit',
   [{'maidens': 1, 'overs': '0.4', 'runs': 4, 'wickets': ['lbw', 'run out']}], {'balls': 4, 'points': 45}),
  ('partial repair probe: economy minimum overs unit',
   [{'maidens': 1, 'overs': '2', 'runs': 24, 'wickets': ['caught', 'caught', 'bowled', 'stumped']}],
   {'balls': 12, 'points': 124}),
  ('second regression', [{'maidens': 1, 'overs': '1.6', 'runs': 14, 'wickets': []}],
   {'balls': 12, 'points': 14}),
  ('normal control 1',
   [{'maidens': 0,
     'overs': '4',
     'runs': 16,
     'wickets': ['caught', 'bowled', 'run out', 'stumped', 'run out']}],
   {'balls': 24, 'points': 93}),
  ('normal control 2', [{'maidens': 0, 'overs': '3.4', 'runs': 44, 'wickets': ['caught', 'caught']}],
   {'balls': 22, 'points': 46}),
  ('normal control 3',
   [{'maidens': 1,
     'overs': '3.4',
     'runs': 25,
     'wickets': ['stumped', 'run out', 'run out', 'caught', 'bowled']}],
   {'balls': 22, 'points': 101}),
  ('normal control 4',
   [{'maidens': 1, 'overs': '4', 'runs': 28, 'wickets': ['bowled', 'caught', 'caught', 'caught']}],
   {'balls': 24, 'points': 130})],
 [('regression: economy minimum overs unit',
   [{'maidens': 0, 'overs': '1.5', 'runs': 22, 'wickets': ['bowled', 'bowled', 'caught']}],
   {'balls': 11, 'points': 95}),
  ('partial repair probe: economy minimum overs unit',
   [{'maidens': 1, 'overs': '2', 'runs': 14, 'wickets': ['run out', 'caught', 'caught', 'stumped']}],
   {'balls': 12, 'points': 93}),
  ('second regression', [{'maidens': 1, 'overs': '1.5', 'runs': 12, 'wickets': ['run out']}],
   {'balls': 11, 'points': 12}),
  ('normal control 1', [{'maidens': 0, 'overs': '3.4', 'runs': 44, 'wickets': ['caught', 'lbw']}],
   {'balls': 22, 'points': 54}),
  ('normal control 2', [{'maidens': 1, 'overs': '4', 'runs': 48, 'wickets': ['lbw']}],
   {'balls': 24, 'points': 41}),
  ('normal control 3',
   [{'maidens': 0, 'overs': '2.3', 'runs': 17, 'wickets': ['run out', 'stumped', 'caught', 'caught']}],
   {'balls': 15, 'points': 81}),
  ('normal control 4', [{'maidens': 0, 'overs': '2.3', 'runs': 30, 'wickets': []}],
   {'balls': 15, 'points': -4})],
 [('regression: economy minimum overs unit',
   [{'maidens': 1, 'overs': '1.5', 'runs': 12, 'wickets': ['run out', 'caught', 'lbw', 'bowled']}],
   {'balls': 11, 'points': 107}),
  ('partial repair probe: economy minimum overs unit',
   [{'maidens': 1, 'overs': '2.0', 'runs': 14, 'wickets': ['run out', 'caught', 'run out', 'run out']}],
   {'balls': 12, 'points': 39}),
  ('second regression', [{'maidens': 1, 'overs': '0.4', 'runs': 0, 'wickets': ['lbw', 'caught']}],
   {'balls': 4, 'points': 70}),
  ('normal control 1', [{'maidens': 0, 'overs': '3.4', 'runs': 44, 'wickets': []}],
   {'balls': 22, 'points': -4}),
  ('normal control 2', [{'maidens': 0, 'overs': '1.5', 'runs': 15, 'wickets': []}],
   {'balls': 11, 'points': 0}),
  ('normal control 3',
   [{'maidens': 0, 'overs': '3.4', 'runs': 25, 'wickets': ['lbw', 'bowled', 'caught', 'caught']}],
   {'balls': 22, 'points': 126}),
  ('normal control 4', [{'maidens': 1, 'overs': '3.4', 'runs': 29, 'wickets': []}],
   {'balls': 22, 'points': 12})],
 [('regression: economy minimum overs unit',
   [{'maidens': 1, 'overs': '0.4', 'runs': 4, 'wickets': ['run out', 'bowled', 'run out']}],
   {'balls': 4, 'points': 45}),
  ('partial repair probe: economy minimum overs unit',
   [{'maidens': 1, 'overs': '1.6', 'runs': 12, 'wickets': ['caught']}], {'balls': 12, 'points': 39}),
  ('second regression',
   [{'maidens': 1, 'overs': '1.5', 'runs': 11, 'wickets': ['lbw', 'caught', 'run out', 'caught']}],
   {'balls': 11, 'points': 99}),
  ('normal control 1', [{'maidens': 0, 'overs': '2.3', 'runs': 30, 'wickets': ['caught', 'caught']}],
   {'balls': 15, 'points': 46}),
  ('normal control 2', [{'maidens': 0, 'overs': '4', 'runs': 28, 'wickets': ['bowled', 'stumped']}],
   {'balls': 24, 'points': 60}),
  ('normal control 3',
   [{'maidens': 1, 'overs': '4', 'runs': 28, 'wickets': ['stumped', 'stumped', 'stumped', 'stumped', 'lbw']}],
   {'balls': 24, 'points': 163}),
  ('normal control 4', [{'maidens': 1, 'overs': '4', 'runs': 28, 'wickets': ['lbw', 'bowled', 'bowled']}],
   {'balls': 24, 'points': 117})],
 [('regression: economy minimum overs unit',
   [{'maidens': 1, 'overs': '1.5', 'runs': 12, 'wickets': ['run out', 'caught', 'stumped', 'lbw']}],
   {'balls': 11, 'points': 99}),
  ('partial repair probe: economy minimum overs unit',
   [{'maidens': 1, 'overs': '1.6', 'runs': 14, 'wickets': ['lbw', 'stumped', 'caught', 'bowled', 'stumped']}],
   {'balls': 12, 'points': 171}),
  ('second regression', [{'maidens': 1, 'overs': '2.0', 'runs': 24, 'wickets': ['caught']}],
   {'balls': 12, 'points': 33}),
  ('normal control 1', [{'maidens': 0, 'overs': '4', 'runs': 28, 'wickets': ['run out']}],
   {'balls': 24, 'points': 2}),
  ('normal control 2', [{'maidens': 1, 'overs': '2.3', 'runs': 15, 'wickets': ['lbw', 'lbw']}],
   {'balls': 15, 'points': 80}),
  ('normal control 3',
   [{'maidens': 0, 'overs': '3.4', 'runs': 44, 'wickets': ['stumped', 'stumped', 'caught', 'stumped']}],
   {'balls': 22, 'points': 104}),
  ('normal control 4',
   [{'maidens': 0, 'overs': '3.4', 'runs': 22, 'wickets': ['lbw', 'lbw', 'lbw', 'bowled', 'lbw']}],
   {'balls': 22, 'points': 183})]]
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
from fractions import Fraction
N = 1
observations = []
def solve(spell):
    whole, _, part = spell['overs'].partition('.')
    balls = int(whole) * 6 + int(part or 0)
    wk = [d for d in spell['wickets'] if d != 'run out']
    pts = 25 * len(wk)
    pts += 8 * sum(1 for d in wk if d in ('bowled', 'lbw'))
    if len(wk) >= 5:
        pts += 16
    elif len(wk) >= 4:
        pts += 8
    elif len(wk) >= 3:
        pts += 4
    pts += 12 * spell['maidens']
    if balls > 12:
        econ = Fraction(spell['runs'] * 6, balls)
        if econ < 5:
            pts += 6
        elif econ < 6:
            pts += 4
        elif econ <= 7:
            pts += 2
        elif econ < 10:
            pass
        elif econ <= 11:
            pts -= 2
        elif econ <= 12:
            pts -= 4
        else:
            pts -= 6
    return {'balls': balls, 'points': pts}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: economy minimum overs unit',
   [{'maidens': 1, 'overs': '0.4', 'runs': 4, 'wickets': ['lbw', 'run out']}], {'balls': 4, 'points': 45}),
  ('partial repair probe: economy minimum overs unit',
   [{'maidens': 1, 'overs': '2', 'runs': 24, 'wickets': ['caught', 'caught', 'bowled', 'stumped']}],
   {'balls': 12, 'points': 124}),
  ('second regression', [{'maidens': 1, 'overs': '1.6', 'runs': 14, 'wickets': []}],
   {'balls': 12, 'points': 14}),
  ('normal control 1',
   [{'maidens': 0,
     'overs': '4',
     'runs': 16,
     'wickets': ['caught', 'bowled', 'run out', 'stumped', 'run out']}],
   {'balls': 24, 'points': 93}),
  ('normal control 2', [{'maidens': 0, 'overs': '3.4', 'runs': 44, 'wickets': ['caught', 'caught']}],
   {'balls': 22, 'points': 46}),
  ('normal control 3',
   [{'maidens': 1,
     'overs': '3.4',
     'runs': 25,
     'wickets': ['stumped', 'run out', 'run out', 'caught', 'bowled']}],
   {'balls': 22, 'points': 101}),
  ('normal control 4',
   [{'maidens': 1, 'overs': '4', 'runs': 28, 'wickets': ['bowled', 'caught', 'caught', 'caught']}],
   {'balls': 24, 'points': 130})],
 [('regression: economy minimum overs unit',
   [{'maidens': 0, 'overs': '1.5', 'runs': 22, 'wickets': ['bowled', 'bowled', 'caught']}],
   {'balls': 11, 'points': 95}),
  ('partial repair probe: economy minimum overs unit',
   [{'maidens': 1, 'overs': '2', 'runs': 14, 'wickets': ['run out', 'caught', 'caught', 'stumped']}],
   {'balls': 12, 'points': 93}),
  ('second regression', [{'maidens': 1, 'overs': '1.5', 'runs': 12, 'wickets': ['run out']}],
   {'balls': 11, 'points': 12}),
  ('normal control 1', [{'maidens': 0, 'overs': '3.4', 'runs': 44, 'wickets': ['caught', 'lbw']}],
   {'balls': 22, 'points': 54}),
  ('normal control 2', [{'maidens': 1, 'overs': '4', 'runs': 48, 'wickets': ['lbw']}],
   {'balls': 24, 'points': 41}),
  ('normal control 3',
   [{'maidens': 0, 'overs': '2.3', 'runs': 17, 'wickets': ['run out', 'stumped', 'caught', 'caught']}],
   {'balls': 15, 'points': 81}),
  ('normal control 4', [{'maidens': 0, 'overs': '2.3', 'runs': 30, 'wickets': []}],
   {'balls': 15, 'points': -4})],
 [('regression: economy minimum overs unit',
   [{'maidens': 1, 'overs': '1.5', 'runs': 12, 'wickets': ['run out', 'caught', 'lbw', 'bowled']}],
   {'balls': 11, 'points': 107}),
  ('partial repair probe: economy minimum overs unit',
   [{'maidens': 1, 'overs': '2.0', 'runs': 14, 'wickets': ['run out', 'caught', 'run out', 'run out']}],
   {'balls': 12, 'points': 39}),
  ('second regression', [{'maidens': 1, 'overs': '0.4', 'runs': 0, 'wickets': ['lbw', 'caught']}],
   {'balls': 4, 'points': 70}),
  ('normal control 1', [{'maidens': 0, 'overs': '3.4', 'runs': 44, 'wickets': []}],
   {'balls': 22, 'points': -4}),
  ('normal control 2', [{'maidens': 0, 'overs': '1.5', 'runs': 15, 'wickets': []}],
   {'balls': 11, 'points': 0}),
  ('normal control 3',
   [{'maidens': 0, 'overs': '3.4', 'runs': 25, 'wickets': ['lbw', 'bowled', 'caught', 'caught']}],
   {'balls': 22, 'points': 126}),
  ('normal control 4', [{'maidens': 1, 'overs': '3.4', 'runs': 29, 'wickets': []}],
   {'balls': 22, 'points': 12})],
 [('regression: economy minimum overs unit',
   [{'maidens': 1, 'overs': '0.4', 'runs': 4, 'wickets': ['run out', 'bowled', 'run out']}],
   {'balls': 4, 'points': 45}),
  ('partial repair probe: economy minimum overs unit',
   [{'maidens': 1, 'overs': '1.6', 'runs': 12, 'wickets': ['caught']}], {'balls': 12, 'points': 39}),
  ('second regression',
   [{'maidens': 1, 'overs': '1.5', 'runs': 11, 'wickets': ['lbw', 'caught', 'run out', 'caught']}],
   {'balls': 11, 'points': 99}),
  ('normal control 1', [{'maidens': 0, 'overs': '2.3', 'runs': 30, 'wickets': ['caught', 'caught']}],
   {'balls': 15, 'points': 46}),
  ('normal control 2', [{'maidens': 0, 'overs': '4', 'runs': 28, 'wickets': ['bowled', 'stumped']}],
   {'balls': 24, 'points': 60}),
  ('normal control 3',
   [{'maidens': 1, 'overs': '4', 'runs': 28, 'wickets': ['stumped', 'stumped', 'stumped', 'stumped', 'lbw']}],
   {'balls': 24, 'points': 163}),
  ('normal control 4', [{'maidens': 1, 'overs': '4', 'runs': 28, 'wickets': ['lbw', 'bowled', 'bowled']}],
   {'balls': 24, 'points': 117})],
 [('regression: economy minimum overs unit',
   [{'maidens': 1, 'overs': '1.5', 'runs': 12, 'wickets': ['run out', 'caught', 'stumped', 'lbw']}],
   {'balls': 11, 'points': 99}),
  ('partial repair probe: economy minimum overs unit',
   [{'maidens': 1, 'overs': '1.6', 'runs': 14, 'wickets': ['lbw', 'stumped', 'caught', 'bowled', 'stumped']}],
   {'balls': 12, 'points': 171}),
  ('second regression', [{'maidens': 1, 'overs': '2.0', 'runs': 24, 'wickets': ['caught']}],
   {'balls': 12, 'points': 33}),
  ('normal control 1', [{'maidens': 0, 'overs': '4', 'runs': 28, 'wickets': ['run out']}],
   {'balls': 24, 'points': 2}),
  ('normal control 2', [{'maidens': 1, 'overs': '2.3', 'runs': 15, 'wickets': ['lbw', 'lbw']}],
   {'balls': 15, 'points': 80}),
  ('normal control 3',
   [{'maidens': 0, 'overs': '3.4', 'runs': 44, 'wickets': ['stumped', 'stumped', 'caught', 'stumped']}],
   {'balls': 22, 'points': 104}),
  ('normal control 4',
   [{'maidens': 0, 'overs': '3.4', 'runs': 22, 'wickets': ['lbw', 'lbw', 'lbw', 'bowled', 'lbw']}],
   {'balls': 22, 'points': 183})]]
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 bowler who delivered 5 balls for 1 run receives the best economy bonus.

Score a T20 bowling spell. Overs use cricket notation ("3.4" = 3 overs and 4 balls, 6 balls per over). Each wicket credited to the bowler scores 25 (run outs are not credited); bowled and lbw earn +8 each; haul bonus for 3/4/5+ credited wickets is 4/8/16 (highest only); maiden +12. Economy (exact runs per 6 balls) applies from 2 full overs (12 balls): <5 +6, <6 +4, <=7 +2, <10 0, <=11 -2, <=12 -4, else -6.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(spell):
    whole, _, part = spell['overs'].partition('.')
    balls = int(whole) * 6 + int(part or 0)
    wk = [d for d in spell['wickets'] if d != 'run out']
    pts = 25 * len(wk)
    pts += 8 * sum(1 for d in wk if d in ('bowled', 'lbw'))
    if len(wk) >= 5:
        pts += 16
    elif len(wk) >= 4:
        pts += 8
    elif len(wk) >= 3:
        pts += 4
    pts += 12 * spell['maidens']
    if balls >= 12:
        econ = Fraction(spell['runs']) / Fraction(spell['overs'])
        if econ < 5:
            pts += 6
        elif econ < 6:
            pts += 4
        elif econ <= 7:
            pts += 2
        elif econ < 10:
            pass
        elif econ <= 11:
            pts -= 2
        elif econ <= 12:
            pts -= 4
        else:
            pts -= 6
    return {'balls': balls, 'points': pts}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: economy from decimal overs',
   [{'maidens': 1, 'overs': '1.6', 'runs': 13, 'wickets': ['stumped', 'lbw', 'bowled', 'caught', 'run out']}],
   {'balls': 12, 'points': 138}),
  ('partial repair probe: economy from decimal overs',
   [{'maidens': 1, 'overs': '3.4', 'runs': 25, 'wickets': ['bowled']}], {'balls': 22, 'points': 47}),
  ('second regression', [{'maidens': 1, 'overs': '3.4', 'runs': 44, 'wickets': ['lbw']}],
   {'balls': 22, 'points': 41}),
  ('normal control 1',
   [{'maidens': 0, 'overs': '0.4', 'runs': 8, 'wickets': ['lbw', 'run out', 'stumped', 'caught']}],
   {'balls': 4, 'points': 87}),
  ('normal control 2',
   [{'maidens': 0, 'overs': '4', 'runs': 28, 'wickets': ['caught', 'run out', 'run out']}],
   {'balls': 24, 'points': 27}),
  ('normal control 3',
   [{'maidens': 0, 'overs': '2', 'runs': 24, 'wickets': ['stumped', 'caught', 'caught', 'caught']}],
   {'balls': 12, 'points': 104}),
  ('normal control 4', [{'maidens': 0, 'overs': '1.5', 'runs': 22, 'wickets': ['caught']}],
   {'balls': 11, 'points': 25})],
 [('regression: economy from decimal overs', [{'maidens': 1, 'overs': '2.3', 'runs': 30, 'wickets': []}],
   {'balls': 15, 'points': 8}),
  ('partial repair probe: economy from decimal overs',
   [{'maidens': 0, 'overs': '3.4', 'runs': 22, 'wickets': ['run out']}], {'balls': 22, 'points': 2}),
  ('second regression', [{'maidens': 0, 'overs': '1.6', 'runs': 14, 'wickets': ['caught']}],
   {'balls': 12, 'points': 27}),
  ('normal control 1', [{'maidens': 0, 'overs': '2.0', 'runs': 24, 'wickets': ['run out']}],
   {'balls': 12, 'points': -4}),
  ('normal control 2',
   [{'maidens': 1, 'overs': '0.4', 'runs': 4, 'wickets': ['stumped', 'lbw', 'run out', 'lbw']}],
   {'balls': 4, 'points': 107}),
  ('normal control 3', [{'maidens': 0, 'overs': '2', 'runs': 3, 'wickets': []}], {'balls': 12, 'points': 6}),
  ('normal control 4', [{'maidens': 1, 'overs': '0.4', 'runs': 9, 'wickets': ['caught']}],
   {'balls': 4, 'points': 37})],
 [('regression: economy from decimal overs',
   [{'maidens': 0, 'overs': '1.6', 'runs': 14, 'wickets': ['bowled', 'caught']}],
   {'balls': 12, 'points': 60}),
  ('partial repair probe: economy from decimal overs',
   [{'maidens': 1, 'overs': '1.6', 'runs': 24, 'wickets': []}], {'balls': 12, 'points': 8}),
  ('second regression', [{'maidens': 0, 'overs': '1.6', 'runs': 24, 'wickets': ['lbw']}],
   {'balls': 12, 'points': 29}),
  ('normal control 1',
   [{'maidens': 0, 'overs': '2.0', 'runs': 14, 'wickets': ['bowled', 'bowled', 'lbw', 'lbw']}],
   {'balls': 12, 'points': 142}),
  ('normal control 2', [{'maidens': 0, 'overs': '0.4', 'runs': 6, 'wickets': []}], {'balls': 4, 'points': 0}),
  ('normal control 3', [{'maidens': 1, 'overs': '2.0', 'runs': 14, 'wickets': ['run out', 'lbw']}],
   {'balls': 12, 'points': 47}),
  ('normal control 4',
   [{'maidens': 1, 'overs': '4', 'runs': 28, 'wickets': ['lbw', 'caught', 'caught', 'run out', 'stumped']}],
   {'balls': 24, 'points': 130})],
 [('regression: economy from decimal overs', [{'maidens': 1, 'overs': '3.4', 'runs': 25, 'wickets': []}],
   {'balls': 22, 'points': 14}),
  ('partial repair probe: economy from decimal overs',
   [{'maidens': 1, 'overs': '3.4', 'runs': 25, 'wickets': ['caught', 'lbw', 'stumped', 'run out', 'lbw']}],
   {'balls': 22, 'points': 138}),
  ('second regression',
   [{'maidens': 1, 'overs': '3.4', 'runs': 25, 'wickets': ['lbw', 'caught', 'stumped', 'bowled']}],
   {'balls': 22, 'points': 138}),
  ('normal control 1',
   [{'maidens': 1, 'overs': '2.0', 'runs': 24, 'wickets': ['caught', 'caught', 'run out']}],
   {'balls': 12, 'points': 58}),
  ('normal control 2',
   [{'maidens': 0, 'overs': '2', 'runs': 14, 'wickets': ['lbw', 'caught', 'stumped', 'run out', 'caught']}],
   {'balls': 12, 'points': 118}),
  ('normal control 3',
   [{'maidens': 1, 'overs': '4', 'runs': 24, 'wickets': ['bowled', 'stumped', 'caught', 'lbw', 'bowled']}],
   {'balls': 24, 'points': 179}),
  ('normal control 4', [{'maidens': 1, 'overs': '1.5', 'runs': 12, 'wickets': ['bowled', 'bowled']}],
   {'balls': 11, 'points': 78})],
 [('regression: economy from decimal overs',
   [{'maidens': 1, 'overs': '1.6', 'runs': 24, 'wickets': ['caught', 'lbw', 'caught', 'run out']}],
   {'balls': 12, 'points': 95}),
  ('partial repair probe: economy from decimal overs',
   [{'maidens': 1, 'overs': '1.6', 'runs': 6, 'wickets': []}], {'balls': 12, 'points': 18}),
  ('second regression',
   [{'maidens': 1, 'overs': '2.3', 'runs': 15, 'wickets': ['stumped', 'caught', 'caught']}],
   {'balls': 15, 'points': 93}),
  ('normal control 1',
   [{'maidens': 1, 'overs': '2', 'runs': 24, 'wickets': ['stumped', 'bowled', 'run out']}],
   {'balls': 12, 'points': 66}),
  ('normal control 2', [{'maidens': 0, 'overs': '4', 'runs': 48, 'wickets': ['run out']}],
   {'balls': 24, 'points': -4}),
  ('normal control 3', [{'maidens': 1, 'overs': '1.5', 'runs': 9, 'wickets': ['bowled', 'stumped']}],
   {'balls': 11, 'points': 70}),
  ('normal control 4', [{'maidens': 1, 'overs': '1.5', 'runs': 12, 'wickets': []}],
   {'balls': 11, 'points': 12})]]
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
from fractions import Fraction
N = 1
observations = []
def solve(spell):
    whole, _, part = spell['overs'].partition('.')
    balls = int(whole) * 6 + int(part or 0)
    wk = [d for d in spell['wickets'] if d != 'run out']
    pts = 25 * len(wk)
    pts += 8 * sum(1 for d in wk if d in ('bowled', 'lbw'))
    if len(wk) >= 5:
        pts += 16
    elif len(wk) >= 4:
        pts += 8
    elif len(wk) >= 3:
        pts += 4
    pts += 12 * spell['maidens']
    if balls >= 12:
        econ = Fraction(spell['runs'] * 6, int(whole) * 6)
        if econ < 5:
            pts += 6
        elif econ < 6:
            pts += 4
        elif econ <= 7:
            pts += 2
        elif econ < 10:
            pass
        elif econ <= 11:
            pts -= 2
        elif econ <= 12:
            pts -= 4
        else:
            pts -= 6
    return {'balls': balls, 'points': pts}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: economy from decimal overs',
   [{'maidens': 1, 'overs': '1.6', 'runs': 13, 'wickets': ['stumped', 'lbw', 'bowled', 'caught', 'run out']}],
   {'balls': 12, 'points': 138}),
  ('partial repair probe: economy from decimal overs',
   [{'maidens': 1, 'overs': '3.4', 'runs': 25, 'wickets': ['bowled']}], {'balls': 22, 'points': 47}),
  ('second regression', [{'maidens': 1, 'overs': '3.4', 'runs': 44, 'wickets': ['lbw']}],
   {'balls': 22, 'points': 41}),
  ('normal control 1',
   [{'maidens': 0, 'overs': '0.4', 'runs': 8, 'wickets': ['lbw', 'run out', 'stumped', 'caught']}],
   {'balls': 4, 'points': 87}),
  ('normal control 2',
   [{'maidens': 0, 'overs': '4', 'runs': 28, 'wickets': ['caught', 'run out', 'run out']}],
   {'balls': 24, 'points': 27}),
  ('normal control 3',
   [{'maidens': 0, 'overs': '2', 'runs': 24, 'wickets': ['stumped', 'caught', 'caught', 'caught']}],
   {'balls': 12, 'points': 104}),
  ('normal control 4', [{'maidens': 0, 'overs': '1.5', 'runs': 22, 'wickets': ['caught']}],
   {'balls': 11, 'points': 25})],
 [('regression: economy from decimal overs', [{'maidens': 1, 'overs': '2.3', 'runs': 30, 'wickets': []}],
   {'balls': 15, 'points': 8}),
  ('partial repair probe: economy from decimal overs',
   [{'maidens': 0, 'overs': '3.4', 'runs': 22, 'wickets': ['run out']}], {'balls': 22, 'points': 2}),
  ('second regression', [{'maidens': 0, 'overs': '1.6', 'runs': 14, 'wickets': ['caught']}],
   {'balls': 12, 'points': 27}),
  ('normal control 1', [{'maidens': 0, 'overs': '2.0', 'runs': 24, 'wickets': ['run out']}],
   {'balls': 12, 'points': -4}),
  ('normal control 2',
   [{'maidens': 1, 'overs': '0.4', 'runs': 4, 'wickets': ['stumped', 'lbw', 'run out', 'lbw']}],
   {'balls': 4, 'points': 107}),
  ('normal control 3', [{'maidens': 0, 'overs': '2', 'runs': 3, 'wickets': []}], {'balls': 12, 'points': 6}),
  ('normal control 4', [{'maidens': 1, 'overs': '0.4', 'runs': 9, 'wickets': ['caught']}],
   {'balls': 4, 'points': 37})],
 [('regression: economy from decimal overs',
   [{'maidens': 0, 'overs': '1.6', 'runs': 14, 'wickets': ['bowled', 'caught']}],
   {'balls': 12, 'points': 60}),
  ('partial repair probe: economy from decimal overs',
   [{'maidens': 1, 'overs': '1.6', 'runs': 24, 'wickets': []}], {'balls': 12, 'points': 8}),
  ('second regression', [{'maidens': 0, 'overs': '1.6', 'runs': 24, 'wickets': ['lbw']}],
   {'balls': 12, 'points': 29}),
  ('normal control 1',
   [{'maidens': 0, 'overs': '2.0', 'runs': 14, 'wickets': ['bowled', 'bowled', 'lbw', 'lbw']}],
   {'balls': 12, 'points': 142}),
  ('normal control 2', [{'maidens': 0, 'overs': '0.4', 'runs': 6, 'wickets': []}], {'balls': 4, 'points': 0}),
  ('normal control 3', [{'maidens': 1, 'overs': '2.0', 'runs': 14, 'wickets': ['run out', 'lbw']}],
   {'balls': 12, 'points': 47}),
  ('normal control 4',
   [{'maidens': 1, 'overs': '4', 'runs': 28, 'wickets': ['lbw', 'caught', 'caught', 'run out', 'stumped']}],
   {'balls': 24, 'points': 130})],
 [('regression: economy from decimal overs', [{'maidens': 1, 'overs': '3.4', 'runs': 25, 'wickets': []}],
   {'balls': 22, 'points': 14}),
  ('partial repair probe: economy from decimal overs',
   [{'maidens': 1, 'overs': '3.4', 'runs': 25, 'wickets': ['caught', 'lbw', 'stumped', 'run out', 'lbw']}],
   {'balls': 22, 'points': 138}),
  ('second regression',
   [{'maidens': 1, 'overs': '3.4', 'runs': 25, 'wickets': ['lbw', 'caught', 'stumped', 'bowled']}],
   {'balls': 22, 'points': 138}),
  ('normal control 1',
   [{'maidens': 1, 'overs': '2.0', 'runs': 24, 'wickets': ['caught', 'caught', 'run out']}],
   {'balls': 12, 'points': 58}),
  ('normal control 2',
   [{'maidens': 0, 'overs': '2', 'runs': 14, 'wickets': ['lbw', 'caught', 'stumped', 'run out', 'caught']}],
   {'balls': 12, 'points': 118}),
  ('normal control 3',
   [{'maidens': 1, 'overs': '4', 'runs': 24, 'wickets': ['bowled', 'stumped', 'caught', 'lbw', 'bowled']}],
   {'balls': 24, 'points': 179}),
  ('normal control 4', [{'maidens': 1, 'overs': '1.5', 'runs': 12, 'wickets': ['bowled', 'bowled']}],
   {'balls': 11, 'points': 78})],
 [('regression: economy from decimal overs',
   [{'maidens': 1, 'overs': '1.6', 'runs': 24, 'wickets': ['caught', 'lbw', 'caught', 'run out']}],
   {'balls': 12, 'points': 95}),
  ('partial repair probe: economy from decimal overs',
   [{'maidens': 1, 'overs': '1.6', 'runs': 6, 'wickets': []}], {'balls': 12, 'points': 18}),
  ('second regression',
   [{'maidens': 1, 'overs': '2.3', 'runs': 15, 'wickets': ['stumped', 'caught', 'caught']}],
   {'balls': 15, 'points': 93}),
  ('normal control 1',
   [{'maidens': 1, 'overs': '2', 'runs': 24, 'wickets': ['stumped', 'bowled', 'run out']}],
   {'balls': 12, 'points': 66}),
  ('normal control 2', [{'maidens': 0, 'overs': '4', 'runs': 48, 'wickets': ['run out']}],
   {'balls': 24, 'points': -4}),
  ('normal control 3', [{'maidens': 1, 'overs': '1.5', 'runs': 9, 'wickets': ['bowled', 'stumped']}],
   {'balls': 11, 'points': 70}),
  ('normal control 4', [{'maidens': 1, 'overs': '1.5', 'runs': 12, 'wickets': []}],
   {'balls': 11, 'points': 12})]]
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:
2.3 overs is treated as 2.3 overs rather than 2.5, inflating economy.

Score a T20 bowling spell. Overs use cricket notation ("3.4" = 3 overs and 4 balls, 6 balls per over). Each wicket credited to the bowler scores 25 (run outs are not credited); bowled and lbw earn +8 each; haul bonus for 3/4/5+ credited wickets is 4/8/16 (highest only); maiden +12. Economy (exact runs per 6 balls) applies from 2 full overs (12 balls): <5 +6, <6 +4, <=7 +2, <10 0, <=11 -2, <=12 -4, else -6.

split: open-access


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

N = 1
observations = []
def solve(p):
    if p['minutes'] == 0:
        return 0
    pos = p['pos']
    pts = 2 if p['minutes'] > 60 else 1
    pts += p['goals'] * {'GK': 6, 'DEF': 6, 'MID': 5, 'FWD': 4}[pos]
    pts += p['assists'] * 3
    if p['conceded'] == 0 and p['minutes'] >= 60:
        pts += {'GK': 4, 'DEF': 4, 'MID': 1, 'FWD': 0}[pos]
    if pos in ('GK', 'DEF'):
        pts -= p['conceded'] // 2
    if pos == 'GK':
        pts += p['saves'] // 3
    pts += p['pen_saved'] * 5 - p['pen_missed'] * 2 - p['own_goals'] * 2
    if p['red']:
        pts -= 3
    elif p['yellow']:
        pts -= 1
    return pts
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: sixty-minute appearance',
   [{'assists': 2,
     'conceded': 1,
     'goals': 1,
     'minutes': 60,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 2,
     'yellow': False}],
   14),
  ('partial repair probe: sixty-minute appearance',
   [{'assists': 0,
     'conceded': 3,
     'goals': 0,
     'minutes': 46,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 4,
     'yellow': False}],
   -1),
  ('second regression',
   [{'assists': 2,
     'conceded': 4,
     'goals': 1,
     'minutes': 46,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   9),
  ('normal control 1',
   [{'assists': 0,
     'conceded': 4,
     'goals': 0,
     'minutes': 61,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   -2),
  ('normal control 2',
   [{'assists': 0,
     'conceded': 4,
     'goals': 1,
     'minutes': 61,
     'own_goals': 0,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': True,
     'saves': 0,
     'yellow': False}],
   1),
  ('normal control 3',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': True,
     'saves': 0,
     'yellow': False}],
   0),
  ('normal control 4',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': True}],
   0)],
 [('regression: sixty-minute appearance',
   [{'assists': 1,
     'conceded': 0,
     'goals': 1,
     'minutes': 60,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   7),
  ('partial repair probe: sixty-minute appearance',
   [{'assists': 1,
     'conceded': 2,
     'goals': 2,
     'minutes': 59,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   13),
  ('second regression',
   [{'assists': 1,
     'conceded': 0,
     'goals': 1,
     'minutes': 59,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': True,
     'saves': 0,
     'yellow': True}],
   7),
  ('normal control 1',
   [{'assists': 1,
     'conceded': 1,
     'goals': 0,
     'minutes': 90,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   5),
  ('normal control 2',
   [{'assists': 1,
     'conceded': 4,
     'goals': 2,
     'minutes': 45,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': True}],
   11),
  ('normal control 3',
   [{'assists': 0,
     'conceded': 2,
     'goals': 1,
     'minutes': 45,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   4),
  ('normal control 4',
   [{'assists': 1,
     'conceded': 0,
     'goals': 2,
     'minutes': 1,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 4,
     'yellow': False}],
   17)],
 [('regression: sixty-minute appearance',
   [{'assists': 1,
     'conceded': 1,
     'goals': 1,
     'minutes': 60,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   9),
  ('partial repair probe: sixty-minute appearance',
   [{'assists': 1,
     'conceded': 3,
     'goals': 0,
     'minutes': 59,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': True,
     'saves': 0,
     'yellow': False}],
   1),
  ('second regression',
   [{'assists': 1,
     'conceded': 4,
     'goals': 0,
     'minutes': 60,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 1,
     'yellow': False}],
   -1),
  ('normal control 1',
   [{'assists': 1,
     'conceded': 2,
     'goals': 0,
     'minutes': 45,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   0),
  ('normal control 2',
   [{'assists': 1,
     'conceded': 3,
     'goals': 0,
     'minutes': 1,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   2),
  ('normal control 3',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': True,
     'saves': 0,
     'yellow': False}],
   0),
  ('normal control 4',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 0,
     'yellow': False}],
   0)],
 [('regression: sixty-minute appearance',
   [{'assists': 0,
     'conceded': 3,
     'goals': 0,
     'minutes': 60,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   2),
  ('partial repair probe: sixty-minute appearance',
   [{'assists': 0,
     'conceded': 4,
     'goals': 2,
     'minutes': 46,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': True}],
   10),
  ('second regression',
   [{'assists': 0,
     'conceded': 0,
     'goals': 1,
     'minutes': 46,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': True,
     'saves': 0,
     'yellow': False}],
   2),
  ('normal control 1',
   [{'assists': 2,
     'conceded': 0,
     'goals': 0,
     'minutes': 45,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   5),
  ('normal control 2',
   [{'assists': 1,
     'conceded': 0,
     'goals': 0,
     'minutes': 90,
     'own_goals': 0,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   7),
  ('normal control 3',
   [{'assists': 0,
     'conceded': 0,
     'goals': 1,
     'minutes': 1,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': True}],
   5),
  ('normal control 4',
   [{'assists': 1,
     'conceded': 2,
     'goals': 0,
     'minutes': 1,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   4)],
 [('regression: sixty-minute appearance',
   [{'assists': 2,
     'conceded': 2,
     'goals': 1,
     'minutes': 60,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 3,
     'yellow': False}],
   14),
  ('partial repair probe: sixty-minute appearance',
   [{'assists': 1,
     'conceded': 3,
     'goals': 0,
     'minutes': 46,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   4),
  ('second regression',
   [{'assists': 0,
     'conceded': 2,
     'goals': 0,
     'minutes': 46,
     'own_goals': 0,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': True,
     'saves': 0,
     'yellow': True}],
   -4),
  ('normal control 1',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': True}],
   0),
  ('normal control 2',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 90,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   4),
  ('normal control 3',
   [{'assists': 1,
     'conceded': 2,
     'goals': 1,
     'minutes': 1,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': True}],
   6),
  ('normal control 4',
   [{'assists': 0,
     'conceded': 4,
     'goals': 1,
     'minutes': 1,
     'own_goals': 0,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': True,
     'saves': 0,
     'yellow': False}],
   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(p):
    if p['minutes'] == 0:
        return 0
    pos = p['pos']
    pts = 2 if p['minutes'] > 45 else 1
    pts += p['goals'] * {'GK': 6, 'DEF': 6, 'MID': 5, 'FWD': 4}[pos]
    pts += p['assists'] * 3
    if p['conceded'] == 0 and p['minutes'] >= 60:
        pts += {'GK': 4, 'DEF': 4, 'MID': 1, 'FWD': 0}[pos]
    if pos in ('GK', 'DEF'):
        pts -= p['conceded'] // 2
    if pos == 'GK':
        pts += p['saves'] // 3
    pts += p['pen_saved'] * 5 - p['pen_missed'] * 2 - p['own_goals'] * 2
    if p['red']:
        pts -= 3
    elif p['yellow']:
        pts -= 1
    return pts
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: sixty-minute appearance',
   [{'assists': 2,
     'conceded': 1,
     'goals': 1,
     'minutes': 60,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 2,
     'yellow': False}],
   14),
  ('partial repair probe: sixty-minute appearance',
   [{'assists': 0,
     'conceded': 3,
     'goals': 0,
     'minutes': 46,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 4,
     'yellow': False}],
   -1),
  ('second regression',
   [{'assists': 2,
     'conceded': 4,
     'goals': 1,
     'minutes': 46,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   9),
  ('normal control 1',
   [{'assists': 0,
     'conceded': 4,
     'goals': 0,
     'minutes': 61,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   -2),
  ('normal control 2',
   [{'assists': 0,
     'conceded': 4,
     'goals': 1,
     'minutes': 61,
     'own_goals': 0,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': True,
     'saves': 0,
     'yellow': False}],
   1),
  ('normal control 3',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': True,
     'saves': 0,
     'yellow': False}],
   0),
  ('normal control 4',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': True}],
   0)],
 [('regression: sixty-minute appearance',
   [{'assists': 1,
     'conceded': 0,
     'goals': 1,
     'minutes': 60,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   7),
  ('partial repair probe: sixty-minute appearance',
   [{'assists': 1,
     'conceded': 2,
     'goals': 2,
     'minutes': 59,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   13),
  ('second regression',
   [{'assists': 1,
     'conceded': 0,
     'goals': 1,
     'minutes': 59,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': True,
     'saves': 0,
     'yellow': True}],
   7),
  ('normal control 1',
   [{'assists': 1,
     'conceded': 1,
     'goals': 0,
     'minutes': 90,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   5),
  ('normal control 2',
   [{'assists': 1,
     'conceded': 4,
     'goals': 2,
     'minutes': 45,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': True}],
   11),
  ('normal control 3',
   [{'assists': 0,
     'conceded': 2,
     'goals': 1,
     'minutes': 45,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   4),
  ('normal control 4',
   [{'assists': 1,
     'conceded': 0,
     'goals': 2,
     'minutes': 1,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 4,
     'yellow': False}],
   17)],
 [('regression: sixty-minute appearance',
   [{'assists': 1,
     'conceded': 1,
     'goals': 1,
     'minutes': 60,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   9),
  ('partial repair probe: sixty-minute appearance',
   [{'assists': 1,
     'conceded': 3,
     'goals': 0,
     'minutes': 59,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': True,
     'saves': 0,
     'yellow': False}],
   1),
  ('second regression',
   [{'assists': 1,
     'conceded': 4,
     'goals': 0,
     'minutes': 60,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 1,
     'yellow': False}],
   -1),
  ('normal control 1',
   [{'assists': 1,
     'conceded': 2,
     'goals': 0,
     'minutes': 45,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   0),
  ('normal control 2',
   [{'assists': 1,
     'conceded': 3,
     'goals': 0,
     'minutes': 1,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   2),
  ('normal control 3',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': True,
     'saves': 0,
     'yellow': False}],
   0),
  ('normal control 4',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 0,
     'yellow': False}],
   0)],
 [('regression: sixty-minute appearance',
   [{'assists': 0,
     'conceded': 3,
     'goals': 0,
     'minutes': 60,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   2),
  ('partial repair probe: sixty-minute appearance',
   [{'assists': 0,
     'conceded': 4,
     'goals': 2,
     'minutes': 46,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': True}],
   10),
  ('second regression',
   [{'assists': 0,
     'conceded': 0,
     'goals': 1,
     'minutes': 46,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': True,
     'saves': 0,
     'yellow': False}],
   2),
  ('normal control 1',
   [{'assists': 2,
     'conceded': 0,
     'goals': 0,
     'minutes': 45,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   5),
  ('normal control 2',
   [{'assists': 1,
     'conceded': 0,
     'goals': 0,
     'minutes': 90,
     'own_goals': 0,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   7),
  ('normal control 3',
   [{'assists': 0,
     'conceded': 0,
     'goals': 1,
     'minutes': 1,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': True}],
   5),
  ('normal control 4',
   [{'assists': 1,
     'conceded': 2,
     'goals': 0,
     'minutes': 1,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   4)],
 [('regression: sixty-minute appearance',
   [{'assists': 2,
     'conceded': 2,
     'goals': 1,
     'minutes': 60,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 3,
     'yellow': False}],
   14),
  ('partial repair probe: sixty-minute appearance',
   [{'assists': 1,
     'conceded': 3,
     'goals': 0,
     'minutes': 46,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   4),
  ('second regression',
   [{'assists': 0,
     'conceded': 2,
     'goals': 0,
     'minutes': 46,
     'own_goals': 0,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': True,
     'saves': 0,
     'yellow': True}],
   -4),
  ('normal control 1',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': True}],
   0),
  ('normal control 2',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 90,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   4),
  ('normal control 3',
   [{'assists': 1,
     'conceded': 2,
     'goals': 1,
     'minutes': 1,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': True}],
   6),
  ('normal control 4',
   [{'assists': 0,
     'conceded': 4,
     'goals': 1,
     'minutes': 1,
     'own_goals': 0,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': True,
     'saves': 0,
     'yellow': False}],
   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:
A player substituted in the 60th minute gets 1 appearance point.

Score an association-football fantasy player. 0 minutes scores 0 (even cards shown on the bench). Appearance 1, or 2 for 60+ minutes. Goals GK/DEF 6, MID 5, FWD 4; assist 3. Clean sheet (0 conceded while on pitch, 60+ minutes) GK/DEF 4, MID 1. GK/DEF lose 1 per 2 goals conceded (floor). GK +1 per 3 saves. Penalty save 5, penalty miss -2, own goal -2. A red card is -3 and replaces any yellow (-1).

split: open-access


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

N = 1
observations = []
def solve(p):
    if p['minutes'] == 0:
        return 0
    pos = p['pos']
    pts = 2 if p['minutes'] >= 60 else 1
    pts += p['goals'] * {'GK': 6, 'DEF': 6, 'MID': 5, 'FWD': 4}[pos]
    pts += p['assists'] * 3
    if p['conceded'] == 0:
        pts += {'GK': 4, 'DEF': 4, 'MID': 1, 'FWD': 0}[pos]
    if pos in ('GK', 'DEF'):
        pts -= p['conceded'] // 2
    if pos == 'GK':
        pts += p['saves'] // 3
    pts += p['pen_saved'] * 5 - p['pen_missed'] * 2 - p['own_goals'] * 2
    if p['red']:
        pts -= 3
    elif p['yellow']:
        pts -= 1
    return pts
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: clean sheet minutes',
   [{'assists': 0,
     'conceded': 0,
     'goals': 1,
     'minutes': 59,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   6),
  ('partial repair probe: clean sheet minutes',
   [{'assists': 1,
     'conceded': 0,
     'goals': 0,
     'minutes': 45,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 1,
     'yellow': False}],
   2),
  ('second regression',
   [{'assists': 1,
     'conceded': 0,
     'goals': 2,
     'minutes': 46,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   14),
  ('normal control 1',
   [{'assists': 0,
     'conceded': 0,
     'goals': 1,
     'minutes': 1,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   1),
  ('normal control 2',
   [{'assists': 2,
     'conceded': 2,
     'goals': 1,
     'minutes': 1,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': True}],
   9),
  ('normal control 3',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   0),
  ('normal control 4',
   [{'assists': 0,
     'conceded': 2,
     'goals': 1,
     'minutes': 45,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': True}],
   4)],
 [('regression: clean sheet minutes',
   [{'assists': 2,
     'conceded': 0,
     'goals': 0,
     'minutes': 1,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   3),
  ('partial repair probe: clean sheet minutes',
   [{'assists': 2,
     'conceded': 0,
     'goals': 0,
     'minutes': 59,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 2,
     'yellow': False}],
   3),
  ('second regression',
   [{'assists': 1,
     'conceded': 0,
     'goals': 0,
     'minutes': 1,
     'own_goals': 0,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'GK',
     'red': True,
     'saves': 7,
     'yellow': True}],
   1),
  ('normal control 1',
   [{'assists': 2,
     'conceded': 1,
     'goals': 0,
     'minutes': 46,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   7),
  ('normal control 2',
   [{'assists': 0,
     'conceded': 2,
     'goals': 1,
     'minutes': 1,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': True}],
   3),
  ('normal control 3',
   [{'assists': 1,
     'conceded': 3,
     'goals': 2,
     'minutes': 46,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   10),
  ('normal control 4',
   [{'assists': 1,
     'conceded': 0,
     'goals': 0,
     'minutes': 90,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   9)],
 [('regression: clean sheet minutes',
   [{'assists': 2,
     'conceded': 0,
     'goals': 0,
     'minutes': 45,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 4,
     'yellow': True}],
   7),
  ('partial repair probe: clean sheet minutes',
   [{'assists': 1,
     'conceded': 0,
     'goals': 0,
     'minutes': 59,
     'own_goals': 0,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 4,
     'yellow': False}],
   3),
  ('second regression',
   [{'assists': 1,
     'conceded': 0,
     'goals': 0,
     'minutes': 45,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   0),
  ('normal control 1',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': True,
     'saves': 0,
     'yellow': False}],
   0),
  ('normal control 2',
   [{'assists': 0,
     'conceded': 4,
     'goals': 0,
     'minutes': 46,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   -1),
  ('normal control 3',
   [{'assists': 2,
     'conceded': 1,
     'goals': 0,
     'minutes': 46,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': True,
     'saves': 0,
     'yellow': True}],
   4),
  ('normal control 4',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   0)],
 [('regression: clean sheet minutes',
   [{'assists': 2,
     'conceded': 0,
     'goals': 0,
     'minutes': 45,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   5),
  ('partial repair probe: clean sheet minutes',
   [{'assists': 1,
     'conceded': 0,
     'goals': 1,
     'minutes': 45,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 0,
     'yellow': False}],
   8),
  ('second regression',
   [{'assists': 1,
     'conceded': 0,
     'goals': 0,
     'minutes': 59,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': True}],
   1),
  ('normal control 1',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 0,
     'yellow': True}],
   0),
  ('normal control 2',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   0),
  ('normal control 3',
   [{'assists': 1,
     'conceded': 1,
     'goals': 0,
     'minutes': 45,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   2),
  ('normal control 4',
   [{'assists': 0,
     'conceded': 3,
     'goals': 2,
     'minutes': 59,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   8)],
 [('regression: clean sheet minutes',
   [{'assists': 2,
     'conceded': 0,
     'goals': 0,
     'minutes': 1,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 3,
     'yellow': False}],
   8),
  ('partial repair probe: clean sheet minutes',
   [{'assists': 2,
     'conceded': 0,
     'goals': 1,
     'minutes': 46,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   10),
  ('second regression',
   [{'assists': 2,
     'conceded': 0,
     'goals': 0,
     'minutes': 59,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': True,
     'saves': 2,
     'yellow': True}],
   4),
  ('normal control 1',
   [{'assists': 0,
     'conceded': 2,
     'goals': 0,
     'minutes': 61,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': True}],
   -3),
  ('normal control 2',
   [{'assists': 2,
     'conceded': 3,
     'goals': 0,
     'minutes': 61,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': True}],
   2),
  ('normal control 3',
   [{'assists': 1,
     'conceded': 0,
     'goals': 2,
     'minutes': 61,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': True,
     'saves': 0,
     'yellow': False}],
   13),
  ('normal control 4',
   [{'assists': 2,
     'conceded': 4,
     'goals': 0,
     'minutes': 61,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   6)]]
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(p):
    if p['minutes'] == 0:
        return 0
    pos = p['pos']
    pts = 2 if p['minutes'] >= 60 else 1
    pts += p['goals'] * {'GK': 6, 'DEF': 6, 'MID': 5, 'FWD': 4}[pos]
    pts += p['assists'] * 3
    if p['conceded'] == 0 and p['minutes'] >= 45:
        pts += {'GK': 4, 'DEF': 4, 'MID': 1, 'FWD': 0}[pos]
    if pos in ('GK', 'DEF'):
        pts -= p['conceded'] // 2
    if pos == 'GK':
        pts += p['saves'] // 3
    pts += p['pen_saved'] * 5 - p['pen_missed'] * 2 - p['own_goals'] * 2
    if p['red']:
        pts -= 3
    elif p['yellow']:
        pts -= 1
    return pts
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: clean sheet minutes',
   [{'assists': 0,
     'conceded': 0,
     'goals': 1,
     'minutes': 59,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   6),
  ('partial repair probe: clean sheet minutes',
   [{'assists': 1,
     'conceded': 0,
     'goals': 0,
     'minutes': 45,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 1,
     'yellow': False}],
   2),
  ('second regression',
   [{'assists': 1,
     'conceded': 0,
     'goals': 2,
     'minutes': 46,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   14),
  ('normal control 1',
   [{'assists': 0,
     'conceded': 0,
     'goals': 1,
     'minutes': 1,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   1),
  ('normal control 2',
   [{'assists': 2,
     'conceded': 2,
     'goals': 1,
     'minutes': 1,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': True}],
   9),
  ('normal control 3',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   0),
  ('normal control 4',
   [{'assists': 0,
     'conceded': 2,
     'goals': 1,
     'minutes': 45,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': True}],
   4)],
 [('regression: clean sheet minutes',
   [{'assists': 2,
     'conceded': 0,
     'goals': 0,
     'minutes': 1,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   3),
  ('partial repair probe: clean sheet minutes',
   [{'assists': 2,
     'conceded': 0,
     'goals': 0,
     'minutes': 59,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 2,
     'yellow': False}],
   3),
  ('second regression',
   [{'assists': 1,
     'conceded': 0,
     'goals': 0,
     'minutes': 1,
     'own_goals': 0,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'GK',
     'red': True,
     'saves': 7,
     'yellow': True}],
   1),
  ('normal control 1',
   [{'assists': 2,
     'conceded': 1,
     'goals': 0,
     'minutes': 46,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   7),
  ('normal control 2',
   [{'assists': 0,
     'conceded': 2,
     'goals': 1,
     'minutes': 1,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': True}],
   3),
  ('normal control 3',
   [{'assists': 1,
     'conceded': 3,
     'goals': 2,
     'minutes': 46,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   10),
  ('normal control 4',
   [{'assists': 1,
     'conceded': 0,
     'goals': 0,
     'minutes': 90,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   9)],
 [('regression: clean sheet minutes',
   [{'assists': 2,
     'conceded': 0,
     'goals': 0,
     'minutes': 45,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 4,
     'yellow': True}],
   7),
  ('partial repair probe: clean sheet minutes',
   [{'assists': 1,
     'conceded': 0,
     'goals': 0,
     'minutes': 59,
     'own_goals': 0,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 4,
     'yellow': False}],
   3),
  ('second regression',
   [{'assists': 1,
     'conceded': 0,
     'goals': 0,
     'minutes': 45,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   0),
  ('normal control 1',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': True,
     'saves': 0,
     'yellow': False}],
   0),
  ('normal control 2',
   [{'assists': 0,
     'conceded': 4,
     'goals': 0,
     'minutes': 46,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   -1),
  ('normal control 3',
   [{'assists': 2,
     'conceded': 1,
     'goals': 0,
     'minutes': 46,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': True,
     'saves': 0,
     'yellow': True}],
   4),
  ('normal control 4',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   0)],
 [('regression: clean sheet minutes',
   [{'assists': 2,
     'conceded': 0,
     'goals': 0,
     'minutes': 45,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   5),
  ('partial repair probe: clean sheet minutes',
   [{'assists': 1,
     'conceded': 0,
     'goals': 1,
     'minutes': 45,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 0,
     'yellow': False}],
   8),
  ('second regression',
   [{'assists': 1,
     'conceded': 0,
     'goals': 0,
     'minutes': 59,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': True}],
   1),
  ('normal control 1',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 0,
     'yellow': True}],
   0),
  ('normal control 2',
   [{'assists': 0,
     'conceded': 0,
     'goals': 0,
     'minutes': 0,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   0),
  ('normal control 3',
   [{'assists': 1,
     'conceded': 1,
     'goals': 0,
     'minutes': 45,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   2),
  ('normal control 4',
   [{'assists': 0,
     'conceded': 3,
     'goals': 2,
     'minutes': 59,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': False}],
   8)],
 [('regression: clean sheet minutes',
   [{'assists': 2,
     'conceded': 0,
     'goals': 0,
     'minutes': 1,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': False,
     'saves': 3,
     'yellow': False}],
   8),
  ('partial repair probe: clean sheet minutes',
   [{'assists': 2,
     'conceded': 0,
     'goals': 1,
     'minutes': 46,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': False,
     'saves': 0,
     'yellow': False}],
   10),
  ('second regression',
   [{'assists': 2,
     'conceded': 0,
     'goals': 0,
     'minutes': 59,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'GK',
     'red': True,
     'saves': 2,
     'yellow': True}],
   4),
  ('normal control 1',
   [{'assists': 0,
     'conceded': 2,
     'goals': 0,
     'minutes': 61,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': True}],
   -3),
  ('normal control 2',
   [{'assists': 2,
     'conceded': 3,
     'goals': 0,
     'minutes': 61,
     'own_goals': 1,
     'pen_missed': 1,
     'pen_saved': 0,
     'pos': 'DEF',
     'red': False,
     'saves': 0,
     'yellow': True}],
   2),
  ('normal control 3',
   [{'assists': 1,
     'conceded': 0,
     'goals': 2,
     'minutes': 61,
     'own_goals': 0,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'MID',
     'red': True,
     'saves': 0,
     'yellow': False}],
   13),
  ('normal control 4',
   [{'assists': 2,
     'conceded': 4,
     'goals': 0,
     'minutes': 61,
     'own_goals': 1,
     'pen_missed': 0,
     'pen_saved': 0,
     'pos': 'FWD',
     'red': False,
     'saves': 0,
     'yellow': False}],
   6)]]
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 defender who played 10 minutes gets 4 clean-sheet points.

Score an association-football fantasy player. 0 minutes scores 0 (even cards shown on the bench). Appearance 1, or 2 for 60+ minutes. Goals GK/DEF 6, MID 5, FWD 4; assist 3. Clean sheet (0 conceded while on pitch, 60+ minutes) GK/DEF 4, MID 1. GK/DEF lose 1 per 2 goals conceded (floor). GK +1 per 3 saves. Penalty save 5, penalty miss -2, own goal -2. A red card is -3 and replaces any yellow (-1).

split: open-access