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

N = 1
observations = []
def solve(holes, handicap):
    per = []
    for par, si, strokes in holes:
        if handicap >= 0:
            received = handicap // 18 + (1 if si < handicap % 18 else 0)
        else:
            received = -1 if si > 18 + handicap else 0
        if strokes is None:
            per.append(0)
            continue
        per.append(max(0, 2 + par - (strokes - received)))
    return [sum(per), per]
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 scratch par', ([[4, 1, 4], [3, 18, 3]], 0), [4, [2, 2]]),
  ('boundary stroke index equals remainder', ([[4, 5, 5], [4, 6, 5]], 5), [3, [2, 1]]),
  ('boundary second shot above 18', ([[4, 2, 6], [4, 3, 6]], 20), [3, [2, 1]]),
  ('boundary plus handicap', ([[4, 18, 4], [4, 17, 4]], -1), [3, [1, 2]]),
  ('control blob hole', ([[5, 1, 9], [4, 2, None]], 10), [0, [0, 0]]),
  ('control net albatross', ([[5, 1, 4]], 18), [4, [4]]),
  ('regression: allocation boundary',
   ([[3, 18, 6], [5, 7, 8], [4, 1, None], [3, 4, 4], [3, 5, 4]], 20),
   [4, [0, 0, 0, 2, 2]]),
  ('regression: allocation boundary',
   ([[3, 7, 6], [3, 5, 3], [4, 14, 7], [3, 3, 6], [4, 11, 8], [4, 9, None], [5, 16, 7], [5, 2, 6]],
    25),
   [10, [1, 4, 0, 1, 0, 0, 1, 3]]),
  ('variant scenario 1', ([[4, 4, 7], [4, 10, 5], [3, 12, 1]], 18), [7, [0, 2, 5]]),
  ('variant scenario 2',
   ([[3, 7, 3], [4, 8, 6], [3, 18, 3], [5, 17, 7], [5, 9, 4]], 5),
   [7, [2, 0, 2, 0, 3]])],
 [('control scratch par', ([[4, 1, 4], [3, 18, 3]], 0), [4, [2, 2]]),
  ('boundary stroke index equals remainder', ([[4, 5, 5], [4, 6, 5]], 5), [3, [2, 1]]),
  ('boundary second shot above 18', ([[4, 2, 6], [4, 3, 6]], 20), [3, [2, 1]]),
  ('boundary plus handicap', ([[4, 18, 4], [4, 17, 4]], -1), [3, [1, 2]]),
  ('control blob hole', ([[5, 1, 9], [4, 2, None]], 10), [0, [0, 0]]),
  ('control net albatross', ([[5, 1, 4]], 18), [4, [4]]),
  ('regression: allocation boundary',
   ([[5, 18, 6],
     [3, 9, 5],
     [4, 5, 5],
     [4, 15, 7],
     [4, 7, 2],
     [4, 4, 4],
     [3, 13, 2],
     [5, 10, 5],
     [5, 1, 9],
     [4, 6, 7]],
    11),
   [18, [1, 1, 2, 0, 5, 3, 3, 3, 0, 0]]),
  ('regression: allocation boundary',
   ([[4, 15, 2], [4, 17, 4], [5, 10, 5], [4, 18, 5], [3, 2, 2], [4, 16, 8], [3, 14, 4], [4, 9, 2]],
    20),
   [25, [5, 3, 3, 2, 5, 0, 2, 5]]),
  ('variant scenario 1',
   ([[5, 17, 9], [5, 1, 6], [3, 16, 3], [4, 2, 4], [5, 18, 3], [4, 15, 7], [4, 3, 7]], 0),
   [9, [0, 1, 2, 2, 4, 0, 0]]),
  ('variant scenario 2',
   ([[5, 18, 8],
     [3, 10, 3],
     [3, 17, 7],
     [4, 3, 4],
     [4, 8, 5],
     [4, 4, 4],
     [3, 14, 2],
     [5, 6, 5],
     [4, 1, 2]],
    18),
   [23, [0, 3, 0, 3, 2, 3, 4, 3, 5]])],
 [('control scratch par', ([[4, 1, 4], [3, 18, 3]], 0), [4, [2, 2]]),
  ('boundary stroke index equals remainder', ([[4, 5, 5], [4, 6, 5]], 5), [3, [2, 1]]),
  ('boundary second shot above 18', ([[4, 2, 6], [4, 3, 6]], 20), [3, [2, 1]]),
  ('boundary plus handicap', ([[4, 18, 4], [4, 17, 4]], -1), [3, [1, 2]]),
  ('control blob hole', ([[5, 1, 9], [4, 2, None]], 10), [0, [0, 0]]),
  ('control net albatross', ([[5, 1, 4]], 18), [4, [4]]),
  ('regression: allocation boundary',
   ([[4, 18, 8], [3, 16, 5], [3, 5, 1], [5, 17, 4], [3, 12, 7], [3, 9, 5], [4, 7, 5]], 8),
   [10, [0, 0, 5, 3, 0, 0, 2]]),
  ('regression: allocation boundary',
   ([[4, 15, 6], [3, 2, 1], [4, 13, 7], [5, 16, None], [3, 10, 3], [4, 5, 5], [4, 11, 2]], 20),
   [17, [1, 6, 0, 0, 3, 2, 5]]),
  ('variant scenario 1', ([[4, 11, 3], [4, 1, 6], [3, 13, 3], [4, 12, 4]], -2), [7, [3, 0, 2, 2]]),
  ('variant scenario 2', ([[4, 6, 4], [5, 7, 4], [3, 2, 7], [4, 8, 2]], 18), [12, [3, 4, 0, 5]])],
 [('control scratch par', ([[4, 1, 4], [3, 18, 3]], 0), [4, [2, 2]]),
  ('boundary stroke index equals remainder', ([[4, 5, 5], [4, 6, 5]], 5), [3, [2, 1]]),
  ('boundary second shot above 18', ([[4, 2, 6], [4, 3, 6]], 20), [3, [2, 1]]),
  ('boundary plus handicap', ([[4, 18, 4], [4, 17, 4]], -1), [3, [1, 2]]),
  ('control blob hole', ([[5, 1, 9], [4, 2, None]], 10), [0, [0, 0]]),
  ('control net albatross', ([[5, 1, 4]], 18), [4, [4]]),
  ('regression: allocation boundary',
   ([[4, 3, 5], [5, 9, 5], [5, 14, 9], [3, 4, 4], [3, 12, 3], [3, 2, 4], [5, 10, 9]], 2),
   [8, [1, 2, 0, 1, 2, 2, 0]]),
  ('variant scenario 1',
   ([[4, 11, 2], [4, 12, 5], [4, 10, None], [5, 4, 4], [5, 18, 4], [5, 13, 5], [5, 1, 5]], 18),
   [21, [5, 2, 0, 4, 4, 3, 3]]),
  ('variant scenario 2',
   ([[5, 14, 4], [4, 12, 3], [5, 8, 5], [5, 10, 6], [5, 16, 6]], 6),
   [10, [3, 3, 2, 1, 1]])],
 [('control scratch par', ([[4, 1, 4], [3, 18, 3]], 0), [4, [2, 2]]),
  ('boundary stroke index equals remainder', ([[4, 5, 5], [4, 6, 5]], 5), [3, [2, 1]]),
  ('boundary second shot above 18', ([[4, 2, 6], [4, 3, 6]], 20), [3, [2, 1]]),
  ('boundary plus handicap', ([[4, 18, 4], [4, 17, 4]], -1), [3, [1, 2]]),
  ('control blob hole', ([[5, 1, 9], [4, 2, None]], 10), [0, [0, 0]]),
  ('control net albatross', ([[5, 1, 4]], 18), [4, [4]]),
  ('regression: allocation boundary',
   ([[4, 18, 6],
     [5, 7, 5],
     [3, 14, 5],
     [5, 4, 5],
     [5, 11, 5],
     [5, 3, 5],
     [4, 5, 7],
     [4, 1, 4],
     [4, 2, None],
     [4, 17, 4],
     [3, 16, 2],
     [3, 9, 2],
     [4, 6, 8],
     [4, 10, 5]],
    15),
   [27, [0, 3, 1, 3, 3, 3, 0, 3, 0, 2, 3, 4, 0, 2]]),
  ('regression: allocation boundary',
   ([[4, 11, 5],
     [4, 13, 3],
     [5, 9, 5],
     [5, 3, 6],
     [4, 6, 6],
     [4, 17, 4],
     [3, 5, 3],
     [4, 8, 5],
     [4, 15, 3],
     [4, 14, 2]],
    31),
   [36, [3, 5, 4, 3, 2, 3, 4, 3, 4, 5]]),
  ('variant scenario 1',
   ([[4, 10, 4],
     [4, 12, 6],
     [3, 1, 2],
     [4, 9, 4],
     [3, 17, 2],
     [4, 16, 5],
     [5, 5, 5],
     [4, 6, 4],
     [4, 7, 7],
     [5, 2, 8],
     [5, 4, 9]],
    18),
   [23, [3, 1, 4, 3, 4, 2, 3, 3, 0, 0, 0]]),
  ('variant scenario 2',
   ([[4, 5, 3], [5, 15, 4], [5, 3, None], [4, 12, 5], [3, 6, 4], [3, 13, 2]], 14),
   [15, [4, 3, 0, 2, 2, 4]])]]
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(holes, handicap):
    per = []
    for par, si, strokes in holes:
        if handicap >= 0:
            received = handicap // 18 + (1 if si > 18 - handicap % 18 else 0)
        else:
            received = -1 if si > 18 + handicap else 0
        if strokes is None:
            per.append(0)
            continue
        per.append(max(0, 2 + par - (strokes - received)))
    return [sum(per), per]
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 scratch par', ([[4, 1, 4], [3, 18, 3]], 0), [4, [2, 2]]),
  ('boundary stroke index equals remainder', ([[4, 5, 5], [4, 6, 5]], 5), [3, [2, 1]]),
  ('boundary second shot above 18', ([[4, 2, 6], [4, 3, 6]], 20), [3, [2, 1]]),
  ('boundary plus handicap', ([[4, 18, 4], [4, 17, 4]], -1), [3, [1, 2]]),
  ('control blob hole', ([[5, 1, 9], [4, 2, None]], 10), [0, [0, 0]]),
  ('control net albatross', ([[5, 1, 4]], 18), [4, [4]]),
  ('regression: allocation boundary',
   ([[3, 18, 6], [5, 7, 8], [4, 1, None], [3, 4, 4], [3, 5, 4]], 20),
   [4, [0, 0, 0, 2, 2]]),
  ('regression: allocation boundary',
   ([[3, 7, 6], [3, 5, 3], [4, 14, 7], [3, 3, 6], [4, 11, 8], [4, 9, None], [5, 16, 7], [5, 2, 6]],
    25),
   [10, [1, 4, 0, 1, 0, 0, 1, 3]]),
  ('variant scenario 1', ([[4, 4, 7], [4, 10, 5], [3, 12, 1]], 18), [7, [0, 2, 5]]),
  ('variant scenario 2',
   ([[3, 7, 3], [4, 8, 6], [3, 18, 3], [5, 17, 7], [5, 9, 4]], 5),
   [7, [2, 0, 2, 0, 3]])],
 [('control scratch par', ([[4, 1, 4], [3, 18, 3]], 0), [4, [2, 2]]),
  ('boundary stroke index equals remainder', ([[4, 5, 5], [4, 6, 5]], 5), [3, [2, 1]]),
  ('boundary second shot above 18', ([[4, 2, 6], [4, 3, 6]], 20), [3, [2, 1]]),
  ('boundary plus handicap', ([[4, 18, 4], [4, 17, 4]], -1), [3, [1, 2]]),
  ('control blob hole', ([[5, 1, 9], [4, 2, None]], 10), [0, [0, 0]]),
  ('control net albatross', ([[5, 1, 4]], 18), [4, [4]]),
  ('regression: allocation boundary',
   ([[5, 18, 6],
     [3, 9, 5],
     [4, 5, 5],
     [4, 15, 7],
     [4, 7, 2],
     [4, 4, 4],
     [3, 13, 2],
     [5, 10, 5],
     [5, 1, 9],
     [4, 6, 7]],
    11),
   [18, [1, 1, 2, 0, 5, 3, 3, 3, 0, 0]]),
  ('regression: allocation boundary',
   ([[4, 15, 2], [4, 17, 4], [5, 10, 5], [4, 18, 5], [3, 2, 2], [4, 16, 8], [3, 14, 4], [4, 9, 2]],
    20),
   [25, [5, 3, 3, 2, 5, 0, 2, 5]]),
  ('variant scenario 1',
   ([[5, 17, 9], [5, 1, 6], [3, 16, 3], [4, 2, 4], [5, 18, 3], [4, 15, 7], [4, 3, 7]], 0),
   [9, [0, 1, 2, 2, 4, 0, 0]]),
  ('variant scenario 2',
   ([[5, 18, 8],
     [3, 10, 3],
     [3, 17, 7],
     [4, 3, 4],
     [4, 8, 5],
     [4, 4, 4],
     [3, 14, 2],
     [5, 6, 5],
     [4, 1, 2]],
    18),
   [23, [0, 3, 0, 3, 2, 3, 4, 3, 5]])],
 [('control scratch par', ([[4, 1, 4], [3, 18, 3]], 0), [4, [2, 2]]),
  ('boundary stroke index equals remainder', ([[4, 5, 5], [4, 6, 5]], 5), [3, [2, 1]]),
  ('boundary second shot above 18', ([[4, 2, 6], [4, 3, 6]], 20), [3, [2, 1]]),
  ('boundary plus handicap', ([[4, 18, 4], [4, 17, 4]], -1), [3, [1, 2]]),
  ('control blob hole', ([[5, 1, 9], [4, 2, None]], 10), [0, [0, 0]]),
  ('control net albatross', ([[5, 1, 4]], 18), [4, [4]]),
  ('regression: allocation boundary',
   ([[4, 18, 8], [3, 16, 5], [3, 5, 1], [5, 17, 4], [3, 12, 7], [3, 9, 5], [4, 7, 5]], 8),
   [10, [0, 0, 5, 3, 0, 0, 2]]),
  ('regression: allocation boundary',
   ([[4, 15, 6], [3, 2, 1], [4, 13, 7], [5, 16, None], [3, 10, 3], [4, 5, 5], [4, 11, 2]], 20),
   [17, [1, 6, 0, 0, 3, 2, 5]]),
  ('variant scenario 1', ([[4, 11, 3], [4, 1, 6], [3, 13, 3], [4, 12, 4]], -2), [7, [3, 0, 2, 2]]),
  ('variant scenario 2', ([[4, 6, 4], [5, 7, 4], [3, 2, 7], [4, 8, 2]], 18), [12, [3, 4, 0, 5]])],
 [('control scratch par', ([[4, 1, 4], [3, 18, 3]], 0), [4, [2, 2]]),
  ('boundary stroke index equals remainder', ([[4, 5, 5], [4, 6, 5]], 5), [3, [2, 1]]),
  ('boundary second shot above 18', ([[4, 2, 6], [4, 3, 6]], 20), [3, [2, 1]]),
  ('boundary plus handicap', ([[4, 18, 4], [4, 17, 4]], -1), [3, [1, 2]]),
  ('control blob hole', ([[5, 1, 9], [4, 2, None]], 10), [0, [0, 0]]),
  ('control net albatross', ([[5, 1, 4]], 18), [4, [4]]),
  ('regression: allocation boundary',
   ([[4, 3, 5], [5, 9, 5], [5, 14, 9], [3, 4, 4], [3, 12, 3], [3, 2, 4], [5, 10, 9]], 2),
   [8, [1, 2, 0, 1, 2, 2, 0]]),
  ('variant scenario 1',
   ([[4, 11, 2], [4, 12, 5], [4, 10, None], [5, 4, 4], [5, 18, 4], [5, 13, 5], [5, 1, 5]], 18),
   [21, [5, 2, 0, 4, 4, 3, 3]]),
  ('variant scenario 2',
   ([[5, 14, 4], [4, 12, 3], [5, 8, 5], [5, 10, 6], [5, 16, 6]], 6),
   [10, [3, 3, 2, 1, 1]])],
 [('control scratch par', ([[4, 1, 4], [3, 18, 3]], 0), [4, [2, 2]]),
  ('boundary stroke index equals remainder', ([[4, 5, 5], [4, 6, 5]], 5), [3, [2, 1]]),
  ('boundary second shot above 18', ([[4, 2, 6], [4, 3, 6]], 20), [3, [2, 1]]),
  ('boundary plus handicap', ([[4, 18, 4], [4, 17, 4]], -1), [3, [1, 2]]),
  ('control blob hole', ([[5, 1, 9], [4, 2, None]], 10), [0, [0, 0]]),
  ('control net albatross', ([[5, 1, 4]], 18), [4, [4]]),
  ('regression: allocation boundary',
   ([[4, 18, 6],
     [5, 7, 5],
     [3, 14, 5],
     [5, 4, 5],
     [5, 11, 5],
     [5, 3, 5],
     [4, 5, 7],
     [4, 1, 4],
     [4, 2, None],
     [4, 17, 4],
     [3, 16, 2],
     [3, 9, 2],
     [4, 6, 8],
     [4, 10, 5]],
    15),
   [27, [0, 3, 1, 3, 3, 3, 0, 3, 0, 2, 3, 4, 0, 2]]),
  ('regression: allocation boundary',
   ([[4, 11, 5],
     [4, 13, 3],
     [5, 9, 5],
     [5, 3, 6],
     [4, 6, 6],
     [4, 17, 4],
     [3, 5, 3],
     [4, 8, 5],
     [4, 15, 3],
     [4, 14, 2]],
    31),
   [36, [3, 5, 4, 3, 2, 3, 4, 3, 4, 5]]),
  ('variant scenario 1',
   ([[4, 10, 4],
     [4, 12, 6],
     [3, 1, 2],
     [4, 9, 4],
     [3, 17, 2],
     [4, 16, 5],
     [5, 5, 5],
     [4, 6, 4],
     [4, 7, 7],
     [5, 2, 8],
     [5, 4, 9]],
    18),
   [23, [3, 1, 4, 3, 4, 2, 3, 3, 0, 0, 0]]),
  ('variant scenario 2',
   ([[4, 5, 3], [5, 15, 4], [5, 3, None], [4, 12, 5], [3, 6, 4], [3, 13, 2]], 14),
   [15, [4, 3, 0, 2, 2, 4]])]]
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 5-handicap player gets no stroke on stroke index 5.

Stableford points with stroke allocation. holes rows are [par, stroke_index, strokes] with stroke index 1-18 and strokes None for a hole with no score. A handicap H >= 0 receives H // 18 strokes on every hole plus one more on holes with stroke index <= H % 18. A plus handicap (H < 0) gives back one stroke on holes with stroke index > 18 + H. Points = max(0, 2 + par - (strokes - received)); a hole with no score earns 0. Return [total, per-hole points].

split: open-access


meaning: Fixture-count band, not measured model difficulty

deps: stdlib

prompt:
A double-bogey on a stroke hole scores too many or too few points.

Stableford points with stroke allocation. holes rows are [par, stroke_index, strokes] with stroke index 1-18 and strokes None for a hole with no score. A handicap H >= 0 receives H // 18 strokes on every hole plus one more on holes with stroke index <= H % 18. A plus handicap (H < 0) gives back one stroke on holes with stroke index > 18 + H. Points = max(0, 2 + par - (strokes - received)); a hole with no score earns 0. Return [total, per-hole points].

split: open-access


prompt:
A +2 golfer is given strokes on the two hardest holes.

Stableford points with stroke allocation. holes rows are [par, stroke_index, strokes] with stroke index 1-18 and strokes None for a hole with no score. A handicap H >= 0 receives H // 18 strokes on every hole plus one more on holes with stroke index <= H % 18. A plus handicap (H < 0) gives back one stroke on holes with stroke index > 18 + H. Points = max(0, 2 + par - (strokes - received)); a hole with no score earns 0. Return [total, per-hole points].

split: open-access


prompt:
A 20-handicap player receives only one stroke on the hardest holes.

Stableford points with stroke allocation. holes rows are [par, stroke_index, strokes] with stroke index 1-18 and strokes None for a hole with no score. A handicap H >= 0 receives H // 18 strokes on every hole plus one more on holes with stroke index <= H % 18. A plus handicap (H < 0) gives back one stroke on holes with stroke index > 18 + H. Points = max(0, 2 + par - (strokes - received)); a hole with no score earns 0. Return [total, per-hole points].

split: open-access


prompt:
A hole marked with no score raises an error or disappears from the per-hole list.

Stableford points with stroke allocation. holes rows are [par, stroke_index, strokes] with stroke index 1-18 and strokes None for a hole with no score. A handicap H >= 0 receives H // 18 strokes on every hole plus one more on holes with stroke index <= H % 18. A plus handicap (H < 0) gives back one stroke on holes with stroke index > 18 + H. Points = max(0, 2 + par - (strokes - received)); a hole with no score earns 0. Return [total, per-hole points].

split: open-access


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

N = 1
observations = []
def solve(holes):
    lead = 0
    played = 0
    for h in holes:
        played += 1
        if h == 'A':
            lead += 1
        elif h == 'B':
            lead -= 1
        remaining = 18 - played
        if abs(lead) >= remaining:
            side = 'A' if lead > 0 else 'B'
            if remaining == 0:
                return '%s wins %d up' % (side, abs(lead))
            return '%s wins %d&%d' % (side, abs(lead), remaining)
    if played == 18:
        return 'halved'
    remaining = 18 - played
    if lead == 0:
        return 'all square'
    side = 'A' if lead > 0 else 'B'
    if abs(lead) == remaining:
        return '%s dormie %d' % (side, remaining)
    return '%s %d up' % (side, abs(lead))
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 early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure condition', ('BBHAABABABBHBBABA',), 'B wins 4&2'),
  ('variant scenario 1', ('HBAABBABBBAAABAHBBAABB',), 'B wins 2 up'),
  ('variant scenario 2', ('HABBAHHAAH',), 'A 2 up')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure condition', ('BBHAAHHBBABBBABBABH',), 'B wins 4&3'),
  ('regression: closure condition', ('AAHAHABAAHABH',), 'A dormie 5'),
  ('variant scenario 1', ('HBHBAHBHAHBBAAA',), 'all square'),
  ('variant scenario 2', ('BABHBBBAAHA',), 'B 1 up')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure condition', ('AABHAHABBBAAABAB',), 'A dormie 2'),
  ('regression: closure condition', ('AAHBABAHABBHBBBHABHA',), 'B wins 2 up'),
  ('variant scenario 1', ('ABAHAAAHAAAAAAHHBBABA',), 'A wins 8&6'),
  ('variant scenario 2', ('AHAHHABAABAAAABAH',), 'A wins 6&5')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure condition', ('BBBAAHHBAABBBHHBAB',), 'B wins 4&2'),
  ('variant scenario 1', ('BHABBABABHAH',), 'B 1 up'),
  ('variant scenario 2', ('ABHBABBBHHBBBAB',), 'B wins 6&5')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure condition', ('BBHABABABBABHHBBHB',), 'B wins 4&3'),
  ('regression: closure condition', ('BAAHHAAHAHBBABAAAAA',), 'A wins 4&2'),
  ('variant scenario 1', ('ABBBABHAAAH',), 'A 1 up'),
  ('variant scenario 2', ('AABBHAAHBAAHAABABA',), 'A wins 5&4')]]
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(holes):
    lead = 0
    played = 0
    for h in holes:
        played += 1
        if h == 'A':
            lead += 1
        elif h == 'B':
            lead -= 1
        remaining = 18 - played
        if lead > remaining:
            side = 'A' if lead > 0 else 'B'
            if remaining == 0:
                return '%s wins %d up' % (side, abs(lead))
            return '%s wins %d&%d' % (side, abs(lead), remaining)
    if played == 18:
        return 'halved'
    remaining = 18 - played
    if lead == 0:
        return 'all square'
    side = 'A' if lead > 0 else 'B'
    if abs(lead) == remaining:
        return '%s dormie %d' % (side, remaining)
    return '%s %d up' % (side, abs(lead))
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 early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure condition', ('BBHAABABABBHBBABA',), 'B wins 4&2'),
  ('variant scenario 1', ('HBAABBABBBAAABAHBBAABB',), 'B wins 2 up'),
  ('variant scenario 2', ('HABBAHHAAH',), 'A 2 up')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure condition', ('BBHAAHHBBABBBABBABH',), 'B wins 4&3'),
  ('regression: closure condition', ('AAHAHABAAHABH',), 'A dormie 5'),
  ('variant scenario 1', ('HBHBAHBHAHBBAAA',), 'all square'),
  ('variant scenario 2', ('BABHBBBAAHA',), 'B 1 up')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure condition', ('AABHAHABBBAAABAB',), 'A dormie 2'),
  ('regression: closure condition', ('AAHBABAHABBHBBBHABHA',), 'B wins 2 up'),
  ('variant scenario 1', ('ABAHAAAHAAAAAAHHBBABA',), 'A wins 8&6'),
  ('variant scenario 2', ('AHAHHABAABAAAABAH',), 'A wins 6&5')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure condition', ('BBBAAHHBAABBBHHBAB',), 'B wins 4&2'),
  ('variant scenario 1', ('BHABBABABHAH',), 'B 1 up'),
  ('variant scenario 2', ('ABHBABBBHHBBBAB',), 'B wins 6&5')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure condition', ('BBHABABABBABHHBBHB',), 'B wins 4&3'),
  ('regression: closure condition', ('BAAHHAAHAHBBABAAAAA',), 'A wins 4&2'),
  ('variant scenario 1', ('ABBBABHAAAH',), 'A 1 up'),
  ('variant scenario 2', ('AABBHAAHBAAHAABABA',), 'A wins 5&4')]]
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 player 3 up with 3 to play is declared the winner.

Eighteen-hole match play. holes is a string of hole results: A, B or H (halved). The match closes as soon as the lead exceeds the holes remaining: "X wins L&R" (L lead, R remaining), or "X wins L up" if it closes on the 18th. Later characters are ignored. After 18 holes level: "halved". Unfinished: "all square", "X dormie R" when the lead equals the holes remaining, otherwise "X L up".

split: open-access


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

N = 1
observations = []
def solve(holes):
    lead = 0
    played = 0
    for h in holes:
        played += 1
        if h == 'A':
            lead += 1
        elif h == 'B':
            lead -= 1
        remaining = 18 - played
        if abs(lead) > remaining:
            side = 'A' if lead > 0 else 'B'
            if remaining == 0:
                return '%s wins %d up' % (side, abs(lead))
            return '%s wins %d&%d' % (side, abs(lead), played)
    if played == 18:
        return 'halved'
    remaining = 18 - played
    if lead == 0:
        return 'all square'
    side = 'A' if lead > 0 else 'B'
    if abs(lead) == remaining:
        return '%s dormie %d' % (side, remaining)
    return '%s %d up' % (side, abs(lead))
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 early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure notation', ('ABHHAHBBAAABAABAAAH',), 'A wins 3&2'),
  ('variant scenario 1', ('AHAAAAAAB',), 'A 6 up'),
  ('variant scenario 2', ('AABBBHHBBBBABAA',), 'B dormie 3')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure notation', ('BBAHHHHBHHABAHBHAAA',), 'A wins 1&-1'),
  ('variant scenario 1', ('HAAHHBBH',), 'all square'),
  ('variant scenario 2', ('BAABABHB',), 'B 1 up')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure notation', ('AHAHHABAAHHAHBAAABAABB',), 'A wins 5&3'),
  ('variant scenario 1', ('ABABHAHA',), 'A 2 up'),
  ('variant scenario 2', ('HAHAHAAAAAAAAHAHHA',), 'A wins 8&7')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure notation', ('HAAAABHBBAAAHBBHAHB',), 'A wins 3&1'),
  ('variant scenario 1', ('ABAHBHBAA',), 'A 1 up'),
  ('variant scenario 2', ('BBBAAHAAABBBABH',), 'B 1 up')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure notation', ('ABHBHAAAAHAAA',), 'A wins 6&5'),
  ('variant scenario 1', ('BABHHBHAAAABAAABBHHB',), 'A wins 4&3'),
  ('variant scenario 2', ('AHBAAHBAHAAAABABAABAB',), 'A wins 6&5')]]
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(holes):
    lead = 0
    played = 0
    for h in holes:
        played += 1
        if h == 'A':
            lead += 1
        elif h == 'B':
            lead -= 1
        remaining = 18 - played
        if abs(lead) > remaining:
            side = 'A' if lead > 0 else 'B'
            if remaining == 0:
                return '%s wins %d up' % (side, abs(lead))
            return '%s wins %d&%d' % (side, abs(lead), remaining + 1)
    if played == 18:
        return 'halved'
    remaining = 18 - played
    if lead == 0:
        return 'all square'
    side = 'A' if lead > 0 else 'B'
    if abs(lead) == remaining:
        return '%s dormie %d' % (side, remaining)
    return '%s %d up' % (side, abs(lead))
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 early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure notation', ('ABHHAHBBAAABAABAAAH',), 'A wins 3&2'),
  ('variant scenario 1', ('AHAAAAAAB',), 'A 6 up'),
  ('variant scenario 2', ('AABBBHHBBBBABAA',), 'B dormie 3')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure notation', ('BBAHHHHBHHABAHBHAAA',), 'A wins 1&-1'),
  ('variant scenario 1', ('HAAHHBBH',), 'all square'),
  ('variant scenario 2', ('BAABABHB',), 'B 1 up')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure notation', ('AHAHHABAAHHAHBAAABAABB',), 'A wins 5&3'),
  ('variant scenario 1', ('ABABHAHA',), 'A 2 up'),
  ('variant scenario 2', ('HAHAHAAAAAAAAHAHHA',), 'A wins 8&7')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure notation', ('HAAAABHBBAAAHBBHAHB',), 'A wins 3&1'),
  ('variant scenario 1', ('ABAHBHBAA',), 'A 1 up'),
  ('variant scenario 2', ('BBBAAHAAABBBABH',), 'B 1 up')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: closure notation', ('ABHBHAAAAHAAA',), 'A wins 6&5'),
  ('variant scenario 1', ('BABHHBHAAAABAAABBHHB',), 'A wins 4&3'),
  ('variant scenario 2', ('AHBAAHBAHAAAABABAABAB',), 'A wins 6&5')]]
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 3&2 win is printed as "3&16" or "3&3".

Eighteen-hole match play. holes is a string of hole results: A, B or H (halved). The match closes as soon as the lead exceeds the holes remaining: "X wins L&R" (L lead, R remaining), or "X wins L up" if it closes on the 18th. Later characters are ignored. After 18 holes level: "halved". Unfinished: "all square", "X dormie R" when the lead equals the holes remaining, otherwise "X L up".

split: open-access


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

N = 1
observations = []
def solve(holes):
    lead = 0
    played = 0
    for h in holes:
        played += 1
        if h == 'A':
            lead += 1
        elif h == 'B':
            lead -= 1
        remaining = 18 - played
        if abs(lead) > remaining:
            side = 'A' if lead > 0 else 'B'
            if False:
                return '%s wins %d up' % (side, abs(lead))
            return '%s wins %d&%d' % (side, abs(lead), remaining)
    if played == 18:
        return 'halved'
    remaining = 18 - played
    if lead == 0:
        return 'all square'
    side = 'A' if lead > 0 else 'B'
    if abs(lead) == remaining:
        return '%s dormie %d' % (side, remaining)
    return '%s %d up' % (side, abs(lead))
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 early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: final hole closure', ('BBABAHABBABABHHABHHABH',), 'B wins 2&1'),
  ('regression: final hole closure', ('HABBABHAHAABBBBHAHBAAA',), 'B wins 1 up'),
  ('variant scenario 1', ('AAAHAHHBABAHA',), 'A dormie 5'),
  ('variant scenario 2', ('HHBBAAAAABHABAABBB',), 'A wins 4&3')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: final hole closure', ('BABABABHABBBHAAHHAHAA',), 'B wins 0&-1'),
  ('regression: final hole closure', ('AHBHABBAABHBHAABHABAAB',), 'A wins 1 up'),
  ('variant scenario 1', ('BBBBHBBBHBA',), 'B dormie 7'),
  ('variant scenario 2', ('ABHBBHBBAAAAA',), 'A 1 up')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: final hole closure', ('BAAABHAABAHABBBBBAB',), 'B wins 1&-1'),
  ('regression: final hole closure', ('HABHHABBBHABHBAAHBA',), 'B wins 2 up'),
  ('variant scenario 1', ('AHABBABAHBAAABAAAA',), 'A wins 4&2'),
  ('variant scenario 2', ('AABAAHHAAABBBBHABABHBB',), 'A wins 3&2')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: final hole closure', ('BHBBBHAABHBAABAAHABBBA',), 'B wins 1&-1'),
  ('regression: final hole closure', ('ABHHBABABBAHABAHBBB',), 'B wins 2 up'),
  ('variant scenario 1', ('HBHHHHBAA',), 'all square'),
  ('variant scenario 2', ('HAHHABBBAAHAB',), 'A 1 up')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: final hole closure', ('BBBABBAHBBAABAHABBAABA',), 'B wins 3&1'),
  ('regression: final hole closure', ('HHABABAAHBBABBBAABABA',), 'B wins 1 up'),
  ('variant scenario 1', ('ABHAABABABAH',), 'A 2 up'),
  ('variant scenario 2', ('AHBAAABBAAAH',), 'A 4 up')]]
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(holes):
    lead = 0
    played = 0
    for h in holes:
        played += 1
        if h == 'A':
            lead += 1
        elif h == 'B':
            lead -= 1
        remaining = 18 - played
        if abs(lead) > remaining:
            side = 'A' if lead > 0 else 'B'
            if remaining <= 1:
                return '%s wins %d up' % (side, abs(lead))
            return '%s wins %d&%d' % (side, abs(lead), remaining)
    if played == 18:
        return 'halved'
    remaining = 18 - played
    if lead == 0:
        return 'all square'
    side = 'A' if lead > 0 else 'B'
    if abs(lead) == remaining:
        return '%s dormie %d' % (side, remaining)
    return '%s %d up' % (side, abs(lead))
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 early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: final hole closure', ('BBABAHABBABABHHABHHABH',), 'B wins 2&1'),
  ('regression: final hole closure', ('HABBABHAHAABBBBHAHBAAA',), 'B wins 1 up'),
  ('variant scenario 1', ('AAAHAHHBABAHA',), 'A dormie 5'),
  ('variant scenario 2', ('HHBBAAAAABHABAABBB',), 'A wins 4&3')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: final hole closure', ('BABABABHABBBHAAHHAHAA',), 'B wins 0&-1'),
  ('regression: final hole closure', ('AHBHABBAABHBHAABHABAAB',), 'A wins 1 up'),
  ('variant scenario 1', ('BBBBHBBBHBA',), 'B dormie 7'),
  ('variant scenario 2', ('ABHBBHBBAAAAA',), 'A 1 up')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: final hole closure', ('BAAABHAABAHABBBBBAB',), 'B wins 1&-1'),
  ('regression: final hole closure', ('HABHHABBBHABHBAAHBA',), 'B wins 2 up'),
  ('variant scenario 1', ('AHABBABAHBAAABAAAA',), 'A wins 4&2'),
  ('variant scenario 2', ('AABAAHHAAABBBBHABABHBB',), 'A wins 3&2')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: final hole closure', ('BHBBBHAABHBAABAAHABBBA',), 'B wins 1&-1'),
  ('regression: final hole closure', ('ABHHBABABBAHABAHBBB',), 'B wins 2 up'),
  ('variant scenario 1', ('HBHHHHBAA',), 'all square'),
  ('variant scenario 2', ('HAHHABBBAAHAB',), 'A 1 up')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: final hole closure', ('BBBABBAHBBAABAHABBAABA',), 'B wins 3&1'),
  ('regression: final hole closure', ('HHABABAAHBBABBBAABABA',), 'B wins 1 up'),
  ('variant scenario 1', ('ABHAABABABAH',), 'A 2 up'),
  ('variant scenario 2', ('AHBAAABBAAAH',), 'A 4 up')]]
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 match won on the last hole is shown as "A wins 1&0".

Eighteen-hole match play. holes is a string of hole results: A, B or H (halved). The match closes as soon as the lead exceeds the holes remaining: "X wins L&R" (L lead, R remaining), or "X wins L up" if it closes on the 18th. Later characters are ignored. After 18 holes level: "halved". Unfinished: "all square", "X dormie R" when the lead equals the holes remaining, otherwise "X L up".

split: open-access


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

N = 1
observations = []
def solve(holes):
    lead = 0
    played = 0
    for h in holes:
        played += 1
        if h == 'A':
            lead += 1
        elif h == 'B':
            lead -= 1
        remaining = 18 - played
        if abs(lead) > remaining:
            side = 'A' if lead > 0 else 'B'
            if remaining == 0:
                return '%s wins %d up' % (side, abs(lead))
            return '%s wins %d&%d' % (side, abs(lead), remaining)
    if played == 18:
        return 'halved'
    remaining = 18 - played
    if lead == 0:
        return 'all square'
    side = 'A' if lead > 0 else 'B'
    if lead == remaining:
        return '%s dormie %d' % (side, remaining)
    return '%s %d up' % (side, abs(lead))
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 early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: dormie detection', ('BAHBHBAABAAAHHBA',), 'A dormie 2'),
  ('regression: dormie detection', ('ABBBBBAHABBHBA',), 'B dormie 4'),
  ('variant scenario 1', ('HBHAABAHBBBBHABBAABH',), 'B wins 4&2'),
  ('variant scenario 2', ('AHABABAA',), 'A 3 up')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: dormie detection', ('HABBHABHBABBHBA',), 'B dormie 3'),
  ('variant scenario 1', ('AHAAABBHBAABA',), 'A 3 up'),
  ('variant scenario 2', ('BBAAAABAB',), 'A 1 up')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: dormie detection', ('AABBBAHBAAAAABH',), 'A dormie 3'),
  ('regression: dormie detection', ('ABABBHBBHAABBAB',), 'B dormie 3'),
  ('variant scenario 1', ('AABAAAAAAAHBHBH',), 'A wins 8&7'),
  ('variant scenario 2', ('HBAHBABABAA',), 'A 1 up')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: dormie detection', ('BBHABABABAHBBAB',), 'B dormie 3'),
  ('variant scenario 1', ('BAAHBABA',), 'A 1 up'),
  ('variant scenario 2', ('AABBABHAAAHAAAHBH',), 'A wins 6&4')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: dormie detection', ('AHAAAABABAABBBH',), 'A dormie 3'),
  ('regression: dormie detection', ('BHABAAABHABBBBB',), 'B dormie 3'),
  ('variant scenario 1', ('HHABAAABHA',), 'A 3 up'),
  ('variant scenario 2', ('AHBBAAAHBHBAAHBABAH',), 'A wins 2 up')]]
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(holes):
    lead = 0
    played = 0
    for h in holes:
        played += 1
        if h == 'A':
            lead += 1
        elif h == 'B':
            lead -= 1
        remaining = 18 - played
        if abs(lead) > remaining:
            side = 'A' if lead > 0 else 'B'
            if remaining == 0:
                return '%s wins %d up' % (side, abs(lead))
            return '%s wins %d&%d' % (side, abs(lead), remaining)
    if played == 18:
        return 'halved'
    remaining = 18 - played
    if lead == 0:
        return 'all square'
    side = 'A' if lead > 0 else 'B'
    if abs(lead) == remaining == 1:
        return '%s dormie %d' % (side, remaining)
    return '%s %d up' % (side, abs(lead))
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 early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: dormie detection', ('BAHBHBAABAAAHHBA',), 'A dormie 2'),
  ('regression: dormie detection', ('ABBBBBAHABBHBA',), 'B dormie 4'),
  ('variant scenario 1', ('HBHAABAHBBBBHABBAABH',), 'B wins 4&2'),
  ('variant scenario 2', ('AHABABAA',), 'A 3 up')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: dormie detection', ('HABBHABHBABBHBA',), 'B dormie 3'),
  ('variant scenario 1', ('AHAAABBHBAABA',), 'A 3 up'),
  ('variant scenario 2', ('BBAAAABAB',), 'A 1 up')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: dormie detection', ('AABBBAHBAAAAABH',), 'A dormie 3'),
  ('regression: dormie detection', ('ABABBHBBHAABBAB',), 'B dormie 3'),
  ('variant scenario 1', ('AABAAAAAAAHBHBH',), 'A wins 8&7'),
  ('variant scenario 2', ('HBAHBABABAA',), 'A 1 up')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: dormie detection', ('BBHABABABAHBBAB',), 'B dormie 3'),
  ('variant scenario 1', ('BAAHBABA',), 'A 1 up'),
  ('variant scenario 2', ('AABBABHAAAHAAAHBH',), 'A wins 6&4')],
 [('control early lead', ('AAH',), 'A 2 up'),
  ('boundary dormie', ('AAAHHHHHHHHHHHH',), 'A dormie 3'),
  ('boundary closure three and two', ('BBBHHHHHHHHHHHHH',), 'B wins 3&2'),
  ('boundary one up at eighteen', ('AHHHHHHHHHHHHHHHHH',), 'A wins 1 up'),
  ('control halved match', ('ABABABABABABABABAB',), 'halved'),
  ('control all square', ('HAB',), 'all square'),
  ('regression: dormie detection', ('AHAAAABABAABBBH',), 'A dormie 3'),
  ('regression: dormie detection', ('BHABAAABHABBBBB',), 'B dormie 3'),
  ('variant scenario 1', ('HHABAAABHA',), 'A 3 up'),
  ('variant scenario 2', ('AHBBAAAHBHBAAHBABAH',), 'A wins 2 up')]]
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:
B dormie situations display as "B 3 up".

Eighteen-hole match play. holes is a string of hole results: A, B or H (halved). The match closes as soon as the lead exceeds the holes remaining: "X wins L&R" (L lead, R remaining), or "X wins L up" if it closes on the 18th. Later characters are ignored. After 18 holes level: "halved". Unfinished: "all square", "X dormie R" when the lead equals the holes remaining, otherwise "X L up".

split: open-access


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

N = 1
observations = []
def solve(start, darts):
    def value(d):
        if d == 'M':
            return 0, False
        if d == 'SB':
            return 25, False
        if d == 'DB':
            return 50, True
        mult = {'S': 1, 'D': 2, 'T': 3}[d[0]]
        return mult * int(d[1:]), d[0] == 'D'
    score = start
    turns = 0
    i = 0
    while i < len(darts):
        turns += 1
        turn_start = score
        for k in range(3):
            if i >= len(darts):
                break
            v, dbl = value(darts[i])
            i += 1
            score -= v
            if score == 0 and dbl:
                return [0, turns, True]
            if score < 2:
                score += v
                break
    return [score, turns, False]
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 checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust reversion scope',
   (20, ['S13', 'D5', 'T12', 'T17', 'D7', 'D13', 'S6']),
   [14, 5, False]),
  ('regression: bust reversion scope',
   (54, ['D13', 'S13', 'DB', 'M', 'S9', 'S16', 'D16', 'M']),
   [29, 4, False]),
  ('variant scenario 1',
   (45, ['T10', 'S14', 'S20', 'D1', 'SB', 'D19', 'D20', 'D16', 'S14']),
   [45, 4, False]),
  ('variant scenario 2',
   (36, ['S18', 'D12', 'D4', 'D15', 'D11', 'D12', 'D11', 'D11']),
   [36, 4, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust reversion scope', (50, ['T3', 'D4', 'S8', 'T8', 'S9', 'SB']), [25, 3, False]),
  ('variant scenario 1', (32, ['D4', 'D14', 'SB', 'DB', 'D15', 'S4', 'S5', 'T5']), [12, 4, False]),
  ('variant scenario 2', (50, ['DB']), [0, 1, True])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust reversion scope', (32, ['T2', 'S18', 'S12', 'D7']), [18, 2, False]),
  ('regression: bust reversion scope',
   (101, ['D11', 'D9', 'S5', 'D12', 'D11', 'DB']),
   [56, 2, False]),
  ('variant scenario 1', (3, ['D10', 'T9']), [3, 2, False]),
  ('variant scenario 2', (101, ['D15', 'S1', 'D1']), [68, 1, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust reversion scope', (50, ['T4', 'S8', 'S4', 'T1', 'SB', 'T12']), [26, 3, False]),
  ('variant scenario 1', (3, ['S19', 'D6', 'D4', 'D19', 'D5', 'D9', 'T10', 'S14']), [3, 8, False]),
  ('variant scenario 2', (16, ['D13', 'D17', 'D8', 'S8']), [0, 3, True])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust reversion scope',
   (10, ['S16', 'D18', 'T5', 'D20', 'D2', 'D4', 'S9', 'D16', 'D2']),
   [6, 8, False]),
  ('regression: bust reversion scope',
   (101, ['D9', 'T11', 'SB', 'D15', 'T19', 'S7']),
   [18, 4, False]),
  ('variant scenario 1', (3, ['M', 'D19', 'T10', 'T8', 'D5', 'S4', 'M', 'S3']), [3, 6, False]),
  ('variant scenario 2', (101, ['D5', 'D12']), [67, 1, False])]]
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(start, darts):
    def value(d):
        if d == 'M':
            return 0, False
        if d == 'SB':
            return 25, False
        if d == 'DB':
            return 50, True
        mult = {'S': 1, 'D': 2, 'T': 3}[d[0]]
        return mult * int(d[1:]), d[0] == 'D'
    score = start
    turns = 0
    i = 0
    while i < len(darts):
        turns += 1
        turn_start = score
        for k in range(3):
            if i >= len(darts):
                break
            v, dbl = value(darts[i])
            i += 1
            score -= v
            if score == 0 and dbl:
                return [0, turns, True]
            if score < 2:
                score = start
                break
    return [score, turns, False]
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 checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust reversion scope',
   (20, ['S13', 'D5', 'T12', 'T17', 'D7', 'D13', 'S6']),
   [14, 5, False]),
  ('regression: bust reversion scope',
   (54, ['D13', 'S13', 'DB', 'M', 'S9', 'S16', 'D16', 'M']),
   [29, 4, False]),
  ('variant scenario 1',
   (45, ['T10', 'S14', 'S20', 'D1', 'SB', 'D19', 'D20', 'D16', 'S14']),
   [45, 4, False]),
  ('variant scenario 2',
   (36, ['S18', 'D12', 'D4', 'D15', 'D11', 'D12', 'D11', 'D11']),
   [36, 4, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust reversion scope', (50, ['T3', 'D4', 'S8', 'T8', 'S9', 'SB']), [25, 3, False]),
  ('variant scenario 1', (32, ['D4', 'D14', 'SB', 'DB', 'D15', 'S4', 'S5', 'T5']), [12, 4, False]),
  ('variant scenario 2', (50, ['DB']), [0, 1, True])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust reversion scope', (32, ['T2', 'S18', 'S12', 'D7']), [18, 2, False]),
  ('regression: bust reversion scope',
   (101, ['D11', 'D9', 'S5', 'D12', 'D11', 'DB']),
   [56, 2, False]),
  ('variant scenario 1', (3, ['D10', 'T9']), [3, 2, False]),
  ('variant scenario 2', (101, ['D15', 'S1', 'D1']), [68, 1, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust reversion scope', (50, ['T4', 'S8', 'S4', 'T1', 'SB', 'T12']), [26, 3, False]),
  ('variant scenario 1', (3, ['S19', 'D6', 'D4', 'D19', 'D5', 'D9', 'T10', 'S14']), [3, 8, False]),
  ('variant scenario 2', (16, ['D13', 'D17', 'D8', 'S8']), [0, 3, True])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust reversion scope',
   (10, ['S16', 'D18', 'T5', 'D20', 'D2', 'D4', 'S9', 'D16', 'D2']),
   [6, 8, False]),
  ('regression: bust reversion scope',
   (101, ['D9', 'T11', 'SB', 'D15', 'T19', 'S7']),
   [18, 4, False]),
  ('variant scenario 1', (3, ['M', 'D19', 'T10', 'T8', 'D5', 'S4', 'M', 'S3']), [3, 6, False]),
  ('variant scenario 2', (101, ['D5', 'D12']), [67, 1, False])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
After a bust the remaining score keeps the earlier darts of the turn.

Double-out darts leg from a remaining score. darts lists thrown darts: S/D/T followed by 1-20, SB (25), DB (50, a double) or M (miss). Turns are three darts. After each dart: reaching exactly 0 with a double (D* or DB) checks out and later darts are ignored; a remaining score below 2 otherwise is a bust, the score reverts to its value at the start of the turn and the turn ends immediately (the next dart in the list starts a new turn). Return [remaining, turns used, checked_out].

split: open-access


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

N = 1
observations = []
def solve(start, darts):
    def value(d):
        if d == 'M':
            return 0, False
        if d == 'SB':
            return 25, False
        if d == 'DB':
            return 50, True
        mult = {'S': 1, 'D': 2, 'T': 3}[d[0]]
        return mult * int(d[1:]), d[0] == 'D'
    score = start
    turns = 0
    i = 0
    while i < len(darts):
        turns += 1
        turn_start = score
        for k in range(3):
            if i >= len(darts):
                break
            v, dbl = value(darts[i])
            i += 1
            score -= v
            if score == 0 and dbl:
                return [0, turns, True]
            if score < 2:
                score = turn_start
    return [score, turns, False]
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 checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust ends turn', (3, ['S14', 'D16', 'D3']), [3, 3, False]),
  ('variant scenario 1', (15, ['T4', 'D13', 'DB', 'D5', 'S19', 'D12', 'D4']), [7, 5, False]),
  ('variant scenario 2', (59, ['D10', 'S18', 'S11', 'D1', 'SB']), [10, 2, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust ends turn',
   (23, ['D8', 'D8', 'S16', 'D2', 'D8', 'S1', 'M', 'DB', 'T19']),
   [23, 4, False]),
  ('variant scenario 1', (101, ['D15', 'D20', 'SB', 'D3', 'S4', 'D13', 'T5', 'S16']), [0, 2, True]),
  ('variant scenario 2', (32, ['D9', 'S4', 'S6', 'D16', 'D18', 'S13']), [4, 4, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust ends turn', (7, ['D1', 'S3', 'D17', 'S19', 'D1', 'D20', 'S7']), [7, 4, False]),
  ('variant scenario 1', (101, ['D10', 'T4']), [69, 1, False]),
  ('variant scenario 2',
   (10, ['D20', 'D6', 'D5', 'M', 'D18', 'SB', 'D16', 'S18', 'T12']),
   [0, 3, True])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust ends turn', (50, ['D13', 'D5', 'S14', 'T19', 'D5', 'SB']), [15, 3, False]),
  ('variant scenario 1', (40, ['T15']), [40, 1, False]),
  ('variant scenario 2', (40, ['D5', 'D1', 'T18']), [40, 1, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust ends turn', (3, ['D13', 'S6', 'D18', 'D14']), [3, 4, False]),
  ('variant scenario 1', (101, ['M', 'D13', 'T6']), [57, 1, False]),
  ('variant scenario 2', (50, ['S1']), [49, 1, False])]]
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(start, darts):
    def value(d):
        if d == 'M':
            return 0, False
        if d == 'SB':
            return 25, False
        if d == 'DB':
            return 50, True
        mult = {'S': 1, 'D': 2, 'T': 3}[d[0]]
        return mult * int(d[1:]), d[0] == 'D'
    score = start
    turns = 0
    i = 0
    while i < len(darts):
        turns += 1
        turn_start = score
        for k in range(3):
            if i >= len(darts):
                break
            v, dbl = value(darts[i])
            i += 1
            score -= v
            if score == 0 and dbl:
                return [0, turns, True]
            if score < 2:
                score = turn_start
                i += 2 - k
                break
    return [score, turns, False]
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 checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust ends turn', (3, ['S14', 'D16', 'D3']), [3, 3, False]),
  ('variant scenario 1', (15, ['T4', 'D13', 'DB', 'D5', 'S19', 'D12', 'D4']), [7, 5, False]),
  ('variant scenario 2', (59, ['D10', 'S18', 'S11', 'D1', 'SB']), [10, 2, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust ends turn',
   (23, ['D8', 'D8', 'S16', 'D2', 'D8', 'S1', 'M', 'DB', 'T19']),
   [23, 4, False]),
  ('variant scenario 1', (101, ['D15', 'D20', 'SB', 'D3', 'S4', 'D13', 'T5', 'S16']), [0, 2, True]),
  ('variant scenario 2', (32, ['D9', 'S4', 'S6', 'D16', 'D18', 'S13']), [4, 4, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust ends turn', (7, ['D1', 'S3', 'D17', 'S19', 'D1', 'D20', 'S7']), [7, 4, False]),
  ('variant scenario 1', (101, ['D10', 'T4']), [69, 1, False]),
  ('variant scenario 2',
   (10, ['D20', 'D6', 'D5', 'M', 'D18', 'SB', 'D16', 'S18', 'T12']),
   [0, 3, True])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust ends turn', (50, ['D13', 'D5', 'S14', 'T19', 'D5', 'SB']), [15, 3, False]),
  ('variant scenario 1', (40, ['T15']), [40, 1, False]),
  ('variant scenario 2', (40, ['D5', 'D1', 'T18']), [40, 1, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust ends turn', (3, ['D13', 'S6', 'D18', 'D14']), [3, 4, False]),
  ('variant scenario 1', (101, ['M', 'D13', 'T6']), [57, 1, False]),
  ('variant scenario 2', (50, ['S1']), [49, 1, False])]]
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:
Darts after a bust in the same turn are scored against the reverted total.

Double-out darts leg from a remaining score. darts lists thrown darts: S/D/T followed by 1-20, SB (25), DB (50, a double) or M (miss). Turns are three darts. After each dart: reaching exactly 0 with a double (D* or DB) checks out and later darts are ignored; a remaining score below 2 otherwise is a bust, the score reverts to its value at the start of the turn and the turn ends immediately (the next dart in the list starts a new turn). Return [remaining, turns used, checked_out].

split: open-access


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

N = 1
observations = []
def solve(start, darts):
    def value(d):
        if d == 'M':
            return 0, False
        if d == 'SB':
            return 25, False
        if d == 'DB':
            return 50, True
        mult = {'S': 1, 'D': 2, 'T': 3}[d[0]]
        return mult * int(d[1:]), d[0] == 'D'
    score = start
    turns = 0
    i = 0
    while i < len(darts):
        turns += 1
        turn_start = score
        for k in range(3):
            if i >= len(darts):
                break
            v, dbl = value(darts[i])
            i += 1
            score -= v
            if score == 0 and dbl:
                return [0, turns, True]
            if score < 0:
                score = turn_start
                break
    return [score, turns, False]
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 checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust threshold',
   (3, ['D16', 'D12', 'D19', 'T11', 'D1', 'T17', 'D13']),
   [3, 7, False]),
  ('variant scenario 1', (13, ['S10', 'M', 'T3', 'D11']), [13, 2, False]),
  ('variant scenario 2', (101, ['D1', 'S18', 'T5', 'T6']), [48, 2, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust threshold', (12, ['S18', 'S16', 'T17', 'T4']), [12, 4, False]),
  ('regression: bust threshold', (40, ['T1', 'D11', 'D2', 'D5', 'D8']), [11, 3, False]),
  ('variant scenario 1', (3, ['T17', 'D3']), [3, 2, False]),
  ('variant scenario 2',
   (40, ['T12', 'D8', 'D1', 'D19', 'S1', 'D15', 'T6', 'T16', 'T1']),
   [0, 2, True])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust threshold', (3, ['T9', 'D10', 'D2', 'T16', 'T1', 'D20']), [3, 6, False]),
  ('regression: bust threshold',
   (50, ['D3', 'D4', 'T10', 'D17', 'D4', 'D14', 'SB', 'S11', 'S5']),
   [6, 7, False]),
  ('variant scenario 1', (28, ['D6', 'D3', 'D15', 'D20', 'D5']), [18, 3, False]),
  ('variant scenario 2', (101, ['S7', 'D5', 'S20', 'D5']), [54, 2, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust threshold',
   (18, ['S4', 'SB', 'D1', 'T5', 'D20', 'D20', 'S4']),
   [14, 5, False]),
  ('variant scenario 1', (101, ['D5']), [91, 1, False]),
  ('variant scenario 2', (50, ['T11']), [17, 1, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust threshold',
   (3, ['S2', 'D7', 'D7', 'S5', 'D9', 'D13', 'T7', 'T6', 'T7']),
   [3, 9, False]),
  ('variant scenario 1', (101, ['S12', 'T5', 'T18', 'T10', 'T4']), [8, 3, False]),
  ('variant scenario 2', (53, ['D17', 'S16', 'D6', 'D14', 'T12', 'D4', 'D4']), [37, 3, False])]]
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(start, darts):
    def value(d):
        if d == 'M':
            return 0, False
        if d == 'SB':
            return 25, False
        if d == 'DB':
            return 50, True
        mult = {'S': 1, 'D': 2, 'T': 3}[d[0]]
        return mult * int(d[1:]), d[0] == 'D'
    score = start
    turns = 0
    i = 0
    while i < len(darts):
        turns += 1
        turn_start = score
        for k in range(3):
            if i >= len(darts):
                break
            v, dbl = value(darts[i])
            i += 1
            score -= v
            if score == 0 and dbl:
                return [0, turns, True]
            if score < 1:
                score = turn_start
                break
    return [score, turns, False]
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 checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust threshold',
   (3, ['D16', 'D12', 'D19', 'T11', 'D1', 'T17', 'D13']),
   [3, 7, False]),
  ('variant scenario 1', (13, ['S10', 'M', 'T3', 'D11']), [13, 2, False]),
  ('variant scenario 2', (101, ['D1', 'S18', 'T5', 'T6']), [48, 2, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust threshold', (12, ['S18', 'S16', 'T17', 'T4']), [12, 4, False]),
  ('regression: bust threshold', (40, ['T1', 'D11', 'D2', 'D5', 'D8']), [11, 3, False]),
  ('variant scenario 1', (3, ['T17', 'D3']), [3, 2, False]),
  ('variant scenario 2',
   (40, ['T12', 'D8', 'D1', 'D19', 'S1', 'D15', 'T6', 'T16', 'T1']),
   [0, 2, True])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust threshold', (3, ['T9', 'D10', 'D2', 'T16', 'T1', 'D20']), [3, 6, False]),
  ('regression: bust threshold',
   (50, ['D3', 'D4', 'T10', 'D17', 'D4', 'D14', 'SB', 'S11', 'S5']),
   [6, 7, False]),
  ('variant scenario 1', (28, ['D6', 'D3', 'D15', 'D20', 'D5']), [18, 3, False]),
  ('variant scenario 2', (101, ['S7', 'D5', 'S20', 'D5']), [54, 2, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust threshold',
   (18, ['S4', 'SB', 'D1', 'T5', 'D20', 'D20', 'S4']),
   [14, 5, False]),
  ('variant scenario 1', (101, ['D5']), [91, 1, False]),
  ('variant scenario 2', (50, ['T11']), [17, 1, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bust threshold',
   (3, ['S2', 'D7', 'D7', 'S5', 'D9', 'D13', 'T7', 'T6', 'T7']),
   [3, 9, False]),
  ('variant scenario 1', (101, ['S12', 'T5', 'T18', 'T10', 'T4']), [8, 3, False]),
  ('variant scenario 2', (53, ['D17', 'S16', 'D6', 'D14', 'T12', 'D4', 'D4']), [37, 3, False])]]
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 player who leaves 1, or reaches 0 without a double, is left on that score.

Double-out darts leg from a remaining score. darts lists thrown darts: S/D/T followed by 1-20, SB (25), DB (50, a double) or M (miss). Turns are three darts. After each dart: reaching exactly 0 with a double (D* or DB) checks out and later darts are ignored; a remaining score below 2 otherwise is a bust, the score reverts to its value at the start of the turn and the turn ends immediately (the next dart in the list starts a new turn). Return [remaining, turns used, checked_out].

split: open-access


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

N = 1
observations = []
def solve(start, darts):
    def value(d):
        if d == 'M':
            return 0, False
        if d == 'SB':
            return 25, False
        if d == 'DB':
            return 50, False
        mult = {'S': 1, 'D': 2, 'T': 3}[d[0]]
        return mult * int(d[1:]), d[0] == 'D'
    score = start
    turns = 0
    i = 0
    while i < len(darts):
        turns += 1
        turn_start = score
        for k in range(3):
            if i >= len(darts):
                break
            v, dbl = value(darts[i])
            i += 1
            score -= v
            if score == 0 and dbl:
                return [0, turns, True]
            if score < 2:
                score = turn_start
                break
    return [score, turns, False]
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 checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bull double', (50, ['D2', 'DB', 'DB', 'T15', 'D15', 'D11']), [0, 2, True]),
  ('variant scenario 1', (27, ['D1', 'S7', 'SB', 'D11', 'SB', 'S7', 'T3']), [11, 3, False]),
  ('variant scenario 2', (50, ['D4', 'D3', 'D13', 'S7', 'D3', 'S18', 'D3']), [4, 4, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bull double', (50, ['D8', 'DB', 'D5', 'D16', 'D4', 'D12', 'D20']), [0, 2, True]),
  ('regression: bull double',
   (50, ['D9', 'T13', 'D11', 'D13', 'D6', 'DB', 'M', 'D5', 'D15']),
   [0, 3, True]),
  ('variant scenario 1', (32, ['D16', 'SB']), [0, 1, True]),
  ('variant scenario 2', (40, ['D18', 'T20', 'T14', 'D12', 'S20']), [40, 3, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bull double', (50, ['D9', 'T4', 'D13', 'DB', 'D20', 'T13']), [0, 2, True]),
  ('variant scenario 1', (40, ['D1', 'T4', 'T9', 'DB', 'D9', 'T13']), [40, 3, False]),
  ('variant scenario 2', (3, ['T3', 'SB', 'T5']), [3, 3, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bull double',
   (40, ['D8', 'D5', 'D13', 'T4', 'DB', 'D18', 'D11', 'S15']),
   [25, 4, False]),
  ('regression: bull double', (50, ['T20', 'DB', 'D15', 'D13', 'SB']), [0, 2, True]),
  ('variant scenario 1', (31, ['T17']), [31, 1, False]),
  ('variant scenario 2', (32, ['D16']), [0, 1, True])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bull double', (32, ['D6', 'D11', 'DB', 'DB', 'D7', 'D7', 'S17']), [32, 4, False]),
  ('regression: bull double',
   (50, ['DB', 'S13', 'D3', 'S20', 'M', 'D18', 'M', 'T1']),
   [0, 1, True]),
  ('variant scenario 1', (32, ['T7', 'T20', 'D2', 'T20', 'D6', 'D19', 'D12']), [8, 4, False]),
  ('variant scenario 2', (40, ['S3', 'S10', 'D16', 'D1', 'D3', 'D3']), [26, 2, False])]]
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(start, darts):
    def value(d):
        if d == 'M':
            return 0, False
        if d == 'SB':
            return 25, False
        if d == 'DB':
            return 25, True
        mult = {'S': 1, 'D': 2, 'T': 3}[d[0]]
        return mult * int(d[1:]), d[0] == 'D'
    score = start
    turns = 0
    i = 0
    while i < len(darts):
        turns += 1
        turn_start = score
        for k in range(3):
            if i >= len(darts):
                break
            v, dbl = value(darts[i])
            i += 1
            score -= v
            if score == 0 and dbl:
                return [0, turns, True]
            if score < 2:
                score = turn_start
                break
    return [score, turns, False]
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 checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bull double', (50, ['D2', 'DB', 'DB', 'T15', 'D15', 'D11']), [0, 2, True]),
  ('variant scenario 1', (27, ['D1', 'S7', 'SB', 'D11', 'SB', 'S7', 'T3']), [11, 3, False]),
  ('variant scenario 2', (50, ['D4', 'D3', 'D13', 'S7', 'D3', 'S18', 'D3']), [4, 4, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bull double', (50, ['D8', 'DB', 'D5', 'D16', 'D4', 'D12', 'D20']), [0, 2, True]),
  ('regression: bull double',
   (50, ['D9', 'T13', 'D11', 'D13', 'D6', 'DB', 'M', 'D5', 'D15']),
   [0, 3, True]),
  ('variant scenario 1', (32, ['D16', 'SB']), [0, 1, True]),
  ('variant scenario 2', (40, ['D18', 'T20', 'T14', 'D12', 'S20']), [40, 3, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bull double', (50, ['D9', 'T4', 'D13', 'DB', 'D20', 'T13']), [0, 2, True]),
  ('variant scenario 1', (40, ['D1', 'T4', 'T9', 'DB', 'D9', 'T13']), [40, 3, False]),
  ('variant scenario 2', (3, ['T3', 'SB', 'T5']), [3, 3, False])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bull double',
   (40, ['D8', 'D5', 'D13', 'T4', 'DB', 'D18', 'D11', 'S15']),
   [25, 4, False]),
  ('regression: bull double', (50, ['T20', 'DB', 'D15', 'D13', 'SB']), [0, 2, True]),
  ('variant scenario 1', (31, ['T17']), [31, 1, False]),
  ('variant scenario 2', (32, ['D16']), [0, 1, True])],
 [('control checkout on double', (40, ['D20']), [0, 1, True]),
  ('boundary finish on single busts', (20, ['S20', 'D10']), [0, 2, True]),
  ('boundary leave one busts', (21, ['S20', 'S1']), [20, 2, False]),
  ('control bull finish', (50, ['DB']), [0, 1, True]),
  ('boundary bust mid-turn reverts', (32, ['S10', 'T20', 'D16']), [0, 2, True]),
  ('control scoring turn', (101, ['T20', 'S1', 'S20']), [20, 1, False]),
  ('regression: bull double', (32, ['D6', 'D11', 'DB', 'DB', 'D7', 'D7', 'S17']), [32, 4, False]),
  ('regression: bull double',
   (50, ['DB', 'S13', 'D3', 'S20', 'M', 'D18', 'M', 'T1']),
   [0, 1, True]),
  ('variant scenario 1', (32, ['T7', 'T20', 'D2', 'T20', 'D6', 'D19', 'D12']), [8, 4, False]),
  ('variant scenario 2', (40, ['S3', 'S10', 'D16', 'D1', 'D3', 'D3']), [26, 2, False])]]
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:
Finishing 50 with the bull is treated as a bust.

Double-out darts leg from a remaining score. darts lists thrown darts: S/D/T followed by 1-20, SB (25), DB (50, a double) or M (miss). Turns are three darts. After each dart: reaching exactly 0 with a double (D* or DB) checks out and later darts are ignored; a remaining score below 2 otherwise is a bust, the score reverts to its value at the start of the turn and the turn ends immediately (the next dart in the list starts a new turn). Return [remaining, turns used, checked_out].

split: open-access