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

N = 1
observations = []
def solve(events):
    total = wickets = legal = extras = 0
    striker, non = 1, 2
    next_bat = 3
    for e in events:
        if e == 'W':
            wickets += 1
            legal += 1
            striker = next_bat
            next_bat += 1
            ran = 0
        elif e.startswith('wd'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1 + k
            ran = k
        elif e.startswith('nb'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1 + k
            ran = k
        elif e[0] in 'bl':
            k = int(e.lstrip('lb'))
            total += k
            extras += k
            legal += 1
            ran = k
        else:
            k = int(e)
            total += k
            legal += 1
            ran = k
        if ran % 2 == 1:
            striker, non = non, striker
        if e[:2] not in ('wd', 'nb') and legal % 6 == 0:
            striker, non = non, striker
    return [total, wickets, '%d.%d' % (legal // 6, legal % 6), extras, striker]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: no ball extras',
   (['2', 'nb', 'lb1', '3', '1', 'nb', 'b4', 'nb'],),
   [14, 0, '0.5', 8, 2]),
  ('regression: no ball extras',
   (['3', 'nb4', 'b1', '0', '1', '0', 'wd4', '4', 'nb4', '1', 'wd', '0'],),
   [26, 0, '1.2', 9, 2]),
  ('variant scenario 1', (['3', '0', '4'],), [7, 0, '0.3', 0, 2]),
  ('variant scenario 2', (['4', '0', 'W', '1'],), [5, 1, '0.4', 0, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: no ball extras',
   (['0', '1', 'nb4', '4', 'lb2', '1', 'lb2', 'wd', 'wd1', '0', '0', '6', '4', '0'],),
   [28, 0, '1.5', 8, 1]),
  ('variant scenario 1',
   (['4', '1', 'lb1', 'wd1', '1', '1', 'wd', 'wd', '2', '4', '2', '2', '1', '2', '2', '1'],),
   [28, 0, '2.1', 5, 2]),
  ('variant scenario 2', (['wd', '4', '1', '1'],), [7, 0, '0.3', 1, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: no ball extras',
   (['nb',
     '1',
     '0',
     'lb2',
     '0',
     'nb4',
     'lb1',
     'b4',
     'lb1',
     'nb1',
     'lb1',
     '4',
     'lb2',
     '0',
     '6',
     'nb1',
     '0',
     '0',
     '6',
     'lb2'],),
   [40, 0, '2.4', 17, 1]),
  ('variant scenario 1',
   (['4', '0', '0', 'wd4', '4', '0', 'lb1', '0', 'wd1', 'wd4', '4', '4', '4', '4'],),
   [37, 0, '1.5', 13, 2]),
  ('variant scenario 2',
   (['0', '4', '0', 'nb1', '1', 'b1', 'nb', 'wd4', 'wd', '2', 'wd4', '0', '1', '1', 'nb'],),
   [25, 0, '1.3', 15, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: no ball extras',
   (['0',
     'nb4',
     '3',
     '0',
     '0',
     '4',
     'W',
     'lb1',
     '4',
     'b4',
     '1',
     'wd',
     'W',
     'b4',
     '2',
     '0',
     '4',
     '1',
     'wd1',
     '4'],),
   [40, 2, '2.5', 13, 3]),
  ('variant scenario 1', (['0', '2', '1', '4', 'nb4', 'W', '0', '1', '0'],), [13, 1, '1.2', 1, 3]),
  ('variant scenario 2', (['1', '3', '4', '1', '4', 'nb', '2', '0', 'b1'],), [17, 0, '1.2', 2, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: no ball extras',
   (['1', '0', '4', '4', '1', '1', '0', '0', 'nb1', '1', 'lb2', 'lb2', 'wd1'],),
   [20, 0, '1.5', 7, 2]),
  ('regression: no ball extras',
   (['1', '2', 'nb', 'wd4', '0', '1', 'wd4', 'nb1', 'wd1', '2', 'nb'],),
   [22, 0, '0.5', 15, 1]),
  ('variant scenario 1', (['b1', '4', '1'],), [6, 0, '0.3', 1, 1]),
  ('variant scenario 2',
   (['wd', '1', 'wd1', 'W', 'b1', '2', 'nb1', '1', '1', 'wd4', '2', 'wd', '0', '0', '2'],),
   [21, 1, '1.4', 11, 2])]]
for label, args, expected in cases[N - 1]:
    check(label, run(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(events):
    total = wickets = legal = extras = 0
    striker, non = 1, 2
    next_bat = 3
    for e in events:
        if e == 'W':
            wickets += 1
            legal += 1
            striker = next_bat
            next_bat += 1
            ran = 0
        elif e.startswith('wd'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1 + k
            ran = k
        elif e.startswith('nb'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += k
            ran = k
        elif e[0] in 'bl':
            k = int(e.lstrip('lb'))
            total += k
            extras += k
            legal += 1
            ran = k
        else:
            k = int(e)
            total += k
            legal += 1
            ran = k
        if ran % 2 == 1:
            striker, non = non, striker
        if e[:2] not in ('wd', 'nb') and legal % 6 == 0:
            striker, non = non, striker
    return [total, wickets, '%d.%d' % (legal // 6, legal % 6), extras, striker]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: no ball extras',
   (['2', 'nb', 'lb1', '3', '1', 'nb', 'b4', 'nb'],),
   [14, 0, '0.5', 8, 2]),
  ('regression: no ball extras',
   (['3', 'nb4', 'b1', '0', '1', '0', 'wd4', '4', 'nb4', '1', 'wd', '0'],),
   [26, 0, '1.2', 9, 2]),
  ('variant scenario 1', (['3', '0', '4'],), [7, 0, '0.3', 0, 2]),
  ('variant scenario 2', (['4', '0', 'W', '1'],), [5, 1, '0.4', 0, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: no ball extras',
   (['0', '1', 'nb4', '4', 'lb2', '1', 'lb2', 'wd', 'wd1', '0', '0', '6', '4', '0'],),
   [28, 0, '1.5', 8, 1]),
  ('variant scenario 1',
   (['4', '1', 'lb1', 'wd1', '1', '1', 'wd', 'wd', '2', '4', '2', '2', '1', '2', '2', '1'],),
   [28, 0, '2.1', 5, 2]),
  ('variant scenario 2', (['wd', '4', '1', '1'],), [7, 0, '0.3', 1, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: no ball extras',
   (['nb',
     '1',
     '0',
     'lb2',
     '0',
     'nb4',
     'lb1',
     'b4',
     'lb1',
     'nb1',
     'lb1',
     '4',
     'lb2',
     '0',
     '6',
     'nb1',
     '0',
     '0',
     '6',
     'lb2'],),
   [40, 0, '2.4', 17, 1]),
  ('variant scenario 1',
   (['4', '0', '0', 'wd4', '4', '0', 'lb1', '0', 'wd1', 'wd4', '4', '4', '4', '4'],),
   [37, 0, '1.5', 13, 2]),
  ('variant scenario 2',
   (['0', '4', '0', 'nb1', '1', 'b1', 'nb', 'wd4', 'wd', '2', 'wd4', '0', '1', '1', 'nb'],),
   [25, 0, '1.3', 15, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: no ball extras',
   (['0',
     'nb4',
     '3',
     '0',
     '0',
     '4',
     'W',
     'lb1',
     '4',
     'b4',
     '1',
     'wd',
     'W',
     'b4',
     '2',
     '0',
     '4',
     '1',
     'wd1',
     '4'],),
   [40, 2, '2.5', 13, 3]),
  ('variant scenario 1', (['0', '2', '1', '4', 'nb4', 'W', '0', '1', '0'],), [13, 1, '1.2', 1, 3]),
  ('variant scenario 2', (['1', '3', '4', '1', '4', 'nb', '2', '0', 'b1'],), [17, 0, '1.2', 2, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: no ball extras',
   (['1', '0', '4', '4', '1', '1', '0', '0', 'nb1', '1', 'lb2', 'lb2', 'wd1'],),
   [20, 0, '1.5', 7, 2]),
  ('regression: no ball extras',
   (['1', '2', 'nb', 'wd4', '0', '1', 'wd4', 'nb1', 'wd1', '2', 'nb'],),
   [22, 0, '0.5', 15, 1]),
  ('variant scenario 1', (['b1', '4', '1'],), [6, 0, '0.3', 1, 1]),
  ('variant scenario 2',
   (['wd', '1', 'wd1', 'W', 'b1', '2', 'nb1', '1', '1', 'wd4', '2', 'wd', '0', '0', '2'],),
   [21, 1, '1.4', 11, 2])]]
for label, args, expected in cases[N - 1]:
    check(label, run(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:
Extras are inflated when runs are hit off a no-ball.

Ball-by-ball innings tally. Events: "0".."6" runs off the bat (legal ball); "W" wicket (legal ball, no runs, the new batter takes strike); "wdK" wide: 1 penalty + K run wides, all extras, not a legal ball, K runs completed; "nbK" no-ball: 1 penalty extra + K runs off the bat, not a legal ball; "bK"/"lbK" byes/leg byes: K extras on a legal ball. Batters change ends when an odd number of runs is completed, and again after the 6th legal ball of an over. Batters are numbered 1, 2 and then 3, 4, ... as they come in; batter 1 starts on strike. Return [total, wickets, overs "O.B", extras, batter on strike].

split: open-access


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

N = 1
observations = []
def solve(events):
    total = wickets = legal = extras = 0
    striker, non = 1, 2
    next_bat = 3
    for e in events:
        if e == 'W':
            wickets += 1
            legal += 1
            striker = next_bat
            next_bat += 1
            ran = 0
        elif e.startswith('wd'):
            k = int(e[2:] or 0)
            total += k
            extras += k
            ran = k
        elif e.startswith('nb'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1
            ran = k
        elif e[0] in 'bl':
            k = int(e.lstrip('lb'))
            total += k
            extras += k
            legal += 1
            ran = k
        else:
            k = int(e)
            total += k
            legal += 1
            ran = k
        if ran % 2 == 1:
            striker, non = non, striker
        if e[:2] not in ('wd', 'nb') and legal % 6 == 0:
            striker, non = non, striker
    return [total, wickets, '%d.%d' % (legal // 6, legal % 6), extras, striker]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: wide penalty',
   (['nb', 'W', '0', '0', '1', '0', 'nb1', 'wd4', 'nb', '2', '0'],),
   [12, 1, '1.1', 8, 2]),
  ('variant scenario 1', (['W', 'lb2', '6'],), [8, 1, '0.3', 2, 3]),
  ('variant scenario 2',
   (['lb2', '0', 'nb4', '0', 'wd4', 'nb4', 'nb4', 'nb4', '0', '4', '4', 'wd'],),
   [36, 0, '1.0', 12, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: wide penalty', (['0', '1', 'wd4', '3', '0', '0', '6'],), [15, 0, '1.0', 5, 2]),
  ('variant scenario 1', (['1', '4', '0', '4', '4', 'b1'],), [14, 0, '1.0', 1, 2]),
  ('variant scenario 2', (['4', '1', 'b1', '4', 'nb1', 'b4', '0', 'b1'],), [17, 0, '1.1', 7, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: wide penalty',
   (['wd',
     '0',
     'nb4',
     'wd1',
     'b4',
     '1',
     '0',
     'b4',
     'nb4',
     '4',
     'nb1',
     '4',
     '1',
     '0',
     '0',
     'b1',
     '4',
     '0',
     'lb1'],),
   [39, 0, '2.2', 16, 1]),
  ('variant scenario 1',
   (['4',
     'lb2',
     '4',
     '1',
     '4',
     '0',
     '6',
     'lb2',
     'nb4',
     '1',
     'lb2',
     'b4',
     '0',
     '0',
     '2',
     '0',
     '0',
     '0'],),
   [37, 0, '2.5', 11, 1]),
  ('variant scenario 2',
   (['1',
     '0',
     '2',
     'nb4',
     '1',
     'nb',
     'nb4',
     '0',
     '1',
     'nb4',
     '2',
     'lb1',
     'nb',
     'lb1',
     'b4',
     '0',
     '0',
     '2',
     'b1',
     'lb1'],),
   [34, 0, '2.3', 13, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: wide penalty',
   (['4',
     'nb4',
     '0',
     'lb2',
     'W',
     '0',
     '0',
     'W',
     '1',
     '0',
     'W',
     '0',
     'wd1',
     '2',
     '4',
     '1',
     '0',
     '0',
     'wd',
     'W',
     '1',
     '0',
     '4',
     'lb1'],),
   [28, 4, '3.3', 7, 5]),
  ('variant scenario 1', (['wd', '4', '4', '4', '0', 'nb', '6'],), [20, 0, '0.5', 2, 1]),
  ('variant scenario 2', (['0', '0', 'nb4', '2', '0', 'nb'],), [8, 0, '0.4', 2, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: wide penalty',
   (['lb2',
     '0',
     'W',
     '2',
     '1',
     'nb4',
     '2',
     '0',
     '0',
     '1',
     '6',
     'b4',
     'wd',
     'nb',
     '0',
     'W',
     'nb1',
     'b4'],),
   [31, 2, '2.2', 14, 2]),
  ('variant scenario 1', (['1', 'wd4', '0', '4', '1', '0'],), [11, 0, '0.5', 5, 1]),
  ('variant scenario 2',
   (['1',
     '0',
     '1',
     '1',
     '6',
     '2',
     '2',
     'wd',
     'nb4',
     'lb1',
     'nb4',
     'nb1',
     '0',
     'lb1',
     '1',
     '0',
     '1',
     '0',
     '1',
     '1',
     'nb1',
     '1',
     '0',
     '1',
     'b1',
     '4',
     '1',
     '4'],),
   [46, 0, '3.5', 8, 1])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(events):
    total = wickets = legal = extras = 0
    striker, non = 1, 2
    next_bat = 3
    for e in events:
        if e == 'W':
            wickets += 1
            legal += 1
            striker = next_bat
            next_bat += 1
            ran = 0
        elif e.startswith('wd'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += k
            ran = k
        elif e.startswith('nb'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1
            ran = k
        elif e[0] in 'bl':
            k = int(e.lstrip('lb'))
            total += k
            extras += k
            legal += 1
            ran = k
        else:
            k = int(e)
            total += k
            legal += 1
            ran = k
        if ran % 2 == 1:
            striker, non = non, striker
        if e[:2] not in ('wd', 'nb') and legal % 6 == 0:
            striker, non = non, striker
    return [total, wickets, '%d.%d' % (legal // 6, legal % 6), extras, striker]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: wide penalty',
   (['nb', 'W', '0', '0', '1', '0', 'nb1', 'wd4', 'nb', '2', '0'],),
   [12, 1, '1.1', 8, 2]),
  ('variant scenario 1', (['W', 'lb2', '6'],), [8, 1, '0.3', 2, 3]),
  ('variant scenario 2',
   (['lb2', '0', 'nb4', '0', 'wd4', 'nb4', 'nb4', 'nb4', '0', '4', '4', 'wd'],),
   [36, 0, '1.0', 12, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: wide penalty', (['0', '1', 'wd4', '3', '0', '0', '6'],), [15, 0, '1.0', 5, 2]),
  ('variant scenario 1', (['1', '4', '0', '4', '4', 'b1'],), [14, 0, '1.0', 1, 2]),
  ('variant scenario 2', (['4', '1', 'b1', '4', 'nb1', 'b4', '0', 'b1'],), [17, 0, '1.1', 7, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: wide penalty',
   (['wd',
     '0',
     'nb4',
     'wd1',
     'b4',
     '1',
     '0',
     'b4',
     'nb4',
     '4',
     'nb1',
     '4',
     '1',
     '0',
     '0',
     'b1',
     '4',
     '0',
     'lb1'],),
   [39, 0, '2.2', 16, 1]),
  ('variant scenario 1',
   (['4',
     'lb2',
     '4',
     '1',
     '4',
     '0',
     '6',
     'lb2',
     'nb4',
     '1',
     'lb2',
     'b4',
     '0',
     '0',
     '2',
     '0',
     '0',
     '0'],),
   [37, 0, '2.5', 11, 1]),
  ('variant scenario 2',
   (['1',
     '0',
     '2',
     'nb4',
     '1',
     'nb',
     'nb4',
     '0',
     '1',
     'nb4',
     '2',
     'lb1',
     'nb',
     'lb1',
     'b4',
     '0',
     '0',
     '2',
     'b1',
     'lb1'],),
   [34, 0, '2.3', 13, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: wide penalty',
   (['4',
     'nb4',
     '0',
     'lb2',
     'W',
     '0',
     '0',
     'W',
     '1',
     '0',
     'W',
     '0',
     'wd1',
     '2',
     '4',
     '1',
     '0',
     '0',
     'wd',
     'W',
     '1',
     '0',
     '4',
     'lb1'],),
   [28, 4, '3.3', 7, 5]),
  ('variant scenario 1', (['wd', '4', '4', '4', '0', 'nb', '6'],), [20, 0, '0.5', 2, 1]),
  ('variant scenario 2', (['0', '0', 'nb4', '2', '0', 'nb'],), [8, 0, '0.4', 2, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: wide penalty',
   (['lb2',
     '0',
     'W',
     '2',
     '1',
     'nb4',
     '2',
     '0',
     '0',
     '1',
     '6',
     'b4',
     'wd',
     'nb',
     '0',
     'W',
     'nb1',
     'b4'],),
   [31, 2, '2.2', 14, 2]),
  ('variant scenario 1', (['1', 'wd4', '0', '4', '1', '0'],), [11, 0, '0.5', 5, 1]),
  ('variant scenario 2',
   (['1',
     '0',
     '1',
     '1',
     '6',
     '2',
     '2',
     'wd',
     'nb4',
     'lb1',
     'nb4',
     'nb1',
     '0',
     'lb1',
     '1',
     '0',
     '1',
     '0',
     '1',
     '1',
     'nb1',
     '1',
     '0',
     '1',
     'b1',
     '4',
     '1',
     '4'],),
   [46, 0, '3.5', 8, 1])]]
for label, args, expected in cases[N - 1]:
    check(label, run(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 plain wide adds nothing to the total.

Ball-by-ball innings tally. Events: "0".."6" runs off the bat (legal ball); "W" wicket (legal ball, no runs, the new batter takes strike); "wdK" wide: 1 penalty + K run wides, all extras, not a legal ball, K runs completed; "nbK" no-ball: 1 penalty extra + K runs off the bat, not a legal ball; "bK"/"lbK" byes/leg byes: K extras on a legal ball. Batters change ends when an odd number of runs is completed, and again after the 6th legal ball of an over. Batters are numbered 1, 2 and then 3, 4, ... as they come in; batter 1 starts on strike. Return [total, wickets, overs "O.B", extras, batter on strike].

split: open-access


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

N = 1
observations = []
def solve(events):
    total = wickets = legal = extras = 0
    striker, non = 1, 2
    next_bat = 3
    for e in events:
        if e == 'W':
            wickets += 1
            legal += 1
            striker = next_bat
            next_bat += 1
            ran = 0
        elif e.startswith('wd'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1 + k
            ran = k
        elif e.startswith('nb'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1
            ran = k
        elif e[0] in 'bl':
            k = int(e.lstrip('lb'))
            total += k
            extras += k
            legal += 1
            ran = k
        else:
            k = int(e)
            total += k
            legal += 1
            ran = k
        if ran % 2 == 1:
            striker, non = non, striker
    return [total, wickets, '%d.%d' % (legal // 6, legal % 6), extras, striker]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: over end rotation', (['nb', '2', '0', '4'],), [7, 0, '0.3', 1, 1]),
  ('regression: over end rotation', (['wd', '0', '1', '4', '0', '1', '0'],), [7, 0, '1.0', 1, 2]),
  ('variant scenario 1', (['b1', '4', '1'],), [6, 0, '0.3', 1, 1]),
  ('variant scenario 2',
   (['1', '4', '4', '0', '0', '2', '4', 'b1', '0', 'wd1'],),
   [18, 0, '1.3', 3, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: over end rotation',
   (['nb4', '1', '0', 'nb1', '1', 'W', '0', '0', 'wd4', '1', 'b4', '1'],),
   [20, 1, '1.3', 11, 1]),
  ('variant scenario 1',
   (['1', '3', '4', 'nb1', 'wd', '4', '0', '4', '1', '1', 'wd1', '1', 'nb', 'lb2'],),
   [27, 0, '1.4', 7, 1]),
  ('variant scenario 2', (['6', 'lb2', '1'],), [9, 0, '0.3', 2, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: over end rotation',
   (['0', 'b1', 'b1', '0', '1', '1', 'b4', '0', 'nb4', '0'],),
   [13, 0, '1.3', 7, 2]),
  ('regression: over end rotation',
   (['wd1',
     '2',
     'b1',
     'wd1',
     'nb',
     '4',
     '1',
     'wd',
     '1',
     '0',
     'wd1',
     'wd',
     '2',
     '0',
     'nb4',
     '1',
     '1',
     'wd',
     'wd1',
     '6'],),
   [36, 0, '1.5', 14, 1]),
  ('variant scenario 1',
   (['1', '2', 'nb1', '3', '1', 'nb', '0', 'W', '4', '0', '1', '0', 'b1', 'nb', '1', '3', 'lb1'],),
   [22, 1, '2.2', 5, 2]),
  ('variant scenario 2',
   (['1', '0', '1', '1', '2', 'b1', '4', '1', 'nb', '2', '4', '4', '6', 'lb2', 'wd4', 'W'],),
   [35, 1, '2.2', 9, 3])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: over end rotation',
   (['4',
     'nb',
     '4',
     '3',
     'b4',
     '1',
     '1',
     'W',
     'nb4',
     '6',
     '1',
     '0',
     'b4',
     'nb4',
     '2',
     '1',
     '0',
     'W',
     '2',
     '0',
     'lb1',
     '1'],),
   [46, 2, '3.1', 12, 3]),
  ('regression: over end rotation',
   (['wd',
     '1',
     'nb4',
     'wd1',
     '1',
     'wd',
     '2',
     '1',
     'nb4',
     '1',
     '1',
     '4',
     'wd4',
     '4',
     '6',
     '0',
     'wd1',
     '6'],),
   [48, 0, '1.5', 13, 1]),
  ('variant scenario 1',
   (['W', 'wd1', '3', 'wd4', '4', 'b1', '3', 'wd', 'b1'],),
   [20, 1, '1.0', 10, 3]),
  ('variant scenario 2',
   (['0',
     '6',
     'b1',
     'wd1',
     'lb2',
     'lb1',
     'lb1',
     'nb1',
     '0',
     'W',
     '4',
     'lb1',
     '0',
     '1',
     'nb4',
     '1',
     '0'],),
   [27, 1, '2.2', 10, 3])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: over end rotation',
   (['lb2',
     '4',
     '2',
     '4',
     '2',
     'b4',
     'wd',
     '1',
     'wd4',
     '4',
     'nb1',
     '6',
     '6',
     'nb',
     '1',
     'nb4',
     '0',
     '1',
     '4',
     '1',
     'nb1',
     '2',
     'nb'],),
   [61, 0, '2.4', 17, 1]),
  ('regression: over end rotation',
   (['4', '4', 'W', '2', 'nb4', '0', 'nb4', '6'],),
   [26, 1, '1.0', 2, 2]),
  ('variant scenario 1',
   (['lb1',
     'wd4',
     '0',
     '6',
     'W',
     '1',
     '2',
     'b1',
     '0',
     '1',
     'wd4',
     '0',
     '1',
     '0',
     '1',
     'wd',
     '1',
     '3',
     '6',
     '2',
     '0',
     'W',
     'wd',
     'b4'],),
   [42, 2, '3.2', 18, 4]),
  ('variant scenario 2', (['0', '1', '4', 'wd', '1', 'b1'],), [8, 0, '0.5', 2, 2])]]
for label, args, expected in cases[N - 1]:
    check(label, run(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(events):
    total = wickets = legal = extras = 0
    striker, non = 1, 2
    next_bat = 3
    for e in events:
        if e == 'W':
            wickets += 1
            legal += 1
            striker = next_bat
            next_bat += 1
            ran = 0
        elif e.startswith('wd'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1 + k
            ran = k
        elif e.startswith('nb'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1
            ran = k
        elif e[0] in 'bl':
            k = int(e.lstrip('lb'))
            total += k
            extras += k
            legal += 1
            ran = k
        else:
            k = int(e)
            total += k
            legal += 1
            ran = k
        if ran % 2 == 1:
            striker, non = non, striker
        if legal % 6 == 0:
            striker, non = non, striker
    return [total, wickets, '%d.%d' % (legal // 6, legal % 6), extras, striker]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: over end rotation', (['nb', '2', '0', '4'],), [7, 0, '0.3', 1, 1]),
  ('regression: over end rotation', (['wd', '0', '1', '4', '0', '1', '0'],), [7, 0, '1.0', 1, 2]),
  ('variant scenario 1', (['b1', '4', '1'],), [6, 0, '0.3', 1, 1]),
  ('variant scenario 2',
   (['1', '4', '4', '0', '0', '2', '4', 'b1', '0', 'wd1'],),
   [18, 0, '1.3', 3, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: over end rotation',
   (['nb4', '1', '0', 'nb1', '1', 'W', '0', '0', 'wd4', '1', 'b4', '1'],),
   [20, 1, '1.3', 11, 1]),
  ('variant scenario 1',
   (['1', '3', '4', 'nb1', 'wd', '4', '0', '4', '1', '1', 'wd1', '1', 'nb', 'lb2'],),
   [27, 0, '1.4', 7, 1]),
  ('variant scenario 2', (['6', 'lb2', '1'],), [9, 0, '0.3', 2, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: over end rotation',
   (['0', 'b1', 'b1', '0', '1', '1', 'b4', '0', 'nb4', '0'],),
   [13, 0, '1.3', 7, 2]),
  ('regression: over end rotation',
   (['wd1',
     '2',
     'b1',
     'wd1',
     'nb',
     '4',
     '1',
     'wd',
     '1',
     '0',
     'wd1',
     'wd',
     '2',
     '0',
     'nb4',
     '1',
     '1',
     'wd',
     'wd1',
     '6'],),
   [36, 0, '1.5', 14, 1]),
  ('variant scenario 1',
   (['1', '2', 'nb1', '3', '1', 'nb', '0', 'W', '4', '0', '1', '0', 'b1', 'nb', '1', '3', 'lb1'],),
   [22, 1, '2.2', 5, 2]),
  ('variant scenario 2',
   (['1', '0', '1', '1', '2', 'b1', '4', '1', 'nb', '2', '4', '4', '6', 'lb2', 'wd4', 'W'],),
   [35, 1, '2.2', 9, 3])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: over end rotation',
   (['4',
     'nb',
     '4',
     '3',
     'b4',
     '1',
     '1',
     'W',
     'nb4',
     '6',
     '1',
     '0',
     'b4',
     'nb4',
     '2',
     '1',
     '0',
     'W',
     '2',
     '0',
     'lb1',
     '1'],),
   [46, 2, '3.1', 12, 3]),
  ('regression: over end rotation',
   (['wd',
     '1',
     'nb4',
     'wd1',
     '1',
     'wd',
     '2',
     '1',
     'nb4',
     '1',
     '1',
     '4',
     'wd4',
     '4',
     '6',
     '0',
     'wd1',
     '6'],),
   [48, 0, '1.5', 13, 1]),
  ('variant scenario 1',
   (['W', 'wd1', '3', 'wd4', '4', 'b1', '3', 'wd', 'b1'],),
   [20, 1, '1.0', 10, 3]),
  ('variant scenario 2',
   (['0',
     '6',
     'b1',
     'wd1',
     'lb2',
     'lb1',
     'lb1',
     'nb1',
     '0',
     'W',
     '4',
     'lb1',
     '0',
     '1',
     'nb4',
     '1',
     '0'],),
   [27, 1, '2.2', 10, 3])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: over end rotation',
   (['lb2',
     '4',
     '2',
     '4',
     '2',
     'b4',
     'wd',
     '1',
     'wd4',
     '4',
     'nb1',
     '6',
     '6',
     'nb',
     '1',
     'nb4',
     '0',
     '1',
     '4',
     '1',
     'nb1',
     '2',
     'nb'],),
   [61, 0, '2.4', 17, 1]),
  ('regression: over end rotation',
   (['4', '4', 'W', '2', 'nb4', '0', 'nb4', '6'],),
   [26, 1, '1.0', 2, 2]),
  ('variant scenario 1',
   (['lb1',
     'wd4',
     '0',
     '6',
     'W',
     '1',
     '2',
     'b1',
     '0',
     '1',
     'wd4',
     '0',
     '1',
     '0',
     '1',
     'wd',
     '1',
     '3',
     '6',
     '2',
     '0',
     'W',
     'wd',
     'b4'],),
   [42, 2, '3.2', 18, 4]),
  ('variant scenario 2', (['0', '1', '4', 'wd', '1', 'b1'],), [8, 0, '0.5', 2, 2])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The same batter is shown on strike for the first ball of the new over.

Ball-by-ball innings tally. Events: "0".."6" runs off the bat (legal ball); "W" wicket (legal ball, no runs, the new batter takes strike); "wdK" wide: 1 penalty + K run wides, all extras, not a legal ball, K runs completed; "nbK" no-ball: 1 penalty extra + K runs off the bat, not a legal ball; "bK"/"lbK" byes/leg byes: K extras on a legal ball. Batters change ends when an odd number of runs is completed, and again after the 6th legal ball of an over. Batters are numbered 1, 2 and then 3, 4, ... as they come in; batter 1 starts on strike. Return [total, wickets, overs "O.B", extras, batter on strike].

split: open-access


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

N = 1
observations = []
def solve(events):
    total = wickets = legal = extras = 0
    striker, non = 1, 2
    next_bat = 3
    for e in events:
        if e == 'W':
            wickets += 1
            legal += 1
            striker = next_bat
            next_bat += 1
            ran = 0
        elif e.startswith('wd'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1 + k
            ran = 0
        elif e.startswith('nb'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1
            ran = k
        elif e[0] in 'bl':
            k = int(e.lstrip('lb'))
            total += k
            extras += k
            legal += 1
            ran = k
        else:
            k = int(e)
            total += k
            legal += 1
            ran = k
        if ran % 2 == 1:
            striker, non = non, striker
        if e[:2] not in ('wd', 'nb') and legal % 6 == 0:
            striker, non = non, striker
    return [total, wickets, '%d.%d' % (legal // 6, legal % 6), extras, striker]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: run wide strike',
   (['0', 'lb1', '1', '1', '4', '1', '0', 'wd', '0', '0', '4'],),
   [13, 0, '1.4', 2, 2]),
  ('regression: run wide strike',
   (['wd', '1', 'nb', '2', '2', '6', '0', 'wd1', '0', '1', '6'],),
   [22, 0, '1.2', 4, 1]),
  ('variant scenario 1', (['b4', '4', '2', 'b4'],), [14, 0, '0.4', 8, 1]),
  ('variant scenario 2', (['nb1', '1', '0', '4', '1', '4'],), [12, 0, '0.5', 1, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: run wide strike',
   (['4', 'wd1', '1', '4', '0', '2', 'nb1', '1', 'lb2', '1'],),
   [19, 0, '1.2', 5, 1]),
  ('variant scenario 1',
   (['4', '1', 'nb', 'wd1', '2', '1', 'wd1', '0', 'nb4', '0', 'lb1', 'b4'],),
   [23, 0, '1.2', 11, 1]),
  ('variant scenario 2', (['1', '1', 'wd', '1', 'W', '2'],), [6, 1, '0.5', 1, 3])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: run wide strike', (['0', 'wd1', '1', '2'],), [5, 0, '0.3', 2, 1]),
  ('variant scenario 1',
   (['4', 'wd4', '6', 'nb', '1', '6', 'wd', '0', '1', '0', 'nb', 'wd4'],),
   [31, 0, '1.1', 13, 2]),
  ('variant scenario 2',
   (['3', '0', '1', 'wd', '0', 'wd', '1', '3', 'b1', '2', '3', '1', '0', '4'],),
   [21, 0, '2.0', 3, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: run wide strike',
   (['6',
     '1',
     '0',
     '4',
     '0',
     'wd4',
     '6',
     '1',
     'nb1',
     '1',
     '1',
     'wd1',
     'wd',
     '0',
     'wd',
     '6',
     'nb1',
     '1',
     '0'],),
   [40, 0, '2.1', 11, 1]),
  ('regression: run wide strike',
   (['1',
     'b1',
     '2',
     '2',
     '1',
     '1',
     '0',
     '4',
     'nb',
     'wd1',
     '6',
     '6',
     'nb4',
     'nb4',
     'wd4',
     'lb1',
     '0',
     'nb',
     'wd1',
     '6'],),
   [52, 0, '2.1', 15, 2]),
  ('variant scenario 1',
   (['0', '0', 'wd4', 'wd', 'b1', '2', '1', '0', '6', '1', 'nb', '1', '1', '4', '1'],),
   [25, 0, '2.0', 8, 1]),
  ('variant scenario 2', (['2', '1', '6', '1'],), [10, 0, '0.4', 0, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: run wide strike',
   (['0', 'wd', '4', '0', 'lb2', '1', '2', 'nb4', '1', 'nb', 'nb4', '1', 'wd1'],),
   [25, 0, '1.2', 8, 2]),
  ('regression: run wide strike',
   (['lb1',
     'b4',
     'wd1',
     'W',
     'wd1',
     '2',
     'wd',
     'lb1',
     '0',
     '0',
     'nb1',
     'nb4',
     'wd1',
     '2',
     '6',
     'nb1'],),
   [32, 1, '1.3', 16, 3]),
  ('variant scenario 1',
   (['4', '1', 'lb2', 'lb2', 'nb4', '1', '6', '6', '1', 'lb1', 'wd1'],),
   [31, 0, '1.3', 8, 1]),
  ('variant scenario 2', (['0', '0', 'wd1', '0', 'nb', 'b1'],), [4, 0, '0.4', 4, 1])]]
for label, args, expected in cases[N - 1]:
    check(label, run(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(events):
    total = wickets = legal = extras = 0
    striker, non = 1, 2
    next_bat = 3
    for e in events:
        if e == 'W':
            wickets += 1
            legal += 1
            striker = next_bat
            next_bat += 1
            ran = 0
        elif e.startswith('wd'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1 + k
            ran = 1 + k
        elif e.startswith('nb'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1
            ran = k
        elif e[0] in 'bl':
            k = int(e.lstrip('lb'))
            total += k
            extras += k
            legal += 1
            ran = k
        else:
            k = int(e)
            total += k
            legal += 1
            ran = k
        if ran % 2 == 1:
            striker, non = non, striker
        if e[:2] not in ('wd', 'nb') and legal % 6 == 0:
            striker, non = non, striker
    return [total, wickets, '%d.%d' % (legal // 6, legal % 6), extras, striker]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: run wide strike',
   (['0', 'lb1', '1', '1', '4', '1', '0', 'wd', '0', '0', '4'],),
   [13, 0, '1.4', 2, 2]),
  ('regression: run wide strike',
   (['wd', '1', 'nb', '2', '2', '6', '0', 'wd1', '0', '1', '6'],),
   [22, 0, '1.2', 4, 1]),
  ('variant scenario 1', (['b4', '4', '2', 'b4'],), [14, 0, '0.4', 8, 1]),
  ('variant scenario 2', (['nb1', '1', '0', '4', '1', '4'],), [12, 0, '0.5', 1, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: run wide strike',
   (['4', 'wd1', '1', '4', '0', '2', 'nb1', '1', 'lb2', '1'],),
   [19, 0, '1.2', 5, 1]),
  ('variant scenario 1',
   (['4', '1', 'nb', 'wd1', '2', '1', 'wd1', '0', 'nb4', '0', 'lb1', 'b4'],),
   [23, 0, '1.2', 11, 1]),
  ('variant scenario 2', (['1', '1', 'wd', '1', 'W', '2'],), [6, 1, '0.5', 1, 3])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: run wide strike', (['0', 'wd1', '1', '2'],), [5, 0, '0.3', 2, 1]),
  ('variant scenario 1',
   (['4', 'wd4', '6', 'nb', '1', '6', 'wd', '0', '1', '0', 'nb', 'wd4'],),
   [31, 0, '1.1', 13, 2]),
  ('variant scenario 2',
   (['3', '0', '1', 'wd', '0', 'wd', '1', '3', 'b1', '2', '3', '1', '0', '4'],),
   [21, 0, '2.0', 3, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: run wide strike',
   (['6',
     '1',
     '0',
     '4',
     '0',
     'wd4',
     '6',
     '1',
     'nb1',
     '1',
     '1',
     'wd1',
     'wd',
     '0',
     'wd',
     '6',
     'nb1',
     '1',
     '0'],),
   [40, 0, '2.1', 11, 1]),
  ('regression: run wide strike',
   (['1',
     'b1',
     '2',
     '2',
     '1',
     '1',
     '0',
     '4',
     'nb',
     'wd1',
     '6',
     '6',
     'nb4',
     'nb4',
     'wd4',
     'lb1',
     '0',
     'nb',
     'wd1',
     '6'],),
   [52, 0, '2.1', 15, 2]),
  ('variant scenario 1',
   (['0', '0', 'wd4', 'wd', 'b1', '2', '1', '0', '6', '1', 'nb', '1', '1', '4', '1'],),
   [25, 0, '2.0', 8, 1]),
  ('variant scenario 2', (['2', '1', '6', '1'],), [10, 0, '0.4', 0, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: run wide strike',
   (['0', 'wd', '4', '0', 'lb2', '1', '2', 'nb4', '1', 'nb', 'nb4', '1', 'wd1'],),
   [25, 0, '1.2', 8, 2]),
  ('regression: run wide strike',
   (['lb1',
     'b4',
     'wd1',
     'W',
     'wd1',
     '2',
     'wd',
     'lb1',
     '0',
     '0',
     'nb1',
     'nb4',
     'wd1',
     '2',
     '6',
     'nb1'],),
   [32, 1, '1.3', 16, 3]),
  ('variant scenario 1',
   (['4', '1', 'lb2', 'lb2', 'nb4', '1', '6', '6', '1', 'lb1', 'wd1'],),
   [31, 0, '1.3', 8, 1]),
  ('variant scenario 2', (['0', '0', 'wd1', '0', 'nb', 'b1'],), [4, 0, '0.4', 4, 1])]]
for label, args, expected in cases[N - 1]:
    check(label, run(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:
After the batters run one on a wide the wrong batter is on strike.

Ball-by-ball innings tally. Events: "0".."6" runs off the bat (legal ball); "W" wicket (legal ball, no runs, the new batter takes strike); "wdK" wide: 1 penalty + K run wides, all extras, not a legal ball, K runs completed; "nbK" no-ball: 1 penalty extra + K runs off the bat, not a legal ball; "bK"/"lbK" byes/leg byes: K extras on a legal ball. Batters change ends when an odd number of runs is completed, and again after the 6th legal ball of an over. Batters are numbered 1, 2 and then 3, 4, ... as they come in; batter 1 starts on strike. Return [total, wickets, overs "O.B", extras, batter on strike].

split: open-access


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

N = 1
observations = []
def solve(events):
    total = wickets = legal = extras = 0
    striker, non = 1, 2
    next_bat = 3
    for e in events:
        if e == 'W':
            wickets += 1
            legal += 1
            next_bat += 1
            ran = 0
        elif e.startswith('wd'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1 + k
            ran = k
        elif e.startswith('nb'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1
            ran = k
        elif e[0] in 'bl':
            k = int(e.lstrip('lb'))
            total += k
            extras += k
            legal += 1
            ran = k
        else:
            k = int(e)
            total += k
            legal += 1
            ran = k
        if ran % 2 == 1:
            striker, non = non, striker
        if e[:2] not in ('wd', 'nb') and legal % 6 == 0:
            striker, non = non, striker
    return [total, wickets, '%d.%d' % (legal // 6, legal % 6), extras, striker]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: incoming batter end', (['W', 'wd', 'wd', 'b1', '1', 'nb'],), [5, 1, '0.3', 4, 3]),
  ('variant scenario 1', (['1', '4', 'wd1', '0', 'wd', '0', '4', '1'],), [13, 0, '1.0', 3, 1]),
  ('variant scenario 2', (['3', 'b4', '1', 'wd1', '1'],), [11, 0, '0.4', 6, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: incoming batter end',
   (['0', '6', '0', '1', '2', 'wd1', '2', '1', '6', 'nb1', 'wd', 'wd1', 'W', 'W'],),
   [25, 2, '1.4', 6, 4]),
  ('variant scenario 1', (['0', 'wd4', 'wd4', '1', '1', 'lb2', '2'],), [16, 0, '0.5', 12, 1]),
  ('variant scenario 2', (['0', '0', '4', '0', '0', '1'],), [5, 0, '1.0', 0, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: incoming batter end',
   (['wd4', '2', '1', '0', '6', 'W', '1', '0'],),
   [15, 1, '1.1', 5, 3]),
  ('variant scenario 1', (['4', '1', '1'],), [6, 0, '0.3', 0, 1]),
  ('variant scenario 2',
   (['1',
     'nb',
     '3',
     '4',
     'lb2',
     '2',
     'b1',
     '0',
     '4',
     '6',
     '1',
     'b1',
     '4',
     '3',
     'lb1',
     'nb1',
     'lb2'],),
   [38, 0, '2.3', 9, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: incoming batter end',
   (['0',
     '4',
     'nb1',
     '1',
     'nb4',
     'wd1',
     'nb1',
     '6',
     'W',
     '1',
     'nb',
     '3',
     'wd1',
     'b4',
     '0',
     'b4',
     '1'],),
   [38, 1, '1.5', 16, 2]),
  ('regression: incoming batter end',
   (['nb4', '0', 'lb2', '6', '3', '4', 'W', 'lb1'],),
   [21, 1, '1.1', 4, 3]),
  ('variant scenario 1',
   (['nb', 'nb', 'wd4', '1', '1', '0', 'nb1', '4', 'b4', 'nb4'],),
   [24, 0, '0.5', 13, 2]),
  ('variant scenario 2',
   (['4', '1', 'lb1', '2', '1', 'b1', '0', '0', 'wd', 'nb1', '1', '0', '2', '4', 'nb4'],),
   [25, 0, '2.0', 5, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: incoming batter end', (['wd1', '2', '0', 'W', 'b4', 'b1'],), [9, 1, '0.5', 7, 1]),
  ('regression: incoming batter end',
   (['b4', 'W', '0', '1', '2', 'W', '1', '2', 'wd', '1', '0', '2', '2', '6', 'wd', '0'],),
   [23, 2, '2.2', 6, 4]),
  ('variant scenario 1', (['4', '2', '4', '6', '2', '1'],), [19, 0, '1.0', 0, 1]),
  ('variant scenario 2',
   (['wd4', '1', 'wd1', '0', '6', '1', 'nb', '0', 'b4', '4', '0', 'wd', '4', 'nb'],),
   [30, 0, '1.3', 14, 1])]]
for label, args, expected in cases[N - 1]:
    check(label, run(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(events):
    total = wickets = legal = extras = 0
    striker, non = 1, 2
    next_bat = 3
    for e in events:
        if e == 'W':
            wickets += 1
            legal += 1
            non = next_bat
            next_bat += 1
            ran = 0
        elif e.startswith('wd'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1 + k
            ran = k
        elif e.startswith('nb'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1
            ran = k
        elif e[0] in 'bl':
            k = int(e.lstrip('lb'))
            total += k
            extras += k
            legal += 1
            ran = k
        else:
            k = int(e)
            total += k
            legal += 1
            ran = k
        if ran % 2 == 1:
            striker, non = non, striker
        if e[:2] not in ('wd', 'nb') and legal % 6 == 0:
            striker, non = non, striker
    return [total, wickets, '%d.%d' % (legal // 6, legal % 6), extras, striker]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: incoming batter end', (['W', 'wd', 'wd', 'b1', '1', 'nb'],), [5, 1, '0.3', 4, 3]),
  ('variant scenario 1', (['1', '4', 'wd1', '0', 'wd', '0', '4', '1'],), [13, 0, '1.0', 3, 1]),
  ('variant scenario 2', (['3', 'b4', '1', 'wd1', '1'],), [11, 0, '0.4', 6, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: incoming batter end',
   (['0', '6', '0', '1', '2', 'wd1', '2', '1', '6', 'nb1', 'wd', 'wd1', 'W', 'W'],),
   [25, 2, '1.4', 6, 4]),
  ('variant scenario 1', (['0', 'wd4', 'wd4', '1', '1', 'lb2', '2'],), [16, 0, '0.5', 12, 1]),
  ('variant scenario 2', (['0', '0', '4', '0', '0', '1'],), [5, 0, '1.0', 0, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: incoming batter end',
   (['wd4', '2', '1', '0', '6', 'W', '1', '0'],),
   [15, 1, '1.1', 5, 3]),
  ('variant scenario 1', (['4', '1', '1'],), [6, 0, '0.3', 0, 1]),
  ('variant scenario 2',
   (['1',
     'nb',
     '3',
     '4',
     'lb2',
     '2',
     'b1',
     '0',
     '4',
     '6',
     '1',
     'b1',
     '4',
     '3',
     'lb1',
     'nb1',
     'lb2'],),
   [38, 0, '2.3', 9, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: incoming batter end',
   (['0',
     '4',
     'nb1',
     '1',
     'nb4',
     'wd1',
     'nb1',
     '6',
     'W',
     '1',
     'nb',
     '3',
     'wd1',
     'b4',
     '0',
     'b4',
     '1'],),
   [38, 1, '1.5', 16, 2]),
  ('regression: incoming batter end',
   (['nb4', '0', 'lb2', '6', '3', '4', 'W', 'lb1'],),
   [21, 1, '1.1', 4, 3]),
  ('variant scenario 1',
   (['nb', 'nb', 'wd4', '1', '1', '0', 'nb1', '4', 'b4', 'nb4'],),
   [24, 0, '0.5', 13, 2]),
  ('variant scenario 2',
   (['4', '1', 'lb1', '2', '1', 'b1', '0', '0', 'wd', 'nb1', '1', '0', '2', '4', 'nb4'],),
   [25, 0, '2.0', 5, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: incoming batter end', (['wd1', '2', '0', 'W', 'b4', 'b1'],), [9, 1, '0.5', 7, 1]),
  ('regression: incoming batter end',
   (['b4', 'W', '0', '1', '2', 'W', '1', '2', 'wd', '1', '0', '2', '2', '6', 'wd', '0'],),
   [23, 2, '2.2', 6, 4]),
  ('variant scenario 1', (['4', '2', '4', '6', '2', '1'],), [19, 0, '1.0', 0, 1]),
  ('variant scenario 2',
   (['wd4', '1', 'wd1', '0', '6', '1', 'nb', '0', 'b4', '4', '0', 'wd', '4', 'nb'],),
   [30, 0, '1.3', 14, 1])]]
for label, args, expected in cases[N - 1]:
    check(label, run(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:
After a dismissal the dismissed batter number stays on strike.

Ball-by-ball innings tally. Events: "0".."6" runs off the bat (legal ball); "W" wicket (legal ball, no runs, the new batter takes strike); "wdK" wide: 1 penalty + K run wides, all extras, not a legal ball, K runs completed; "nbK" no-ball: 1 penalty extra + K runs off the bat, not a legal ball; "bK"/"lbK" byes/leg byes: K extras on a legal ball. Batters change ends when an odd number of runs is completed, and again after the 6th legal ball of an over. Batters are numbered 1, 2 and then 3, 4, ... as they come in; batter 1 starts on strike. Return [total, wickets, overs "O.B", extras, batter on strike].

split: open-access


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

N = 1
observations = []
def solve(events):
    total = wickets = legal = extras = 0
    striker, non = 1, 2
    next_bat = 3
    for e in events:
        if e == 'W':
            wickets += 1
            legal += 1
            striker = next_bat
            next_bat += 1
            ran = 0
        elif e.startswith('wd'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1 + k
            ran = k
        elif e.startswith('nb'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1
            ran = k
        elif e[0] in 'bl':
            k = int(e.lstrip('lb'))
            total += k
            extras += k
            legal += 1
            ran = k
        else:
            k = int(e)
            total += k
            legal += 1
            ran = k
        if ran % 2 == 1:
            striker, non = non, striker
        if e[:2] not in ('wd', 'nb') and legal % 6 == 0:
            striker, non = non, striker
    return [total, wickets, '%.1f' % (legal / 6), extras, striker]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: overs display',
   (['0', 'nb', 'W', '0', 'b1', '0', '1', '1', '1', 'W', 'nb', 'nb4'],),
   [11, 2, '1.3', 4, 4]),
  ('regression: overs display',
   (['3', 'b4', '6', 'wd', '1', 'nb4', '0', '1'],),
   [21, 0, '1.0', 6, 1]),
  ('variant scenario 1', (['nb', '1', 'b1'],), [3, 0, '0.2', 2, 1]),
  ('variant scenario 2',
   (['wd4', '2', '0', 'nb', '2', '1', 'wd1', '2', 'W', 'lb1', '6'],),
   [22, 1, '1.2', 9, 3])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: overs display', (['lb1', '4', '0', '0'],), [5, 0, '0.4', 1, 2]),
  ('regression: overs display',
   (['b4', 'wd1', 'wd', 'wd4', 'W', 'nb', '4', 'b4', 'b1', '0'],),
   [22, 1, '1.0', 18, 3]),
  ('variant scenario 1', (['0', 'nb4', 'wd4', 'b4'],), [14, 0, '0.2', 10, 1]),
  ('variant scenario 2',
   (['wd', 'wd', '0', '0', '4', '0', '6', '1', '0', '0', 'W', 'b1'],),
   [14, 1, '1.4', 3, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: overs display', (['2', '1', 'nb1', '4', 'nb1', 'lb2'],), [13, 0, '0.4', 4, 2]),
  ('regression: overs display', (['6', '3', '0', '0', 'b1', '4'],), [14, 0, '1.0', 1, 2]),
  ('variant scenario 1',
   (['b1', 'nb1', '4', 'wd', '1', 'nb1', '0', 'wd1', 'W', '4', '1', '0', '0'],),
   [18, 1, '1.3', 6, 3]),
  ('variant scenario 2',
   (['wd',
     '4',
     '4',
     'nb',
     '0',
     '0',
     '3',
     '0',
     'nb',
     '2',
     '1',
     'nb4',
     '0',
     '4',
     '4',
     '0',
     'b4',
     '4'],),
   [38, 0, '2.2', 8, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: overs display', (['nb4', '0', '3', '0', 'nb1', '0'],), [10, 0, '0.4', 2, 1]),
  ('regression: overs display',
   (['0', '1', '0', 'wd4', 'lb2', 'nb', '4', '0', '0', 'lb2', 'lb1', '0', '1', '4'],),
   [21, 0, '2.0', 11, 2]),
  ('variant scenario 1',
   (['W',
     '0',
     'nb1',
     'nb',
     'lb2',
     '0',
     'b4',
     'nb4',
     'W',
     '4',
     '1',
     '1',
     'wd',
     '0',
     'W',
     '4',
     '0',
     'lb2',
     '1',
     'b4',
     '2'],),
   [34, 3, '2.5', 16, 5]),
  ('variant scenario 2', (['2', '4', '1', '4', '6'],), [17, 0, '0.5', 0, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: overs display',
   (['1',
     '1',
     '1',
     '1',
     'nb',
     'lb1',
     'nb4',
     '1',
     '4',
     'b1',
     'wd1',
     '4',
     '2',
     '0',
     '1',
     '1',
     'nb',
     '0',
     '1',
     'wd4',
     'nb1'],),
   [36, 0, '2.3', 13, 1]),
  ('regression: overs display',
   (['wd4', 'nb', 'wd1', '0', '2', '6', '2', '4', '1', 'nb'],),
   [24, 0, '1.0', 9, 2]),
  ('variant scenario 1',
   (['4',
     '0',
     '0',
     '2',
     'nb4',
     'wd',
     'nb1',
     '0',
     '3',
     'nb',
     '2',
     '6',
     '0',
     '6',
     '6',
     '1',
     '0',
     '1'],),
   [40, 0, '2.2', 4, 1]),
  ('variant scenario 2',
   (['1', '3', '4', '0', '0', '0', '1', '4', 'b4', 'lb2', '6', 'b1', '1', '1', '0', 'W'],),
   [28, 1, '2.4', 7, 3])]]
for label, args, expected in cases[N - 1]:
    check(label, run(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(events):
    total = wickets = legal = extras = 0
    striker, non = 1, 2
    next_bat = 3
    for e in events:
        if e == 'W':
            wickets += 1
            legal += 1
            striker = next_bat
            next_bat += 1
            ran = 0
        elif e.startswith('wd'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1 + k
            ran = k
        elif e.startswith('nb'):
            k = int(e[2:] or 0)
            total += 1 + k
            extras += 1
            ran = k
        elif e[0] in 'bl':
            k = int(e.lstrip('lb'))
            total += k
            extras += k
            legal += 1
            ran = k
        else:
            k = int(e)
            total += k
            legal += 1
            ran = k
        if ran % 2 == 1:
            striker, non = non, striker
        if e[:2] not in ('wd', 'nb') and legal % 6 == 0:
            striker, non = non, striker
    return [total, wickets, ('%d.%d' % ((legal - 1) // 6, (legal - 1) % 6 + 1) if legal else '0.0'), extras, striker]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: overs display',
   (['0', 'nb', 'W', '0', 'b1', '0', '1', '1', '1', 'W', 'nb', 'nb4'],),
   [11, 2, '1.3', 4, 4]),
  ('regression: overs display',
   (['3', 'b4', '6', 'wd', '1', 'nb4', '0', '1'],),
   [21, 0, '1.0', 6, 1]),
  ('variant scenario 1', (['nb', '1', 'b1'],), [3, 0, '0.2', 2, 1]),
  ('variant scenario 2',
   (['wd4', '2', '0', 'nb', '2', '1', 'wd1', '2', 'W', 'lb1', '6'],),
   [22, 1, '1.2', 9, 3])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: overs display', (['lb1', '4', '0', '0'],), [5, 0, '0.4', 1, 2]),
  ('regression: overs display',
   (['b4', 'wd1', 'wd', 'wd4', 'W', 'nb', '4', 'b4', 'b1', '0'],),
   [22, 1, '1.0', 18, 3]),
  ('variant scenario 1', (['0', 'nb4', 'wd4', 'b4'],), [14, 0, '0.2', 10, 1]),
  ('variant scenario 2',
   (['wd', 'wd', '0', '0', '4', '0', '6', '1', '0', '0', 'W', 'b1'],),
   [14, 1, '1.4', 3, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: overs display', (['2', '1', 'nb1', '4', 'nb1', 'lb2'],), [13, 0, '0.4', 4, 2]),
  ('regression: overs display', (['6', '3', '0', '0', 'b1', '4'],), [14, 0, '1.0', 1, 2]),
  ('variant scenario 1',
   (['b1', 'nb1', '4', 'wd', '1', 'nb1', '0', 'wd1', 'W', '4', '1', '0', '0'],),
   [18, 1, '1.3', 6, 3]),
  ('variant scenario 2',
   (['wd',
     '4',
     '4',
     'nb',
     '0',
     '0',
     '3',
     '0',
     'nb',
     '2',
     '1',
     'nb4',
     '0',
     '4',
     '4',
     '0',
     'b4',
     '4'],),
   [38, 0, '2.2', 8, 1])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: overs display', (['nb4', '0', '3', '0', 'nb1', '0'],), [10, 0, '0.4', 2, 1]),
  ('regression: overs display',
   (['0', '1', '0', 'wd4', 'lb2', 'nb', '4', '0', '0', 'lb2', 'lb1', '0', '1', '4'],),
   [21, 0, '2.0', 11, 2]),
  ('variant scenario 1',
   (['W',
     '0',
     'nb1',
     'nb',
     'lb2',
     '0',
     'b4',
     'nb4',
     'W',
     '4',
     '1',
     '1',
     'wd',
     '0',
     'W',
     '4',
     '0',
     'lb2',
     '1',
     'b4',
     '2'],),
   [34, 3, '2.5', 16, 5]),
  ('variant scenario 2', (['2', '4', '1', '4', '6'],), [17, 0, '0.5', 0, 2])],
 [('control maiden over', (['0', '0', '0', '0', '0', '0'],), [0, 0, '1.0', 0, 2]),
  ('boundary single rotates strike', (['1'],), [1, 0, '0.1', 0, 2]),
  ('boundary wide is not a legal ball', (['wd', '4'],), [5, 0, '0.1', 1, 1]),
  ('control no-ball boundary', (['nb4'],), [5, 0, '0.0', 1, 1]),
  ('boundary wicket brings new striker', (['W', '0'],), [0, 1, '0.2', 0, 3]),
  ('control leg byes', (['lb1', '2'],), [3, 0, '0.2', 1, 2]),
  ('regression: overs display',
   (['1',
     '1',
     '1',
     '1',
     'nb',
     'lb1',
     'nb4',
     '1',
     '4',
     'b1',
     'wd1',
     '4',
     '2',
     '0',
     '1',
     '1',
     'nb',
     '0',
     '1',
     'wd4',
     'nb1'],),
   [36, 0, '2.3', 13, 1]),
  ('regression: overs display',
   (['wd4', 'nb', 'wd1', '0', '2', '6', '2', '4', '1', 'nb'],),
   [24, 0, '1.0', 9, 2]),
  ('variant scenario 1',
   (['4',
     '0',
     '0',
     '2',
     'nb4',
     'wd',
     'nb1',
     '0',
     '3',
     'nb',
     '2',
     '6',
     '0',
     '6',
     '6',
     '1',
     '0',
     '1'],),
   [40, 0, '2.2', 4, 1]),
  ('variant scenario 2',
   (['1', '3', '4', '0', '0', '0', '1', '4', 'b4', 'lb2', '6', 'b1', '1', '1', '0', 'W'],),
   [28, 1, '2.4', 7, 3])]]
for label, args, expected in cases[N - 1]:
    check(label, run(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:
After seven legal balls the overs read "1.2" or an over boundary reads "0.6".

Ball-by-ball innings tally. Events: "0".."6" runs off the bat (legal ball); "W" wicket (legal ball, no runs, the new batter takes strike); "wdK" wide: 1 penalty + K run wides, all extras, not a legal ball, K runs completed; "nbK" no-ball: 1 penalty extra + K runs off the bat, not a legal ball; "bK"/"lbK" byes/leg byes: K extras on a legal ball. Batters change ends when an odd number of runs is completed, and again after the 6th legal ball of an over. Batters are numbered 1, 2 and then 3, 4, ... as they come in; batter 1 starts on strike. Return [total, wickets, overs "O.B", extras, batter on strike].

split: open-access