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

N = 1
observations = []
def solve(stones, hammer):
    inside = sorted((d, t) for t, d in stones if d <= 1830)
    tie = bool(inside) and any(d == inside[0][0] and t != inside[0][1] for d, t in inside)
    if not inside or tie:
        return [None, 0, hammer]
    best_d, team = inside[0]
    opp = [d for d, t in inside if t != team]
    limit = min(opp) if opp else None
    points = sum(1 for d, t in inside if t == team and (limit is None or d < limit))
    nxt = 'B' if team == 'A' else 'A'
    return [team, points, nxt]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: house edge',
   ([['A', 1577], ['A', 237], ['A', 1562], ['A', 1383], ['A', 1874]], 'A'),
   ['A', 5, 'B']),
  ('regression: house edge', ([['B', 1991]], 'B'), [None, 0, 'B']),
  ('variant scenario 1', ([], 'B'), [None, 0, 'B']),
  ('variant scenario 2',
   ([['B', 505], ['B', 120], ['A', 1845], ['A', 444], ['B', 357], ['A', 1976]], 'A'),
   ['B', 2, 'A'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: house edge', ([['B', 1985]], 'A'), [None, 0, 'A']),
  ('regression: house edge', ([['A', 1837], ['A', 251]], 'A'), ['A', 2, 'B']),
  ('variant scenario 1',
   ([['B', 97],
     ['B', 1854],
     ['A', 384],
     ['A', 139],
     ['A', 363],
     ['B', 479],
     ['A', 71],
     ['A', 1720]],
    'B'),
   ['A', 1, 'B']),
  ('variant scenario 2', ([['B', 155]], 'A'), ['B', 1, 'A'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: house edge', ([['A', 2065]], 'A'), [None, 0, 'A']),
  ('regression: house edge', ([['B', 1921], ['B', 241], ['A', 2086]], 'B'), ['B', 2, 'A']),
  ('variant scenario 1', ([['A', 1555], ['A', 2016], ['B', 251]], 'B'), ['B', 1, 'A']),
  ('variant scenario 2',
   ([['A', 2048], ['B', 547], ['B', 1960], ['A', 1783]], 'B'),
   ['B', 1, 'A'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: house edge', ([['A', 2074], ['A', 375], ['A', 2060]], 'B'), ['A', 1, 'B']),
  ('regression: house edge',
   ([['B', 70], ['B', 1549], ['A', 1913], ['B', 1896], ['A', 2038]], 'B'),
   ['B', 3, 'A']),
  ('variant scenario 1',
   ([['A', 2096], ['A', 1446], ['A', 119], ['B', 948], ['A', 63], ['A', 792]], 'A'),
   ['A', 3, 'B']),
  ('variant scenario 2', ([['A', 1724]], 'B'), ['A', 1, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: house edge', ([['A', 237], ['A', 1878], ['B', 1945]], 'B'), ['A', 2, 'B']),
  ('regression: house edge',
   ([['A', 2098], ['A', 1789], ['A', 1751], ['A', 1825], ['A', 1965], ['A', 389]], 'A'),
   ['A', 5, 'B']),
  ('variant scenario 1', ([['B', 50]], 'A'), ['B', 1, 'A']),
  ('variant scenario 2',
   ([['B', 2106],
     ['A', 1855],
     ['A', 1782],
     ['A', 86],
     ['B', 185],
     ['A', 212],
     ['A', 1713],
     ['A', 366]],
    'B'),
   ['A', 1, 'B'])]]
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(stones, hammer):
    inside = sorted((d, t) for t, d in stones if d <= 1830 + 290)
    tie = bool(inside) and any(d == inside[0][0] and t != inside[0][1] for d, t in inside)
    if not inside or tie:
        return [None, 0, hammer]
    best_d, team = inside[0]
    opp = [d for d, t in inside if t != team]
    limit = min(opp) if opp else None
    points = sum(1 for d, t in inside if t == team and (limit is None or d < limit))
    nxt = 'B' if team == 'A' else 'A'
    return [team, points, nxt]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: house edge',
   ([['A', 1577], ['A', 237], ['A', 1562], ['A', 1383], ['A', 1874]], 'A'),
   ['A', 5, 'B']),
  ('regression: house edge', ([['B', 1991]], 'B'), [None, 0, 'B']),
  ('variant scenario 1', ([], 'B'), [None, 0, 'B']),
  ('variant scenario 2',
   ([['B', 505], ['B', 120], ['A', 1845], ['A', 444], ['B', 357], ['A', 1976]], 'A'),
   ['B', 2, 'A'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: house edge', ([['B', 1985]], 'A'), [None, 0, 'A']),
  ('regression: house edge', ([['A', 1837], ['A', 251]], 'A'), ['A', 2, 'B']),
  ('variant scenario 1',
   ([['B', 97],
     ['B', 1854],
     ['A', 384],
     ['A', 139],
     ['A', 363],
     ['B', 479],
     ['A', 71],
     ['A', 1720]],
    'B'),
   ['A', 1, 'B']),
  ('variant scenario 2', ([['B', 155]], 'A'), ['B', 1, 'A'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: house edge', ([['A', 2065]], 'A'), [None, 0, 'A']),
  ('regression: house edge', ([['B', 1921], ['B', 241], ['A', 2086]], 'B'), ['B', 2, 'A']),
  ('variant scenario 1', ([['A', 1555], ['A', 2016], ['B', 251]], 'B'), ['B', 1, 'A']),
  ('variant scenario 2',
   ([['A', 2048], ['B', 547], ['B', 1960], ['A', 1783]], 'B'),
   ['B', 1, 'A'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: house edge', ([['A', 2074], ['A', 375], ['A', 2060]], 'B'), ['A', 1, 'B']),
  ('regression: house edge',
   ([['B', 70], ['B', 1549], ['A', 1913], ['B', 1896], ['A', 2038]], 'B'),
   ['B', 3, 'A']),
  ('variant scenario 1',
   ([['A', 2096], ['A', 1446], ['A', 119], ['B', 948], ['A', 63], ['A', 792]], 'A'),
   ['A', 3, 'B']),
  ('variant scenario 2', ([['A', 1724]], 'B'), ['A', 1, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: house edge', ([['A', 237], ['A', 1878], ['B', 1945]], 'B'), ['A', 2, 'B']),
  ('regression: house edge',
   ([['A', 2098], ['A', 1789], ['A', 1751], ['A', 1825], ['A', 1965], ['A', 389]], 'A'),
   ['A', 5, 'B']),
  ('variant scenario 1', ([['B', 50]], 'A'), ['B', 1, 'A']),
  ('variant scenario 2',
   ([['B', 2106],
     ['A', 1855],
     ['A', 1782],
     ['A', 86],
     ['B', 185],
     ['A', 212],
     ['A', 1713],
     ['A', 366]],
    'B'),
   ['A', 1, 'B'])]]
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 stone whose edge overlaps the twelve-foot ring does not count.

Curling end result. stones rows are [team, distance_mm] from the button to the stone centre; a stone counts only if it touches the house: distance <= 1830 + 145 (house radius plus stone radius). The team with the closest counting stone scores one point for each of its counting stones strictly closer than the opponent's closest counting stone (all its counting stones if the opponent has none). If no stone counts, or the two closest counting stones of different teams are at the same distance, the end is blank and the hammer stays. After a score the hammer goes to the team that did not score. Return [scoring team or None, points, hammer for next end].

split: open-access


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

N = 1
observations = []
def solve(stones, hammer):
    inside = sorted((d, t) for t, d in stones if d <= 1830 + 145)
    tie = bool(inside) and any(d == inside[0][0] and t != inside[0][1] for d, t in inside)
    if not inside or tie:
        return [None, 0, hammer]
    best_d, team = inside[0]
    opp = [d for d, t in inside if t != team]
    limit = min(opp) if opp else None
    points = sum(1 for d, t in inside if t == team and (limit is None or d < limit))
    nxt = team
    return [team, points, nxt]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: hammer after score',
   ([['B', 1771], ['B', 1727], ['B', 2067], ['A', 1934], ['B', 262], ['B', 499], ['B', 1851]], 'B'),
   ['B', 5, 'A']),
  ('regression: hammer after score',
   ([['B', 433], ['A', 41], ['A', 57], ['A', 254], ['B', 1877], ['A', 792]], 'B'),
   ['A', 3, 'B']),
  ('variant scenario 1', ([['A', 290], ['A', 1718], ['B', 1957], ['B', 210]], 'B'), ['B', 1, 'A']),
  ('variant scenario 2', ([['B', 1797], ['A', 1797]], 'B'), [None, 0, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: hammer after score',
   ([['A', 42], ['A', 474], ['A', 1879], ['B', 526]], 'A'),
   ['A', 2, 'B']),
  ('regression: hammer after score',
   ([['B', 1889],
     ['A', 1272],
     ['A', 450],
     ['A', 459],
     ['A', 59],
     ['A', 1811],
     ['A', 293],
     ['B', 263]],
    'B'),
   ['A', 1, 'B']),
  ('variant scenario 1',
   ([['B', 261], ['A', 1016], ['A', 439], ['A', 515], ['B', 2090]], 'B'),
   ['B', 1, 'A']),
  ('variant scenario 2', ([['B', 1059], ['A', 279], ['A', 171], ['A', 2071]], 'B'), ['A', 2, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: hammer after score', ([['B', 1811], ['A', 429], ['A', 669]], 'A'), ['A', 2, 'B']),
  ('regression: hammer after score',
   ([['A', 518], ['B', 2006], ['B', 410], ['B', 2313], ['A', 518]], 'A'),
   ['B', 1, 'A']),
  ('variant scenario 1', ([['A', 1776], ['A', 2036], ['A', 293], ['A', 1902]], 'A'), ['A', 3, 'B']),
  ('variant scenario 2', ([], 'B'), [None, 0, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: hammer after score',
   ([['B', 2174], ['B', 199], ['A', 2055], ['A', 2174]], 'A'),
   ['B', 1, 'A']),
  ('variant scenario 1',
   ([['B', 166],
     ['B', 1724],
     ['B', 2226],
     ['A', 1998],
     ['A', 509],
     ['A', 576],
     ['B', 2004],
     ['B', 1904]],
    'B'),
   ['B', 1, 'A']),
  ('variant scenario 2', ([['B', 2323], ['A', 397]], 'B'), ['A', 1, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: hammer after score', ([['A', 1923], ['B', 1922], ['B', 1923]], 'A'), ['B', 1, 'A']),
  ('variant scenario 1', ([], 'A'), [None, 0, 'A']),
  ('variant scenario 2',
   ([['A', 1859], ['A', 861], ['A', 73], ['A', 1750], ['A', 1858], ['B', 1938], ['B', 353]], 'A'),
   ['A', 1, 'B'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(stones, hammer):
    inside = sorted((d, t) for t, d in stones if d <= 1830 + 145)
    tie = bool(inside) and any(d == inside[0][0] and t != inside[0][1] for d, t in inside)
    if not inside or tie:
        return [None, 0, hammer]
    best_d, team = inside[0]
    opp = [d for d, t in inside if t != team]
    limit = min(opp) if opp else None
    points = sum(1 for d, t in inside if t == team and (limit is None or d < limit))
    nxt = 'B' if hammer == 'A' else 'A'
    return [team, points, nxt]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: hammer after score',
   ([['B', 1771], ['B', 1727], ['B', 2067], ['A', 1934], ['B', 262], ['B', 499], ['B', 1851]], 'B'),
   ['B', 5, 'A']),
  ('regression: hammer after score',
   ([['B', 433], ['A', 41], ['A', 57], ['A', 254], ['B', 1877], ['A', 792]], 'B'),
   ['A', 3, 'B']),
  ('variant scenario 1', ([['A', 290], ['A', 1718], ['B', 1957], ['B', 210]], 'B'), ['B', 1, 'A']),
  ('variant scenario 2', ([['B', 1797], ['A', 1797]], 'B'), [None, 0, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: hammer after score',
   ([['A', 42], ['A', 474], ['A', 1879], ['B', 526]], 'A'),
   ['A', 2, 'B']),
  ('regression: hammer after score',
   ([['B', 1889],
     ['A', 1272],
     ['A', 450],
     ['A', 459],
     ['A', 59],
     ['A', 1811],
     ['A', 293],
     ['B', 263]],
    'B'),
   ['A', 1, 'B']),
  ('variant scenario 1',
   ([['B', 261], ['A', 1016], ['A', 439], ['A', 515], ['B', 2090]], 'B'),
   ['B', 1, 'A']),
  ('variant scenario 2', ([['B', 1059], ['A', 279], ['A', 171], ['A', 2071]], 'B'), ['A', 2, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: hammer after score', ([['B', 1811], ['A', 429], ['A', 669]], 'A'), ['A', 2, 'B']),
  ('regression: hammer after score',
   ([['A', 518], ['B', 2006], ['B', 410], ['B', 2313], ['A', 518]], 'A'),
   ['B', 1, 'A']),
  ('variant scenario 1', ([['A', 1776], ['A', 2036], ['A', 293], ['A', 1902]], 'A'), ['A', 3, 'B']),
  ('variant scenario 2', ([], 'B'), [None, 0, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: hammer after score',
   ([['B', 2174], ['B', 199], ['A', 2055], ['A', 2174]], 'A'),
   ['B', 1, 'A']),
  ('variant scenario 1',
   ([['B', 166],
     ['B', 1724],
     ['B', 2226],
     ['A', 1998],
     ['A', 509],
     ['A', 576],
     ['B', 2004],
     ['B', 1904]],
    'B'),
   ['B', 1, 'A']),
  ('variant scenario 2', ([['B', 2323], ['A', 397]], 'B'), ['A', 1, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: hammer after score', ([['A', 1923], ['B', 1922], ['B', 1923]], 'A'), ['B', 1, 'A']),
  ('variant scenario 1', ([], 'A'), [None, 0, 'A']),
  ('variant scenario 2',
   ([['A', 1859], ['A', 861], ['A', 73], ['A', 1750], ['A', 1858], ['B', 1938], ['B', 353]], 'A'),
   ['A', 1, 'B'])]]
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 scoring, the scoring team is shown with the hammer.

Curling end result. stones rows are [team, distance_mm] from the button to the stone centre; a stone counts only if it touches the house: distance <= 1830 + 145 (house radius plus stone radius). The team with the closest counting stone scores one point for each of its counting stones strictly closer than the opponent's closest counting stone (all its counting stones if the opponent has none). If no stone counts, or the two closest counting stones of different teams are at the same distance, the end is blank and the hammer stays. After a score the hammer goes to the team that did not score. Return [scoring team or None, points, hammer for next end].

split: open-access


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

N = 1
observations = []
def solve(stones, hammer):
    inside = sorted((d, t) for t, d in stones if d <= 1830 + 145)
    tie = bool(inside) and any(d == inside[0][0] and t != inside[0][1] for d, t in inside)
    if not inside or tie:
        return [None, 0, 'B' if hammer == 'A' else 'A']
    best_d, team = inside[0]
    opp = [d for d, t in inside if t != team]
    limit = min(opp) if opp else None
    points = sum(1 for d, t in inside if t == team and (limit is None or d < limit))
    nxt = 'B' if team == 'A' else 'A'
    return [team, points, nxt]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: blank end hammer', ([], 'B'), [None, 0, 'B']),
  ('regression: blank end hammer',
   ([['B', 692], ['B', 1576], ['A', 1452], ['B', 1818], ['A', 1841], ['A', 692]], 'A'),
   [None, 0, 'A']),
  ('variant scenario 1',
   ([['B', 343],
     ['A', 945],
     ['B', 1884],
     ['B', 851],
     ['B', 495],
     ['A', 267],
     ['B', 1922],
     ['B', 577]],
    'A'),
   ['A', 1, 'B']),
  ('variant scenario 2',
   ([['B', 99], ['A', 1540], ['B', 717], ['B', 1757], ['B', 384], ['A', 1770]], 'A'),
   ['B', 3, 'A'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: blank end hammer', ([], 'B'), [None, 0, 'B']),
  ('regression: blank end hammer', ([['B', 1623], ['A', 1623]], 'B'), [None, 0, 'B']),
  ('variant scenario 1',
   ([['A', 309],
     ['B', 1239],
     ['A', 1835],
     ['B', 1945],
     ['A', 1934],
     ['B', 1837],
     ['B', 58],
     ['A', 1212]],
    'B'),
   ['B', 1, 'A']),
  ('variant scenario 2',
   ([['A', 457], ['B', 1891], ['A', 1820], ['B', 245], ['A', 8], ['B', 2374], ['A', 1284]], 'B'),
   ['A', 1, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: blank end hammer', ([], 'B'), [None, 0, 'B']),
  ('regression: blank end hammer', ([['A', 313], ['B', 313]], 'B'), [None, 0, 'B']),
  ('variant scenario 1', ([['B', 554], ['A', 1888]], 'B'), ['B', 1, 'A']),
  ('variant scenario 2',
   ([['A', 330],
     ['B', 236],
     ['B', 2134],
     ['A', 231],
     ['A', 462],
     ['A', 339],
     ['A', 435],
     ['A', 56]],
    'A'),
   ['A', 2, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: blank end hammer', ([], 'A'), [None, 0, 'A']),
  ('regression: blank end hammer', ([['A', 443], ['A', 2079], ['B', 443]], 'A'), [None, 0, 'A']),
  ('variant scenario 1',
   ([['B', 2009], ['B', 1963], ['A', 1721], ['A', 1920], ['B', 1762], ['A', 1743]], 'A'),
   ['A', 2, 'B']),
  ('variant scenario 2',
   ([['B', 1886], ['B', 713], ['A', 2079], ['A', 545], ['A', 1886]], 'A'),
   ['A', 1, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: blank end hammer', ([['A', 276], ['A', 1891], ['B', 276]], 'B'), [None, 0, 'B']),
  ('variant scenario 1', ([['B', 348], ['B', 1990]], 'B'), ['B', 1, 'A']),
  ('variant scenario 2',
   ([['A', 1789],
     ['B', 1136],
     ['B', 932],
     ['A', 1719],
     ['B', 2013],
     ['B', 543],
     ['A', 1850],
     ['B', 364]],
    'A'),
   ['B', 4, 'A'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(stones, hammer):
    inside = sorted((d, t) for t, d in stones if d <= 1830 + 145)
    tie = bool(inside) and any(d == inside[0][0] and t != inside[0][1] for d, t in inside)
    if not inside or tie:
        return [None, 0, hammer if not inside else ('B' if hammer == 'A' else 'A')]
    best_d, team = inside[0]
    opp = [d for d, t in inside if t != team]
    limit = min(opp) if opp else None
    points = sum(1 for d, t in inside if t == team and (limit is None or d < limit))
    nxt = 'B' if team == 'A' else 'A'
    return [team, points, nxt]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: blank end hammer', ([], 'B'), [None, 0, 'B']),
  ('regression: blank end hammer',
   ([['B', 692], ['B', 1576], ['A', 1452], ['B', 1818], ['A', 1841], ['A', 692]], 'A'),
   [None, 0, 'A']),
  ('variant scenario 1',
   ([['B', 343],
     ['A', 945],
     ['B', 1884],
     ['B', 851],
     ['B', 495],
     ['A', 267],
     ['B', 1922],
     ['B', 577]],
    'A'),
   ['A', 1, 'B']),
  ('variant scenario 2',
   ([['B', 99], ['A', 1540], ['B', 717], ['B', 1757], ['B', 384], ['A', 1770]], 'A'),
   ['B', 3, 'A'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: blank end hammer', ([], 'B'), [None, 0, 'B']),
  ('regression: blank end hammer', ([['B', 1623], ['A', 1623]], 'B'), [None, 0, 'B']),
  ('variant scenario 1',
   ([['A', 309],
     ['B', 1239],
     ['A', 1835],
     ['B', 1945],
     ['A', 1934],
     ['B', 1837],
     ['B', 58],
     ['A', 1212]],
    'B'),
   ['B', 1, 'A']),
  ('variant scenario 2',
   ([['A', 457], ['B', 1891], ['A', 1820], ['B', 245], ['A', 8], ['B', 2374], ['A', 1284]], 'B'),
   ['A', 1, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: blank end hammer', ([], 'B'), [None, 0, 'B']),
  ('regression: blank end hammer', ([['A', 313], ['B', 313]], 'B'), [None, 0, 'B']),
  ('variant scenario 1', ([['B', 554], ['A', 1888]], 'B'), ['B', 1, 'A']),
  ('variant scenario 2',
   ([['A', 330],
     ['B', 236],
     ['B', 2134],
     ['A', 231],
     ['A', 462],
     ['A', 339],
     ['A', 435],
     ['A', 56]],
    'A'),
   ['A', 2, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: blank end hammer', ([], 'A'), [None, 0, 'A']),
  ('regression: blank end hammer', ([['A', 443], ['A', 2079], ['B', 443]], 'A'), [None, 0, 'A']),
  ('variant scenario 1',
   ([['B', 2009], ['B', 1963], ['A', 1721], ['A', 1920], ['B', 1762], ['A', 1743]], 'A'),
   ['A', 2, 'B']),
  ('variant scenario 2',
   ([['B', 1886], ['B', 713], ['A', 2079], ['A', 545], ['A', 1886]], 'A'),
   ['A', 1, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: blank end hammer', ([['A', 276], ['A', 1891], ['B', 276]], 'B'), [None, 0, 'B']),
  ('variant scenario 1', ([['B', 348], ['B', 1990]], 'B'), ['B', 1, 'A']),
  ('variant scenario 2',
   ([['A', 1789],
     ['B', 1136],
     ['B', 932],
     ['A', 1719],
     ['B', 2013],
     ['B', 543],
     ['A', 1850],
     ['B', 364]],
    'A'),
   ['B', 4, 'A'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
After a blank end the other team is given the hammer.

Curling end result. stones rows are [team, distance_mm] from the button to the stone centre; a stone counts only if it touches the house: distance <= 1830 + 145 (house radius plus stone radius). The team with the closest counting stone scores one point for each of its counting stones strictly closer than the opponent's closest counting stone (all its counting stones if the opponent has none). If no stone counts, or the two closest counting stones of different teams are at the same distance, the end is blank and the hammer stays. After a score the hammer goes to the team that did not score. Return [scoring team or None, points, hammer for next end].

split: open-access


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

N = 1
observations = []
def solve(stones, hammer):
    inside = sorted((d, t) for t, d in stones if d <= 1830 + 145)
    tie = bool(inside) and any(d == inside[0][0] and t != inside[0][1] for d, t in inside)
    if not inside:
        return [None, 0, hammer]
    best_d, team = inside[0]
    opp = [d for d, t in inside if t != team]
    limit = min(opp) if opp else None
    points = sum(1 for d, t in inside if t == team and (limit is None or d < limit))
    nxt = 'B' if team == 'A' else 'A'
    return [team, points, nxt]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: measured tie',
   ([['A', 142],
     ['B', 2076],
     ['A', 231],
     ['A', 503],
     ['B', 1837],
     ['B', 465],
     ['A', 455],
     ['B', 1715],
     ['B', 142]],
    'B'),
   [None, 0, 'B']),
  ('variant scenario 1',
   ([['B', 1754], ['B', 1853], ['A', 292], ['B', 6], ['B', 880], ['A', 1806], ['B', 1151]], 'A'),
   ['B', 1, 'A']),
  ('variant scenario 2', ([['B', 2023], ['B', 1835]], 'A'), ['B', 1, 'A'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: measured tie', ([['A', 1717], ['B', 1872], ['B', 1717]], 'A'), [None, 0, 'A']),
  ('variant scenario 1',
   ([['A', 1814], ['B', 340], ['A', 651], ['B', 1838], ['A', 254]], 'A'),
   ['A', 1, 'B']),
  ('variant scenario 2',
   ([['A', 1746], ['A', 2081], ['B', 341], ['A', 1926]], 'B'),
   ['B', 1, 'A'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: measured tie', ([['A', 501], ['B', 501]], 'A'), [None, 0, 'A']),
  ('variant scenario 1',
   ([['A', 1600], ['B', 569], ['B', 1676], ['B', 101], ['B', 458], ['B', 1600]], 'A'),
   ['B', 3, 'A']),
  ('variant scenario 2', ([['B', 1700], ['A', 1676], ['B', 15]], 'B'), ['B', 1, 'A'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: measured tie', ([['A', 13], ['B', 13]], 'B'), [None, 0, 'B']),
  ('variant scenario 1', ([['A', 627], ['A', 2084]], 'B'), ['A', 1, 'B']),
  ('variant scenario 2', ([['A', 343], ['A', 1779], ['A', 2240]], 'B'), ['A', 2, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: measured tie', ([['B', 1805], ['A', 1805]], 'A'), [None, 0, 'A']),
  ('variant scenario 1',
   ([['B', 1763], ['A', 883], ['B', 131], ['A', 418], ['B', 1450]], 'A'),
   ['B', 1, 'A']),
  ('variant scenario 2', ([['A', 134], ['B', 1848], ['A', 20]], 'B'), ['A', 2, 'B'])]]
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(stones, hammer):
    inside = sorted((d, t) for t, d in stones if d <= 1830 + 145)
    tie = bool(inside) and any(d == inside[0][0] and t != inside[0][1] for d, t in inside)
    if not inside:
        return [None, 0, hammer]
    if tie:
        return [hammer, 1, 'B' if hammer == 'A' else 'A']
    best_d, team = inside[0]
    opp = [d for d, t in inside if t != team]
    limit = min(opp) if opp else None
    points = sum(1 for d, t in inside if t == team and (limit is None or d < limit))
    nxt = 'B' if team == 'A' else 'A'
    return [team, points, nxt]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: measured tie',
   ([['A', 142],
     ['B', 2076],
     ['A', 231],
     ['A', 503],
     ['B', 1837],
     ['B', 465],
     ['A', 455],
     ['B', 1715],
     ['B', 142]],
    'B'),
   [None, 0, 'B']),
  ('variant scenario 1',
   ([['B', 1754], ['B', 1853], ['A', 292], ['B', 6], ['B', 880], ['A', 1806], ['B', 1151]], 'A'),
   ['B', 1, 'A']),
  ('variant scenario 2', ([['B', 2023], ['B', 1835]], 'A'), ['B', 1, 'A'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: measured tie', ([['A', 1717], ['B', 1872], ['B', 1717]], 'A'), [None, 0, 'A']),
  ('variant scenario 1',
   ([['A', 1814], ['B', 340], ['A', 651], ['B', 1838], ['A', 254]], 'A'),
   ['A', 1, 'B']),
  ('variant scenario 2',
   ([['A', 1746], ['A', 2081], ['B', 341], ['A', 1926]], 'B'),
   ['B', 1, 'A'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: measured tie', ([['A', 501], ['B', 501]], 'A'), [None, 0, 'A']),
  ('variant scenario 1',
   ([['A', 1600], ['B', 569], ['B', 1676], ['B', 101], ['B', 458], ['B', 1600]], 'A'),
   ['B', 3, 'A']),
  ('variant scenario 2', ([['B', 1700], ['A', 1676], ['B', 15]], 'B'), ['B', 1, 'A'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: measured tie', ([['A', 13], ['B', 13]], 'B'), [None, 0, 'B']),
  ('variant scenario 1', ([['A', 627], ['A', 2084]], 'B'), ['A', 1, 'B']),
  ('variant scenario 2', ([['A', 343], ['A', 1779], ['A', 2240]], 'B'), ['A', 2, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: measured tie', ([['B', 1805], ['A', 1805]], 'A'), [None, 0, 'A']),
  ('variant scenario 1',
   ([['B', 1763], ['A', 883], ['B', 131], ['A', 418], ['B', 1450]], 'A'),
   ['B', 1, 'A']),
  ('variant scenario 2', ([['A', 134], ['B', 1848], ['A', 20]], 'B'), ['A', 2, 'B'])]]
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:
Two stones of different teams at the same distance give a point to team A.

Curling end result. stones rows are [team, distance_mm] from the button to the stone centre; a stone counts only if it touches the house: distance <= 1830 + 145 (house radius plus stone radius). The team with the closest counting stone scores one point for each of its counting stones strictly closer than the opponent's closest counting stone (all its counting stones if the opponent has none). If no stone counts, or the two closest counting stones of different teams are at the same distance, the end is blank and the hammer stays. After a score the hammer goes to the team that did not score. Return [scoring team or None, points, hammer for next end].

split: open-access


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

N = 1
observations = []
def solve(stones, hammer):
    inside = sorted((d, t) for t, d in stones if d <= 1830 + 145)
    tie = bool(inside) and any(d == inside[0][0] and t != inside[0][1] for d, t in inside)
    if not inside or tie:
        return [None, 0, hammer]
    best_d, team = inside[0]
    opp = [d for d, t in inside if t != team]
    limit = min(opp) if opp else None
    points = sum(1 for d, t in inside if t == team and True)
    nxt = 'B' if team == 'A' else 'A'
    return [team, points, nxt]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: counting limit',
   ([['A', 406],
     ['B', 399],
     ['B', 898],
     ['A', 2048],
     ['B', 1613],
     ['B', 1262],
     ['B', 412],
     ['B', 1363],
     ['B', 406]],
    'B'),
   ['B', 1, 'A']),
  ('regression: counting limit',
   ([['B', 371], ['B', 1920], ['B', 433], ['A', 2318], ['B', 194], ['B', 118], ['B', 409]], 'A'),
   ['B', 6, 'A']),
  ('variant scenario 1',
   ([['A', 454], ['A', 400], ['B', 1405], ['A', 1720], ['A', 1746]], 'A'),
   ['A', 2, 'B']),
  ('variant scenario 2', ([['B', 598], ['A', 2040], ['A', 127]], 'A'), ['A', 1, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: counting limit',
   ([['A', 432], ['A', 1730], ['B', 1904], ['A', 584], ['B', 2380], ['B', 1638], ['A', 1972]], 'B'),
   ['A', 2, 'B']),
  ('regression: counting limit', ([['B', 1314], ['B', 531]], 'B'), ['B', 2, 'A']),
  ('variant scenario 1', ([['A', 308], ['B', 924]], 'A'), ['A', 1, 'B']),
  ('variant scenario 2',
   ([['B', 1722], ['B', 465], ['A', 1918], ['A', 571], ['B', 1958]], 'A'),
   ['B', 1, 'A'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: counting limit',
   ([['B', 318],
     ['A', 2016],
     ['A', 1759],
     ['B', 98],
     ['B', 24],
     ['A', 2032],
     ['B', 1781],
     ['A', 1850]],
    'A'),
   ['B', 3, 'A']),
  ('regression: counting limit', ([['B', 430], ['B', 1878]], 'A'), ['B', 2, 'A']),
  ('variant scenario 1', ([['B', 805]], 'B'), ['B', 1, 'A']),
  ('variant scenario 2',
   ([['A', 1716], ['A', 1304], ['B', 1756], ['B', 36], ['A', 2270]], 'A'),
   ['B', 1, 'A'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: counting limit', ([['A', 361], ['A', 240]], 'A'), ['A', 2, 'B']),
  ('regression: counting limit',
   ([['A', 1727], ['A', 392], ['A', 1729], ['B', 732], ['A', 2097]], 'A'),
   ['A', 1, 'B']),
  ('variant scenario 1',
   ([['A', 187], ['B', 456], ['B', 142], ['B', 1993], ['B', 187]], 'A'),
   ['B', 1, 'A']),
  ('variant scenario 2',
   ([['B', 552],
     ['B', 476],
     ['B', 561],
     ['B', 1762],
     ['A', 418],
     ['A', 194],
     ['A', 1127],
     ['B', 1615]],
    'A'),
   ['A', 2, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: counting limit',
   ([['B', 585],
     ['A', 132],
     ['A', 1567],
     ['B', 1729],
     ['A', 948],
     ['B', 121],
     ['A', 523],
     ['B', 910]],
    'B'),
   ['B', 1, 'A']),
  ('regression: counting limit', ([['B', 1969], ['B', 163]], 'B'), ['B', 2, 'A']),
  ('variant scenario 1',
   ([['A', 231],
     ['A', 14],
     ['A', 1952],
     ['A', 2020],
     ['B', 238],
     ['A', 2269],
     ['B', 1723],
     ['B', 231]],
    'B'),
   ['A', 1, 'B']),
  ('variant scenario 2', ([['A', 390]], 'A'), ['A', 1, 'B'])]]
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(stones, hammer):
    inside = sorted((d, t) for t, d in stones if d <= 1830 + 145)
    tie = bool(inside) and any(d == inside[0][0] and t != inside[0][1] for d, t in inside)
    if not inside or tie:
        return [None, 0, hammer]
    best_d, team = inside[0]
    opp = [d for d, t in inside if t != team]
    limit = min(opp) if opp else None
    points = sum(1 for d, t in inside if t == team and (d < limit if limit is not None else d == best_d))
    nxt = 'B' if team == 'A' else 'A'
    return [team, points, nxt]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: counting limit',
   ([['A', 406],
     ['B', 399],
     ['B', 898],
     ['A', 2048],
     ['B', 1613],
     ['B', 1262],
     ['B', 412],
     ['B', 1363],
     ['B', 406]],
    'B'),
   ['B', 1, 'A']),
  ('regression: counting limit',
   ([['B', 371], ['B', 1920], ['B', 433], ['A', 2318], ['B', 194], ['B', 118], ['B', 409]], 'A'),
   ['B', 6, 'A']),
  ('variant scenario 1',
   ([['A', 454], ['A', 400], ['B', 1405], ['A', 1720], ['A', 1746]], 'A'),
   ['A', 2, 'B']),
  ('variant scenario 2', ([['B', 598], ['A', 2040], ['A', 127]], 'A'), ['A', 1, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: counting limit',
   ([['A', 432], ['A', 1730], ['B', 1904], ['A', 584], ['B', 2380], ['B', 1638], ['A', 1972]], 'B'),
   ['A', 2, 'B']),
  ('regression: counting limit', ([['B', 1314], ['B', 531]], 'B'), ['B', 2, 'A']),
  ('variant scenario 1', ([['A', 308], ['B', 924]], 'A'), ['A', 1, 'B']),
  ('variant scenario 2',
   ([['B', 1722], ['B', 465], ['A', 1918], ['A', 571], ['B', 1958]], 'A'),
   ['B', 1, 'A'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: counting limit',
   ([['B', 318],
     ['A', 2016],
     ['A', 1759],
     ['B', 98],
     ['B', 24],
     ['A', 2032],
     ['B', 1781],
     ['A', 1850]],
    'A'),
   ['B', 3, 'A']),
  ('regression: counting limit', ([['B', 430], ['B', 1878]], 'A'), ['B', 2, 'A']),
  ('variant scenario 1', ([['B', 805]], 'B'), ['B', 1, 'A']),
  ('variant scenario 2',
   ([['A', 1716], ['A', 1304], ['B', 1756], ['B', 36], ['A', 2270]], 'A'),
   ['B', 1, 'A'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: counting limit', ([['A', 361], ['A', 240]], 'A'), ['A', 2, 'B']),
  ('regression: counting limit',
   ([['A', 1727], ['A', 392], ['A', 1729], ['B', 732], ['A', 2097]], 'A'),
   ['A', 1, 'B']),
  ('variant scenario 1',
   ([['A', 187], ['B', 456], ['B', 142], ['B', 1993], ['B', 187]], 'A'),
   ['B', 1, 'A']),
  ('variant scenario 2',
   ([['B', 552],
     ['B', 476],
     ['B', 561],
     ['B', 1762],
     ['A', 418],
     ['A', 194],
     ['A', 1127],
     ['B', 1615]],
    'A'),
   ['A', 2, 'B'])],
 [('control single shot', ([['A', 100], ['B', 400]], 'A'), ['A', 1, 'B']),
  ('boundary stone biting house edge', ([['B', 1975]], 'A'), ['B', 1, 'A']),
  ('boundary stone just outside', ([['B', 1976]], 'A'), [None, 0, 'A']),
  ('control steal of two', ([['B', 50], ['B', 300], ['A', 500]], 'A'), ['B', 2, 'A']),
  ('boundary measured tie', ([['A', 200], ['B', 200]], 'B'), [None, 0, 'B']),
  ('control empty house', ([], 'A'), [None, 0, 'A']),
  ('regression: counting limit',
   ([['B', 585],
     ['A', 132],
     ['A', 1567],
     ['B', 1729],
     ['A', 948],
     ['B', 121],
     ['A', 523],
     ['B', 910]],
    'B'),
   ['B', 1, 'A']),
  ('regression: counting limit', ([['B', 1969], ['B', 163]], 'B'), ['B', 2, 'A']),
  ('variant scenario 1',
   ([['A', 231],
     ['A', 14],
     ['A', 1952],
     ['A', 2020],
     ['B', 238],
     ['A', 2269],
     ['B', 1723],
     ['B', 231]],
    'B'),
   ['A', 1, 'B']),
  ('variant scenario 2', ([['A', 390]], 'A'), ['A', 1, 'B'])]]
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 team is credited with stones that lie behind the opponent's closest stone.

Curling end result. stones rows are [team, distance_mm] from the button to the stone centre; a stone counts only if it touches the house: distance <= 1830 + 145 (house radius plus stone radius). The team with the closest counting stone scores one point for each of its counting stones strictly closer than the opponent's closest counting stone (all its counting stones if the opponent has none). If no stone counts, or the two closest counting stones of different teams are at the same distance, the end is blank and the hammer stays. After a score the hammer goes to the team that did not score. Return [scoring team or None, points, hammer for next end].

split: open-access


prompt:
Seven-judge dive scores sum five marks and come out far too high.

Diving dive score. scores are judge marks as strings from 0 to 10 in half points; any other mark returns "invalid mark <s>". A 5-judge panel drops the single highest and lowest marks, a 7-judge panel the two highest and two lowest; any other panel size returns "invalid panel". The three remaining marks are summed and multiplied by the degree of difficulty dd (a decimal string); return the exact result with two decimals.

split: open-access


prompt:
A generous outlier judge inflates the dive score.

Diving dive score. scores are judge marks as strings from 0 to 10 in half points; any other mark returns "invalid mark <s>". A 5-judge panel drops the single highest and lowest marks, a 7-judge panel the two highest and two lowest; any other panel size returns "invalid panel". The three remaining marks are summed and multiplied by the degree of difficulty dd (a decimal string); return the exact result with two decimals.

split: open-access


prompt:
A 7.3 mark is accepted, or a legitimate 10.0 is rejected.

Diving dive score. scores are judge marks as strings from 0 to 10 in half points; any other mark returns "invalid mark <s>". A 5-judge panel drops the single highest and lowest marks, a 7-judge panel the two highest and two lowest; any other panel size returns "invalid panel". The three remaining marks are summed and multiplied by the degree of difficulty dd (a decimal string); return the exact result with two decimals.

split: open-access


prompt:
Dive scores are a third of the expected value.

Diving dive score. scores are judge marks as strings from 0 to 10 in half points; any other mark returns "invalid mark <s>". A 5-judge panel drops the single highest and lowest marks, a 7-judge panel the two highest and two lowest; any other panel size returns "invalid panel". The three remaining marks are summed and multiplied by the degree of difficulty dd (a decimal string); return the exact result with two decimals.

split: open-access


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

N = 1
observations = []
def solve(results):
    fin = []
    dnf = []
    for name, t in results:
        if t == 'DQ':
            continue
        if t == 'DNF':
            dnf.append(name)
            continue
        whole, _, frac = t.partition('.')
        thous = int(whole) * 1000 + int((frac + '000')[:3])
        hund = thous // 10
        fin.append((hund, name))
    fin.sort()
    out = []
    for i, (h, name) in enumerate(fin):
        place = i + 1 if i == 0 or fin[i - 1][0] != h else out[-1][0]
        out.append([place, name, '%d.%02d' % (h // 100, h % 100)])
    for name in sorted(dnf):
        out.append([None, name, 'DNF'])
    return out
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 distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: round up hundredths',
   ([['Fay', '10.2'], ['Cy', '10.26'], ['Dee', '10.245'], ['Eli', '10.234']],),
   [[1, 'Fay', '10.20'], [2, 'Eli', '10.24'], [3, 'Dee', '10.25'], [4, 'Cy', '10.26']]),
  ('variant scenario 1',
   ([['Fay', '10.24'],
     ['Dee', '10.24'],
     ['Bo', 'DNF'],
     ['Cy', 'DNF'],
     ['Eli', '10.265'],
     ['Ade', '10.']],),
   [[1, 'Ade', '10.00'],
    [2, 'Dee', '10.24'],
    [2, 'Fay', '10.24'],
    [4, 'Eli', '10.27'],
    [None, 'Bo', 'DNF'],
    [None, 'Cy', 'DNF']]),
  ('variant scenario 2',
   ([['Bo', '10.219'], ['Eli', '10.2'], ['Fay', 'DNF']],),
   [[1, 'Eli', '10.20'], [2, 'Bo', '10.22'], [None, 'Fay', 'DNF']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: round up hundredths',
   ([['Dee', '10.666'], ['Ade', '10.674'], ['Fay', '10.676'], ['Eli', '10.66']],),
   [[1, 'Eli', '10.66'], [2, 'Dee', '10.67'], [3, 'Ade', '10.68'], [3, 'Fay', '10.68']]),
  ('variant scenario 1',
   ([['Eli', '9.835'], ['Fay', '9.826'], ['Ade', '9.81'], ['Dee', '9.814']],),
   [[1, 'Ade', '9.81'], [2, 'Dee', '9.82'], [3, 'Fay', '9.83'], [4, 'Eli', '9.84']]),
  ('variant scenario 2',
   ([['Fay', '10.88'], ['Eli', '10.906'], ['Dee', '10.907']],),
   [[1, 'Fay', '10.88'], [2, 'Dee', '10.91'], [2, 'Eli', '10.91']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: round up hundredths',
   ([['Eli', '11.384'], ['Dee', '11.360'], ['Fay', '11.'], ['Bo', '11.377']],),
   [[1, 'Fay', '11.00'], [2, 'Dee', '11.36'], [3, 'Bo', '11.38'], [4, 'Eli', '11.39']]),
  ('variant scenario 1',
   ([['Fay', '11.159'],
     ['Eli', '11.15'],
     ['Cy', '11.167'],
     ['Bo', 'DQ'],
     ['Ade', '11.14'],
     ['Dee', '11.146']],),
   [[1, 'Ade', '11.14'],
    [2, 'Dee', '11.15'],
    [2, 'Eli', '11.15'],
    [4, 'Fay', '11.16'],
    [5, 'Cy', '11.17']]),
  ('variant scenario 2',
   ([['Bo', '10.68'], ['Dee', '10.703'], ['Fay', '10.694'], ['Eli', '10.713']],),
   [[1, 'Bo', '10.68'], [2, 'Fay', '10.70'], [3, 'Dee', '10.71'], [4, 'Eli', '10.72']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: round up hundredths',
   ([['Cy', '11.364'], ['Dee', '11.391'], ['Ade', 'DQ']],),
   [[1, 'Cy', '11.37'], [2, 'Dee', '11.40']]),
  ('variant scenario 1',
   ([['Eli', '9.884'], ['Ade', '9.873'], ['Bo', '9.882'], ['Cy', '9.868'], ['Fay', '9.885']],),
   [[1, 'Cy', '9.87'],
    [2, 'Ade', '9.88'],
    [3, 'Bo', '9.89'],
    [3, 'Eli', '9.89'],
    [3, 'Fay', '9.89']]),
  ('variant scenario 2',
   ([['Dee', '10.455'], ['Fay', '10.47'], ['Bo', '10.471'], ['Ade', '10.469'], ['Cy', 'DQ']],),
   [[1, 'Dee', '10.46'], [2, 'Ade', '10.47'], [2, 'Fay', '10.47'], [4, 'Bo', '10.48']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: round up hundredths',
   ([['Eli', '11.310'], ['Ade', 'DQ'], ['Fay', '11.34'], ['Dee', '11.323'], ['Cy', 'DNF']],),
   [[1, 'Eli', '11.31'], [2, 'Dee', '11.33'], [3, 'Fay', '11.34'], [None, 'Cy', 'DNF']]),
  ('variant scenario 1',
   ([['Eli', 'DNF'], ['Fay', 'DNF'], ['Dee', 'DQ'], ['Ade', '11.155']],),
   [[1, 'Ade', '11.16'], [None, 'Eli', 'DNF'], [None, 'Fay', 'DNF']]),
  ('variant scenario 2',
   ([['Dee', '11.420'], ['Eli', '11.38'], ['Cy', '11.41'], ['Ade', '11.416'], ['Bo', '11.40']],),
   [[1, 'Eli', '11.38'],
    [2, 'Bo', '11.40'],
    [3, 'Cy', '11.41'],
    [4, 'Ade', '11.42'],
    [4, 'Dee', '11.42']])]]
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(results):
    fin = []
    dnf = []
    for name, t in results:
        if t == 'DQ':
            continue
        if t == 'DNF':
            dnf.append(name)
            continue
        whole, _, frac = t.partition('.')
        thous = int(whole) * 1000 + int((frac + '000')[:3])
        hund = (thous + 5) // 10
        fin.append((hund, name))
    fin.sort()
    out = []
    for i, (h, name) in enumerate(fin):
        place = i + 1 if i == 0 or fin[i - 1][0] != h else out[-1][0]
        out.append([place, name, '%d.%02d' % (h // 100, h % 100)])
    for name in sorted(dnf):
        out.append([None, name, 'DNF'])
    return out
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 distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: round up hundredths',
   ([['Fay', '10.2'], ['Cy', '10.26'], ['Dee', '10.245'], ['Eli', '10.234']],),
   [[1, 'Fay', '10.20'], [2, 'Eli', '10.24'], [3, 'Dee', '10.25'], [4, 'Cy', '10.26']]),
  ('variant scenario 1',
   ([['Fay', '10.24'],
     ['Dee', '10.24'],
     ['Bo', 'DNF'],
     ['Cy', 'DNF'],
     ['Eli', '10.265'],
     ['Ade', '10.']],),
   [[1, 'Ade', '10.00'],
    [2, 'Dee', '10.24'],
    [2, 'Fay', '10.24'],
    [4, 'Eli', '10.27'],
    [None, 'Bo', 'DNF'],
    [None, 'Cy', 'DNF']]),
  ('variant scenario 2',
   ([['Bo', '10.219'], ['Eli', '10.2'], ['Fay', 'DNF']],),
   [[1, 'Eli', '10.20'], [2, 'Bo', '10.22'], [None, 'Fay', 'DNF']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: round up hundredths',
   ([['Dee', '10.666'], ['Ade', '10.674'], ['Fay', '10.676'], ['Eli', '10.66']],),
   [[1, 'Eli', '10.66'], [2, 'Dee', '10.67'], [3, 'Ade', '10.68'], [3, 'Fay', '10.68']]),
  ('variant scenario 1',
   ([['Eli', '9.835'], ['Fay', '9.826'], ['Ade', '9.81'], ['Dee', '9.814']],),
   [[1, 'Ade', '9.81'], [2, 'Dee', '9.82'], [3, 'Fay', '9.83'], [4, 'Eli', '9.84']]),
  ('variant scenario 2',
   ([['Fay', '10.88'], ['Eli', '10.906'], ['Dee', '10.907']],),
   [[1, 'Fay', '10.88'], [2, 'Dee', '10.91'], [2, 'Eli', '10.91']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: round up hundredths',
   ([['Eli', '11.384'], ['Dee', '11.360'], ['Fay', '11.'], ['Bo', '11.377']],),
   [[1, 'Fay', '11.00'], [2, 'Dee', '11.36'], [3, 'Bo', '11.38'], [4, 'Eli', '11.39']]),
  ('variant scenario 1',
   ([['Fay', '11.159'],
     ['Eli', '11.15'],
     ['Cy', '11.167'],
     ['Bo', 'DQ'],
     ['Ade', '11.14'],
     ['Dee', '11.146']],),
   [[1, 'Ade', '11.14'],
    [2, 'Dee', '11.15'],
    [2, 'Eli', '11.15'],
    [4, 'Fay', '11.16'],
    [5, 'Cy', '11.17']]),
  ('variant scenario 2',
   ([['Bo', '10.68'], ['Dee', '10.703'], ['Fay', '10.694'], ['Eli', '10.713']],),
   [[1, 'Bo', '10.68'], [2, 'Fay', '10.70'], [3, 'Dee', '10.71'], [4, 'Eli', '10.72']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: round up hundredths',
   ([['Cy', '11.364'], ['Dee', '11.391'], ['Ade', 'DQ']],),
   [[1, 'Cy', '11.37'], [2, 'Dee', '11.40']]),
  ('variant scenario 1',
   ([['Eli', '9.884'], ['Ade', '9.873'], ['Bo', '9.882'], ['Cy', '9.868'], ['Fay', '9.885']],),
   [[1, 'Cy', '9.87'],
    [2, 'Ade', '9.88'],
    [3, 'Bo', '9.89'],
    [3, 'Eli', '9.89'],
    [3, 'Fay', '9.89']]),
  ('variant scenario 2',
   ([['Dee', '10.455'], ['Fay', '10.47'], ['Bo', '10.471'], ['Ade', '10.469'], ['Cy', 'DQ']],),
   [[1, 'Dee', '10.46'], [2, 'Ade', '10.47'], [2, 'Fay', '10.47'], [4, 'Bo', '10.48']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: round up hundredths',
   ([['Eli', '11.310'], ['Ade', 'DQ'], ['Fay', '11.34'], ['Dee', '11.323'], ['Cy', 'DNF']],),
   [[1, 'Eli', '11.31'], [2, 'Dee', '11.33'], [3, 'Fay', '11.34'], [None, 'Cy', 'DNF']]),
  ('variant scenario 1',
   ([['Eli', 'DNF'], ['Fay', 'DNF'], ['Dee', 'DQ'], ['Ade', '11.155']],),
   [[1, 'Ade', '11.16'], [None, 'Eli', 'DNF'], [None, 'Fay', 'DNF']]),
  ('variant scenario 2',
   ([['Dee', '11.420'], ['Eli', '11.38'], ['Cy', '11.41'], ['Ade', '11.416'], ['Bo', '11.40']],),
   [[1, 'Eli', '11.38'],
    [2, 'Bo', '11.40'],
    [3, 'Cy', '11.41'],
    [4, 'Ade', '11.42'],
    [4, 'Dee', '11.42']])]]
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:
10.101 is published as 10.10 and ties are split that should be shared.

Sprint results. results rows are [name, time] where time is seconds with up to three decimals, or "DNF"/"DQ". Times are rounded up to the next hundredth for publication. Rank by rounded time then name; equal rounded times share the place and the next place is skipped (1, 2, 2, 4). DNF athletes follow the finishers in name order with place None and time "DNF"; DQ athletes are omitted. Return [place, name, time "S.hh"] rows.

split: open-access


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

N = 1
observations = []
def solve(results):
    fin = []
    dnf = []
    for name, t in results:
        if t == 'DQ':
            continue
        if t == 'DNF':
            dnf.append(name)
            continue
        whole, _, frac = t.partition('.')
        thous = int(whole) * 1000 + int(frac or 0)
        hund = -(-thous // 10)
        fin.append((hund, name))
    fin.sort()
    out = []
    for i, (h, name) in enumerate(fin):
        place = i + 1 if i == 0 or fin[i - 1][0] != h else out[-1][0]
        out.append([place, name, '%d.%02d' % (h // 100, h % 100)])
    for name in sorted(dnf):
        out.append([None, name, 'DNF'])
    return out
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 distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: fraction padding',
   ([['Cy', '11.170'], ['Bo', 'DNF'], ['Ade', '11.17'], ['Eli', 'DNF']],),
   [[1, 'Ade', '11.17'], [1, 'Cy', '11.17'], [None, 'Bo', 'DNF'], [None, 'Eli', 'DNF']]),
  ('regression: fraction padding',
   ([['Bo', '9.983'], ['Cy', '9.998'], ['Eli', '9.993'], ['Dee', '9.960'], ['Fay', 'DQ']],),
   [[1, 'Dee', '9.96'], [2, 'Bo', '9.99'], [3, 'Cy', '10.00'], [3, 'Eli', '10.00']]),
  ('variant scenario 1',
   ([['Cy', 'DQ'],
     ['Fay', '10.082'],
     ['Dee', '10.09'],
     ['Bo', '10.085'],
     ['Ade', '10.072'],
     ['Eli', '10.086']],),
   [[1, 'Ade', '10.08'],
    [2, 'Bo', '10.09'],
    [2, 'Dee', '10.09'],
    [2, 'Eli', '10.09'],
    [2, 'Fay', '10.09']]),
  ('variant scenario 2',
   ([['Ade', '11.474'], ['Dee', 'DQ'], ['Fay', '11.482'], ['Cy', '11.501']],),
   [[1, 'Ade', '11.48'], [2, 'Fay', '11.49'], [3, 'Cy', '11.51']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: fraction padding',
   ([['Fay', '10.250'], ['Eli', 'DNF'], ['Cy', '10.26']],),
   [[1, 'Fay', '10.25'], [2, 'Cy', '10.26'], [None, 'Eli', 'DNF']]),
  ('regression: fraction padding',
   ([['Eli', '11.286'], ['Fay', '11.28'], ['Dee', '11.292']],),
   [[1, 'Fay', '11.28'], [2, 'Eli', '11.29'], [3, 'Dee', '11.30']]),
  ('variant scenario 1',
   ([['Dee', 'DQ'], ['Ade', 'DQ'], ['Eli', '11.0'], ['Bo', '11.01']],),
   [[1, 'Eli', '11.00'], [2, 'Bo', '11.01']]),
  ('variant scenario 2',
   ([['Bo', '10.874'], ['Ade', '10.884'], ['Fay', 'DQ']],),
   [[1, 'Bo', '10.88'], [2, 'Ade', '10.89']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: fraction padding',
   ([['Eli', '10.636'], ['Dee', '10.62'], ['Ade', '10.644']],),
   [[1, 'Dee', '10.62'], [2, 'Eli', '10.64'], [3, 'Ade', '10.65']]),
  ('variant scenario 1',
   ([['Fay', '10.081'], ['Dee', '10.118'], ['Bo', '10.'], ['Eli', 'DNF'], ['Ade', '10.088']],),
   [[1, 'Bo', '10.00'],
    [2, 'Ade', '10.09'],
    [2, 'Fay', '10.09'],
    [4, 'Dee', '10.12'],
    [None, 'Eli', 'DNF']]),
  ('variant scenario 2',
   ([['Bo', '9.964'],
     ['Eli', 'DQ'],
     ['Dee', '9.'],
     ['Cy', '9.940'],
     ['Fay', 'DQ'],
     ['Ade', '9.953']],),
   [[1, 'Dee', '9.00'], [2, 'Cy', '9.94'], [3, 'Ade', '9.96'], [4, 'Bo', '9.97']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: fraction padding',
   ([['Dee', '11.248'],
     ['Ade', '11.232'],
     ['Eli', '11.250'],
     ['Bo', '11.250'],
     ['Cy', '11.264'],
     ['Fay', '11.229']],),
   [[1, 'Fay', '11.23'],
    [2, 'Ade', '11.24'],
    [3, 'Bo', '11.25'],
    [3, 'Dee', '11.25'],
    [3, 'Eli', '11.25'],
    [6, 'Cy', '11.27']]),
  ('regression: fraction padding',
   ([['Fay', '10.641'], ['Bo', '10.622'], ['Cy', '10.60'], ['Ade', '10.6']],),
   [[1, 'Ade', '10.60'], [1, 'Cy', '10.60'], [3, 'Bo', '10.63'], [4, 'Fay', '10.65']]),
  ('variant scenario 1',
   ([['Bo', '10.298'], ['Cy', 'DQ'], ['Fay', '10.277']],),
   [[1, 'Fay', '10.28'], [2, 'Bo', '10.30']]),
  ('variant scenario 2',
   ([['Eli', '10.166'], ['Fay', '10.156'], ['Cy', '10.188']],),
   [[1, 'Fay', '10.16'], [2, 'Eli', '10.17'], [3, 'Cy', '10.19']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: fraction padding',
   ([['Ade', '10.599'], ['Fay', '10.590'], ['Dee', '10.593'], ['Cy', '10.588'], ['Bo', 'DQ']],),
   [[1, 'Cy', '10.59'], [1, 'Fay', '10.59'], [3, 'Ade', '10.60'], [3, 'Dee', '10.60']]),
  ('regression: fraction padding',
   ([['Eli', '11.47'], ['Cy', '11.'], ['Bo', '11.471'], ['Fay', '11.46']],),
   [[1, 'Cy', '11.00'], [2, 'Fay', '11.46'], [3, 'Eli', '11.47'], [4, 'Bo', '11.48']]),
  ('variant scenario 1',
   ([['Dee', '11.485'], ['Fay', '11.486'], ['Cy', '11.48'], ['Ade', '11.480']],),
   [[1, 'Ade', '11.48'], [1, 'Cy', '11.48'], [3, 'Dee', '11.49'], [3, 'Fay', '11.49']]),
  ('variant scenario 2',
   ([['Bo', '11.012'], ['Fay', '11.013'], ['Dee', '10.999']],),
   [[1, 'Dee', '11.00'], [2, 'Bo', '11.02'], [2, 'Fay', '11.02']])]]
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(results):
    fin = []
    dnf = []
    for name, t in results:
        if t == 'DQ':
            continue
        if t == 'DNF':
            dnf.append(name)
            continue
        whole, _, frac = t.partition('.')
        thous = int(whole) * 1000 + int((frac + '00')[:2]) * 10
        hund = -(-thous // 10)
        fin.append((hund, name))
    fin.sort()
    out = []
    for i, (h, name) in enumerate(fin):
        place = i + 1 if i == 0 or fin[i - 1][0] != h else out[-1][0]
        out.append([place, name, '%d.%02d' % (h // 100, h % 100)])
    for name in sorted(dnf):
        out.append([None, name, 'DNF'])
    return out
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 distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: fraction padding',
   ([['Cy', '11.170'], ['Bo', 'DNF'], ['Ade', '11.17'], ['Eli', 'DNF']],),
   [[1, 'Ade', '11.17'], [1, 'Cy', '11.17'], [None, 'Bo', 'DNF'], [None, 'Eli', 'DNF']]),
  ('regression: fraction padding',
   ([['Bo', '9.983'], ['Cy', '9.998'], ['Eli', '9.993'], ['Dee', '9.960'], ['Fay', 'DQ']],),
   [[1, 'Dee', '9.96'], [2, 'Bo', '9.99'], [3, 'Cy', '10.00'], [3, 'Eli', '10.00']]),
  ('variant scenario 1',
   ([['Cy', 'DQ'],
     ['Fay', '10.082'],
     ['Dee', '10.09'],
     ['Bo', '10.085'],
     ['Ade', '10.072'],
     ['Eli', '10.086']],),
   [[1, 'Ade', '10.08'],
    [2, 'Bo', '10.09'],
    [2, 'Dee', '10.09'],
    [2, 'Eli', '10.09'],
    [2, 'Fay', '10.09']]),
  ('variant scenario 2',
   ([['Ade', '11.474'], ['Dee', 'DQ'], ['Fay', '11.482'], ['Cy', '11.501']],),
   [[1, 'Ade', '11.48'], [2, 'Fay', '11.49'], [3, 'Cy', '11.51']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: fraction padding',
   ([['Fay', '10.250'], ['Eli', 'DNF'], ['Cy', '10.26']],),
   [[1, 'Fay', '10.25'], [2, 'Cy', '10.26'], [None, 'Eli', 'DNF']]),
  ('regression: fraction padding',
   ([['Eli', '11.286'], ['Fay', '11.28'], ['Dee', '11.292']],),
   [[1, 'Fay', '11.28'], [2, 'Eli', '11.29'], [3, 'Dee', '11.30']]),
  ('variant scenario 1',
   ([['Dee', 'DQ'], ['Ade', 'DQ'], ['Eli', '11.0'], ['Bo', '11.01']],),
   [[1, 'Eli', '11.00'], [2, 'Bo', '11.01']]),
  ('variant scenario 2',
   ([['Bo', '10.874'], ['Ade', '10.884'], ['Fay', 'DQ']],),
   [[1, 'Bo', '10.88'], [2, 'Ade', '10.89']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: fraction padding',
   ([['Eli', '10.636'], ['Dee', '10.62'], ['Ade', '10.644']],),
   [[1, 'Dee', '10.62'], [2, 'Eli', '10.64'], [3, 'Ade', '10.65']]),
  ('variant scenario 1',
   ([['Fay', '10.081'], ['Dee', '10.118'], ['Bo', '10.'], ['Eli', 'DNF'], ['Ade', '10.088']],),
   [[1, 'Bo', '10.00'],
    [2, 'Ade', '10.09'],
    [2, 'Fay', '10.09'],
    [4, 'Dee', '10.12'],
    [None, 'Eli', 'DNF']]),
  ('variant scenario 2',
   ([['Bo', '9.964'],
     ['Eli', 'DQ'],
     ['Dee', '9.'],
     ['Cy', '9.940'],
     ['Fay', 'DQ'],
     ['Ade', '9.953']],),
   [[1, 'Dee', '9.00'], [2, 'Cy', '9.94'], [3, 'Ade', '9.96'], [4, 'Bo', '9.97']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: fraction padding',
   ([['Dee', '11.248'],
     ['Ade', '11.232'],
     ['Eli', '11.250'],
     ['Bo', '11.250'],
     ['Cy', '11.264'],
     ['Fay', '11.229']],),
   [[1, 'Fay', '11.23'],
    [2, 'Ade', '11.24'],
    [3, 'Bo', '11.25'],
    [3, 'Dee', '11.25'],
    [3, 'Eli', '11.25'],
    [6, 'Cy', '11.27']]),
  ('regression: fraction padding',
   ([['Fay', '10.641'], ['Bo', '10.622'], ['Cy', '10.60'], ['Ade', '10.6']],),
   [[1, 'Ade', '10.60'], [1, 'Cy', '10.60'], [3, 'Bo', '10.63'], [4, 'Fay', '10.65']]),
  ('variant scenario 1',
   ([['Bo', '10.298'], ['Cy', 'DQ'], ['Fay', '10.277']],),
   [[1, 'Fay', '10.28'], [2, 'Bo', '10.30']]),
  ('variant scenario 2',
   ([['Eli', '10.166'], ['Fay', '10.156'], ['Cy', '10.188']],),
   [[1, 'Fay', '10.16'], [2, 'Eli', '10.17'], [3, 'Cy', '10.19']])],
 [('control distinct times',
   ([['Bo', '10.12'], ['Ade', '10.15']],),
   [[1, 'Bo', '10.12'], [2, 'Ade', '10.15']]),
  ('boundary thousandth rounds up', ([['Cy', '9.991']],), [[1, 'Cy', '10.00']]),
  ('boundary shared place skips next',
   ([['Ade', '10.101'], ['Bo', '10.11'], ['Cy', '10.2']],),
   [[1, 'Ade', '10.11'], [1, 'Bo', '10.11'], [3, 'Cy', '10.20']]),
  ('control dnf and dq',
   ([['Eli', 'DNF'], ['Dee', '11.0'], ['Fay', 'DQ']],),
   [[1, 'Dee', '11.00'], [None, 'Eli', 'DNF']]),
  ('regression: fraction padding',
   ([['Ade', '10.599'], ['Fay', '10.590'], ['Dee', '10.593'], ['Cy', '10.588'], ['Bo', 'DQ']],),
   [[1, 'Cy', '10.59'], [1, 'Fay', '10.59'], [3, 'Ade', '10.60'], [3, 'Dee', '10.60']]),
  ('regression: fraction padding',
   ([['Eli', '11.47'], ['Cy', '11.'], ['Bo', '11.471'], ['Fay', '11.46']],),
   [[1, 'Cy', '11.00'], [2, 'Fay', '11.46'], [3, 'Eli', '11.47'], [4, 'Bo', '11.48']]),
  ('variant scenario 1',
   ([['Dee', '11.485'], ['Fay', '11.486'], ['Cy', '11.48'], ['Ade', '11.480']],),
   [[1, 'Ade', '11.48'], [1, 'Cy', '11.48'], [3, 'Dee', '11.49'], [3, 'Fay', '11.49']]),
  ('variant scenario 2',
   ([['Bo', '11.012'], ['Fay', '11.013'], ['Dee', '10.999']],),
   [[1, 'Dee', '11.00'], [2, 'Bo', '11.02'], [2, 'Fay', '11.02']])]]
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 time of "10.2" is treated as 10.002 seconds.

Sprint results. results rows are [name, time] where time is seconds with up to three decimals, or "DNF"/"DQ". Times are rounded up to the next hundredth for publication. Rank by rounded time then name; equal rounded times share the place and the next place is skipped (1, 2, 2, 4). DNF athletes follow the finishers in name order with place None and time "DNF"; DQ athletes are omitted. Return [place, name, time "S.hh"] rows.

split: open-access