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

N = 1
observations = []
def solve(jobs, stations, speed, now):
    free = [0] * stations
    done = []
    for idx, (name, dur) in enumerate(jobs):
        d = dur * (100 - speed) // 100
        s = min(range(stations), key=lambda k: (free[k], k))
        start = free[s]
        free[s] = start + d
        done.append((free[s], idx, name))
    return [name for fin, idx, name in sorted(done) if fin <= now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('fault site duration floor #1',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask']),
  ('fault site duration floor #2', [[['anvil', 2], ['dagger', 2], ['flask', 5]], 1, 90, 1], ['anvil']),
  ('partial repair boundary #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger']),
  ('partial repair boundary #2', [[['flask', 10], ['bow', 60]], 1, 90, 5], ['flask']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['anvil', 2], ['flask', 2], ['cape', 1], ['dagger', 103], ['ember', 5]], 2, 10, 60],
   ['anvil', 'flask', 'cape', 'ember'])],
 [('fault site duration floor #1', [[['anvil', 5], ['dagger', 10], ['cape', 1]], 1, 90, 1], ['anvil']),
  ('fault site duration floor #2', [[['dagger', 60], ['cape', 5], ['flask', 1]], 3, 25, 0], []),
  ('partial repair boundary #1',
   [[['anvil', 10], ['bow', 1], ['dagger', 10], ['cape', 60]], 2, 25, 1],
   ['bow']),
  ('partial repair boundary #2',
   [[['flask', 5], ['bow', 10], ['anvil', 1], ['dagger', 2], ['cape', 78]], 2, 50, 208],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('control #1',
   [[['anvil', 2], ['flask', 2], ['cape', 1], ['dagger', 103], ['ember', 5]], 2, 10, 60],
   ['anvil', 'flask', 'cape', 'ember']),
  ('control #2',
   [[['dagger', 10], ['bow', 119], ['cape', 1], ['flask', 2], ['ember', 60], ['anvil', 5]], 1, 0, 60],
   ['dagger'])],
 [('fault site duration floor #1', [[['anvil', 1], ['flask', 5], ['ember', 5]], 2, 90, 0], []),
  ('fault site duration floor #2',
   [[['dagger', 2], ['anvil', 1], ['bow', 5], ['ember', 75], ['cape', 60], ['flask', 59]], 2, 50, 0],
   []),
  ('partial repair boundary #1',
   [[['ember', 60], ['anvil', 1], ['dagger', 1], ['cape', 1], ['bow', 1], ['flask', 2]], 2, 90, 60],
   ['anvil', 'dagger', 'cape', 'bow', 'flask', 'ember']),
  ('partial repair boundary #2',
   [[['bow', 5], ['flask', 60], ['dagger', 1], ['anvil', 10]], 1, 50, 30],
   ['bow']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['dagger', 10], ['bow', 119], ['cape', 1], ['flask', 2], ['ember', 60], ['anvil', 5]], 1, 0, 60],
   ['dagger']),
  ('control #2', [[['dagger', 1], ['bow', 5]], 1, 99, 161], ['dagger', 'bow'])],
 [('fault site duration floor #1',
   [[['anvil', 5], ['ember', 5], ['bow', 1], ['cape', 10], ['dagger', 2], ['flask', 2]], 1, 99, 0],
   []),
  ('fault site duration floor #2', [[['anvil', 1], ['ember', 2]], 3, 50, 0], []),
  ('partial repair boundary #1',
   [[['ember', 11], ['bow', 60], ['dagger', 5]], 3, 10, 30],
   ['dagger', 'ember']),
  ('partial repair boundary #2',
   [[['anvil', 10], ['dagger', 19], ['flask', 2], ['cape', 60], ['ember', 90], ['bow', 5]], 3, 25, 60],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('control #1',
   [[['dagger', 60], ['flask', 1], ['anvil', 60], ['cape', 1], ['ember', 5], ['bow', 33]], 1, 99, 154],
   ['dagger', 'flask', 'anvil', 'cape', 'ember', 'bow']),
  ('control #2', [[['anvil', 2]], 3, 90, 1], ['anvil'])],
 [('fault site duration floor #1', [[['dagger', 1], ['anvil', 60]], 2, 25, 0], []),
  ('fault site duration floor #2', [[['flask', 2], ['cape', 10], ['bow', 81]], 2, 99, 1], ['flask', 'cape']),
  ('partial repair boundary #1',
   [[['cape', 2], ['anvil', 10], ['ember', 2], ['bow', 2], ['flask', 1]], 1, 50, 5],
   ['cape']),
  ('partial repair boundary #2', [[['dagger', 5], ['flask', 10], ['anvil', 1], ['ember', 60]], 2, 10, 1], []),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('control #1', [[['flask', 60]], 1, 25, 30], []),
  ('control #2',
   [[['anvil', 105], ['dagger', 10], ['ember', 1], ['flask', 5], ['cape', 5], ['bow', 5]], 1, 99, 0],
   [])]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(jobs, stations, speed, now):
    free = [0] * stations
    done = []
    for idx, (name, dur) in enumerate(jobs):
        d = max(1, dur - speed)
        s = min(range(stations), key=lambda k: (free[k], k))
        start = free[s]
        free[s] = start + d
        done.append((free[s], idx, name))
    return [name for fin, idx, name in sorted(done) if fin <= now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('fault site duration floor #1',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask']),
  ('fault site duration floor #2', [[['anvil', 2], ['dagger', 2], ['flask', 5]], 1, 90, 1], ['anvil']),
  ('partial repair boundary #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger']),
  ('partial repair boundary #2', [[['flask', 10], ['bow', 60]], 1, 90, 5], ['flask']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['anvil', 2], ['flask', 2], ['cape', 1], ['dagger', 103], ['ember', 5]], 2, 10, 60],
   ['anvil', 'flask', 'cape', 'ember'])],
 [('fault site duration floor #1', [[['anvil', 5], ['dagger', 10], ['cape', 1]], 1, 90, 1], ['anvil']),
  ('fault site duration floor #2', [[['dagger', 60], ['cape', 5], ['flask', 1]], 3, 25, 0], []),
  ('partial repair boundary #1',
   [[['anvil', 10], ['bow', 1], ['dagger', 10], ['cape', 60]], 2, 25, 1],
   ['bow']),
  ('partial repair boundary #2',
   [[['flask', 5], ['bow', 10], ['anvil', 1], ['dagger', 2], ['cape', 78]], 2, 50, 208],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('control #1',
   [[['anvil', 2], ['flask', 2], ['cape', 1], ['dagger', 103], ['ember', 5]], 2, 10, 60],
   ['anvil', 'flask', 'cape', 'ember']),
  ('control #2',
   [[['dagger', 10], ['bow', 119], ['cape', 1], ['flask', 2], ['ember', 60], ['anvil', 5]], 1, 0, 60],
   ['dagger'])],
 [('fault site duration floor #1', [[['anvil', 1], ['flask', 5], ['ember', 5]], 2, 90, 0], []),
  ('fault site duration floor #2',
   [[['dagger', 2], ['anvil', 1], ['bow', 5], ['ember', 75], ['cape', 60], ['flask', 59]], 2, 50, 0],
   []),
  ('partial repair boundary #1',
   [[['ember', 60], ['anvil', 1], ['dagger', 1], ['cape', 1], ['bow', 1], ['flask', 2]], 2, 90, 60],
   ['anvil', 'dagger', 'cape', 'bow', 'flask', 'ember']),
  ('partial repair boundary #2',
   [[['bow', 5], ['flask', 60], ['dagger', 1], ['anvil', 10]], 1, 50, 30],
   ['bow']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['dagger', 10], ['bow', 119], ['cape', 1], ['flask', 2], ['ember', 60], ['anvil', 5]], 1, 0, 60],
   ['dagger']),
  ('control #2', [[['dagger', 1], ['bow', 5]], 1, 99, 161], ['dagger', 'bow'])],
 [('fault site duration floor #1',
   [[['anvil', 5], ['ember', 5], ['bow', 1], ['cape', 10], ['dagger', 2], ['flask', 2]], 1, 99, 0],
   []),
  ('fault site duration floor #2', [[['anvil', 1], ['ember', 2]], 3, 50, 0], []),
  ('partial repair boundary #1',
   [[['ember', 11], ['bow', 60], ['dagger', 5]], 3, 10, 30],
   ['dagger', 'ember']),
  ('partial repair boundary #2',
   [[['anvil', 10], ['dagger', 19], ['flask', 2], ['cape', 60], ['ember', 90], ['bow', 5]], 3, 25, 60],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('control #1',
   [[['dagger', 60], ['flask', 1], ['anvil', 60], ['cape', 1], ['ember', 5], ['bow', 33]], 1, 99, 154],
   ['dagger', 'flask', 'anvil', 'cape', 'ember', 'bow']),
  ('control #2', [[['anvil', 2]], 3, 90, 1], ['anvil'])],
 [('fault site duration floor #1', [[['dagger', 1], ['anvil', 60]], 2, 25, 0], []),
  ('fault site duration floor #2', [[['flask', 2], ['cape', 10], ['bow', 81]], 2, 99, 1], ['flask', 'cape']),
  ('partial repair boundary #1',
   [[['cape', 2], ['anvil', 10], ['ember', 2], ['bow', 2], ['flask', 1]], 1, 50, 5],
   ['cape']),
  ('partial repair boundary #2', [[['dagger', 5], ['flask', 10], ['anvil', 1], ['ember', 60]], 2, 10, 1], []),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('control #1', [[['flask', 60]], 1, 25, 30], []),
  ('control #2',
   [[['anvil', 105], ['dagger', 10], ['ember', 1], ['flask', 5], ['cape', 5], ['bow', 5]], 1, 99, 0],
   [])]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Short jobs take zero time at high speed.

jobs = [[name, duration], ...] in queue order. Effective duration = max(1, floor(duration*(100-speed)/100)). Each job starts on the station that frees earliest (lowest index on ties) at that station free time. Return names of jobs finished by now (finish <= now) ordered by finish time then queue position.

split: open-access


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

N = 1
observations = []
def solve(jobs, stations, speed, now):
    free = [0] * stations
    done = []
    for idx, (name, dur) in enumerate(jobs):
        d = max(1, -(-dur * (100 - speed) // 100))
        s = min(range(stations), key=lambda k: (free[k], k))
        start = free[s]
        free[s] = start + d
        done.append((free[s], idx, name))
    return [name for fin, idx, name in sorted(done) if fin <= now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('fault site duration rounding #1',
   [[['flask', 5], ['bow', 10], ['anvil', 1], ['dagger', 2], ['cape', 78]], 2, 50, 208],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('regression duration rounding #1', [[['ember', 2], ['cape', 5]], 1, 10, 5], ['ember', 'cape']),
  ('regression duration rounding #2', [[['flask', 2], ['cape', 1]], 3, 25, 30], ['flask', 'cape']),
  ('regression duration rounding #3',
   [[['cape', 2], ['flask', 2], ['dagger', 32], ['anvil', 1]], 1, 10, 30],
   ['cape', 'flask', 'dagger']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger'])],
 [('fault site duration rounding #1',
   [[['flask', 114], ['ember', 60], ['cape', 10], ['anvil', 5]], 2, 99, 169],
   ['flask', 'ember', 'cape', 'anvil']),
  ('regression duration rounding #1', [[['flask', 2], ['cape', 1]], 3, 25, 30], ['flask', 'cape']),
  ('regression duration rounding #2',
   [[['cape', 2], ['flask', 2], ['dagger', 32], ['anvil', 1]], 1, 10, 30],
   ['cape', 'flask', 'dagger']),
  ('regression duration rounding #3', [[['dagger', 2], ['flask', 1]], 2, 10, 148], ['dagger', 'flask']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('control #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger']),
  ('control #2',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask'])],
 [('regression duration rounding #1',
   [[['cape', 2], ['flask', 2], ['dagger', 32], ['anvil', 1]], 1, 10, 30],
   ['cape', 'flask', 'dagger']),
  ('regression duration rounding #2', [[['dagger', 2], ['flask', 1]], 2, 10, 148], ['dagger', 'flask']),
  ('regression duration rounding #3', [[['dagger', 2], ['ember', 1]], 3, 25, 48], ['dagger', 'ember']),
  ('regression duration rounding #4',
   [[['ember', 2], ['cape', 2], ['dagger', 55], ['anvil', 1]], 3, 90, 5],
   ['ember', 'cape', 'anvil', 'dagger']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask']),
  ('control #2',
   [[['anvil', 2], ['flask', 2], ['cape', 1], ['dagger', 103], ['ember', 5]], 2, 10, 60],
   ['anvil', 'flask', 'cape', 'ember'])],
 [('fault site duration rounding #1',
   [[['cape', 32], ['anvil', 1], ['flask', 1], ['ember', 5], ['bow', 10], ['dagger', 5]], 3, 50, 5],
   ['anvil', 'flask', 'ember', 'dagger']),
  ('regression duration rounding #1', [[['dagger', 2], ['ember', 1]], 3, 25, 48], ['dagger', 'ember']),
  ('regression duration rounding #2',
   [[['cape', 10], ['bow', 5], ['dagger', 38], ['anvil', 60]], 1, 90, 5],
   ['cape', 'bow', 'dagger']),
  ('regression duration rounding #3',
   [[['bow', 5], ['anvil', 2], ['cape', 60], ['dagger', 60], ['ember', 44], ['flask', 2]], 1, 25, 5],
   ['bow', 'anvil']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('control #1',
   [[['dagger', 10], ['bow', 119], ['cape', 1], ['flask', 2], ['ember', 60], ['anvil', 5]], 1, 0, 60],
   ['dagger']),
  ('control #2', [[['dagger', 1], ['bow', 5]], 1, 99, 161], ['dagger', 'bow'])],
 [('regression duration rounding #1',
   [[['ember', 2], ['cape', 2], ['dagger', 55], ['anvil', 1]], 3, 90, 5],
   ['ember', 'cape', 'anvil', 'dagger']),
  ('fault site duration rounding #1',
   [[['anvil', 71], ['ember', 5], ['flask', 16], ['dagger', 60], ['cape', 88]], 3, 90, 60],
   ['ember', 'flask', 'anvil', 'dagger', 'cape']),
  ('regression duration rounding #2',
   [[['anvil', 69], ['bow', 118], ['flask', 2], ['ember', 60], ['dagger', 1]], 3, 10, 1],
   ['flask']),
  ('regression duration rounding #3',
   [[['flask', 17], ['bow', 1], ['dagger', 60], ['ember', 17]], 3, 90, 1],
   ['flask', 'bow']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('control #1',
   [[['dagger', 60], ['flask', 1], ['anvil', 60], ['cape', 1], ['ember', 5], ['bow', 33]], 1, 99, 154],
   ['dagger', 'flask', 'anvil', 'cape', 'ember', 'bow']),
  ('control #2', [[['anvil', 2]], 3, 90, 1], ['anvil'])]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(jobs, stations, speed, now):
    free = [0] * stations
    done = []
    for idx, (name, dur) in enumerate(jobs):
        d = max(1, round(dur * (100 - speed) / 100))
        s = min(range(stations), key=lambda k: (free[k], k))
        start = free[s]
        free[s] = start + d
        done.append((free[s], idx, name))
    return [name for fin, idx, name in sorted(done) if fin <= now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('fault site duration rounding #1',
   [[['flask', 5], ['bow', 10], ['anvil', 1], ['dagger', 2], ['cape', 78]], 2, 50, 208],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('regression duration rounding #1', [[['ember', 2], ['cape', 5]], 1, 10, 5], ['ember', 'cape']),
  ('regression duration rounding #2', [[['flask', 2], ['cape', 1]], 3, 25, 30], ['flask', 'cape']),
  ('regression duration rounding #3',
   [[['cape', 2], ['flask', 2], ['dagger', 32], ['anvil', 1]], 1, 10, 30],
   ['cape', 'flask', 'dagger']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger'])],
 [('fault site duration rounding #1',
   [[['flask', 114], ['ember', 60], ['cape', 10], ['anvil', 5]], 2, 99, 169],
   ['flask', 'ember', 'cape', 'anvil']),
  ('regression duration rounding #1', [[['flask', 2], ['cape', 1]], 3, 25, 30], ['flask', 'cape']),
  ('regression duration rounding #2',
   [[['cape', 2], ['flask', 2], ['dagger', 32], ['anvil', 1]], 1, 10, 30],
   ['cape', 'flask', 'dagger']),
  ('regression duration rounding #3', [[['dagger', 2], ['flask', 1]], 2, 10, 148], ['dagger', 'flask']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('control #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger']),
  ('control #2',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask'])],
 [('regression duration rounding #1',
   [[['cape', 2], ['flask', 2], ['dagger', 32], ['anvil', 1]], 1, 10, 30],
   ['cape', 'flask', 'dagger']),
  ('regression duration rounding #2', [[['dagger', 2], ['flask', 1]], 2, 10, 148], ['dagger', 'flask']),
  ('regression duration rounding #3', [[['dagger', 2], ['ember', 1]], 3, 25, 48], ['dagger', 'ember']),
  ('regression duration rounding #4',
   [[['ember', 2], ['cape', 2], ['dagger', 55], ['anvil', 1]], 3, 90, 5],
   ['ember', 'cape', 'anvil', 'dagger']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask']),
  ('control #2',
   [[['anvil', 2], ['flask', 2], ['cape', 1], ['dagger', 103], ['ember', 5]], 2, 10, 60],
   ['anvil', 'flask', 'cape', 'ember'])],
 [('fault site duration rounding #1',
   [[['cape', 32], ['anvil', 1], ['flask', 1], ['ember', 5], ['bow', 10], ['dagger', 5]], 3, 50, 5],
   ['anvil', 'flask', 'ember', 'dagger']),
  ('regression duration rounding #1', [[['dagger', 2], ['ember', 1]], 3, 25, 48], ['dagger', 'ember']),
  ('regression duration rounding #2',
   [[['cape', 10], ['bow', 5], ['dagger', 38], ['anvil', 60]], 1, 90, 5],
   ['cape', 'bow', 'dagger']),
  ('regression duration rounding #3',
   [[['bow', 5], ['anvil', 2], ['cape', 60], ['dagger', 60], ['ember', 44], ['flask', 2]], 1, 25, 5],
   ['bow', 'anvil']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('control #1',
   [[['dagger', 10], ['bow', 119], ['cape', 1], ['flask', 2], ['ember', 60], ['anvil', 5]], 1, 0, 60],
   ['dagger']),
  ('control #2', [[['dagger', 1], ['bow', 5]], 1, 99, 161], ['dagger', 'bow'])],
 [('regression duration rounding #1',
   [[['ember', 2], ['cape', 2], ['dagger', 55], ['anvil', 1]], 3, 90, 5],
   ['ember', 'cape', 'anvil', 'dagger']),
  ('fault site duration rounding #1',
   [[['anvil', 71], ['ember', 5], ['flask', 16], ['dagger', 60], ['cape', 88]], 3, 90, 60],
   ['ember', 'flask', 'anvil', 'dagger', 'cape']),
  ('regression duration rounding #2',
   [[['anvil', 69], ['bow', 118], ['flask', 2], ['ember', 60], ['dagger', 1]], 3, 10, 1],
   ['flask']),
  ('regression duration rounding #3',
   [[['flask', 17], ['bow', 1], ['dagger', 60], ['ember', 17]], 3, 90, 1],
   ['flask', 'bow']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('control #1',
   [[['dagger', 60], ['flask', 1], ['anvil', 60], ['cape', 1], ['ember', 5], ['bow', 33]], 1, 99, 154],
   ['dagger', 'flask', 'anvil', 'cape', 'ember', 'bow']),
  ('control #2', [[['anvil', 2]], 3, 90, 1], ['anvil'])]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Speed bonuses are worth less than the floor rule.

jobs = [[name, duration], ...] in queue order. Effective duration = max(1, floor(duration*(100-speed)/100)). Each job starts on the station that frees earliest (lowest index on ties) at that station free time. Return names of jobs finished by now (finish <= now) ordered by finish time then queue position.

split: open-access


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

N = 1
observations = []
def solve(jobs, stations, speed, now):
    free = [0] * stations
    done = []
    for idx, (name, dur) in enumerate(jobs):
        d = max(1, dur * (100 - speed) // 100)
        s = idx % stations
        start = free[s]
        free[s] = start + d
        done.append((free[s], idx, name))
    return [name for fin, idx, name in sorted(done) if fin <= now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('regression station selection #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger']),
  ('regression station selection #2',
   [[['cape', 1], ['dagger', 73], ['bow', 1], ['anvil', 2], ['flask', 5], ['ember', 32]], 2, 0, 5],
   ['cape', 'bow', 'anvil']),
  ('partial repair boundary #1',
   [[['anvil', 2], ['flask', 2], ['cape', 1], ['dagger', 103], ['ember', 5]], 2, 10, 60],
   ['anvil', 'flask', 'cape', 'ember']),
  ('partial repair boundary #2',
   [[['anvil', 10], ['bow', 1], ['dagger', 10], ['cape', 60]], 2, 25, 1],
   ['bow']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('regression station selection #1',
   [[['anvil', 2], ['cape', 60], ['bow', 5], ['ember', 1]], 2, 50, 5],
   ['anvil', 'bow', 'ember']),
  ('regression station selection #2',
   [[['flask', 5], ['bow', 10], ['anvil', 1], ['dagger', 2], ['cape', 78]], 2, 50, 208],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('partial repair boundary #1',
   [[['anvil', 2], ['flask', 2], ['cape', 1], ['dagger', 103], ['ember', 5]], 2, 10, 60],
   ['anvil', 'flask', 'cape', 'ember']),
  ('partial repair boundary #2',
   [[['anvil', 10], ['bow', 1], ['dagger', 10], ['cape', 60]], 2, 25, 1],
   ['bow']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('regression station selection #1',
   [[['bow', 60], ['anvil', 60], ['ember', 5], ['dagger', 5]], 3, 0, 133],
   ['ember', 'dagger', 'bow', 'anvil']),
  ('regression station selection #2',
   [[['dagger', 1], ['anvil', 100], ['ember', 60], ['bow', 1], ['flask', 1], ['cape', 5]], 3, 0, 30],
   ['dagger', 'bow', 'flask', 'cape']),
  ('regression station selection #3',
   [[['cape', 1], ['dagger', 73], ['bow', 1], ['anvil', 2], ['flask', 5], ['ember', 32]], 2, 0, 5],
   ['cape', 'bow', 'anvil']),
  ('partial repair boundary #1',
   [[['anvil', 10], ['bow', 60], ['cape', 10]], 2, 50, 260],
   ['anvil', 'cape', 'bow']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('regression station selection #1',
   [[['bow', 1], ['anvil', 60], ['flask', 2], ['dagger', 1], ['ember', 1]], 2, 50, 5],
   ['bow', 'flask', 'dagger', 'ember']),
  ('regression station selection #2',
   [[['ember', 60], ['anvil', 1], ['dagger', 1], ['cape', 1], ['bow', 1], ['flask', 2]], 2, 90, 60],
   ['anvil', 'dagger', 'cape', 'bow', 'flask', 'ember']),
  ('regression station selection #3',
   [[['anvil', 2], ['cape', 60], ['bow', 5], ['ember', 1]], 2, 50, 5],
   ['anvil', 'bow', 'ember']),
  ('regression station selection #4',
   [[['flask', 5], ['bow', 10], ['anvil', 1], ['dagger', 2], ['cape', 78]], 2, 50, 208],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['dagger', 10], ['bow', 119], ['cape', 1], ['flask', 2], ['ember', 60], ['anvil', 5]], 1, 0, 60],
   ['dagger'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('regression station selection #1',
   [[['anvil', 10], ['dagger', 19], ['flask', 2], ['cape', 60], ['ember', 90], ['bow', 5]], 3, 25, 60],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('regression station selection #2',
   [[['ember', 10], ['cape', 60], ['bow', 1], ['flask', 5], ['dagger', 1], ['anvil', 2]], 2, 0, 30],
   ['ember', 'bow', 'flask', 'dagger', 'anvil']),
  ('partial repair boundary #1', [[['ember', 1], ['cape', 1], ['bow', 60]], 3, 50, 1], ['ember', 'cape']),
  ('regression station selection #3',
   [[['bow', 60], ['anvil', 60], ['ember', 5], ['dagger', 5]], 3, 0, 133],
   ['ember', 'dagger', 'bow', 'anvil']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1', [[['dagger', 1], ['bow', 5]], 1, 99, 161], ['dagger', 'bow'])]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(jobs, stations, speed, now):
    free = [0] * stations
    done = []
    for idx, (name, dur) in enumerate(jobs):
        d = max(1, dur * (100 - speed) // 100)
        s = min(range(stations), key=lambda k: (k, free[k]))
        start = free[s]
        free[s] = start + d
        done.append((free[s], idx, name))
    return [name for fin, idx, name in sorted(done) if fin <= now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('regression station selection #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger']),
  ('regression station selection #2',
   [[['cape', 1], ['dagger', 73], ['bow', 1], ['anvil', 2], ['flask', 5], ['ember', 32]], 2, 0, 5],
   ['cape', 'bow', 'anvil']),
  ('partial repair boundary #1',
   [[['anvil', 2], ['flask', 2], ['cape', 1], ['dagger', 103], ['ember', 5]], 2, 10, 60],
   ['anvil', 'flask', 'cape', 'ember']),
  ('partial repair boundary #2',
   [[['anvil', 10], ['bow', 1], ['dagger', 10], ['cape', 60]], 2, 25, 1],
   ['bow']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('regression station selection #1',
   [[['anvil', 2], ['cape', 60], ['bow', 5], ['ember', 1]], 2, 50, 5],
   ['anvil', 'bow', 'ember']),
  ('regression station selection #2',
   [[['flask', 5], ['bow', 10], ['anvil', 1], ['dagger', 2], ['cape', 78]], 2, 50, 208],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('partial repair boundary #1',
   [[['anvil', 2], ['flask', 2], ['cape', 1], ['dagger', 103], ['ember', 5]], 2, 10, 60],
   ['anvil', 'flask', 'cape', 'ember']),
  ('partial repair boundary #2',
   [[['anvil', 10], ['bow', 1], ['dagger', 10], ['cape', 60]], 2, 25, 1],
   ['bow']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('regression station selection #1',
   [[['bow', 60], ['anvil', 60], ['ember', 5], ['dagger', 5]], 3, 0, 133],
   ['ember', 'dagger', 'bow', 'anvil']),
  ('regression station selection #2',
   [[['dagger', 1], ['anvil', 100], ['ember', 60], ['bow', 1], ['flask', 1], ['cape', 5]], 3, 0, 30],
   ['dagger', 'bow', 'flask', 'cape']),
  ('regression station selection #3',
   [[['cape', 1], ['dagger', 73], ['bow', 1], ['anvil', 2], ['flask', 5], ['ember', 32]], 2, 0, 5],
   ['cape', 'bow', 'anvil']),
  ('partial repair boundary #1',
   [[['anvil', 10], ['bow', 60], ['cape', 10]], 2, 50, 260],
   ['anvil', 'cape', 'bow']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('regression station selection #1',
   [[['bow', 1], ['anvil', 60], ['flask', 2], ['dagger', 1], ['ember', 1]], 2, 50, 5],
   ['bow', 'flask', 'dagger', 'ember']),
  ('regression station selection #2',
   [[['ember', 60], ['anvil', 1], ['dagger', 1], ['cape', 1], ['bow', 1], ['flask', 2]], 2, 90, 60],
   ['anvil', 'dagger', 'cape', 'bow', 'flask', 'ember']),
  ('regression station selection #3',
   [[['anvil', 2], ['cape', 60], ['bow', 5], ['ember', 1]], 2, 50, 5],
   ['anvil', 'bow', 'ember']),
  ('regression station selection #4',
   [[['flask', 5], ['bow', 10], ['anvil', 1], ['dagger', 2], ['cape', 78]], 2, 50, 208],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['dagger', 10], ['bow', 119], ['cape', 1], ['flask', 2], ['ember', 60], ['anvil', 5]], 1, 0, 60],
   ['dagger'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('regression station selection #1',
   [[['anvil', 10], ['dagger', 19], ['flask', 2], ['cape', 60], ['ember', 90], ['bow', 5]], 3, 25, 60],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('regression station selection #2',
   [[['ember', 10], ['cape', 60], ['bow', 1], ['flask', 5], ['dagger', 1], ['anvil', 2]], 2, 0, 30],
   ['ember', 'bow', 'flask', 'dagger', 'anvil']),
  ('partial repair boundary #1', [[['ember', 1], ['cape', 1], ['bow', 60]], 3, 50, 1], ['ember', 'cape']),
  ('regression station selection #3',
   [[['bow', 60], ['anvil', 60], ['ember', 5], ['dagger', 5]], 3, 0, 133],
   ['ember', 'dagger', 'bow', 'anvil']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1', [[['dagger', 1], ['bow', 5]], 1, 99, 161], ['dagger', 'bow'])]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A long job blocks its station while another sits idle.

jobs = [[name, duration], ...] in queue order. Effective duration = max(1, floor(duration*(100-speed)/100)). Each job starts on the station that frees earliest (lowest index on ties) at that station free time. Return names of jobs finished by now (finish <= now) ordered by finish time then queue position.

split: open-access


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

N = 1
observations = []
def solve(jobs, stations, speed, now):
    free = [0] * stations
    done = []
    for idx, (name, dur) in enumerate(jobs):
        d = max(1, dur * (100 - speed) // 100)
        s = min(range(stations), key=lambda k: (free[k], k))
        start = max(free)
        free[s] = start + d
        done.append((free[s], idx, name))
    return [name for fin, idx, name in sorted(done) if fin <= now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('regression start time #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger']),
  ('fault site start time #1',
   [[['anvil', 2], ['flask', 2], ['cape', 1], ['dagger', 103], ['ember', 5]], 2, 10, 60],
   ['anvil', 'flask', 'cape', 'ember']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('partial repair boundary #1',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask']),
  ('control #1',
   [[['dagger', 10], ['bow', 119], ['cape', 1], ['flask', 2], ['ember', 60], ['anvil', 5]], 1, 0, 60],
   ['dagger']),
  ('control #2', [[['dagger', 1], ['bow', 5]], 1, 99, 161], ['dagger', 'bow'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('fault site start time #1',
   [[['anvil', 2], ['flask', 2], ['cape', 1], ['dagger', 103], ['ember', 5]], 2, 10, 60],
   ['anvil', 'flask', 'cape', 'ember']),
  ('regression start time #1',
   [[['anvil', 10], ['bow', 1], ['dagger', 10], ['cape', 60]], 2, 25, 1],
   ['bow']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('regression start time #2',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger']),
  ('control #1',
   [[['dagger', 60], ['flask', 1], ['anvil', 60], ['cape', 1], ['ember', 5], ['bow', 33]], 1, 99, 154],
   ['dagger', 'flask', 'anvil', 'cape', 'ember', 'bow']),
  ('control #2', [[['flask', 60]], 1, 25, 30], [])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('regression start time #1',
   [[['cape', 1], ['dagger', 73], ['bow', 1], ['anvil', 2], ['flask', 5], ['ember', 32]], 2, 0, 5],
   ['cape', 'bow', 'anvil']),
  ('fault site start time #1',
   [[['anvil', 10], ['bow', 60], ['cape', 10]], 2, 50, 260],
   ['anvil', 'cape', 'bow']),
  ('partial repair boundary #1',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask']),
  ('partial repair boundary #2', [[['anvil', 2]], 3, 90, 1], ['anvil']),
  ('control #1',
   [[['anvil', 105], ['dagger', 10], ['ember', 1], ['flask', 5], ['cape', 5], ['bow', 5]], 1, 99, 0],
   []),
  ('control #2', [[['flask', 60]], 1, 90, 174], ['flask'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('regression start time #1',
   [[['anvil', 2], ['cape', 60], ['bow', 5], ['ember', 1]], 2, 50, 5],
   ['anvil', 'bow', 'ember']),
  ('regression start time #2',
   [[['flask', 5], ['bow', 10], ['anvil', 1], ['dagger', 2], ['cape', 78]], 2, 50, 208],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('partial repair boundary #1', [[['anvil', 2], ['dagger', 2], ['flask', 5]], 1, 90, 1], ['anvil']),
  ('partial repair boundary #2', [[['anvil', 5], ['dagger', 10], ['cape', 1]], 1, 90, 1], ['anvil']),
  ('control #1', [[['bow', 5]], 3, 0, 0], []),
  ('control #2', [[['flask', 10], ['bow', 60]], 1, 90, 5], ['flask'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('regression start time #1', [[['ember', 1], ['cape', 1], ['bow', 60]], 3, 50, 1], ['ember', 'cape']),
  ('fault site start time #1',
   [[['bow', 60], ['anvil', 60], ['ember', 5], ['dagger', 5]], 3, 0, 133],
   ['ember', 'dagger', 'bow', 'anvil']),
  ('regression start time #2',
   [[['anvil', 10], ['bow', 1], ['dagger', 10], ['cape', 60]], 2, 25, 1],
   ['bow']),
  ('regression start time #3',
   [[['cape', 1], ['dagger', 73], ['bow', 1], ['anvil', 2], ['flask', 5], ['ember', 32]], 2, 0, 5],
   ['cape', 'bow', 'anvil']),
  ('control #1', [[['dagger', 60], ['cape', 5], ['flask', 1]], 3, 25, 0], []),
  ('control #2', [[['bow', 100], ['ember', 2], ['flask', 5], ['dagger', 60]], 1, 0, 30], [])]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(jobs, stations, speed, now):
    free = [0] * stations
    done = []
    for idx, (name, dur) in enumerate(jobs):
        d = max(1, dur * (100 - speed) // 100)
        s = min(range(stations), key=lambda k: (free[k], k))
        start = free[s] + 1
        free[s] = start + d
        done.append((free[s], idx, name))
    return [name for fin, idx, name in sorted(done) if fin <= now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('regression start time #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger']),
  ('fault site start time #1',
   [[['anvil', 2], ['flask', 2], ['cape', 1], ['dagger', 103], ['ember', 5]], 2, 10, 60],
   ['anvil', 'flask', 'cape', 'ember']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('partial repair boundary #1',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask']),
  ('control #1',
   [[['dagger', 10], ['bow', 119], ['cape', 1], ['flask', 2], ['ember', 60], ['anvil', 5]], 1, 0, 60],
   ['dagger']),
  ('control #2', [[['dagger', 1], ['bow', 5]], 1, 99, 161], ['dagger', 'bow'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('fault site start time #1',
   [[['anvil', 2], ['flask', 2], ['cape', 1], ['dagger', 103], ['ember', 5]], 2, 10, 60],
   ['anvil', 'flask', 'cape', 'ember']),
  ('regression start time #1',
   [[['anvil', 10], ['bow', 1], ['dagger', 10], ['cape', 60]], 2, 25, 1],
   ['bow']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('regression start time #2',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger']),
  ('control #1',
   [[['dagger', 60], ['flask', 1], ['anvil', 60], ['cape', 1], ['ember', 5], ['bow', 33]], 1, 99, 154],
   ['dagger', 'flask', 'anvil', 'cape', 'ember', 'bow']),
  ('control #2', [[['flask', 60]], 1, 25, 30], [])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('regression start time #1',
   [[['cape', 1], ['dagger', 73], ['bow', 1], ['anvil', 2], ['flask', 5], ['ember', 32]], 2, 0, 5],
   ['cape', 'bow', 'anvil']),
  ('fault site start time #1',
   [[['anvil', 10], ['bow', 60], ['cape', 10]], 2, 50, 260],
   ['anvil', 'cape', 'bow']),
  ('partial repair boundary #1',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask']),
  ('partial repair boundary #2', [[['anvil', 2]], 3, 90, 1], ['anvil']),
  ('control #1',
   [[['anvil', 105], ['dagger', 10], ['ember', 1], ['flask', 5], ['cape', 5], ['bow', 5]], 1, 99, 0],
   []),
  ('control #2', [[['flask', 60]], 1, 90, 174], ['flask'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('regression start time #1',
   [[['anvil', 2], ['cape', 60], ['bow', 5], ['ember', 1]], 2, 50, 5],
   ['anvil', 'bow', 'ember']),
  ('regression start time #2',
   [[['flask', 5], ['bow', 10], ['anvil', 1], ['dagger', 2], ['cape', 78]], 2, 50, 208],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('partial repair boundary #1', [[['anvil', 2], ['dagger', 2], ['flask', 5]], 1, 90, 1], ['anvil']),
  ('partial repair boundary #2', [[['anvil', 5], ['dagger', 10], ['cape', 1]], 1, 90, 1], ['anvil']),
  ('control #1', [[['bow', 5]], 3, 0, 0], []),
  ('control #2', [[['flask', 10], ['bow', 60]], 1, 90, 5], ['flask'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('regression start time #1', [[['ember', 1], ['cape', 1], ['bow', 60]], 3, 50, 1], ['ember', 'cape']),
  ('fault site start time #1',
   [[['bow', 60], ['anvil', 60], ['ember', 5], ['dagger', 5]], 3, 0, 133],
   ['ember', 'dagger', 'bow', 'anvil']),
  ('regression start time #2',
   [[['anvil', 10], ['bow', 1], ['dagger', 10], ['cape', 60]], 2, 25, 1],
   ['bow']),
  ('regression start time #3',
   [[['cape', 1], ['dagger', 73], ['bow', 1], ['anvil', 2], ['flask', 5], ['ember', 32]], 2, 0, 5],
   ['cape', 'bow', 'anvil']),
  ('control #1', [[['dagger', 60], ['cape', 5], ['flask', 1]], 3, 25, 0], []),
  ('control #2', [[['bow', 100], ['ember', 2], ['flask', 5], ['dagger', 60]], 1, 0, 30], [])]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Parallel stations behave like one serial station.

jobs = [[name, duration], ...] in queue order. Effective duration = max(1, floor(duration*(100-speed)/100)). Each job starts on the station that frees earliest (lowest index on ties) at that station free time. Return names of jobs finished by now (finish <= now) ordered by finish time then queue position.

split: open-access


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

N = 1
observations = []
def solve(jobs, stations, speed, now):
    free = [0] * stations
    done = []
    for idx, (name, dur) in enumerate(jobs):
        d = max(1, dur * (100 - speed) // 100)
        s = min(range(stations), key=lambda k: (free[k], k))
        start = free[s]
        free[s] = d
        done.append((free[s], idx, name))
    return [name for fin, idx, name in sorted(done) if fin <= now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('fault site station release #1',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask']),
  ('fault site station release #2',
   [[['dagger', 10], ['bow', 119], ['cape', 1], ['flask', 2], ['ember', 60], ['anvil', 5]], 1, 0, 60],
   ['dagger']),
  ('partial repair boundary #1',
   [[['dagger', 60], ['flask', 1], ['anvil', 60], ['cape', 1], ['ember', 5], ['bow', 33]], 1, 99, 154],
   ['dagger', 'flask', 'anvil', 'cape', 'ember', 'bow']),
  ('partial repair boundary #2', [[['anvil', 2]], 3, 90, 1], ['anvil']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('fault site station release #1',
   [[['dagger', 10], ['bow', 119], ['cape', 1], ['flask', 2], ['ember', 60], ['anvil', 5]], 1, 0, 60],
   ['dagger']),
  ('regression station release #1', [[['anvil', 2], ['dagger', 2], ['flask', 5]], 1, 90, 1], ['anvil']),
  ('regression station release #2', [[['anvil', 5], ['dagger', 10], ['cape', 1]], 1, 90, 1], ['anvil']),
  ('partial repair boundary #1', [[['flask', 10], ['bow', 60]], 1, 90, 5], ['flask']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('regression station release #1', [[['anvil', 5], ['dagger', 10], ['cape', 1]], 1, 90, 1], ['anvil']),
  ('fault site station release #1',
   [[['bow', 100], ['ember', 2], ['flask', 5], ['dagger', 60]], 1, 0, 30],
   []),
  ('partial repair boundary #1', [[['flask', 10], ['bow', 60]], 1, 90, 5], ['flask']),
  ('partial repair boundary #2',
   [[['flask', 115], ['bow', 60], ['dagger', 19], ['anvil', 96], ['ember', 93], ['cape', 60]], 1, 99, 137],
   ['flask', 'bow', 'dagger', 'anvil', 'ember', 'cape']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('fault site station release #1',
   [[['dagger', 60], ['bow', 84], ['flask', 60], ['ember', 1], ['cape', 10]], 2, 25, 30],
   []),
  ('fault site station release #2',
   [[['cape', 1], ['dagger', 73], ['bow', 1], ['anvil', 2], ['flask', 5], ['ember', 32]], 2, 0, 5],
   ['cape', 'bow', 'anvil']),
  ('regression station release #1',
   [[['anvil', 2], ['cape', 60], ['bow', 5], ['ember', 1]], 2, 50, 5],
   ['anvil', 'bow', 'ember']),
  ('regression station release #2',
   [[['ember', 1], ['cape', 60], ['bow', 60], ['anvil', 10], ['dagger', 5]], 1, 90, 60],
   ['ember', 'cape', 'bow', 'anvil', 'dagger']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['anvil', 2], ['flask', 2], ['cape', 1], ['dagger', 103], ['ember', 5]], 2, 10, 60],
   ['anvil', 'flask', 'cape', 'ember'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('regression station release #1',
   [[['anvil', 2], ['cape', 60], ['bow', 5], ['ember', 1]], 2, 50, 5],
   ['anvil', 'bow', 'ember']),
  ('fault site station release #1',
   [[['flask', 5], ['bow', 10], ['anvil', 1], ['dagger', 2], ['cape', 78]], 2, 50, 208],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('partial repair boundary #1', [[['ember', 2], ['cape', 5]], 1, 10, 5], ['ember', 'cape']),
  ('partial repair boundary #2',
   [[['ember', 2], ['anvil', 5], ['cape', 2]], 3, 90, 293],
   ['ember', 'anvil', 'cape']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1', [[['dagger', 1], ['bow', 5]], 1, 99, 161], ['dagger', 'bow'])]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(jobs, stations, speed, now):
    free = [0] * stations
    done = []
    for idx, (name, dur) in enumerate(jobs):
        d = max(1, dur * (100 - speed) // 100)
        s = min(range(stations), key=lambda k: (free[k], k))
        start = free[s]
        free[s] = start + dur
        done.append((free[s], idx, name))
    return [name for fin, idx, name in sorted(done) if fin <= now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('fault site station release #1',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask']),
  ('fault site station release #2',
   [[['dagger', 10], ['bow', 119], ['cape', 1], ['flask', 2], ['ember', 60], ['anvil', 5]], 1, 0, 60],
   ['dagger']),
  ('partial repair boundary #1',
   [[['dagger', 60], ['flask', 1], ['anvil', 60], ['cape', 1], ['ember', 5], ['bow', 33]], 1, 99, 154],
   ['dagger', 'flask', 'anvil', 'cape', 'ember', 'bow']),
  ('partial repair boundary #2', [[['anvil', 2]], 3, 90, 1], ['anvil']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('fault site station release #1',
   [[['dagger', 10], ['bow', 119], ['cape', 1], ['flask', 2], ['ember', 60], ['anvil', 5]], 1, 0, 60],
   ['dagger']),
  ('regression station release #1', [[['anvil', 2], ['dagger', 2], ['flask', 5]], 1, 90, 1], ['anvil']),
  ('regression station release #2', [[['anvil', 5], ['dagger', 10], ['cape', 1]], 1, 90, 1], ['anvil']),
  ('partial repair boundary #1', [[['flask', 10], ['bow', 60]], 1, 90, 5], ['flask']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('regression station release #1', [[['anvil', 5], ['dagger', 10], ['cape', 1]], 1, 90, 1], ['anvil']),
  ('fault site station release #1',
   [[['bow', 100], ['ember', 2], ['flask', 5], ['dagger', 60]], 1, 0, 30],
   []),
  ('partial repair boundary #1', [[['flask', 10], ['bow', 60]], 1, 90, 5], ['flask']),
  ('partial repair boundary #2',
   [[['flask', 115], ['bow', 60], ['dagger', 19], ['anvil', 96], ['ember', 93], ['cape', 60]], 1, 99, 137],
   ['flask', 'bow', 'dagger', 'anvil', 'ember', 'cape']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('fault site station release #1',
   [[['dagger', 60], ['bow', 84], ['flask', 60], ['ember', 1], ['cape', 10]], 2, 25, 30],
   []),
  ('fault site station release #2',
   [[['cape', 1], ['dagger', 73], ['bow', 1], ['anvil', 2], ['flask', 5], ['ember', 32]], 2, 0, 5],
   ['cape', 'bow', 'anvil']),
  ('regression station release #1',
   [[['anvil', 2], ['cape', 60], ['bow', 5], ['ember', 1]], 2, 50, 5],
   ['anvil', 'bow', 'ember']),
  ('regression station release #2',
   [[['ember', 1], ['cape', 60], ['bow', 60], ['anvil', 10], ['dagger', 5]], 1, 90, 60],
   ['ember', 'cape', 'bow', 'anvil', 'dagger']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['anvil', 2], ['flask', 2], ['cape', 1], ['dagger', 103], ['ember', 5]], 2, 10, 60],
   ['anvil', 'flask', 'cape', 'ember'])],
 [('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('regression station release #1',
   [[['anvil', 2], ['cape', 60], ['bow', 5], ['ember', 1]], 2, 50, 5],
   ['anvil', 'bow', 'ember']),
  ('fault site station release #1',
   [[['flask', 5], ['bow', 10], ['anvil', 1], ['dagger', 2], ['cape', 78]], 2, 50, 208],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('partial repair boundary #1', [[['ember', 2], ['cape', 5]], 1, 10, 5], ['ember', 'cape']),
  ('partial repair boundary #2',
   [[['ember', 2], ['anvil', 5], ['cape', 2]], 3, 90, 293],
   ['ember', 'anvil', 'cape']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1', [[['dagger', 1], ['bow', 5]], 1, 99, 161], ['dagger', 'bow'])]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Consecutive jobs on one station overlap.

jobs = [[name, duration], ...] in queue order. Effective duration = max(1, floor(duration*(100-speed)/100)). Each job starts on the station that frees earliest (lowest index on ties) at that station free time. Return names of jobs finished by now (finish <= now) ordered by finish time then queue position.

split: open-access


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

N = 1
observations = []
def solve(jobs, stations, speed, now):
    free = [0] * stations
    done = []
    for idx, (name, dur) in enumerate(jobs):
        d = max(1, dur * (100 - speed) // 100)
        s = min(range(stations), key=lambda k: (free[k], k))
        start = free[s]
        free[s] = start + d
        done.append((free[s], idx, name))
    return [name for fin, idx, name in done if fin <= now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('fault site result ordering #1',
   [[['anvil', 10], ['bow', 60], ['cape', 10]], 2, 50, 260],
   ['anvil', 'cape', 'bow']),
  ('fault site result ordering #2',
   [[['flask', 5], ['bow', 10], ['anvil', 1], ['dagger', 2], ['cape', 78]], 2, 50, 208],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('partial repair boundary #1', [[['ember', 1], ['cape', 1], ['bow', 60]], 3, 50, 1], ['ember', 'cape']),
  ('regression result ordering #1',
   [[['bow', 60], ['anvil', 60], ['ember', 5], ['dagger', 5]], 3, 0, 133],
   ['ember', 'dagger', 'bow', 'anvil']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger'])],
 [('regression result ordering #1',
   [[['bow', 60], ['anvil', 60], ['ember', 5], ['dagger', 5]], 3, 0, 133],
   ['ember', 'dagger', 'bow', 'anvil']),
  ('fault site result ordering #1',
   [[['ember', 60], ['anvil', 1], ['dagger', 1], ['cape', 1], ['bow', 1], ['flask', 2]], 2, 90, 60],
   ['anvil', 'dagger', 'cape', 'bow', 'flask', 'ember']),
  ('partial repair boundary #1',
   [[['ember', 2], ['anvil', 5], ['cape', 2]], 3, 90, 293],
   ['ember', 'anvil', 'cape']),
  ('partial repair boundary #2',
   [[['flask', 2], ['anvil', 10], ['bow', 60], ['ember', 2]], 2, 99, 30],
   ['flask', 'anvil', 'bow', 'ember']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('control #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger']),
  ('control #2',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask'])],
 [('fault site result ordering #1',
   [[['flask', 1], ['cape', 105], ['ember', 2]], 2, 50, 60],
   ['flask', 'ember', 'cape']),
  ('fault site result ordering #2',
   [[['ember', 11], ['bow', 60], ['dagger', 5]], 3, 10, 30],
   ['dagger', 'ember']),
  ('partial repair boundary #1',
   [[['cape', 1], ['bow', 1], ['dagger', 60], ['anvil', 10], ['flask', 5]], 3, 0, 5],
   ['cape', 'bow']),
  ('partial repair boundary #2',
   [[['anvil', 9], ['flask', 10], ['dagger', 2], ['ember', 5]], 3, 99, 60],
   ['anvil', 'flask', 'dagger', 'ember']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask']),
  ('control #2',
   [[['anvil', 2], ['flask', 2], ['cape', 1], ['dagger', 103], ['ember', 5]], 2, 10, 60],
   ['anvil', 'flask', 'cape', 'ember'])],
 [('fault site result ordering #1',
   [[['anvil', 10], ['dagger', 19], ['flask', 2], ['cape', 60], ['ember', 90], ['bow', 5]], 3, 25, 60],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('regression result ordering #1',
   [[['anvil', 98], ['dagger', 5], ['cape', 1], ['bow', 10], ['flask', 10], ['ember', 5]], 3, 90, 60],
   ['dagger', 'cape', 'bow', 'flask', 'ember', 'anvil']),
  ('partial repair boundary #1',
   [[['bow', 5], ['dagger', 1], ['cape', 5], ['flask', 2], ['ember', 10], ['anvil', 2]], 3, 99, 5],
   ['bow', 'dagger', 'cape', 'flask', 'ember', 'anvil']),
  ('partial repair boundary #2',
   [[['flask', 5], ['cape', 5], ['bow', 5]], 3, 10, 30],
   ['flask', 'cape', 'bow']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('control #1',
   [[['dagger', 10], ['bow', 119], ['cape', 1], ['flask', 2], ['ember', 60], ['anvil', 5]], 1, 0, 60],
   ['dagger']),
  ('control #2', [[['dagger', 1], ['bow', 5]], 1, 99, 161], ['dagger', 'bow'])],
 [('regression result ordering #1',
   [[['dagger', 10], ['ember', 10], ['flask', 5], ['cape', 5]], 3, 0, 52],
   ['flask', 'dagger', 'ember', 'cape']),
  ('fault site result ordering #1',
   [[['flask', 1], ['cape', 58], ['bow', 2], ['dagger', 10]], 2, 10, 133],
   ['flask', 'bow', 'dagger', 'cape']),
  ('partial repair boundary #1',
   [[['flask', 5], ['cape', 5], ['bow', 5]], 3, 10, 30],
   ['flask', 'cape', 'bow']),
  ('partial repair boundary #2', [[['flask', 2], ['cape', 10], ['bow', 81]], 2, 99, 1], ['flask', 'cape']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('control #1',
   [[['dagger', 60], ['flask', 1], ['anvil', 60], ['cape', 1], ['ember', 5], ['bow', 33]], 1, 99, 154],
   ['dagger', 'flask', 'anvil', 'cape', 'ember', 'bow']),
  ('control #2', [[['anvil', 2]], 3, 90, 1], ['anvil'])]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(jobs, stations, speed, now):
    free = [0] * stations
    done = []
    for idx, (name, dur) in enumerate(jobs):
        d = max(1, dur * (100 - speed) // 100)
        s = min(range(stations), key=lambda k: (free[k], k))
        start = free[s]
        free[s] = start + d
        done.append((free[s], idx, name))
    return [name for fin, idx, name in sorted(done, key=lambda e: (e[0], e[2])) if fin <= now]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('fault site result ordering #1',
   [[['anvil', 10], ['bow', 60], ['cape', 10]], 2, 50, 260],
   ['anvil', 'cape', 'bow']),
  ('fault site result ordering #2',
   [[['flask', 5], ['bow', 10], ['anvil', 1], ['dagger', 2], ['cape', 78]], 2, 50, 208],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('partial repair boundary #1', [[['ember', 1], ['cape', 1], ['bow', 60]], 3, 50, 1], ['ember', 'cape']),
  ('regression result ordering #1',
   [[['bow', 60], ['anvil', 60], ['ember', 5], ['dagger', 5]], 3, 0, 133],
   ['ember', 'dagger', 'bow', 'anvil']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger'])],
 [('regression result ordering #1',
   [[['bow', 60], ['anvil', 60], ['ember', 5], ['dagger', 5]], 3, 0, 133],
   ['ember', 'dagger', 'bow', 'anvil']),
  ('fault site result ordering #1',
   [[['ember', 60], ['anvil', 1], ['dagger', 1], ['cape', 1], ['bow', 1], ['flask', 2]], 2, 90, 60],
   ['anvil', 'dagger', 'cape', 'bow', 'flask', 'ember']),
  ('partial repair boundary #1',
   [[['ember', 2], ['anvil', 5], ['cape', 2]], 3, 90, 293],
   ['ember', 'anvil', 'cape']),
  ('partial repair boundary #2',
   [[['flask', 2], ['anvil', 10], ['bow', 60], ['ember', 2]], 2, 99, 30],
   ['flask', 'anvil', 'bow', 'ember']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('control #1',
   [[['flask', 2], ['bow', 10], ['cape', 1], ['dagger', 2], ['anvil', 10], ['ember', 10]], 2, 10, 5],
   ['flask', 'cape', 'dagger']),
  ('control #2',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask'])],
 [('fault site result ordering #1',
   [[['flask', 1], ['cape', 105], ['ember', 2]], 2, 50, 60],
   ['flask', 'ember', 'cape']),
  ('fault site result ordering #2',
   [[['ember', 11], ['bow', 60], ['dagger', 5]], 3, 10, 30],
   ['dagger', 'ember']),
  ('partial repair boundary #1',
   [[['cape', 1], ['bow', 1], ['dagger', 60], ['anvil', 10], ['flask', 5]], 3, 0, 5],
   ['cape', 'bow']),
  ('partial repair boundary #2',
   [[['anvil', 9], ['flask', 10], ['dagger', 2], ['ember', 5]], 3, 99, 60],
   ['anvil', 'flask', 'dagger', 'ember']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('control #1',
   [[['flask', 1], ['cape', 60], ['ember', 1], ['bow', 1], ['anvil', 2], ['dagger', 33]], 2, 25, 1],
   ['flask']),
  ('control #2',
   [[['anvil', 2], ['flask', 2], ['cape', 1], ['dagger', 103], ['ember', 5]], 2, 10, 60],
   ['anvil', 'flask', 'cape', 'ember'])],
 [('fault site result ordering #1',
   [[['anvil', 10], ['dagger', 19], ['flask', 2], ['cape', 60], ['ember', 90], ['bow', 5]], 3, 25, 60],
   ['flask', 'anvil', 'dagger', 'bow', 'cape']),
  ('regression result ordering #1',
   [[['anvil', 98], ['dagger', 5], ['cape', 1], ['bow', 10], ['flask', 10], ['ember', 5]], 3, 90, 60],
   ['dagger', 'cape', 'bow', 'flask', 'ember', 'anvil']),
  ('partial repair boundary #1',
   [[['bow', 5], ['dagger', 1], ['cape', 5], ['flask', 2], ['ember', 10], ['anvil', 2]], 3, 99, 5],
   ['bow', 'dagger', 'cape', 'flask', 'ember', 'anvil']),
  ('partial repair boundary #2',
   [[['flask', 5], ['cape', 5], ['bow', 5]], 3, 10, 30],
   ['flask', 'cape', 'bow']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('speed floor #1', [[['x', 1], ['y', 1]], 1, 90, 2], ['x', 'y']),
  ('control #1',
   [[['dagger', 10], ['bow', 119], ['cape', 1], ['flask', 2], ['ember', 60], ['anvil', 5]], 1, 0, 60],
   ['dagger']),
  ('control #2', [[['dagger', 1], ['bow', 5]], 1, 99, 161], ['dagger', 'bow'])],
 [('regression result ordering #1',
   [[['dagger', 10], ['ember', 10], ['flask', 5], ['cape', 5]], 3, 0, 52],
   ['flask', 'dagger', 'ember', 'cape']),
  ('fault site result ordering #1',
   [[['flask', 1], ['cape', 58], ['bow', 2], ['dagger', 10]], 2, 10, 133],
   ['flask', 'bow', 'dagger', 'cape']),
  ('partial repair boundary #1',
   [[['flask', 5], ['cape', 5], ['bow', 5]], 3, 10, 30],
   ['flask', 'cape', 'bow']),
  ('partial repair boundary #2', [[['flask', 2], ['cape', 10], ['bow', 81]], 2, 99, 1], ['flask', 'cape']),
  ('finish exactly now #1', [[['a', 30]], 1, 0, 30], ['a']),
  ('two stations tie #1', [[['a', 10], ['b', 10], ['c', 5]], 2, 0, 15], ['a', 'b', 'c']),
  ('control #1',
   [[['dagger', 60], ['flask', 1], ['anvil', 60], ['cape', 1], ['ember', 5], ['bow', 33]], 1, 99, 154],
   ['dagger', 'flask', 'anvil', 'cape', 'ember', 'bow']),
  ('control #2', [[['anvil', 2]], 3, 90, 1], ['anvil'])]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Completion notifications arrive out of finish order.

jobs = [[name, duration], ...] in queue order. Effective duration = max(1, floor(duration*(100-speed)/100)). Each job starts on the station that frees earliest (lowest index on ties) at that station free time. Return names of jobs finished by now (finish <= now) ordered by finish time then queue position.

split: open-access


prompt:
A tiny xp gain doubles by the entire rested pool.

Level L needs 80 + 20*L xp to reach L+1; max level 50. Gains are ignored once level 50 is reached (rested untouched). For each gain g: bonus = min(g, rested) is added on top of g and removed from the rested pool; then as many levels as possible are taken, carrying remaining xp; on reaching level 50 the xp bar is set to 0. Returns [level, xp, rested].

split: open-access


prompt:
Rested pool goes negative after a large gain.

Level L needs 80 + 20*L xp to reach L+1; max level 50. Gains are ignored once level 50 is reached (rested untouched). For each gain g: bonus = min(g, rested) is added on top of g and removed from the rested pool; then as many levels as possible are taken, carrying remaining xp; on reaching level 50 the xp bar is set to 0. Returns [level, xp, rested].

split: open-access


prompt:
A huge gain leaves an overfull xp bar.

Level L needs 80 + 20*L xp to reach L+1; max level 50. Gains are ignored once level 50 is reached (rested untouched). For each gain g: bonus = min(g, rested) is added on top of g and removed from the rested pool; then as many levels as possible are taken, carrying remaining xp; on reaching level 50 the xp bar is set to 0. Returns [level, xp, rested].

split: open-access


prompt:
Excess xp beyond the requirement is lost on each level.

Level L needs 80 + 20*L xp to reach L+1; max level 50. Gains are ignored once level 50 is reached (rested untouched). For each gain g: bonus = min(g, rested) is added on top of g and removed from the rested pool; then as many levels as possible are taken, carrying remaining xp; on reaching level 50 the xp bar is set to 0. Returns [level, xp, rested].

split: open-access


prompt:
The xp bar shows progress past the level cap.

Level L needs 80 + 20*L xp to reach L+1; max level 50. Gains are ignored once level 50 is reached (rested untouched). For each gain g: bonus = min(g, rested) is added on top of g and removed from the rested pool; then as many levels as possible are taken, carrying remaining xp; on reaching level 50 the xp bar is set to 0. Returns [level, xp, rested].

split: open-access


prompt:
Rested pool is consumed after the level cap.

Level L needs 80 + 20*L xp to reach L+1; max level 50. Gains are ignored once level 50 is reached (rested untouched). For each gain g: bonus = min(g, rested) is added on top of g and removed from the rested pool; then as many levels as possible are taken, carrying remaining xp; on reaching level 50 the xp bar is set to 0. Returns [level, xp, rested].

split: open-access


prompt:
Generated levels contain 2-wide slivers flagged as rooms.

Candidates [x, y, w, h] are tried in order. A room needs w >= 3 and h >= 3, must stay inside a one-tile border (x >= 1, y >= 1, x+w <= width-1, y+h <= height-1) and must keep at least pad empty tiles to every accepted room on both axes (rooms conflict when their pad-expanded extents overlap). Returns indices of accepted candidates.

split: open-access


prompt:
Rooms touch the map edge, leaving no boundary wall.

Candidates [x, y, w, h] are tried in order. A room needs w >= 3 and h >= 3, must stay inside a one-tile border (x >= 1, y >= 1, x+w <= width-1, y+h <= height-1) and must keep at least pad empty tiles to every accepted room on both axes (rooms conflict when their pad-expanded extents overlap). Returns indices of accepted candidates.

split: open-access


prompt:
Rooms at column or row zero erase the top or left wall.

Candidates [x, y, w, h] are tried in order. A room needs w >= 3 and h >= 3, must stay inside a one-tile border (x >= 1, y >= 1, x+w <= width-1, y+h <= height-1) and must keep at least pad empty tiles to every accepted room on both axes (rooms conflict when their pad-expanded extents overlap). Returns indices of accepted candidates.

split: open-access


prompt:
Side-by-side rooms share a wall with no corridor gap.

Candidates [x, y, w, h] are tried in order. A room needs w >= 3 and h >= 3, must stay inside a one-tile border (x >= 1, y >= 1, x+w <= width-1, y+h <= height-1) and must keep at least pad empty tiles to every accepted room on both axes (rooms conflict when their pad-expanded extents overlap). Returns indices of accepted candidates.

split: open-access


prompt:
A rejected candidate prevents later valid rooms from being placed.

Candidates [x, y, w, h] are tried in order. A room needs w >= 3 and h >= 3, must stay inside a one-tile border (x >= 1, y >= 1, x+w <= width-1, y+h <= height-1) and must keep at least pad empty tiles to every accepted room on both axes (rooms conflict when their pad-expanded extents overlap). Returns indices of accepted candidates.

split: open-access


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

N = 1
observations = []
def solve(grid, start, swim):
    h = len(grid)
    w = len(grid[0])
    sr, sc = start
    seen = {(sr, sc)}
    stack = [(sr, sc)]
    found = False
    while stack:
        r, c = stack.pop()
        if grid[r][c] == 'E':
            found = True
        for dr, dc in ((1, 0), (-1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)):
            nr, nc = r + dr, c + dc
            if 0 <= nr < h and 0 <= nc < w and (nr, nc) not in seen:
                t = grid[nr][nc]
                if t == '#' or (t == '~' and not swim):
                    continue
                seen.add((nr, nc))
                stack.append((nr, nc))
    return {'reachable': len(seen), 'exit': found}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('diagonal gap only #1', [['.#', '#E'], [0, 0], False], {'reachable': 1, 'exit': False}),
  ('regression neighbourhood #1',
   [['..E.#.#', '#.~..#.', 'D.#..#.'], [0, 3], True],
   {'reachable': 12, 'exit': True}),
  ('regression neighbourhood #2',
   [['#.#..', '~~...', 'DDDE~', '.D.D.', '.....', '....#'], [4, 1], False],
   {'reachable': 23, 'exit': True}),
  ('partial repair boundary #1', [['E', '.'], [1, 0], False], {'reachable': 2, 'exit': True}),
  ('partial repair boundary #2', [['.E..', '.D..'], [0, 1], True], {'reachable': 8, 'exit': True}),
  ('door corridor #1', [['.DE'], [0, 0], False], {'reachable': 3, 'exit': True}),
  ('walled-in start #1', [['#.#', '#E#'], [0, 1], True], {'reachable': 2, 'exit': True}),
  ('control #1', [['~.#D##E'], [0, 6], False], {'reachable': 1, 'exit': True})],
 [('diagonal gap only #1', [['.#', '#E'], [0, 0], False], {'reachable': 1, 'exit': False}),
  ('regression neighbourhood #1',
   [['#.#..', '~~...', 'DDDE~', '.D.D.', '.....', '....#'], [4, 1], False],
   {'reachable': 23, 'exit': True}),
  ('fault site neighbourhood #1',
   [['.....D', '......', '.D~#.#', '...E#~'], [0, 0], True],
   {'reachable': 20, 'exit': True}),
  ('partial repair boundary #1',
   [['~.D#.', 'D....', '#.D#E'], [1, 4], True],
   {'reachable': 12, 'exit': True}),
  ('partial repair boundary #2',
   [['D.~E.', '#~~.#', 'DD...'], [2, 3], False],
   {'reachable': 8, 'exit': True}),
  ('door corridor #1', [['.DE'], [0, 0], False], {'reachable': 3, 'exit': True}),
  ('walled-in start #1', [['#.#', '#E#'], [0, 1], True], {'reachable': 2, 'exit': True}),
  ('control #1', [['~.#D##E'], [0, 6], False], {'reachable': 1, 'exit': True})],
 [('diagonal gap only #1', [['.#', '#E'], [0, 0], False], {'reachable': 1, 'exit': False}),
  ('fault site neighbourhood #1',
   [['#D~.##', '.D.~E#', '.~...~', '....#.', '#.....'], [0, 3], False],
   {'reachable': 1, 'exit': False}),
  ('fault site neighbourhood #2', [['~#DD~.', '..~E.D'], [1, 0], False], {'reachable': 2, 'exit': False}),
  ('partial repair boundary #1', [['E', '.', '.', '.', '~'], [2, 0], True], {'reachable': 5, 'exit': True}),
  ('partial repair boundary #2', [['E.D.', '...D'], [1, 0], True], {'reachable': 8, 'exit': True}),
  ('door corridor #1', [['.DE'], [0, 0], False], {'reachable': 3, 'exit': True}),
  ('walled-in start #1', [['#.#', '#E#'], [0, 1], True], {'reachable': 2, 'exit': True}),
  ('control #1', [['~.#D##E'], [0, 6], False], {'reachable': 1, 'exit': True})],
 [('diagonal gap only #1', [['.#', '#E'], [0, 0], False], {'reachable': 1, 'exit': False}),
  ('regression neighbourhood #1',
   [['~D', '.E', '~.', '.#', '..', '.D'], [1, 1], False],
   {'reachable': 4, 'exit': True}),
  ('regression neighbourhood #2',
   [['D#.#~', '.#~~.', 'D..E#', '.....', '.D.D.', '..~.D', '.~.D.'], [6, 2], False],
   {'reachable': 24, 'exit': True}),
  ('partial repair boundary #1',
   [['.##.', '.D#D', 'D...', '.D~.', '.#DE', '.~#.', '.~DD'], [3, 0], False],
   {'reachable': 20, 'exit': True}),
  ('partial repair boundary #2',
   [['..', '.E', 'DD', '.#', '..', '.~', '..'], [6, 0], False],
   {'reachable': 12, 'exit': True}),
  ('door corridor #1', [['.DE'], [0, 0], False], {'reachable': 3, 'exit': True}),
  ('walled-in start #1', [['#.#', '#E#'], [0, 1], True], {'reachable': 2, 'exit': True}),
  ('control #1', [['.E', '.D', 'D.'], [0, 0], True], {'reachable': 6, 'exit': True})],
 [('diagonal gap only #1', [['.#', '#E'], [0, 0], False], {'reachable': 1, 'exit': False}),
  ('regression neighbourhood #1',
   [['.#~D', '#~~.', '~.E.', 'D.##', '~...'], [3, 1], True],
   {'reachable': 15, 'exit': True}),
  ('regression neighbourhood #2',
   [['...', 'E~D', '#.#', '~..', '#..', '~..'], [5, 2], False],
   {'reachable': 7, 'exit': False}),
  ('partial repair boundary #1', [['~D.E..~', '.......'], [1, 5], False], {'reachable': 12, 'exit': True}),
  ('partial repair boundary #2',
   [['#D~..', '.#D.~', '.#...', '....D', 'DD#..', '.D.~#', '~~E.D'], [0, 3], True],
   {'reachable': 30, 'exit': True}),
  ('door corridor #1', [['.DE'], [0, 0], False], {'reachable': 3, 'exit': True}),
  ('walled-in start #1', [['#.#', '#E#'], [0, 1], True], {'reachable': 2, 'exit': True}),
  ('control #1', [['DD~.', '.#.#', '~.E.', '#.~~', 'D.~.'], [4, 3], False], {'reachable': 1, 'exit': False})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(grid, start, swim):
    h = len(grid)
    w = len(grid[0])
    sr, sc = start
    seen = {(sr, sc)}
    stack = [(sr, sc)]
    found = False
    while stack:
        r, c = stack.pop()
        if grid[r][c] == 'E':
            found = True
        for dr, dc in ((1, 0), (0, 1)):
            nr, nc = r + dr, c + dc
            if 0 <= nr < h and 0 <= nc < w and (nr, nc) not in seen:
                t = grid[nr][nc]
                if t == '#' or (t == '~' and not swim):
                    continue
                seen.add((nr, nc))
                stack.append((nr, nc))
    return {'reachable': len(seen), 'exit': found}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('diagonal gap only #1', [['.#', '#E'], [0, 0], False], {'reachable': 1, 'exit': False}),
  ('regression neighbourhood #1',
   [['..E.#.#', '#.~..#.', 'D.#..#.'], [0, 3], True],
   {'reachable': 12, 'exit': True}),
  ('regression neighbourhood #2',
   [['#.#..', '~~...', 'DDDE~', '.D.D.', '.....', '....#'], [4, 1], False],
   {'reachable': 23, 'exit': True}),
  ('partial repair boundary #1', [['E', '.'], [1, 0], False], {'reachable': 2, 'exit': True}),
  ('partial repair boundary #2', [['.E..', '.D..'], [0, 1], True], {'reachable': 8, 'exit': True}),
  ('door corridor #1', [['.DE'], [0, 0], False], {'reachable': 3, 'exit': True}),
  ('walled-in start #1', [['#.#', '#E#'], [0, 1], True], {'reachable': 2, 'exit': True}),
  ('control #1', [['~.#D##E'], [0, 6], False], {'reachable': 1, 'exit': True})],
 [('diagonal gap only #1', [['.#', '#E'], [0, 0], False], {'reachable': 1, 'exit': False}),
  ('regression neighbourhood #1',
   [['#.#..', '~~...', 'DDDE~', '.D.D.', '.....', '....#'], [4, 1], False],
   {'reachable': 23, 'exit': True}),
  ('fault site neighbourhood #1',
   [['.....D', '......', '.D~#.#', '...E#~'], [0, 0], True],
   {'reachable': 20, 'exit': True}),
  ('partial repair boundary #1',
   [['~.D#.', 'D....', '#.D#E'], [1, 4], True],
   {'reachable': 12, 'exit': True}),
  ('partial repair boundary #2',
   [['D.~E.', '#~~.#', 'DD...'], [2, 3], False],
   {'reachable': 8, 'exit': True}),
  ('door corridor #1', [['.DE'], [0, 0], False], {'reachable': 3, 'exit': True}),
  ('walled-in start #1', [['#.#', '#E#'], [0, 1], True], {'reachable': 2, 'exit': True}),
  ('control #1', [['~.#D##E'], [0, 6], False], {'reachable': 1, 'exit': True})],
 [('diagonal gap only #1', [['.#', '#E'], [0, 0], False], {'reachable': 1, 'exit': False}),
  ('fault site neighbourhood #1',
   [['#D~.##', '.D.~E#', '.~...~', '....#.', '#.....'], [0, 3], False],
   {'reachable': 1, 'exit': False}),
  ('fault site neighbourhood #2', [['~#DD~.', '..~E.D'], [1, 0], False], {'reachable': 2, 'exit': False}),
  ('partial repair boundary #1', [['E', '.', '.', '.', '~'], [2, 0], True], {'reachable': 5, 'exit': True}),
  ('partial repair boundary #2', [['E.D.', '...D'], [1, 0], True], {'reachable': 8, 'exit': True}),
  ('door corridor #1', [['.DE'], [0, 0], False], {'reachable': 3, 'exit': True}),
  ('walled-in start #1', [['#.#', '#E#'], [0, 1], True], {'reachable': 2, 'exit': True}),
  ('control #1', [['~.#D##E'], [0, 6], False], {'reachable': 1, 'exit': True})],
 [('diagonal gap only #1', [['.#', '#E'], [0, 0], False], {'reachable': 1, 'exit': False}),
  ('regression neighbourhood #1',
   [['~D', '.E', '~.', '.#', '..', '.D'], [1, 1], False],
   {'reachable': 4, 'exit': True}),
  ('regression neighbourhood #2',
   [['D#.#~', '.#~~.', 'D..E#', '.....', '.D.D.', '..~.D', '.~.D.'], [6, 2], False],
   {'reachable': 24, 'exit': True}),
  ('partial repair boundary #1',
   [['.##.', '.D#D', 'D...', '.D~.', '.#DE', '.~#.', '.~DD'], [3, 0], False],
   {'reachable': 20, 'exit': True}),
  ('partial repair boundary #2',
   [['..', '.E', 'DD', '.#', '..', '.~', '..'], [6, 0], False],
   {'reachable': 12, 'exit': True}),
  ('door corridor #1', [['.DE'], [0, 0], False], {'reachable': 3, 'exit': True}),
  ('walled-in start #1', [['#.#', '#E#'], [0, 1], True], {'reachable': 2, 'exit': True}),
  ('control #1', [['.E', '.D', 'D.'], [0, 0], True], {'reachable': 6, 'exit': True})],
 [('diagonal gap only #1', [['.#', '#E'], [0, 0], False], {'reachable': 1, 'exit': False}),
  ('regression neighbourhood #1',
   [['.#~D', '#~~.', '~.E.', 'D.##', '~...'], [3, 1], True],
   {'reachable': 15, 'exit': True}),
  ('regression neighbourhood #2',
   [['...', 'E~D', '#.#', '~..', '#..', '~..'], [5, 2], False],
   {'reachable': 7, 'exit': False}),
  ('partial repair boundary #1', [['~D.E..~', '.......'], [1, 5], False], {'reachable': 12, 'exit': True}),
  ('partial repair boundary #2',
   [['#D~..', '.#D.~', '.#...', '....D', 'DD#..', '.D.~#', '~~E.D'], [0, 3], True],
   {'reachable': 30, 'exit': True}),
  ('door corridor #1', [['.DE'], [0, 0], False], {'reachable': 3, 'exit': True}),
  ('walled-in start #1', [['#.#', '#E#'], [0, 1], True], {'reachable': 2, 'exit': True}),
  ('control #1', [['DD~.', '.#.#', '~.E.', '#.~~', 'D.~.'], [4, 3], False], {'reachable': 1, 'exit': False})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Levels are validated as solvable although the exit is only diagonally adjacent.

grid rows of '#' wall, '.' floor, 'D' door (passable), '~' water (passable only when swim) and 'E' exit. From start [row, col], 4-neighbour flood fill. Returns {reachable: number of reached cells including start, exit: whether an E cell was reached}.

split: open-access


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

N = 1
observations = []
def solve(grid, start, swim):
    h = len(grid)
    w = len(grid[0])
    sr, sc = start
    seen = {(sr, sc)}
    stack = [(sr, sc)]
    found = False
    while stack:
        r, c = stack.pop()
        if grid[r][c] == 'E':
            found = True
        for dr, dc in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            nr, nc = r + dr, c + dc
            if 0 <= nr < h and 0 <= nc < w and (nr, nc) not in seen:
                t = grid[nr][nc]
                if t == '#' or t == '~':
                    continue
                seen.add((nr, nc))
                stack.append((nr, nc))
    return {'reachable': len(seen), 'exit': found}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression water passability #1',
   [['~.D#.', 'D....', '#.D#E'], [1, 4], True],
   {'reachable': 12, 'exit': True}),
  ('regression water passability #2',
   [['E', '.', '.', '.', '~'], [2, 0], True],
   {'reachable': 5, 'exit': True}),
  ('partial repair boundary #1',
   [['D.~E.', '#~~.#', 'DD...'], [2, 3], False],
   {'reachable': 8, 'exit': True}),
  ('partial repair boundary #2',
   [['.##.', '.D#D', 'D...', '.D~.', '.#DE', '.~#.', '.~DD'], [3, 0], False],
   {'reachable': 20, 'exit': True}),
  ('diagonal gap only #1', [['.#', '#E'], [0, 0], False], {'reachable': 1, 'exit': False}),
  ('door corridor #1', [['.DE'], [0, 0], False], {'reachable': 3, 'exit': True}),
  ('walled-in start #1', [['#.#', '#E#'], [0, 1], True], {'reachable': 2, 'exit': True}),
  ('control #1', [['E', '.'], [1, 0], False], {'reachable': 2, 'exit': True})],
 [('regression water passability #1',
   [['#D~..', '.#D.~', '.#...', '....D', 'DD#..', '.D.~#', '~~E.D'], [0, 3], True],
   {'reachable': 30, 'exit': True}),
  ('regression water passability #2',
   [['.', '.', '~', 'E', '.', '~'], [4, 0], True],
   {'reachable': 6, 'exit': True}),
  ('regression water passability #3',
   [['E', '.', '.', '.', '~'], [2, 0], True],
   {'reachable': 5, 'exit': True}),
  ('partial repair boundary #1',
   [['.##.', '.D#D', 'D...', '.D~.', '.#DE', '.~#.', '.~DD'], [3, 0], False],
   {'reachable': 20, 'exit': True}),
  ('walled-in start #1', [['#.#', '#E#'], [0, 1], True], {'reachable': 2, 'exit': True}),
  ('diagonal gap only #1', [['.#', '#E'], [0, 0], False], {'reachable': 1, 'exit': False}),
  ('control #1', [['E', '.'], [1, 0], False], {'reachable': 2, 'exit': True}),
  ('control #2', [['.E..', '.D..'], [0, 1], True], {'reachable': 8, 'exit': True})],
 [('regression water passability #1', [['#E', '~.'], [0, 1], True], {'reachable': 3, 'exit': True}),
  ('regression water passability #2',
   [['##.E#.D', '.#...#D', '.D.D~~.', '...DDD.', '~.#..#.', '..#....'], [2, 2], True],
   {'reachable': 34, 'exit': True}),
  ('partial repair boundary #1',
   [['..', '.E', 'DD', '.#', '..', '.~', '..'], [6, 0], False],
   {'reachable': 12, 'exit': True}),
  ('partial repair boundary #2', [['~D.E..~', '.......'], [1, 5], False], {'reachable': 12, 'exit': True}),
  ('door corridor #1', [['.DE'], [0, 0], False], {'reachable': 3, 'exit': True}),
  ('walled-in start #1', [['#.#', '#E#'], [0, 1], True], {'reachable': 2, 'exit': True}),
  ('control #1', [['.E..', '.D..'], [0, 1], True], {'reachable': 8, 'exit': True}),
  ('control #2', [['E.D.', '...D'], [1, 0], True], {'reachable': 8, 'exit': True})],
 [('regression water passability #1',
   [['..E.#.#', '#.~..#.', 'D.#..#.'], [0, 3], True],
   {'reachable': 12, 'exit': True}),
  ('regression water passability #2',
   [['..#...', '~.D#D.', 'DD#E~~', '.D..##'], [0, 3], True],
   {'reachable': 19, 'exit': True}),
  ('regression water passability #3',
   [['#D~..', '.#D.~', '.#...', '....D', 'DD#..', '.D.~#', '~~E.D'], [0, 3], True],
   {'reachable': 30, 'exit': True}),
  ('regression water passability #4',
   [['.', '.', '~', 'E', '.', '~'], [4, 0], True],
   {'reachable': 6, 'exit': True}),
  ('diagonal gap only #1', [['.#', '#E'], [0, 0], False], {'reachable': 1, 'exit': False}),
  ('door corridor #1', [['.DE'], [0, 0], False], {'reachable': 3, 'exit': True}),
  ('control #1', [['~.#D##E'], [0, 6], False], {'reachable': 1, 'exit': True}),
  ('control #2', [['E.D..'], [0, 3], False], {'reachable': 5, 'exit': True})],
 [('regression water passability #1',
   [['D#', '.~', '#~', '.D', '~E'], [1, 0], True],
   {'reachable': 8, 'exit': True}),
  ('regression water passability #2',
   [['.', '.', '~', '~', '#', 'E'], [1, 0], True],
   {'reachable': 4, 'exit': False}),
  ('partial repair boundary #1',
   [['DD~.', '.#.#', '~.E.', '#.~~', 'D.~.'], [4, 3], False],
   {'reachable': 1, 'exit': False}),
  ('partial repair boundary #2', [['.', 'E', 'D', '~', '~'], [1, 0], False], {'reachable': 3, 'exit': True}),
  ('walled-in start #1', [['#.#', '#E#'], [0, 1], True], {'reachable': 2, 'exit': True}),
  ('diagonal gap only #1', [['.#', '#E'], [0, 0], False], {'reachable': 1, 'exit': False}),
  ('control #1', [['.E', '.D', 'D.'], [0, 0], True], {'reachable': 6, 'exit': True}),
  ('control #2', [['E..'], [0, 1], False], {'reachable': 3, 'exit': True})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(grid, start, swim):
    h = len(grid)
    w = len(grid[0])
    sr, sc = start
    seen = {(sr, sc)}
    stack = [(sr, sc)]
    found = False
    while stack:
        r, c = stack.pop()
        if grid[r][c] == 'E':
            found = True
        for dr, dc in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            nr, nc = r + dr, c + dc
            if 0 <= nr < h and 0 <= nc < w and (nr, nc) not in seen:
                t = grid[nr][nc]
                if t == '#' or (t == '~' and swim):
                    continue
                seen.add((nr, nc))
                stack.append((nr, nc))
    return {'reachable': len(seen), 'exit': found}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression water passability #1',
   [['~.D#.', 'D....', '#.D#E'], [1, 4], True],
   {'reachable': 12, 'exit': True}),
  ('regression water passability #2',
   [['E', '.', '.', '.', '~'], [2, 0], True],
   {'reachable': 5, 'exit': True}),
  ('partial repair boundary #1',
   [['D.~E.', '#~~.#', 'DD...'], [2, 3], False],
   {'reachable': 8, 'exit': True}),
  ('partial repair boundary #2',
   [['.##.', '.D#D', 'D...', '.D~.', '.#DE', '.~#.', '.~DD'], [3, 0], False],
   {'reachable': 20, 'exit': True}),
  ('diagonal gap only #1', [['.#', '#E'], [0, 0], False], {'reachable': 1, 'exit': False}),
  ('door corridor #1', [['.DE'], [0, 0], False], {'reachable': 3, 'exit': True}),
  ('walled-in start #1', [['#.#', '#E#'], [0, 1], True], {'reachable': 2, 'exit': True}),
  ('control #1', [['E', '.'], [1, 0], False], {'reachable': 2, 'exit': True})],
 [('regression water passability #1',
   [['#D~..', '.#D.~', '.#...', '....D', 'DD#..', '.D.~#', '~~E.D'], [0, 3], True],
   {'reachable': 30, 'exit': True}),
  ('regression water passability #2',
   [['.', '.', '~', 'E', '.', '~'], [4, 0], True],
   {'reachable': 6, 'exit': True}),
  ('regression water passability #3',
   [['E', '.', '.', '.', '~'], [2, 0], True],
   {'reachable': 5, 'exit': True}),
  ('partial repair boundary #1',
   [['.##.', '.D#D', 'D...', '.D~.', '.#DE', '.~#.', '.~DD'], [3, 0], False],
   {'reachable': 20, 'exit': True}),
  ('walled-in start #1', [['#.#', '#E#'], [0, 1], True], {'reachable': 2, 'exit': True}),
  ('diagonal gap only #1', [['.#', '#E'], [0, 0], False], {'reachable': 1, 'exit': False}),
  ('control #1', [['E', '.'], [1, 0], False], {'reachable': 2, 'exit': True}),
  ('control #2', [['.E..', '.D..'], [0, 1], True], {'reachable': 8, 'exit': True})],
 [('regression water passability #1', [['#E', '~.'], [0, 1], True], {'reachable': 3, 'exit': True}),
  ('regression water passability #2',
   [['##.E#.D', '.#...#D', '.D.D~~.', '...DDD.', '~.#..#.', '..#....'], [2, 2], True],
   {'reachable': 34, 'exit': True}),
  ('partial repair boundary #1',
   [['..', '.E', 'DD', '.#', '..', '.~', '..'], [6, 0], False],
   {'reachable': 12, 'exit': True}),
  ('partial repair boundary #2', [['~D.E..~', '.......'], [1, 5], False], {'reachable': 12, 'exit': True}),
  ('door corridor #1', [['.DE'], [0, 0], False], {'reachable': 3, 'exit': True}),
  ('walled-in start #1', [['#.#', '#E#'], [0, 1], True], {'reachable': 2, 'exit': True}),
  ('control #1', [['.E..', '.D..'], [0, 1], True], {'reachable': 8, 'exit': True}),
  ('control #2', [['E.D.', '...D'], [1, 0], True], {'reachable': 8, 'exit': True})],
 [('regression water passability #1',
   [['..E.#.#', '#.~..#.', 'D.#..#.'], [0, 3], True],
   {'reachable': 12, 'exit': True}),
  ('regression water passability #2',
   [['..#...', '~.D#D.', 'DD#E~~', '.D..##'], [0, 3], True],
   {'reachable': 19, 'exit': True}),
  ('regression water passability #3',
   [['#D~..', '.#D.~', '.#...', '....D', 'DD#..', '.D.~#', '~~E.D'], [0, 3], True],
   {'reachable': 30, 'exit': True}),
  ('regression water passability #4',
   [['.', '.', '~', 'E', '.', '~'], [4, 0], True],
   {'reachable': 6, 'exit': True}),
  ('diagonal gap only #1', [['.#', '#E'], [0, 0], False], {'reachable': 1, 'exit': False}),
  ('door corridor #1', [['.DE'], [0, 0], False], {'reachable': 3, 'exit': True}),
  ('control #1', [['~.#D##E'], [0, 6], False], {'reachable': 1, 'exit': True}),
  ('control #2', [['E.D..'], [0, 3], False], {'reachable': 5, 'exit': True})],
 [('regression water passability #1',
   [['D#', '.~', '#~', '.D', '~E'], [1, 0], True],
   {'reachable': 8, 'exit': True}),
  ('regression water passability #2',
   [['.', '.', '~', '~', '#', 'E'], [1, 0], True],
   {'reachable': 4, 'exit': False}),
  ('partial repair boundary #1',
   [['DD~.', '.#.#', '~.E.', '#.~~', 'D.~.'], [4, 3], False],
   {'reachable': 1, 'exit': False}),
  ('partial repair boundary #2', [['.', 'E', 'D', '~', '~'], [1, 0], False], {'reachable': 3, 'exit': True}),
  ('walled-in start #1', [['#.#', '#E#'], [0, 1], True], {'reachable': 2, 'exit': True}),
  ('diagonal gap only #1', [['.#', '#E'], [0, 0], False], {'reachable': 1, 'exit': False}),
  ('control #1', [['.E', '.D', 'D.'], [0, 0], True], {'reachable': 6, 'exit': True}),
  ('control #2', [['E..'], [0, 1], False], {'reachable': 3, 'exit': True})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Levels requiring swimming are rejected even when the player can swim.

grid rows of '#' wall, '.' floor, 'D' door (passable), '~' water (passable only when swim) and 'E' exit. From start [row, col], 4-neighbour flood fill. Returns {reachable: number of reached cells including start, exit: whether an E cell was reached}.

split: open-access