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

N = 1
observations = []
def solve(rallies, first_server):
    a = b = 0
    for r in rallies:
        if r == 'A':
            a += 1
        else:
            b += 1
        if max(a, b) > 11 and abs(a - b) >= 2:
            return [a, b, r, None]
    k = a + b
    other = 'B' if first_server == 'A' else 'A'
    if a >= 10 and b >= 10:
        block = k - 10
    else:
        block = k // 2
    return [a, b, None, first_server if block % 2 == 0 else other]
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 opening server', ('', 'A'), [0, 0, None, 'A']),
  ('boundary second point same server', ('B', 'A'), [0, 1, None, 'A']),
  ('boundary change after two points', ('BA', 'A'), [1, 1, None, 'B']),
  ('boundary ten-all', ('ABABABABABABABABABAB', 'A'), [10, 10, None, 'A']),
  ('boundary eleven-ten alternates each point',
   ('ABABABABABABABABABABA', 'A'),
   [11, 10, None, 'B']),
  ('control eleven-nine', ('AAAAAAAAABBBBBBBBBAA', 'B'), [11, 9, 'A', None]),
  ('regression: game target', ('ABABABABABABABABABABABABBB', 'B'), [12, 14, 'B', None]),
  ('regression: game target', ('ABBBBAABBBABBAAABBBBA', 'A'), [7, 11, 'B', None]),
  ('variant scenario 1', ('AAABABBABABBAB', 'A'), [7, 7, None, 'B']),
  ('variant scenario 2', ('ABABABABABABABABAB', 'A'), [9, 9, None, 'B'])],
 [('control opening server', ('', 'A'), [0, 0, None, 'A']),
  ('boundary second point same server', ('B', 'A'), [0, 1, None, 'A']),
  ('boundary change after two points', ('BA', 'A'), [1, 1, None, 'B']),
  ('boundary ten-all', ('ABABABABABABABABABAB', 'A'), [10, 10, None, 'A']),
  ('boundary eleven-ten alternates each point',
   ('ABABABABABABABABABABA', 'A'),
   [11, 10, None, 'B']),
  ('control eleven-nine', ('AAAAAAAAABBBBBBBBBAA', 'B'), [11, 9, 'A', None]),
  ('regression: game target', ('ABABAABABBAABBBABABBAA', 'B'), [9, 11, 'B', None]),
  ('variant scenario 1', ('ABBBB', 'B'), [1, 4, None, 'B']),
  ('variant scenario 2', ('BBBBBBBBBBA', 'B'), [1, 10, None, 'A'])],
 [('control opening server', ('', 'A'), [0, 0, None, 'A']),
  ('boundary second point same server', ('B', 'A'), [0, 1, None, 'A']),
  ('boundary change after two points', ('BA', 'A'), [1, 1, None, 'B']),
  ('boundary ten-all', ('ABABABABABABABABABAB', 'A'), [10, 10, None, 'A']),
  ('boundary eleven-ten alternates each point',
   ('ABABABABABABABABABABA', 'A'),
   [11, 10, None, 'B']),
  ('control eleven-nine', ('AAAAAAAAABBBBBBBBBAA', 'B'), [11, 9, 'A', None]),
  ('regression: game target', ('AABAABBABBBBBBBAAABA', 'B'), [8, 11, 'B', None]),
  ('variant scenario 1', ('AAAABAA', 'B'), [6, 1, None, 'A']),
  ('variant scenario 2', ('BAABABAABBABB', 'B'), [6, 7, None, 'B'])],
 [('control opening server', ('', 'A'), [0, 0, None, 'A']),
  ('boundary second point same server', ('B', 'A'), [0, 1, None, 'A']),
  ('boundary change after two points', ('BA', 'A'), [1, 1, None, 'B']),
  ('boundary ten-all', ('ABABABABABABABABABAB', 'A'), [10, 10, None, 'A']),
  ('boundary eleven-ten alternates each point',
   ('ABABABABABABABABABABA', 'A'),
   [11, 10, None, 'B']),
  ('control eleven-nine', ('AAAAAAAAABBBBBBBBBAA', 'B'), [11, 9, 'A', None]),
  ('regression: game target', ('ABABABABABABABABABABABBB', 'B'), [11, 13, 'B', None]),
  ('regression: game target', ('ABABABBBBBBBBABBBAABBBBAA', 'B'), [4, 11, 'B', None]),
  ('variant scenario 1', ('ABABABABABABABABABABA', 'B'), [11, 10, None, 'A']),
  ('variant scenario 2', ('ABABABABABABABABABAB', 'B'), [10, 10, None, 'B'])],
 [('control opening server', ('', 'A'), [0, 0, None, 'A']),
  ('boundary second point same server', ('B', 'A'), [0, 1, None, 'A']),
  ('boundary change after two points', ('BA', 'A'), [1, 1, None, 'B']),
  ('boundary ten-all', ('ABABABABABABABABABAB', 'A'), [10, 10, None, 'A']),
  ('boundary eleven-ten alternates each point',
   ('ABABABABABABABABABABA', 'A'),
   [11, 10, None, 'B']),
  ('control eleven-nine', ('AAAAAAAAABBBBBBBBBAA', 'B'), [11, 9, 'A', None]),
  ('regression: game target', ('BABABBAABBBBBAAAABABAABAA', 'B'), [9, 11, 'B', None]),
  ('variant scenario 1', ('ABABABABABABABABABABB', 'B'), [10, 11, None, 'A']),
  ('variant scenario 2', ('ABABABABABABABABABAB', 'A'), [10, 10, None, 'A'])]]
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(rallies, first_server):
    a = b = 0
    for r in rallies:
        if r == 'A':
            a += 1
        else:
            b += 1
        if max(a, b) >= 21 and abs(a - b) >= 2:
            return [a, b, r, None]
    k = a + b
    other = 'B' if first_server == 'A' else 'A'
    if a >= 10 and b >= 10:
        block = k - 10
    else:
        block = k // 2
    return [a, b, None, first_server if block % 2 == 0 else other]
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 opening server', ('', 'A'), [0, 0, None, 'A']),
  ('boundary second point same server', ('B', 'A'), [0, 1, None, 'A']),
  ('boundary change after two points', ('BA', 'A'), [1, 1, None, 'B']),
  ('boundary ten-all', ('ABABABABABABABABABAB', 'A'), [10, 10, None, 'A']),
  ('boundary eleven-ten alternates each point',
   ('ABABABABABABABABABABA', 'A'),
   [11, 10, None, 'B']),
  ('control eleven-nine', ('AAAAAAAAABBBBBBBBBAA', 'B'), [11, 9, 'A', None]),
  ('regression: game target', ('ABABABABABABABABABABABABBB', 'B'), [12, 14, 'B', None]),
  ('regression: game target', ('ABBBBAABBBABBAAABBBBA', 'A'), [7, 11, 'B', None]),
  ('variant scenario 1', ('AAABABBABABBAB', 'A'), [7, 7, None, 'B']),
  ('variant scenario 2', ('ABABABABABABABABAB', 'A'), [9, 9, None, 'B'])],
 [('control opening server', ('', 'A'), [0, 0, None, 'A']),
  ('boundary second point same server', ('B', 'A'), [0, 1, None, 'A']),
  ('boundary change after two points', ('BA', 'A'), [1, 1, None, 'B']),
  ('boundary ten-all', ('ABABABABABABABABABAB', 'A'), [10, 10, None, 'A']),
  ('boundary eleven-ten alternates each point',
   ('ABABABABABABABABABABA', 'A'),
   [11, 10, None, 'B']),
  ('control eleven-nine', ('AAAAAAAAABBBBBBBBBAA', 'B'), [11, 9, 'A', None]),
  ('regression: game target', ('ABABAABABBAABBBABABBAA', 'B'), [9, 11, 'B', None]),
  ('variant scenario 1', ('ABBBB', 'B'), [1, 4, None, 'B']),
  ('variant scenario 2', ('BBBBBBBBBBA', 'B'), [1, 10, None, 'A'])],
 [('control opening server', ('', 'A'), [0, 0, None, 'A']),
  ('boundary second point same server', ('B', 'A'), [0, 1, None, 'A']),
  ('boundary change after two points', ('BA', 'A'), [1, 1, None, 'B']),
  ('boundary ten-all', ('ABABABABABABABABABAB', 'A'), [10, 10, None, 'A']),
  ('boundary eleven-ten alternates each point',
   ('ABABABABABABABABABABA', 'A'),
   [11, 10, None, 'B']),
  ('control eleven-nine', ('AAAAAAAAABBBBBBBBBAA', 'B'), [11, 9, 'A', None]),
  ('regression: game target', ('AABAABBABBBBBBBAAABA', 'B'), [8, 11, 'B', None]),
  ('variant scenario 1', ('AAAABAA', 'B'), [6, 1, None, 'A']),
  ('variant scenario 2', ('BAABABAABBABB', 'B'), [6, 7, None, 'B'])],
 [('control opening server', ('', 'A'), [0, 0, None, 'A']),
  ('boundary second point same server', ('B', 'A'), [0, 1, None, 'A']),
  ('boundary change after two points', ('BA', 'A'), [1, 1, None, 'B']),
  ('boundary ten-all', ('ABABABABABABABABABAB', 'A'), [10, 10, None, 'A']),
  ('boundary eleven-ten alternates each point',
   ('ABABABABABABABABABABA', 'A'),
   [11, 10, None, 'B']),
  ('control eleven-nine', ('AAAAAAAAABBBBBBBBBAA', 'B'), [11, 9, 'A', None]),
  ('regression: game target', ('ABABABABABABABABABABABBB', 'B'), [11, 13, 'B', None]),
  ('regression: game target', ('ABABABBBBBBBBABBBAABBBBAA', 'B'), [4, 11, 'B', None]),
  ('variant scenario 1', ('ABABABABABABABABABABA', 'B'), [11, 10, None, 'A']),
  ('variant scenario 2', ('ABABABABABABABABABAB', 'B'), [10, 10, None, 'B'])],
 [('control opening server', ('', 'A'), [0, 0, None, 'A']),
  ('boundary second point same server', ('B', 'A'), [0, 1, None, 'A']),
  ('boundary change after two points', ('BA', 'A'), [1, 1, None, 'B']),
  ('boundary ten-all', ('ABABABABABABABABABAB', 'A'), [10, 10, None, 'A']),
  ('boundary eleven-ten alternates each point',
   ('ABABABABABABABABABABA', 'A'),
   [11, 10, None, 'B']),
  ('control eleven-nine', ('AAAAAAAAABBBBBBBBBAA', 'B'), [11, 9, 'A', None]),
  ('regression: game target', ('BABABBAABBBBBAAAABABAABAA', 'B'), [9, 11, 'B', None]),
  ('variant scenario 1', ('ABABABABABABABABABABB', 'B'), [10, 11, None, 'A']),
  ('variant scenario 2', ('ABABABABABABABABABAB', 'A'), [10, 10, None, 'A'])]]
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:
An 11-9 game is not recognized as finished.

One table tennis game to 11 with a two-point lead; later rallies are ignored. Service changes after every two points; once both players have at least 10 points it changes after every point. Return [a, b, winner, None] when finished, else [a, b, None, next server].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(matches, quota):
    def balls(text):
        whole, _, part = text.partition('.')
        part = int(part or 0)
        if part > 5:
            return None
        return round(float(text) * 6)
    rf = bf = ra = ba = 0
    for runs_for, faced, out_for, runs_against, bowled, out_against in matches:
        f = quota * 6 if out_for else balls(faced)
        g = quota * 6 if out_against else balls(bowled)
        if f is None or g is None:
            return 'invalid overs'
        rf += runs_for
        bf += f
        ra += runs_against
        ba += g
    if bf == 0 or ba == 0:
        return 'no overs'
    value = Fraction(rf * 6, bf) - Fraction(ra * 6, ba)
    return '%+.3f' % float(value)
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 single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: overs notation', ([[332, '21.5', True, 294, '15.2', False]], 50), '-12.534'),
  ('variant scenario 1', ([[277, '13.1', True, 344, '5', True]], 20), '-3.350'),
  ('variant scenario 2',
   ([[290, '37.4', False, 163, '3.4', True], [227, '17.1', False, 84, '26.5', False]], 50),
   '+6.214')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: overs notation',
   ([[334, '41.1', False, 189, '29.0', False],
     [228, '44.4', True, 194, '6.0', False],
     [213, '10.4', False, 157, '34.4', False],
     [323, '30.3', False, 228, '0.4', False]],
    20),
   '-0.190'),
  ('variant scenario 1', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('variant scenario 2',
   ([[106, '30.1', False, 295, '38.1', False],
     [338, '47.3', False, 295, '10.4', True],
     [129, '47', True, 106, '50.4', False]],
    20),
   '-0.528')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: overs notation',
   ([[124, '12.2', True, 200, '37.3', False],
     [249, '50.5', True, 118, '35.0', False],
     [276, '8.3', False, 220, '32', False],
     [301, '36.4', True, 141, '30.2', True]],
    20),
   '+8.415'),
  ('variant scenario 1',
   ([[194, '27', True, 107, '4.0', False],
     [275, '49.2', True, 248, '36', True],
     [184, '13.4', True, 319, '49.4', True]],
    50),
   '-2.127'),
  ('variant scenario 2',
   ([[160, '2.4', False, 141, '30.4', True], [311, '9.0', False, 308, '36.1', False]], 50),
   '+35.161')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: overs notation',
   ([[234, '41.0', False, 232, '28.1', False],
     [337, '0', False, 86, '32.5', False],
     [282, '26.3', True, 240, '11.7', True],
     [209, '43.2', False, 101, '12', False]],
    20),
   '+3.093'),
  ('variant scenario 1',
   ([[100, '7.3', True, 230, '8.1', True],
     [255, '28', False, 125, '15.2', False],
     [105, '8.3', False, 323, '24.4', True],
     [191, '23.5', False, 223, '21.0', True],
     [291, '34.5', False, 104, '40.4', False],
     [100, '41.4', False, 344, '31.2', True]],
    20),
   '-3.275'),
  ('variant scenario 2',
   ([[221, '18.2', True, 95, '18.2', False],
     [205, '36.4', False, 287, '24.2', False],
     [180, '43.3', False, 224, '9.3', False]],
    20),
   '-5.567')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: overs notation',
   ([[160, '1.1', False, 175, '22.4', False],
     [256, '46.1', True, 300, '0.4', False],
     [303, '43.0', False, 302, '16.3', False],
     [350, '13', False, 142, '28.4', True],
     [323, '39.4', True, 266, '42.2', False],
     [332, '36.1', False, 99, '5.1', False]],
    50),
   '-0.432'),
  ('variant scenario 1',
   ([[292, '42.1', False, 105, '16.2', False], [154, '36.5', False, 159, '19.5', False]], 50),
   '-1.654'),
  ('variant scenario 2', ([[0, '0', False, 0, '0', False]], 50), 'no overs')]]
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
from fractions import Fraction
import math
N = 1
observations = []
def solve(matches, quota):
    def balls(text):
        whole, _, part = text.partition('.')
        part = int(part or 0)
        if part > 5:
            return None
        return int(whole) * 6 + part * 6 // 10
    rf = bf = ra = ba = 0
    for runs_for, faced, out_for, runs_against, bowled, out_against in matches:
        f = quota * 6 if out_for else balls(faced)
        g = quota * 6 if out_against else balls(bowled)
        if f is None or g is None:
            return 'invalid overs'
        rf += runs_for
        bf += f
        ra += runs_against
        ba += g
    if bf == 0 or ba == 0:
        return 'no overs'
    value = Fraction(rf * 6, bf) - Fraction(ra * 6, ba)
    return '%+.3f' % float(value)
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 single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: overs notation', ([[332, '21.5', True, 294, '15.2', False]], 50), '-12.534'),
  ('variant scenario 1', ([[277, '13.1', True, 344, '5', True]], 20), '-3.350'),
  ('variant scenario 2',
   ([[290, '37.4', False, 163, '3.4', True], [227, '17.1', False, 84, '26.5', False]], 50),
   '+6.214')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: overs notation',
   ([[334, '41.1', False, 189, '29.0', False],
     [228, '44.4', True, 194, '6.0', False],
     [213, '10.4', False, 157, '34.4', False],
     [323, '30.3', False, 228, '0.4', False]],
    20),
   '-0.190'),
  ('variant scenario 1', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('variant scenario 2',
   ([[106, '30.1', False, 295, '38.1', False],
     [338, '47.3', False, 295, '10.4', True],
     [129, '47', True, 106, '50.4', False]],
    20),
   '-0.528')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: overs notation',
   ([[124, '12.2', True, 200, '37.3', False],
     [249, '50.5', True, 118, '35.0', False],
     [276, '8.3', False, 220, '32', False],
     [301, '36.4', True, 141, '30.2', True]],
    20),
   '+8.415'),
  ('variant scenario 1',
   ([[194, '27', True, 107, '4.0', False],
     [275, '49.2', True, 248, '36', True],
     [184, '13.4', True, 319, '49.4', True]],
    50),
   '-2.127'),
  ('variant scenario 2',
   ([[160, '2.4', False, 141, '30.4', True], [311, '9.0', False, 308, '36.1', False]], 50),
   '+35.161')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: overs notation',
   ([[234, '41.0', False, 232, '28.1', False],
     [337, '0', False, 86, '32.5', False],
     [282, '26.3', True, 240, '11.7', True],
     [209, '43.2', False, 101, '12', False]],
    20),
   '+3.093'),
  ('variant scenario 1',
   ([[100, '7.3', True, 230, '8.1', True],
     [255, '28', False, 125, '15.2', False],
     [105, '8.3', False, 323, '24.4', True],
     [191, '23.5', False, 223, '21.0', True],
     [291, '34.5', False, 104, '40.4', False],
     [100, '41.4', False, 344, '31.2', True]],
    20),
   '-3.275'),
  ('variant scenario 2',
   ([[221, '18.2', True, 95, '18.2', False],
     [205, '36.4', False, 287, '24.2', False],
     [180, '43.3', False, 224, '9.3', False]],
    20),
   '-5.567')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: overs notation',
   ([[160, '1.1', False, 175, '22.4', False],
     [256, '46.1', True, 300, '0.4', False],
     [303, '43.0', False, 302, '16.3', False],
     [350, '13', False, 142, '28.4', True],
     [323, '39.4', True, 266, '42.2', False],
     [332, '36.1', False, 99, '5.1', False]],
    50),
   '-0.432'),
  ('variant scenario 1',
   ([[292, '42.1', False, 105, '16.2', False], [154, '36.5', False, 159, '19.5', False]], 50),
   '-1.654'),
  ('variant scenario 2', ([[0, '0', False, 0, '0', False]], 50), 'no overs')]]
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:
"43.4" overs is treated as 43.4 decimal overs, skewing net run rate.

Tournament net run rate. Each match row is [runs_for, overs_faced, all_out_for, runs_against, overs_bowled, all_out_against]. Overs strings use cricket notation "O.B" where B is balls 0-5 ("43.4" = 43 overs 4 balls); a ball digit above 5 returns "invalid overs". When a side was all out its innings counts as the full quota of overs. NRR = total runs for / total overs faced - total runs against / total overs bowled, aggregated over all matches before dividing, formatted as "%+.3f" of the exact value. If either overs total is zero return "no overs".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(matches, quota):
    def balls(text):
        whole, _, part = text.partition('.')
        part = int(part or 0)
        if part > 5:
            return None
        return int(whole) * 6 + part
    rf = bf = ra = ba = 0
    for runs_for, faced, out_for, runs_against, bowled, out_against in matches:
        f = balls(faced)
        g = balls(bowled)
        if f is None or g is None:
            return 'invalid overs'
        rf += runs_for
        bf += f
        ra += runs_against
        ba += g
    if bf == 0 or ba == 0:
        return 'no overs'
    value = Fraction(rf * 6, bf) - Fraction(ra * 6, ba)
    return '%+.3f' % float(value)
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 single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: all out quota',
   ([[274, '11.3', False, 153, '36', False],
     [141, '9.4', True, 86, '41.3', True],
     [108, '15', False, 280, '44.5', False]],
    20),
   '+6.100'),
  ('variant scenario 1',
   ([[341, '0.5', False, 330, '45.0', False],
     [313, '19.5', False, 220, '25.3', False],
     [207, '42.1', False, 200, '3.1', False]],
    20),
   '+3.522'),
  ('variant scenario 2',
   ([[222, '5.1', False, 252, '48.1', True],
     [92, '24.4', False, 265, '23.3', True],
     [276, '32.3', False, 297, '6.2', False]],
    20),
   '-8.103')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: all out quota',
   ([[323, '8.5', False, 245, '5', True],
     [198, '15.3', False, 151, '15.4', False],
     [239, '14.2', False, 121, '24.6', True],
     [107, '14', True, 94, '39.3', False]],
    50),
   '+5.840'),
  ('variant scenario 1',
   ([[271, '12.2', False, 108, '19.3', False], [129, '15.7', False, 146, '44.4', False]], 50),
   'invalid overs'),
  ('variant scenario 2',
   ([[260, '42.3', False, 116, '50.2', False],
     [339, '31.5', False, 320, '34.1', False],
     [360, '12.5', False, 211, '37.1', False]],
    50),
   '+5.684')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: all out quota',
   ([[85, '18.2', True, 137, '19.4', False], [211, '33.3', True, 84, '44.5', True]], 50),
   '-0.212'),
  ('variant scenario 1',
   ([[122, '18.3', True, 178, '35.4', False],
     [155, '37.3', False, 116, '4.5', False],
     [134, '45.5', False, 248, '27.4', False]],
    20),
   '-3.974'),
  ('variant scenario 2',
   ([[353, '23.3', False, 353, '24.4', True],
     [233, '49.3', False, 281, '18.3', False],
     [245, '44.4', False, 260, '4.1', True],
     [278, '44', False, 291, '10.5', True],
     [222, '27.6', False, 153, '44', True]],
    50),
   'invalid overs')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: all out quota',
   ([[294, '24.2', False, 86, '24.2', True],
     [111, '30', False, 139, '26.2', True],
     [139, '8.1', True, 316, '35.4', False],
     [115, '35.3', False, 329, '28.5', False],
     [171, '34.5', True, 227, '49.2', False]],
    50),
   '-0.758'),
  ('variant scenario 1', ([[0, '0', False, 0, '0', False]], 50), 'no overs'),
  ('variant scenario 2', ([[345, '2.1', True, 354, '26.5', False]], 20), '+4.057')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: all out quota',
   ([[225, '40.5', False, 354, '9.1', True],
     [167, '22.1', False, 231, '34', False],
     [297, '26.0', False, 98, '19', False],
     [295, '49.2', False, 314, '45.4', False],
     [293, '46.3', False, 305, '29.1', True]],
    50),
   '+0.355'),
  ('variant scenario 1',
   ([[183, '19.5', False, 137, '36.6', False],
     [234, '46.4', False, 179, '46.4', False],
     [173, '24.1', False, 110, '31.6', False],
     [287, '24.0', True, 147, '37.1', True]],
    50),
   'invalid overs'),
  ('variant scenario 2',
   ([[172, '22.1', False, 287, '1.6', False],
     [352, '8', False, 332, '17.0', False],
     [126, '0.4', False, 127, '43.3', True]],
    20),
   'invalid overs')]]
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
from fractions import Fraction
import math
N = 1
observations = []
def solve(matches, quota):
    def balls(text):
        whole, _, part = text.partition('.')
        part = int(part or 0)
        if part > 5:
            return None
        return int(whole) * 6 + part
    rf = bf = ra = ba = 0
    for runs_for, faced, out_for, runs_against, bowled, out_against in matches:
        f = quota * 6 if out_for else balls(faced)
        g = balls(bowled)
        if f is None or g is None:
            return 'invalid overs'
        rf += runs_for
        bf += f
        ra += runs_against
        ba += g
    if bf == 0 or ba == 0:
        return 'no overs'
    value = Fraction(rf * 6, bf) - Fraction(ra * 6, ba)
    return '%+.3f' % float(value)
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 single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: all out quota',
   ([[274, '11.3', False, 153, '36', False],
     [141, '9.4', True, 86, '41.3', True],
     [108, '15', False, 280, '44.5', False]],
    20),
   '+6.100'),
  ('variant scenario 1',
   ([[341, '0.5', False, 330, '45.0', False],
     [313, '19.5', False, 220, '25.3', False],
     [207, '42.1', False, 200, '3.1', False]],
    20),
   '+3.522'),
  ('variant scenario 2',
   ([[222, '5.1', False, 252, '48.1', True],
     [92, '24.4', False, 265, '23.3', True],
     [276, '32.3', False, 297, '6.2', False]],
    20),
   '-8.103')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: all out quota',
   ([[323, '8.5', False, 245, '5', True],
     [198, '15.3', False, 151, '15.4', False],
     [239, '14.2', False, 121, '24.6', True],
     [107, '14', True, 94, '39.3', False]],
    50),
   '+5.840'),
  ('variant scenario 1',
   ([[271, '12.2', False, 108, '19.3', False], [129, '15.7', False, 146, '44.4', False]], 50),
   'invalid overs'),
  ('variant scenario 2',
   ([[260, '42.3', False, 116, '50.2', False],
     [339, '31.5', False, 320, '34.1', False],
     [360, '12.5', False, 211, '37.1', False]],
    50),
   '+5.684')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: all out quota',
   ([[85, '18.2', True, 137, '19.4', False], [211, '33.3', True, 84, '44.5', True]], 50),
   '-0.212'),
  ('variant scenario 1',
   ([[122, '18.3', True, 178, '35.4', False],
     [155, '37.3', False, 116, '4.5', False],
     [134, '45.5', False, 248, '27.4', False]],
    20),
   '-3.974'),
  ('variant scenario 2',
   ([[353, '23.3', False, 353, '24.4', True],
     [233, '49.3', False, 281, '18.3', False],
     [245, '44.4', False, 260, '4.1', True],
     [278, '44', False, 291, '10.5', True],
     [222, '27.6', False, 153, '44', True]],
    50),
   'invalid overs')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: all out quota',
   ([[294, '24.2', False, 86, '24.2', True],
     [111, '30', False, 139, '26.2', True],
     [139, '8.1', True, 316, '35.4', False],
     [115, '35.3', False, 329, '28.5', False],
     [171, '34.5', True, 227, '49.2', False]],
    50),
   '-0.758'),
  ('variant scenario 1', ([[0, '0', False, 0, '0', False]], 50), 'no overs'),
  ('variant scenario 2', ([[345, '2.1', True, 354, '26.5', False]], 20), '+4.057')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: all out quota',
   ([[225, '40.5', False, 354, '9.1', True],
     [167, '22.1', False, 231, '34', False],
     [297, '26.0', False, 98, '19', False],
     [295, '49.2', False, 314, '45.4', False],
     [293, '46.3', False, 305, '29.1', True]],
    50),
   '+0.355'),
  ('variant scenario 1',
   ([[183, '19.5', False, 137, '36.6', False],
     [234, '46.4', False, 179, '46.4', False],
     [173, '24.1', False, 110, '31.6', False],
     [287, '24.0', True, 147, '37.1', True]],
    50),
   'invalid overs'),
  ('variant scenario 2',
   ([[172, '22.1', False, 287, '1.6', False],
     [352, '8', False, 332, '17.0', False],
     [126, '0.4', False, 127, '43.3', True]],
    20),
   'invalid overs')]]
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 side bowled out early is credited with a very high run rate instead of the full quota.

Tournament net run rate. Each match row is [runs_for, overs_faced, all_out_for, runs_against, overs_bowled, all_out_against]. Overs strings use cricket notation "O.B" where B is balls 0-5 ("43.4" = 43 overs 4 balls); a ball digit above 5 returns "invalid overs". When a side was all out its innings counts as the full quota of overs. NRR = total runs for / total overs faced - total runs against / total overs bowled, aggregated over all matches before dividing, formatted as "%+.3f" of the exact value. If either overs total is zero return "no overs".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(matches, quota):
    def balls(text):
        whole, _, part = text.partition('.')
        part = int(part or 0)
        if part > 5:
            return None
        return int(whole) * 6 + part
    rf = bf = ra = ba = 0
    for runs_for, faced, out_for, runs_against, bowled, out_against in matches:
        f = quota * 6 if out_for else balls(faced)
        g = quota * 6 if out_against else balls(bowled)
        if f is None or g is None:
            return 'invalid overs'
        rf += runs_for
        bf += f
        ra += runs_against
        ba += g
    if bf == 0 or ba == 0:
        return 'no overs'
    value = round(rf * 6 / bf, 3) - round(ra * 6 / ba, 3)
    return '%+.3f' % float(value)
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 single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: rounding stage',
   ([[218, '27.4', True, 90, '20.1', False], [291, '6.3', False, 179, '41.5', False]], 20),
   '+14.869'),
  ('regression: rounding stage', ([[174, '18.3', False, 263, '40.2', False]], 50), '+2.885'),
  ('variant scenario 1',
   ([[252, '41.5', True, 332, '8.6', False],
     [269, '15', False, 97, '2.1', False],
     [178, '38.2', False, 191, '44.2', False]],
    20),
   'invalid overs'),
  ('variant scenario 2', ([[162, '6', False, 336, '45.4', False]], 20), '+19.642')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: rounding stage',
   ([[152, '43.1', True, 326, '11.5', True],
     [145, '2.2', False, 253, '19', False],
     [325, '47.2', True, 136, '6.5', True]],
    50),
   '+0.070'),
  ('regression: rounding stage', ([[261, '42.5', False, 211, '37.4', False]], 50), '+0.492'),
  ('variant scenario 1',
   ([[82, '11.4', False, 275, '31.4', False],
     [97, '49', False, 113, '3.1', False],
     [266, '44', False, 144, '48.3', False],
     [358, '27.5', False, 204, '19.6', False]],
    50),
   'invalid overs'),
  ('variant scenario 2',
   ([[297, '37.4', False, 108, '19.5', False], [286, '5.1', False, 167, '33.5', False]], 20),
   '+8.487')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: rounding stage',
   ([[216, '39.5', False, 213, '32.3', False],
     [201, '4.1', False, 350, '39.0', True],
     [204, '38.4', False, 94, '13', False]],
    50),
   '+0.633'),
  ('variant scenario 1', ([[147, '45.4', False, 293, '33.5', False]], 50), '-5.441'),
  ('variant scenario 2', ([[0, '0', False, 0, '0', False]], 50), 'no overs')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: rounding stage',
   ([[121, '36.1', True, 248, '42.2', False],
     [92, '15.7', True, 245, '32.2', True],
     [303, '0.4', False, 184, '12.2', False],
     [168, '0.4', False, 331, '5.2', False]],
    50),
   '-2.414'),
  ('regression: rounding stage',
   ([[327, '48.0', False, 210, '13.5', True],
     [230, '38.2', True, 113, '20.2', False],
     [158, '44.4', True, 281, '26.2', False],
     [344, '46.5', False, 138, '13.4', True]],
    20),
   '-0.707'),
  ('variant scenario 1',
   ([[226, '40.5', False, 269, '26.1', True],
     [167, '33.5', False, 92, '37.0', False],
     [205, '24.5', True, 125, '18', True],
     [199, '47.4', False, 240, '12.2', False],
     [217, '8.2', False, 247, '39', False],
     [296, '18', False, 297, '14.2', False]],
    50),
   '+0.328'),
  ('variant scenario 2', ([[0, '0', False, 0, '0', False]], 50), 'no overs')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: rounding stage',
   ([[168, '4.5', True, 104, '50', False],
     [343, '28.2', False, 323, '38.4', False],
     [90, '38.3', True, 95, '7', True],
     [87, '22', False, 174, '48.3', False],
     [163, '6.1', False, 326, '19.2', False]],
    20),
   '+3.028'),
  ('regression: rounding stage',
   ([[271, '23.3', True, 114, '47.4', False],
     [94, '41.5', True, 238, '3.4', False],
     [315, '34.3', False, 188, '19.2', True],
     [296, '29.4', False, 109, '44.2', True]],
    50),
   '+1.657'),
  ('variant scenario 1',
   ([[114, '36.1', False, 275, '32.0', True],
     [284, '17.4', False, 297, '10.4', True],
     [284, '16.5', False, 223, '30.5', True],
     [305, '45.3', True, 108, '36.1', False],
     [254, '13', True, 317, '37.0', False],
     [89, '15.3', False, 102, '17', True],
     [328, '41', False, 88, '21.2', False]],
    20),
   '+1.838'),
  ('variant scenario 2',
   ([[107, '20.3', False, 313, '10.1', False],
     [299, '42.4', True, 267, '49.1', False],
     [217, '50.4', True, 342, '1.2', True],
     [247, '19.2', False, 278, '49.1', True],
     [296, '28.4', True, 318, '43.3', False],
     [326, '9.0', True, 334, '48.1', False]],
    50),
   '-1.157')]]
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
from fractions import Fraction
import math
N = 1
observations = []
def solve(matches, quota):
    def balls(text):
        whole, _, part = text.partition('.')
        part = int(part or 0)
        if part > 5:
            return None
        return int(whole) * 6 + part
    rf = bf = ra = ba = 0
    for runs_for, faced, out_for, runs_against, bowled, out_against in matches:
        f = quota * 6 if out_for else balls(faced)
        g = quota * 6 if out_against else balls(bowled)
        if f is None or g is None:
            return 'invalid overs'
        rf += runs_for
        bf += f
        ra += runs_against
        ba += g
    if bf == 0 or ba == 0:
        return 'no overs'
    value = Fraction(rf * 6, bf) - Fraction(ra * 6, ba)
    return '%+.3f' % (math.trunc(value * 1000) / 1000)
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 single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: rounding stage',
   ([[218, '27.4', True, 90, '20.1', False], [291, '6.3', False, 179, '41.5', False]], 20),
   '+14.869'),
  ('regression: rounding stage', ([[174, '18.3', False, 263, '40.2', False]], 50), '+2.885'),
  ('variant scenario 1',
   ([[252, '41.5', True, 332, '8.6', False],
     [269, '15', False, 97, '2.1', False],
     [178, '38.2', False, 191, '44.2', False]],
    20),
   'invalid overs'),
  ('variant scenario 2', ([[162, '6', False, 336, '45.4', False]], 20), '+19.642')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: rounding stage',
   ([[152, '43.1', True, 326, '11.5', True],
     [145, '2.2', False, 253, '19', False],
     [325, '47.2', True, 136, '6.5', True]],
    50),
   '+0.070'),
  ('regression: rounding stage', ([[261, '42.5', False, 211, '37.4', False]], 50), '+0.492'),
  ('variant scenario 1',
   ([[82, '11.4', False, 275, '31.4', False],
     [97, '49', False, 113, '3.1', False],
     [266, '44', False, 144, '48.3', False],
     [358, '27.5', False, 204, '19.6', False]],
    50),
   'invalid overs'),
  ('variant scenario 2',
   ([[297, '37.4', False, 108, '19.5', False], [286, '5.1', False, 167, '33.5', False]], 20),
   '+8.487')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: rounding stage',
   ([[216, '39.5', False, 213, '32.3', False],
     [201, '4.1', False, 350, '39.0', True],
     [204, '38.4', False, 94, '13', False]],
    50),
   '+0.633'),
  ('variant scenario 1', ([[147, '45.4', False, 293, '33.5', False]], 50), '-5.441'),
  ('variant scenario 2', ([[0, '0', False, 0, '0', False]], 50), 'no overs')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: rounding stage',
   ([[121, '36.1', True, 248, '42.2', False],
     [92, '15.7', True, 245, '32.2', True],
     [303, '0.4', False, 184, '12.2', False],
     [168, '0.4', False, 331, '5.2', False]],
    50),
   '-2.414'),
  ('regression: rounding stage',
   ([[327, '48.0', False, 210, '13.5', True],
     [230, '38.2', True, 113, '20.2', False],
     [158, '44.4', True, 281, '26.2', False],
     [344, '46.5', False, 138, '13.4', True]],
    20),
   '-0.707'),
  ('variant scenario 1',
   ([[226, '40.5', False, 269, '26.1', True],
     [167, '33.5', False, 92, '37.0', False],
     [205, '24.5', True, 125, '18', True],
     [199, '47.4', False, 240, '12.2', False],
     [217, '8.2', False, 247, '39', False],
     [296, '18', False, 297, '14.2', False]],
    50),
   '+0.328'),
  ('variant scenario 2', ([[0, '0', False, 0, '0', False]], 50), 'no overs')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: rounding stage',
   ([[168, '4.5', True, 104, '50', False],
     [343, '28.2', False, 323, '38.4', False],
     [90, '38.3', True, 95, '7', True],
     [87, '22', False, 174, '48.3', False],
     [163, '6.1', False, 326, '19.2', False]],
    20),
   '+3.028'),
  ('regression: rounding stage',
   ([[271, '23.3', True, 114, '47.4', False],
     [94, '41.5', True, 238, '3.4', False],
     [315, '34.3', False, 188, '19.2', True],
     [296, '29.4', False, 109, '44.2', True]],
    50),
   '+1.657'),
  ('variant scenario 1',
   ([[114, '36.1', False, 275, '32.0', True],
     [284, '17.4', False, 297, '10.4', True],
     [284, '16.5', False, 223, '30.5', True],
     [305, '45.3', True, 108, '36.1', False],
     [254, '13', True, 317, '37.0', False],
     [89, '15.3', False, 102, '17', True],
     [328, '41', False, 88, '21.2', False]],
    20),
   '+1.838'),
  ('variant scenario 2',
   ([[107, '20.3', False, 313, '10.1', False],
     [299, '42.4', True, 267, '49.1', False],
     [217, '50.4', True, 342, '1.2', True],
     [247, '19.2', False, 278, '49.1', True],
     [296, '28.4', True, 318, '43.3', False],
     [326, '9.0', True, 334, '48.1', False]],
    50),
   '-1.157')]]
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 published net run rate differs by 0.001 from the exact value.

Tournament net run rate. Each match row is [runs_for, overs_faced, all_out_for, runs_against, overs_bowled, all_out_against]. Overs strings use cricket notation "O.B" where B is balls 0-5 ("43.4" = 43 overs 4 balls); a ball digit above 5 returns "invalid overs". When a side was all out its innings counts as the full quota of overs. NRR = total runs for / total overs faced - total runs against / total overs bowled, aggregated over all matches before dividing, formatted as "%+.3f" of the exact value. If either overs total is zero return "no overs".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(matches, quota):
    def balls(text):
        whole, _, part = text.partition('.')
        part = int(part or 0)
        if part > 5:
            return None
        return int(whole) * 6 + part
    rf = bf = ra = ba = 0
    for runs_for, faced, out_for, runs_against, bowled, out_against in matches:
        f = quota * 6 if out_for else balls(faced)
        g = quota * 6 if out_against else balls(bowled)
        if f is None or g is None:
            return 'invalid overs'
        rf += runs_for
        bf += f
        ra += runs_against
        ba += g
    if bf == 0 or ba == 0:
        return 'no overs'
    value = Fraction(rf * 6, bf) - Fraction(ra * 6, ba)
    return '%.3f' % float(value)
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 single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: signed format', ([[117, '8.2', False, 249, '48.1', False]], 50), '+8.870'),
  ('regression: signed format',
   ([[142, '41.4', False, 177, '21', True],
     [164, '4.3', True, 198, '25.6', True],
     [249, '18.2', False, 154, '34.4', False]],
    20),
   '-0.147'),
  ('variant scenario 1',
   ([[244, '32.0', True, 245, '29.2', False], [136, '5.2', False, 309, '36.2', False]], 20),
   '+6.563'),
  ('variant scenario 2',
   ([[305, '0.2', False, 323, '48.4', True], [300, '1', False, 289, '43.5', False]], 20),
   '+444.163')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: signed format',
   ([[337, '42.5', False, 347, '42.2', False],
     [272, '1.3', True, 291, '8.1', False],
     [345, '0.2', False, 254, '30.3', False],
     [350, '35.2', False, 96, '46.3', False]],
    50),
   '+2.399'),
  ('regression: signed format',
   ([[260, '44.0', False, 188, '34.4', True], [285, '32.4', True, 343, '12.5', False]], 50),
   '-2.653'),
  ('variant scenario 1',
   ([[153, '33.3', False, 283, '14.5', False],
     [81, '7.1', True, 186, '28.3', False],
     [171, '50.0', False, 88, '47.4', True],
     [251, '33.7', False, 264, '32.2', True]],
    50),
   'invalid overs'),
  ('variant scenario 2', ([[122, '43.5', True, 196, '46.3', False]], 20), '+1.885')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: signed format',
   ([[346, '14.5', False, 358, '2', False], [334, '28.1', False, 343, '4.1', False]], 20),
   '-97.862'),
  ('regression: signed format',
   ([[235, '0.2', True, 147, '40.2', False], [244, '6.4', True, 292, '11.4', False]], 20),
   '+3.533'),
  ('variant scenario 1', ([[309, '10.0', False, 288, '21.1', True]], 50), '+25.140'),
  ('variant scenario 2',
   ([[294, '35.4', False, 358, '14.2', True],
     [196, '32.3', False, 198, '20.1', False],
     [208, '15.3', True, 108, '16.0', False],
     [307, '41.3', True, 167, '48.5', False]],
    50),
   '-0.179')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: signed format',
   ([[302, '14', True, 149, '1.3', False], [327, '9.1', False, 331, '30.3', True]], 20),
   '-0.760'),
  ('regression: signed format',
   ([[333, '25.0', True, 148, '28.1', False],
     [94, '0.0', False, 102, '36.3', True],
     [114, '1.2', False, 242, '9.2', False]],
    20),
   '+16.803'),
  ('variant scenario 1',
   ([[158, '24.3', False, 222, '40.0', True],
     [153, '44.2', True, 220, '22.2', False],
     [108, '26.4', False, 312, '2.3', False],
     [317, '50.4', True, 132, '49', False]],
    20),
   '-1.369'),
  ('variant scenario 2',
   ([[220, '0.6', False, 358, '37.4', False],
     [297, '12.2', True, 340, '50', False],
     [209, '47.3', True, 198, '38.5', False],
     [331, '11.1', False, 245, '30.5', True],
     [324, '41.5', True, 219, '29.7', False]],
    50),
   'invalid overs')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: signed format', ([[248, '40.3', False, 238, '37.5', True]], 50), '+1.363'),
  ('regression: signed format',
   ([[254, '38.0', False, 285, '35.3', False],
     [345, '5.2', False, 85, '45.1', True],
     [201, '5.2', False, 249, '4.5', False],
     [358, '16.0', True, 311, '10.3', True],
     [254, '48.4', False, 181, '0.4', False],
     [176, '38.5', True, 340, '49.2', False],
     [195, '33.1', True, 280, '1.1', False]],
    50),
   '-1.830'),
  ('variant scenario 1', ([[292, '33.4', False, 333, '28.6', True]], 50), '+2.013'),
  ('variant scenario 2',
   ([[264, '5.0', True, 270, '27.4', False],
     [323, '38.5', False, 241, '28.1', True],
     [271, '30.5', False, 261, '17.5', False],
     [192, '26.1', True, 258, '35', True],
     [197, '49.5', False, 190, '24.2', False],
     [356, '46.5', False, 276, '33.4', False],
     [342, '29.4', True, 191, '20.0', False]],
    50),
   '-1.400')]]
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
from fractions import Fraction
import math
N = 1
observations = []
def solve(matches, quota):
    def balls(text):
        whole, _, part = text.partition('.')
        part = int(part or 0)
        if part > 5:
            return None
        return int(whole) * 6 + part
    rf = bf = ra = ba = 0
    for runs_for, faced, out_for, runs_against, bowled, out_against in matches:
        f = quota * 6 if out_for else balls(faced)
        g = quota * 6 if out_against else balls(bowled)
        if f is None or g is None:
            return 'invalid overs'
        rf += runs_for
        bf += f
        ra += runs_against
        ba += g
    if bf == 0 or ba == 0:
        return 'no overs'
    value = Fraction(rf * 6, bf) - Fraction(ra * 6, ba)
    return '+%.3f' % float(value)
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 single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: signed format', ([[117, '8.2', False, 249, '48.1', False]], 50), '+8.870'),
  ('regression: signed format',
   ([[142, '41.4', False, 177, '21', True],
     [164, '4.3', True, 198, '25.6', True],
     [249, '18.2', False, 154, '34.4', False]],
    20),
   '-0.147'),
  ('variant scenario 1',
   ([[244, '32.0', True, 245, '29.2', False], [136, '5.2', False, 309, '36.2', False]], 20),
   '+6.563'),
  ('variant scenario 2',
   ([[305, '0.2', False, 323, '48.4', True], [300, '1', False, 289, '43.5', False]], 20),
   '+444.163')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: signed format',
   ([[337, '42.5', False, 347, '42.2', False],
     [272, '1.3', True, 291, '8.1', False],
     [345, '0.2', False, 254, '30.3', False],
     [350, '35.2', False, 96, '46.3', False]],
    50),
   '+2.399'),
  ('regression: signed format',
   ([[260, '44.0', False, 188, '34.4', True], [285, '32.4', True, 343, '12.5', False]], 50),
   '-2.653'),
  ('variant scenario 1',
   ([[153, '33.3', False, 283, '14.5', False],
     [81, '7.1', True, 186, '28.3', False],
     [171, '50.0', False, 88, '47.4', True],
     [251, '33.7', False, 264, '32.2', True]],
    50),
   'invalid overs'),
  ('variant scenario 2', ([[122, '43.5', True, 196, '46.3', False]], 20), '+1.885')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: signed format',
   ([[346, '14.5', False, 358, '2', False], [334, '28.1', False, 343, '4.1', False]], 20),
   '-97.862'),
  ('regression: signed format',
   ([[235, '0.2', True, 147, '40.2', False], [244, '6.4', True, 292, '11.4', False]], 20),
   '+3.533'),
  ('variant scenario 1', ([[309, '10.0', False, 288, '21.1', True]], 50), '+25.140'),
  ('variant scenario 2',
   ([[294, '35.4', False, 358, '14.2', True],
     [196, '32.3', False, 198, '20.1', False],
     [208, '15.3', True, 108, '16.0', False],
     [307, '41.3', True, 167, '48.5', False]],
    50),
   '-0.179')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: signed format',
   ([[302, '14', True, 149, '1.3', False], [327, '9.1', False, 331, '30.3', True]], 20),
   '-0.760'),
  ('regression: signed format',
   ([[333, '25.0', True, 148, '28.1', False],
     [94, '0.0', False, 102, '36.3', True],
     [114, '1.2', False, 242, '9.2', False]],
    20),
   '+16.803'),
  ('variant scenario 1',
   ([[158, '24.3', False, 222, '40.0', True],
     [153, '44.2', True, 220, '22.2', False],
     [108, '26.4', False, 312, '2.3', False],
     [317, '50.4', True, 132, '49', False]],
    20),
   '-1.369'),
  ('variant scenario 2',
   ([[220, '0.6', False, 358, '37.4', False],
     [297, '12.2', True, 340, '50', False],
     [209, '47.3', True, 198, '38.5', False],
     [331, '11.1', False, 245, '30.5', True],
     [324, '41.5', True, 219, '29.7', False]],
    50),
   'invalid overs')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: signed format', ([[248, '40.3', False, 238, '37.5', True]], 50), '+1.363'),
  ('regression: signed format',
   ([[254, '38.0', False, 285, '35.3', False],
     [345, '5.2', False, 85, '45.1', True],
     [201, '5.2', False, 249, '4.5', False],
     [358, '16.0', True, 311, '10.3', True],
     [254, '48.4', False, 181, '0.4', False],
     [176, '38.5', True, 340, '49.2', False],
     [195, '33.1', True, 280, '1.1', False]],
    50),
   '-1.830'),
  ('variant scenario 1', ([[292, '33.4', False, 333, '28.6', True]], 50), '+2.013'),
  ('variant scenario 2',
   ([[264, '5.0', True, 270, '27.4', False],
     [323, '38.5', False, 241, '28.1', True],
     [271, '30.5', False, 261, '17.5', False],
     [192, '26.1', True, 258, '35', True],
     [197, '49.5', False, 190, '24.2', False],
     [356, '46.5', False, 276, '33.4', False],
     [342, '29.4', True, 191, '20.0', False]],
    50),
   '-1.400')]]
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:
Standings show "0.512" instead of "+0.512", and negative rates may show a doubled sign.

Tournament net run rate. Each match row is [runs_for, overs_faced, all_out_for, runs_against, overs_bowled, all_out_against]. Overs strings use cricket notation "O.B" where B is balls 0-5 ("43.4" = 43 overs 4 balls); a ball digit above 5 returns "invalid overs". When a side was all out its innings counts as the full quota of overs. NRR = total runs for / total overs faced - total runs against / total overs bowled, aggregated over all matches before dividing, formatted as "%+.3f" of the exact value. If either overs total is zero return "no overs".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(matches, quota):
    def balls(text):
        whole, _, part = text.partition('.')
        part = int(part or 0)
        if part > 5:
            return None
        return int(whole) * 6 + part
    rf = bf = ra = ba = 0
    for runs_for, faced, out_for, runs_against, bowled, out_against in matches:
        f = quota * 6 if out_for else balls(faced)
        g = quota * 6 if out_against else balls(bowled)
        if f is None or g is None:
            return 'invalid overs'
        rf += runs_for
        bf += f
        ra += runs_against
        ba += g
    if bf == 0 and ba == 0:
        return 'no overs'
    value = Fraction(rf * 6, bf) - Fraction(ra * 6, ba)
    return '%+.3f' % float(value)
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 single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: zero overs guard', ([[0, '0', False, 50, '10', False]], 20), 'no overs'),
  ('regression: zero overs guard', ([[112, '37.4', False, 359, '0.0', False]], 20), 'no overs'),
  ('variant scenario 1',
   ([[97, '37.1', True, 113, '12.3', True], [243, '29.4', False, 120, '28', False]], 20),
   '+1.991'),
  ('variant scenario 2',
   ([[141, '47.4', True, 121, '13.2', True],
     [241, '15.2', False, 312, '40.3', False],
     [303, '1.2', False, 251, '21.3', False]],
    20),
   '+10.340')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: zero overs guard', ([[0, '0', False, 50, '10', False]], 20), 'no overs'),
  ('regression: zero overs guard', ([[0, '5', False, 30, '5', False]], 20), '-6.000'),
  ('variant scenario 1',
   ([[100, '17.2', False, 124, '24.2', False],
     [116, '23.2', False, 183, '47.4', False],
     [276, '50.4', True, 337, '28.2', False],
     [117, '29.3', False, 123, '27.2', False]],
    20),
   '+0.746'),
  ('variant scenario 2',
   ([[273, '50.3', False, 339, '0.0', False],
     [266, '31.2', False, 139, '40.2', False],
     [108, '1.2', False, 177, '39.2', True],
     [94, '37.2', True, 161, '7.3', False]],
    20),
   '-4.847')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: zero overs guard', ([[132, '6.3', False, 302, '0.0', False]], 20), 'no overs'),
  ('variant scenario 1', ([[118, '30.0', True, 121, '46.5', False]], 50), '-0.224'),
  ('variant scenario 2',
   ([[133, '6.4', False, 152, '24.4', True],
     [348, '27.2', False, 234, '38.4', True],
     [289, '22.1', False, 331, '45', False],
     [122, '44.3', False, 126, '23.1', False],
     [240, '11', False, 199, '17.3', False]],
    20),
   '+1.846')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: zero overs guard', ([[0, '0', False, 50, '10', False]], 20), 'no overs'),
  ('regression: zero overs guard', ([[0, '5', False, 30, '5', False]], 20), '-6.000'),
  ('variant scenario 1',
   ([[133, '4.1', True, 163, '15.4', True],
     [347, '15.6', False, 137, '28.2', False],
     [106, '0.1', False, 162, '0.2', False],
     [128, '7.4', False, 81, '20.5', False],
     [83, '36.2', False, 189, '21.5', False]],
    20),
   'invalid overs'),
  ('variant scenario 2', ([[177, '43.5', True, 267, '47.4', False]], 20), '+3.249')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: zero overs guard', ([[360, '25.4', False, 360, '0.0', False]], 50), 'no overs'),
  ('variant scenario 1',
   ([[118, '12.2', True, 179, '28.0', False],
     [298, '13.1', False, 285, '42.1', False],
     [181, '50.3', False, 90, '32.3', False]],
    50),
   '-0.144'),
  ('variant scenario 2',
   ([[338, '28.5', False, 263, '35.1', True],
     [150, '13.0', False, 270, '26.2', True],
     [223, '14.2', False, 327, '30.2', True],
     [299, '0.2', False, 155, '50.4', False],
     [293, '8.4', False, 283, '0.5', False],
     [176, '41', False, 100, '11.3', False],
     [341, '40', False, 314, '34.0', False]],
    50),
   '+5.520')]]
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
from fractions import Fraction
import math
N = 1
observations = []
def solve(matches, quota):
    def balls(text):
        whole, _, part = text.partition('.')
        part = int(part or 0)
        if part > 5:
            return None
        return int(whole) * 6 + part
    rf = bf = ra = ba = 0
    for runs_for, faced, out_for, runs_against, bowled, out_against in matches:
        f = quota * 6 if out_for else balls(faced)
        g = quota * 6 if out_against else balls(bowled)
        if f is None or g is None:
            return 'invalid overs'
        rf += runs_for
        bf += f
        ra += runs_against
        ba += g
    if rf == 0 or ra == 0:
        return 'no overs'
    value = Fraction(rf * 6, bf) - Fraction(ra * 6, ba)
    return '%+.3f' % float(value)
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 single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: zero overs guard', ([[0, '0', False, 50, '10', False]], 20), 'no overs'),
  ('regression: zero overs guard', ([[112, '37.4', False, 359, '0.0', False]], 20), 'no overs'),
  ('variant scenario 1',
   ([[97, '37.1', True, 113, '12.3', True], [243, '29.4', False, 120, '28', False]], 20),
   '+1.991'),
  ('variant scenario 2',
   ([[141, '47.4', True, 121, '13.2', True],
     [241, '15.2', False, 312, '40.3', False],
     [303, '1.2', False, 251, '21.3', False]],
    20),
   '+10.340')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: zero overs guard', ([[0, '0', False, 50, '10', False]], 20), 'no overs'),
  ('regression: zero overs guard', ([[0, '5', False, 30, '5', False]], 20), '-6.000'),
  ('variant scenario 1',
   ([[100, '17.2', False, 124, '24.2', False],
     [116, '23.2', False, 183, '47.4', False],
     [276, '50.4', True, 337, '28.2', False],
     [117, '29.3', False, 123, '27.2', False]],
    20),
   '+0.746'),
  ('variant scenario 2',
   ([[273, '50.3', False, 339, '0.0', False],
     [266, '31.2', False, 139, '40.2', False],
     [108, '1.2', False, 177, '39.2', True],
     [94, '37.2', True, 161, '7.3', False]],
    20),
   '-4.847')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: zero overs guard', ([[132, '6.3', False, 302, '0.0', False]], 20), 'no overs'),
  ('variant scenario 1', ([[118, '30.0', True, 121, '46.5', False]], 50), '-0.224'),
  ('variant scenario 2',
   ([[133, '6.4', False, 152, '24.4', True],
     [348, '27.2', False, 234, '38.4', True],
     [289, '22.1', False, 331, '45', False],
     [122, '44.3', False, 126, '23.1', False],
     [240, '11', False, 199, '17.3', False]],
    20),
   '+1.846')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: zero overs guard', ([[0, '0', False, 50, '10', False]], 20), 'no overs'),
  ('regression: zero overs guard', ([[0, '5', False, 30, '5', False]], 20), '-6.000'),
  ('variant scenario 1',
   ([[133, '4.1', True, 163, '15.4', True],
     [347, '15.6', False, 137, '28.2', False],
     [106, '0.1', False, 162, '0.2', False],
     [128, '7.4', False, 81, '20.5', False],
     [83, '36.2', False, 189, '21.5', False]],
    20),
   'invalid overs'),
  ('variant scenario 2', ([[177, '43.5', True, 267, '47.4', False]], 20), '+3.249')],
 [('control single match', ([[300, '50', False, 250, '50', False]], 50), '+1.000'),
  ('boundary partial over', ([[150, '20.3', False, 150, '25', False]], 50), '+1.317'),
  ('boundary all out uses quota', ([[120, '15.2', True, 121, '18.1', False]], 20), '-0.661'),
  ('boundary invalid ball digit', ([[100, '10.6', False, 90, '10', False]], 20), 'invalid overs'),
  ('control no overs', ([[0, '0', False, 0, '0', False]], 20), 'no overs'),
  ('control negative rate', ([[100, '20', False, 160, '20', False]], 20), '-3.000'),
  ('regression: zero overs guard', ([[360, '25.4', False, 360, '0.0', False]], 50), 'no overs'),
  ('variant scenario 1',
   ([[118, '12.2', True, 179, '28.0', False],
     [298, '13.1', False, 285, '42.1', False],
     [181, '50.3', False, 90, '32.3', False]],
    50),
   '-0.144'),
  ('variant scenario 2',
   ([[338, '28.5', False, 263, '35.1', True],
     [150, '13.0', False, 270, '26.2', True],
     [223, '14.2', False, 327, '30.2', True],
     [299, '0.2', False, 155, '50.4', False],
     [293, '8.4', False, 283, '0.5', False],
     [176, '41', False, 100, '11.3', False],
     [341, '40', False, 314, '34.0', False]],
    50),
   '+5.520')]]
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 table with no completed deliveries raises or reports a bogus rate.

Tournament net run rate. Each match row is [runs_for, overs_faced, all_out_for, runs_against, overs_bowled, all_out_against]. Overs strings use cricket notation "O.B" where B is balls 0-5 ("43.4" = 43 overs 4 balls); a ball digit above 5 returns "invalid overs". When a side was all out its innings counts as the full quota of overs. NRR = total runs for / total overs faced - total runs against / total overs bowled, aggregated over all matches before dividing, formatted as "%+.3f" of the exact value. If either overs total is zero return "no overs".

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
            legal += 1
            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 legality', (['1', 'lb2', '1', 'wd1'],), [6, 0, '0.3', 4, 2]),
  ('variant scenario 1',
   (['4', '3', 'wd4', '2', 'lb1', '0', 'wd1', '1', '1'],),
   [19, 0, '1.1', 8, 1]),
  ('variant scenario 2', (['nb1', '4', '1', 'wd1', '3', '1', '3'],), [16, 0, '0.5', 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: wide legality', (['W', 'b4', 'b4', 'wd'],), [9, 1, '0.3', 9, 3]),
  ('regression: wide legality', (['lb2', 'b1', '4', 'wd1'],), [9, 0, '0.3', 5, 1]),
  ('variant scenario 1',
   (['W', '1', 'b1', 'lb1', 'lb1', '4', '3', '2', '0'],),
   [13, 1, '1.3', 3, 3]),
  ('variant scenario 2',
   (['0', '4', 'b1', '1', '0', '1', '1', '0', 'nb4', 'lb1', '2'],),
   [16, 0, '1.4', 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: wide legality',
   (['wd', '2', '4', '0', '1', 'wd4', 'nb1', '0'],),
   [15, 0, '0.5', 7, 1]),
  ('variant scenario 1', (['1', 'wd', '4'],), [6, 0, '0.2', 1, 2]),
  ('variant scenario 2',
   (['0', 'lb1', '2', '1', '0', 'wd1', '4', 'nb1', 'b1', '3', '1', '0', '2', '0', '0'],),
   [19, 0, '2.1', 5, 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 legality',
   (['4', '0', '0', '6', '1', 'nb', '0', '0', '1', 'wd', 'b1'],),
   [15, 0, '1.3', 3, 1]),
  ('regression: wide legality',
   (['2',
     '2',
     'wd1',
     'nb1',
     'wd1',
     '1',
     'nb',
     'lb1',
     '1',
     'nb4',
     '0',
     '2',
     'lb2',
     '0',
     'nb',
     '1',
     'wd4',
     '1'],),
   [31, 0, '1.5', 16, 2]),
  ('variant scenario 1',
   (['0', 'W', '1', '6', '0', '0', '2', '4', '4', '2', 'lb1', 'b4', 'nb4', '1', '0'],),
   [30, 1, '2.2', 6, 2]),
  ('variant scenario 2',
   (['1', '3', '4', '0', '0', '0', 'lb2', '1', 'nb4', '0', '4', 'nb', '3'],),
   [24, 0, '1.5', 4, 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 legality',
   (['1',
     'nb',
     '0',
     '3',
     '2',
     'b4',
     'wd1',
     '0',
     '0',
     '0',
     '0',
     'nb1',
     'wd',
     'wd1',
     '2',
     'nb',
     '0',
     '0',
     '0',
     '0',
     '1',
     '2',
     '3',
     '4',
     '2',
     '1'],),
   [34, 0, '3.2', 12, 2]),
  ('variant scenario 1',
   (['nb4',
     '0',
     'b1',
     '0',
     '0',
     '0',
     '0',
     'wd4',
     '2',
     '1',
     '4',
     '2',
     '0',
     'nb',
     'b4',
     '2',
     '1',
     'nb',
     'wd1',
     'wd1',
     '6',
     '6',
     'nb'],),
   [46, 0, '2.4', 18, 2]),
  ('variant scenario 2',
   (['6',
     '1',
     'nb1',
     'wd4',
     '4',
     '0',
     '0',
     '1',
     '2',
     'nb4',
     '2',
     '0',
     '0',
     'wd',
     '2',
     '1',
     'nb4',
     '4',
     '4',
     '2',
     'b1',
     '0',
     'W',
     '1',
     'wd1'],),
   [51, 1, '3.1', 12, 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
            legal += 1 if k else 0
            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 legality', (['1', 'lb2', '1', 'wd1'],), [6, 0, '0.3', 4, 2]),
  ('variant scenario 1',
   (['4', '3', 'wd4', '2', 'lb1', '0', 'wd1', '1', '1'],),
   [19, 0, '1.1', 8, 1]),
  ('variant scenario 2', (['nb1', '4', '1', 'wd1', '3', '1', '3'],), [16, 0, '0.5', 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: wide legality', (['W', 'b4', 'b4', 'wd'],), [9, 1, '0.3', 9, 3]),
  ('regression: wide legality', (['lb2', 'b1', '4', 'wd1'],), [9, 0, '0.3', 5, 1]),
  ('variant scenario 1',
   (['W', '1', 'b1', 'lb1', 'lb1', '4', '3', '2', '0'],),
   [13, 1, '1.3', 3, 3]),
  ('variant scenario 2',
   (['0', '4', 'b1', '1', '0', '1', '1', '0', 'nb4', 'lb1', '2'],),
   [16, 0, '1.4', 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: wide legality',
   (['wd', '2', '4', '0', '1', 'wd4', 'nb1', '0'],),
   [15, 0, '0.5', 7, 1]),
  ('variant scenario 1', (['1', 'wd', '4'],), [6, 0, '0.2', 1, 2]),
  ('variant scenario 2',
   (['0', 'lb1', '2', '1', '0', 'wd1', '4', 'nb1', 'b1', '3', '1', '0', '2', '0', '0'],),
   [19, 0, '2.1', 5, 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 legality',
   (['4', '0', '0', '6', '1', 'nb', '0', '0', '1', 'wd', 'b1'],),
   [15, 0, '1.3', 3, 1]),
  ('regression: wide legality',
   (['2',
     '2',
     'wd1',
     'nb1',
     'wd1',
     '1',
     'nb',
     'lb1',
     '1',
     'nb4',
     '0',
     '2',
     'lb2',
     '0',
     'nb',
     '1',
     'wd4',
     '1'],),
   [31, 0, '1.5', 16, 2]),
  ('variant scenario 1',
   (['0', 'W', '1', '6', '0', '0', '2', '4', '4', '2', 'lb1', 'b4', 'nb4', '1', '0'],),
   [30, 1, '2.2', 6, 2]),
  ('variant scenario 2',
   (['1', '3', '4', '0', '0', '0', 'lb2', '1', 'nb4', '0', '4', 'nb', '3'],),
   [24, 0, '1.5', 4, 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 legality',
   (['1',
     'nb',
     '0',
     '3',
     '2',
     'b4',
     'wd1',
     '0',
     '0',
     '0',
     '0',
     'nb1',
     'wd',
     'wd1',
     '2',
     'nb',
     '0',
     '0',
     '0',
     '0',
     '1',
     '2',
     '3',
     '4',
     '2',
     '1'],),
   [34, 0, '3.2', 12, 2]),
  ('variant scenario 1',
   (['nb4',
     '0',
     'b1',
     '0',
     '0',
     '0',
     '0',
     'wd4',
     '2',
     '1',
     '4',
     '2',
     '0',
     'nb',
     'b4',
     '2',
     '1',
     'nb',
     'wd1',
     'wd1',
     '6',
     '6',
     'nb'],),
   [46, 0, '2.4', 18, 2]),
  ('variant scenario 2',
   (['6',
     '1',
     'nb1',
     'wd4',
     '4',
     '0',
     '0',
     '1',
     '2',
     'nb4',
     '2',
     '0',
     '0',
     'wd',
     '2',
     '1',
     'nb4',
     '4',
     '4',
     '2',
     'b1',
     '0',
     'W',
     '1',
     'wd1'],),
   [51, 1, '3.1', 12, 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:
The over ends after five legal balls when a wide was bowled in it.

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