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

N = 1
observations = []
def solve(vehicles, ports, slots, quantum):
    queue = [[vid, need] for vid, need in vehicles if need > 0]
    done = {vid: (0 if need <= 0 else None) for vid, need in vehicles}
    active = []
    timeline = []
    for t in range(slots):
        while len(active) < ports and queue:
            v = queue.pop(0)
            active.append([v[0], v[1], quantum])
        timeline.append(sorted(a[0] for a in active))
        nxt = []
        for a in active:
            a[1] -= 1
            a[2] -= 1
            if a[1] == 0:
                done[a[0]] = t
            elif a[2] == 0:
                queue.append([a[0], a[1]])
            else:
                nxt.append(a)
        active = nxt
    return [timeline, [[k, done[k]] for k in sorted(done)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index', [[['V0', 2], ['V1', 0], ['V2', 3]], 3, 8, 1],
   [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]],
  ['regression: finish slot index (partial repair)', [[['V0', 3], ['V1', 1], ['V2', 3]], 3, 10, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []],
    [['V0', 3], ['V1', 1], ['V2', 3]]]],
  ['control 1', [[['V0', 1], ['V1', 4], ['V2', 6], ['V3', 2], ['V4', 5], ['V5', 5]], 1, 10, 2],
   [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]],
  ['control 2', [[['V0', 5], ['V1', 3], ['V2', 2]], 1, 6, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index',
   [[['V0', 1], ['V1', 3], ['V2', 2], ['V3', 6], ['V4', 0], ['V5', 0]], 2, 5, 3],
   [[['V0', 'V1'], ['V1', 'V2'], ['V1', 'V2'], ['V3'], ['V3']],
    [['V0', 1], ['V1', 3], ['V2', 3], ['V3', None], ['V4', 0], ['V5', 0]]]],
  ['regression: finish slot index (partial repair)',
   [[['V0', 5], ['V1', 2], ['V2', 5], ['V3', 1], ['V4', 2], ['V5', 5]], 1, 12, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V4'], ['V4'],
     ['V5']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', 9], ['V4', 11], ['V5', None]]]],
  ['control 1', [[['V0', 1], ['V1', 6], ['V2', 6], ['V3', 1], ['V4', 1]], 1, 7, 3],
   [[['V0'], ['V1'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 2], ['V1', 2], ['V2', 3], ['V3', 0], ['V4', 4], ['V5', 3]], 1, 3, 3],
   [[['V0'], ['V0'], ['V1']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', 0], ['V4', None], ['V5', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index',
   [[['V0', 4], ['V1', 2], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 6]], 1, 10, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V3']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['regression: finish slot index (partial repair)', [[['V0', 2], ['V1', 0]], 2, 9, 3],
   [[['V0'], ['V0'], [], [], [], [], [], [], []], [['V0', 2], ['V1', 0]]]],
  ['control 1', [[['V0', 0], ['V1', 6], ['V2', 4]], 2, 7, 3],
   [[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1'], ['V1'], []],
    [['V0', 0], ['V1', 6], ['V2', 4]]]],
  ['control 2', [[['V0', 3], ['V1', 0]], 1, 3, 1],
   [[['V0'], ['V0'], ['V0']], [['V0', 3], ['V1', 0]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index', [[['V0', 3]], 3, 8, 2],
   [[['V0'], ['V0'], ['V0'], [], [], [], [], []], [['V0', 3]]]],
  ['regression: finish slot index (partial repair)',
   [[['V0', 4], ['V1', 6], ['V2', 2], ['V3', 2], ['V4', 5]], 3, 5, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V3'], ['V0', 'V3', 'V4'], ['V1', 'V4']],
    [['V0', 4], ['V1', None], ['V2', 2], ['V3', 4], ['V4', None]]]],
  ['control 1', [[['V0', 2], ['V1', 3], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 3]], 3, 3, 2],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', None], ['V4', 3], ['V5', None]]]],
  ['control 2', [[['V0', 2], ['V1', 6], ['V2', 6]], 1, 10, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V1'], ['V1'], ['V2'], ['V2']],
    [['V0', 2], ['V1', None], ['V2', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index',
   [[['V0', 5], ['V1', 5], ['V2', 6], ['V3', 0], ['V4', 6]], 3, 8, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V4'],
     ['V0', 'V1', 'V4'], ['V2', 'V4'], ['V2', 'V4'], ['V2', 'V4']],
    [['V0', 5], ['V1', 5], ['V2', 8], ['V3', 0], ['V4', None]]]],
  ['regression: finish slot index (partial repair)',
   [[['V0', 3], ['V1', 1], ['V2', 1], ['V3', 1], ['V4', 5], ['V5', 2]], 1, 3, 2],
   [[['V0'], ['V0'], ['V1']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['control 1', [[['V0', 4], ['V1', 3], ['V2', 4], ['V3', 5], ['V4', 6]], 3, 3, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 4], ['V1', 0], ['V2', 0], ['V3', 4], ['V4', 2]], 1, 12, 1],
   [[['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V0'], ['V3'], [], []],
    [['V0', 9], ['V1', 0], ['V2', 0], ['V3', 10], ['V4', 6]]]]]]
for label, args, expected in fixtures[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(vehicles, ports, slots, quantum):
    queue = [[vid, need] for vid, need in vehicles if need > 0]
    done = {vid: (0 if need <= 0 else None) for vid, need in vehicles}
    active = []
    timeline = []
    for t in range(slots):
        while len(active) < ports and queue:
            v = queue.pop(0)
            active.append([v[0], v[1], quantum])
        timeline.append(sorted(a[0] for a in active))
        nxt = []
        for a in active:
            a[1] -= 1
            a[2] -= 1
            if a[1] == 0:
                done[a[0]] = t + quantum
            elif a[2] == 0:
                queue.append([a[0], a[1]])
            else:
                nxt.append(a)
        active = nxt
    return [timeline, [[k, done[k]] for k in sorted(done)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index', [[['V0', 2], ['V1', 0], ['V2', 3]], 3, 8, 1],
   [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]],
  ['regression: finish slot index (partial repair)', [[['V0', 3], ['V1', 1], ['V2', 3]], 3, 10, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []],
    [['V0', 3], ['V1', 1], ['V2', 3]]]],
  ['control 1', [[['V0', 1], ['V1', 4], ['V2', 6], ['V3', 2], ['V4', 5], ['V5', 5]], 1, 10, 2],
   [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]],
  ['control 2', [[['V0', 5], ['V1', 3], ['V2', 2]], 1, 6, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index',
   [[['V0', 1], ['V1', 3], ['V2', 2], ['V3', 6], ['V4', 0], ['V5', 0]], 2, 5, 3],
   [[['V0', 'V1'], ['V1', 'V2'], ['V1', 'V2'], ['V3'], ['V3']],
    [['V0', 1], ['V1', 3], ['V2', 3], ['V3', None], ['V4', 0], ['V5', 0]]]],
  ['regression: finish slot index (partial repair)',
   [[['V0', 5], ['V1', 2], ['V2', 5], ['V3', 1], ['V4', 2], ['V5', 5]], 1, 12, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V4'], ['V4'],
     ['V5']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', 9], ['V4', 11], ['V5', None]]]],
  ['control 1', [[['V0', 1], ['V1', 6], ['V2', 6], ['V3', 1], ['V4', 1]], 1, 7, 3],
   [[['V0'], ['V1'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 2], ['V1', 2], ['V2', 3], ['V3', 0], ['V4', 4], ['V5', 3]], 1, 3, 3],
   [[['V0'], ['V0'], ['V1']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', 0], ['V4', None], ['V5', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index',
   [[['V0', 4], ['V1', 2], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 6]], 1, 10, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V3']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['regression: finish slot index (partial repair)', [[['V0', 2], ['V1', 0]], 2, 9, 3],
   [[['V0'], ['V0'], [], [], [], [], [], [], []], [['V0', 2], ['V1', 0]]]],
  ['control 1', [[['V0', 0], ['V1', 6], ['V2', 4]], 2, 7, 3],
   [[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1'], ['V1'], []],
    [['V0', 0], ['V1', 6], ['V2', 4]]]],
  ['control 2', [[['V0', 3], ['V1', 0]], 1, 3, 1],
   [[['V0'], ['V0'], ['V0']], [['V0', 3], ['V1', 0]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index', [[['V0', 3]], 3, 8, 2],
   [[['V0'], ['V0'], ['V0'], [], [], [], [], []], [['V0', 3]]]],
  ['regression: finish slot index (partial repair)',
   [[['V0', 4], ['V1', 6], ['V2', 2], ['V3', 2], ['V4', 5]], 3, 5, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V3'], ['V0', 'V3', 'V4'], ['V1', 'V4']],
    [['V0', 4], ['V1', None], ['V2', 2], ['V3', 4], ['V4', None]]]],
  ['control 1', [[['V0', 2], ['V1', 3], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 3]], 3, 3, 2],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', None], ['V4', 3], ['V5', None]]]],
  ['control 2', [[['V0', 2], ['V1', 6], ['V2', 6]], 1, 10, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V1'], ['V1'], ['V2'], ['V2']],
    [['V0', 2], ['V1', None], ['V2', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index',
   [[['V0', 5], ['V1', 5], ['V2', 6], ['V3', 0], ['V4', 6]], 3, 8, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V4'],
     ['V0', 'V1', 'V4'], ['V2', 'V4'], ['V2', 'V4'], ['V2', 'V4']],
    [['V0', 5], ['V1', 5], ['V2', 8], ['V3', 0], ['V4', None]]]],
  ['regression: finish slot index (partial repair)',
   [[['V0', 3], ['V1', 1], ['V2', 1], ['V3', 1], ['V4', 5], ['V5', 2]], 1, 3, 2],
   [[['V0'], ['V0'], ['V1']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['control 1', [[['V0', 4], ['V1', 3], ['V2', 4], ['V3', 5], ['V4', 6]], 3, 3, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 4], ['V1', 0], ['V2', 0], ['V3', 4], ['V4', 2]], 1, 12, 1],
   [[['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V0'], ['V3'], [], []],
    [['V0', 9], ['V1', 0], ['V2', 0], ['V3', 10], ['V4', 6]]]]]]
for label, args, expected in fixtures[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:
Reported finish times are one slot earlier than the last charging slot ends.

vehicles is [[id, need_slots]] in arrival order. Each slot, free ports are filled from the FIFO queue; a vehicle holds its port for quantum slots or until done, then goes to the back of the queue. Return [timeline of sorted charging ids per slot, [[id, finish]] sorted by id] where finish is the slot index after its last charging slot, 0 when nothing was needed, None if unfinished.

split: open-access


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

N = 1
observations = []
def solve(vehicles, ports, slots, quantum):
    queue = [[vid, need] for vid, need in vehicles if need > 0]
    done = {vid: (0 if need <= 0 else None) for vid, need in vehicles}
    active = []
    timeline = []
    for t in range(slots):
        while len(active) < ports and queue:
            v = queue.pop(0)
            active.append([v[0], v[1], quantum])
        timeline.append(sorted(a[0] for a in active))
        nxt = []
        for a in active:
            a[1] -= 1
            a[2] -= 1
            if a[1] == 0:
                done[a[0]] = t + 1
            elif a[2] == 0:
                queue.insert(0, [a[0], a[1]])
            else:
                nxt.append(a)
        active = nxt
    return [timeline, [[k, done[k]] for k in sorted(done)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: preempted vehicle queue position',
   [[['V0', 4], ['V1', 4], ['V2', 0], ['V3', 5], ['V4', 6], ['V5', 0]], 1, 9, 1],
   [[['V0'], ['V1'], ['V3'], ['V4'], ['V0'], ['V1'], ['V3'], ['V4'], ['V0']],
    [['V0', None], ['V1', None], ['V2', 0], ['V3', None], ['V4', None], ['V5', 0]]]],
  ['regression: preempted vehicle queue position (partial repair)',
   [[['V0', 3], ['V1', 5], ['V2', 3], ['V3', 4], ['V4', 4], ['V5', 4]], 1, 3, 1],
   [[['V0'], ['V1'], ['V2']],
    [['V0', None], ['V1', None], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['control 1', [[['V0', 1], ['V1', 4], ['V2', 6], ['V3', 2], ['V4', 5], ['V5', 5]], 1, 10, 2],
   [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]],
  ['control 2', [[['V0', 5], ['V1', 3], ['V2', 2]], 1, 6, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: preempted vehicle queue position',
   [[['V0', 5], ['V1', 2], ['V2', 5], ['V3', 1], ['V4', 2], ['V5', 5]], 1, 12, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V4'], ['V4'],
     ['V5']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', 9], ['V4', 11], ['V5', None]]]],
  ['regression: preempted vehicle queue position (partial repair)',
   [[['V0', 5], ['V1', 4], ['V2', 4], ['V3', 1], ['V4', 5], ['V5', 1]], 3, 12, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5'],
     ['V0', 'V1', 'V4'], ['V0', 'V2', 'V4'], ['V4'], ['V4'], [], [], [], []],
    [['V0', 6], ['V1', 5], ['V2', 6], ['V3', 4], ['V4', 8], ['V5', 4]]]],
  ['control 1', [[['V0', 1], ['V1', 6], ['V2', 6], ['V3', 1], ['V4', 1]], 1, 7, 3],
   [[['V0'], ['V1'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 2], ['V1', 2], ['V2', 3], ['V3', 0], ['V4', 4], ['V5', 3]], 1, 3, 3],
   [[['V0'], ['V0'], ['V1']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', 0], ['V4', None], ['V5', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: preempted vehicle queue position',
   [[['V0', 4], ['V1', 2], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 6]], 1, 10, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V3']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['regression: preempted vehicle queue position (partial repair)',
   [[['V0', 4], ['V1', 0], ['V2', 3], ['V3', 1], ['V4', 0], ['V5', 4]], 2, 8, 2],
   [[['V0', 'V2'], ['V0', 'V2'], ['V3', 'V5'], ['V0', 'V5'], ['V0', 'V2'], ['V5'], ['V5'], []],
    [['V0', 5], ['V1', 0], ['V2', 5], ['V3', 3], ['V4', 0], ['V5', 7]]]],
  ['control 1', [[['V0', 0], ['V1', 6], ['V2', 4]], 2, 7, 3],
   [[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1'], ['V1'], []],
    [['V0', 0], ['V1', 6], ['V2', 4]]]],
  ['control 2', [[['V0', 3], ['V1', 0]], 1, 3, 1],
   [[['V0'], ['V0'], ['V0']], [['V0', 3], ['V1', 0]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: preempted vehicle queue position', [[['V0', 6], ['V1', 6]], 1, 3, 2],
   [[['V0'], ['V0'], ['V1']], [['V0', None], ['V1', None]]]],
  ['regression: preempted vehicle queue position (partial repair)',
   [[['V0', 4], ['V1', 6], ['V2', 2], ['V3', 2], ['V4', 5]], 3, 5, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V3'], ['V0', 'V3', 'V4'], ['V1', 'V4']],
    [['V0', 4], ['V1', None], ['V2', 2], ['V3', 4], ['V4', None]]]],
  ['control 1', [[['V0', 2], ['V1', 3], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 3]], 3, 3, 2],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', None], ['V4', 3], ['V5', None]]]],
  ['control 2', [[['V0', 2], ['V1', 6], ['V2', 6]], 1, 10, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V1'], ['V1'], ['V2'], ['V2']],
    [['V0', 2], ['V1', None], ['V2', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: preempted vehicle queue position',
   [[['V0', 5], ['V1', 5], ['V2', 6], ['V3', 0], ['V4', 6]], 3, 8, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V4'],
     ['V0', 'V1', 'V4'], ['V2', 'V4'], ['V2', 'V4'], ['V2', 'V4']],
    [['V0', 5], ['V1', 5], ['V2', 8], ['V3', 0], ['V4', None]]]],
  ['regression: preempted vehicle queue position (partial repair)',
   [[['V0', 5], ['V1', 3], ['V2', 2], ['V3', 1], ['V4', 3]], 3, 3, 2],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V3', 'V4']],
    [['V0', None], ['V1', None], ['V2', 2], ['V3', 3], ['V4', None]]]],
  ['control 1', [[['V0', 4], ['V1', 3], ['V2', 4], ['V3', 5], ['V4', 6]], 3, 3, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 4], ['V1', 0], ['V2', 0], ['V3', 4], ['V4', 2]], 1, 12, 1],
   [[['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V0'], ['V3'], [], []],
    [['V0', 9], ['V1', 0], ['V2', 0], ['V3', 10], ['V4', 6]]]]]]
for label, args, expected in fixtures[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(vehicles, ports, slots, quantum):
    queue = [[vid, need] for vid, need in vehicles if need > 0]
    done = {vid: (0 if need <= 0 else None) for vid, need in vehicles}
    active = []
    timeline = []
    for t in range(slots):
        while len(active) < ports and queue:
            v = queue.pop(0)
            active.append([v[0], v[1], quantum])
        timeline.append(sorted(a[0] for a in active))
        nxt = []
        for a in active:
            a[1] -= 1
            a[2] -= 1
            if a[1] == 0:
                done[a[0]] = t + 1
            elif a[2] == 0:
                queue.insert(1, [a[0], a[1]])
            else:
                nxt.append(a)
        active = nxt
    return [timeline, [[k, done[k]] for k in sorted(done)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: preempted vehicle queue position',
   [[['V0', 4], ['V1', 4], ['V2', 0], ['V3', 5], ['V4', 6], ['V5', 0]], 1, 9, 1],
   [[['V0'], ['V1'], ['V3'], ['V4'], ['V0'], ['V1'], ['V3'], ['V4'], ['V0']],
    [['V0', None], ['V1', None], ['V2', 0], ['V3', None], ['V4', None], ['V5', 0]]]],
  ['regression: preempted vehicle queue position (partial repair)',
   [[['V0', 3], ['V1', 5], ['V2', 3], ['V3', 4], ['V4', 4], ['V5', 4]], 1, 3, 1],
   [[['V0'], ['V1'], ['V2']],
    [['V0', None], ['V1', None], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['control 1', [[['V0', 1], ['V1', 4], ['V2', 6], ['V3', 2], ['V4', 5], ['V5', 5]], 1, 10, 2],
   [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]],
  ['control 2', [[['V0', 5], ['V1', 3], ['V2', 2]], 1, 6, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: preempted vehicle queue position',
   [[['V0', 5], ['V1', 2], ['V2', 5], ['V3', 1], ['V4', 2], ['V5', 5]], 1, 12, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V4'], ['V4'],
     ['V5']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', 9], ['V4', 11], ['V5', None]]]],
  ['regression: preempted vehicle queue position (partial repair)',
   [[['V0', 5], ['V1', 4], ['V2', 4], ['V3', 1], ['V4', 5], ['V5', 1]], 3, 12, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5'],
     ['V0', 'V1', 'V4'], ['V0', 'V2', 'V4'], ['V4'], ['V4'], [], [], [], []],
    [['V0', 6], ['V1', 5], ['V2', 6], ['V3', 4], ['V4', 8], ['V5', 4]]]],
  ['control 1', [[['V0', 1], ['V1', 6], ['V2', 6], ['V3', 1], ['V4', 1]], 1, 7, 3],
   [[['V0'], ['V1'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 2], ['V1', 2], ['V2', 3], ['V3', 0], ['V4', 4], ['V5', 3]], 1, 3, 3],
   [[['V0'], ['V0'], ['V1']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', 0], ['V4', None], ['V5', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: preempted vehicle queue position',
   [[['V0', 4], ['V1', 2], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 6]], 1, 10, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V3']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['regression: preempted vehicle queue position (partial repair)',
   [[['V0', 4], ['V1', 0], ['V2', 3], ['V3', 1], ['V4', 0], ['V5', 4]], 2, 8, 2],
   [[['V0', 'V2'], ['V0', 'V2'], ['V3', 'V5'], ['V0', 'V5'], ['V0', 'V2'], ['V5'], ['V5'], []],
    [['V0', 5], ['V1', 0], ['V2', 5], ['V3', 3], ['V4', 0], ['V5', 7]]]],
  ['control 1', [[['V0', 0], ['V1', 6], ['V2', 4]], 2, 7, 3],
   [[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1'], ['V1'], []],
    [['V0', 0], ['V1', 6], ['V2', 4]]]],
  ['control 2', [[['V0', 3], ['V1', 0]], 1, 3, 1],
   [[['V0'], ['V0'], ['V0']], [['V0', 3], ['V1', 0]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: preempted vehicle queue position', [[['V0', 6], ['V1', 6]], 1, 3, 2],
   [[['V0'], ['V0'], ['V1']], [['V0', None], ['V1', None]]]],
  ['regression: preempted vehicle queue position (partial repair)',
   [[['V0', 4], ['V1', 6], ['V2', 2], ['V3', 2], ['V4', 5]], 3, 5, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V3'], ['V0', 'V3', 'V4'], ['V1', 'V4']],
    [['V0', 4], ['V1', None], ['V2', 2], ['V3', 4], ['V4', None]]]],
  ['control 1', [[['V0', 2], ['V1', 3], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 3]], 3, 3, 2],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', None], ['V4', 3], ['V5', None]]]],
  ['control 2', [[['V0', 2], ['V1', 6], ['V2', 6]], 1, 10, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V1'], ['V1'], ['V2'], ['V2']],
    [['V0', 2], ['V1', None], ['V2', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: preempted vehicle queue position',
   [[['V0', 5], ['V1', 5], ['V2', 6], ['V3', 0], ['V4', 6]], 3, 8, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V4'],
     ['V0', 'V1', 'V4'], ['V2', 'V4'], ['V2', 'V4'], ['V2', 'V4']],
    [['V0', 5], ['V1', 5], ['V2', 8], ['V3', 0], ['V4', None]]]],
  ['regression: preempted vehicle queue position (partial repair)',
   [[['V0', 5], ['V1', 3], ['V2', 2], ['V3', 1], ['V4', 3]], 3, 3, 2],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V3', 'V4']],
    [['V0', None], ['V1', None], ['V2', 2], ['V3', 3], ['V4', None]]]],
  ['control 1', [[['V0', 4], ['V1', 3], ['V2', 4], ['V3', 5], ['V4', 6]], 3, 3, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 4], ['V1', 0], ['V2', 0], ['V3', 4], ['V4', 2]], 1, 12, 1],
   [[['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V0'], ['V3'], [], []],
    [['V0', 9], ['V1', 0], ['V2', 0], ['V3', 10], ['V4', 6]]]]]]
for label, args, expected in fixtures[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 vehicle whose quantum expired immediately gets its port back, starving waiting vehicles.

vehicles is [[id, need_slots]] in arrival order. Each slot, free ports are filled from the FIFO queue; a vehicle holds its port for quantum slots or until done, then goes to the back of the queue. Return [timeline of sorted charging ids per slot, [[id, finish]] sorted by id] where finish is the slot index after its last charging slot, 0 when nothing was needed, None if unfinished.

split: open-access


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

N = 1
observations = []
def solve(vehicles, ports, slots, quantum):
    queue = [[vid, need] for vid, need in vehicles if need > 0]
    done = {vid: (0 if need <= 0 else None) for vid, need in vehicles}
    active = []
    timeline = []
    for t in range(slots):
        while len(active) < ports and queue:
            v = queue.pop(0)
            active.append([v[0], v[1], quantum])
        timeline.append(sorted(a[0] for a in active))
        nxt = []
        for a in active:
            a[1] -= 1
            a[2] -= 1
            if a[2] == 0:
                queue.append([a[0], a[1]])
            elif a[1] == 0:
                done[a[0]] = t + 1
            else:
                nxt.append(a)
        active = nxt
    return [timeline, [[k, done[k]] for k in sorted(done)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: completion before quantum expiry', [[['V0', 2], ['V1', 0], ['V2', 3]], 3, 8, 1],
   [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]],
  ['regression: completion before quantum expiry (partial repair)',
   [[['V0', 3], ['V1', 1], ['V2', 3]], 3, 10, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []],
    [['V0', 3], ['V1', 1], ['V2', 3]]]],
  ['control 1', [[['V0', 1], ['V1', 4], ['V2', 6], ['V3', 2], ['V4', 5], ['V5', 5]], 1, 10, 2],
   [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]],
  ['control 2', [[['V0', 5], ['V1', 3], ['V2', 2]], 1, 6, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: completion before quantum expiry',
   [[['V0', 1], ['V1', 3], ['V2', 2], ['V3', 6], ['V4', 0], ['V5', 0]], 2, 5, 3],
   [[['V0', 'V1'], ['V1', 'V2'], ['V1', 'V2'], ['V3'], ['V3']],
    [['V0', 1], ['V1', 3], ['V2', 3], ['V3', None], ['V4', 0], ['V5', 0]]]],
  ['regression: completion before quantum expiry (partial repair)',
   [[['V0', 4], ['V1', 6]], 3, 12, 1],
   [[['V0', 'V1'], ['V0', 'V1'], ['V0', 'V1'], ['V0', 'V1'], ['V1'], ['V1'], [], [], [], [], [],
     []],
    [['V0', 4], ['V1', 6]]]],
  ['control 1', [[['V0', 1], ['V1', 6], ['V2', 6], ['V3', 1], ['V4', 1]], 1, 7, 3],
   [[['V0'], ['V1'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 2], ['V1', 2], ['V2', 3], ['V3', 0], ['V4', 4], ['V5', 3]], 1, 3, 3],
   [[['V0'], ['V0'], ['V1']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', 0], ['V4', None], ['V5', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: completion before quantum expiry',
   [[['V0', 4], ['V1', 0], ['V2', 3], ['V3', 1], ['V4', 0], ['V5', 4]], 2, 8, 2],
   [[['V0', 'V2'], ['V0', 'V2'], ['V3', 'V5'], ['V0', 'V5'], ['V0', 'V2'], ['V5'], ['V5'], []],
    [['V0', 5], ['V1', 0], ['V2', 5], ['V3', 3], ['V4', 0], ['V5', 7]]]],
  ['regression: completion before quantum expiry (partial repair)',
   [[['V0', 4], ['V1', 2], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 6]], 1, 10, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V3']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['control 1', [[['V0', 0], ['V1', 6], ['V2', 4]], 2, 7, 3],
   [[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1'], ['V1'], []],
    [['V0', 0], ['V1', 6], ['V2', 4]]]],
  ['control 2', [[['V0', 3], ['V1', 0]], 1, 3, 1],
   [[['V0'], ['V0'], ['V0']], [['V0', 3], ['V1', 0]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: completion before quantum expiry',
   [[['V0', 0], ['V1', 6], ['V2', 3], ['V3', 4]], 2, 9, 3],
   [[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V3'], ['V1', 'V3'], ['V1', 'V3'], ['V3'], [],
     []],
    [['V0', 0], ['V1', 6], ['V2', 3], ['V3', 7]]]],
  ['regression: completion before quantum expiry (partial repair)', [[['V0', 3]], 3, 8, 2],
   [[['V0'], ['V0'], ['V0'], [], [], [], [], []], [['V0', 3]]]],
  ['control 1', [[['V0', 2], ['V1', 3], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 3]], 3, 3, 2],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', None], ['V4', 3], ['V5', None]]]],
  ['control 2', [[['V0', 2], ['V1', 6], ['V2', 6]], 1, 10, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V1'], ['V1'], ['V2'], ['V2']],
    [['V0', 2], ['V1', None], ['V2', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: completion before quantum expiry',
   [[['V0', 5], ['V1', 5], ['V2', 6], ['V3', 0], ['V4', 6]], 3, 8, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V4'],
     ['V0', 'V1', 'V4'], ['V2', 'V4'], ['V2', 'V4'], ['V2', 'V4']],
    [['V0', 5], ['V1', 5], ['V2', 8], ['V3', 0], ['V4', None]]]],
  ['regression: completion before quantum expiry (partial repair)', [[['V0', 3]], 2, 9, 1],
   [[['V0'], ['V0'], ['V0'], [], [], [], [], [], []], [['V0', 3]]]],
  ['control 1', [[['V0', 4], ['V1', 3], ['V2', 4], ['V3', 5], ['V4', 6]], 3, 3, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 4], ['V1', 0], ['V2', 0], ['V3', 4], ['V4', 2]], 1, 12, 1],
   [[['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V0'], ['V3'], [], []],
    [['V0', 9], ['V1', 0], ['V2', 0], ['V3', 10], ['V4', 6]]]]]]
for label, args, expected in fixtures[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(vehicles, ports, slots, quantum):
    queue = [[vid, need] for vid, need in vehicles if need > 0]
    done = {vid: (0 if need <= 0 else None) for vid, need in vehicles}
    active = []
    timeline = []
    for t in range(slots):
        while len(active) < ports and queue:
            v = queue.pop(0)
            active.append([v[0], v[1], quantum])
        timeline.append(sorted(a[0] for a in active))
        nxt = []
        for a in active:
            a[1] -= 1
            a[2] -= 1
            if a[1] == 0:
                done[a[0]] = t + 1
            if a[2] == 0:
                queue.append([a[0], a[1]])
            else:
                nxt.append(a)
        active = nxt
    return [timeline, [[k, done[k]] for k in sorted(done)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: completion before quantum expiry', [[['V0', 2], ['V1', 0], ['V2', 3]], 3, 8, 1],
   [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]],
  ['regression: completion before quantum expiry (partial repair)',
   [[['V0', 3], ['V1', 1], ['V2', 3]], 3, 10, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []],
    [['V0', 3], ['V1', 1], ['V2', 3]]]],
  ['control 1', [[['V0', 1], ['V1', 4], ['V2', 6], ['V3', 2], ['V4', 5], ['V5', 5]], 1, 10, 2],
   [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]],
  ['control 2', [[['V0', 5], ['V1', 3], ['V2', 2]], 1, 6, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: completion before quantum expiry',
   [[['V0', 1], ['V1', 3], ['V2', 2], ['V3', 6], ['V4', 0], ['V5', 0]], 2, 5, 3],
   [[['V0', 'V1'], ['V1', 'V2'], ['V1', 'V2'], ['V3'], ['V3']],
    [['V0', 1], ['V1', 3], ['V2', 3], ['V3', None], ['V4', 0], ['V5', 0]]]],
  ['regression: completion before quantum expiry (partial repair)',
   [[['V0', 4], ['V1', 6]], 3, 12, 1],
   [[['V0', 'V1'], ['V0', 'V1'], ['V0', 'V1'], ['V0', 'V1'], ['V1'], ['V1'], [], [], [], [], [],
     []],
    [['V0', 4], ['V1', 6]]]],
  ['control 1', [[['V0', 1], ['V1', 6], ['V2', 6], ['V3', 1], ['V4', 1]], 1, 7, 3],
   [[['V0'], ['V1'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 2], ['V1', 2], ['V2', 3], ['V3', 0], ['V4', 4], ['V5', 3]], 1, 3, 3],
   [[['V0'], ['V0'], ['V1']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', 0], ['V4', None], ['V5', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: completion before quantum expiry',
   [[['V0', 4], ['V1', 0], ['V2', 3], ['V3', 1], ['V4', 0], ['V5', 4]], 2, 8, 2],
   [[['V0', 'V2'], ['V0', 'V2'], ['V3', 'V5'], ['V0', 'V5'], ['V0', 'V2'], ['V5'], ['V5'], []],
    [['V0', 5], ['V1', 0], ['V2', 5], ['V3', 3], ['V4', 0], ['V5', 7]]]],
  ['regression: completion before quantum expiry (partial repair)',
   [[['V0', 4], ['V1', 2], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 6]], 1, 10, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V3']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['control 1', [[['V0', 0], ['V1', 6], ['V2', 4]], 2, 7, 3],
   [[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1'], ['V1'], []],
    [['V0', 0], ['V1', 6], ['V2', 4]]]],
  ['control 2', [[['V0', 3], ['V1', 0]], 1, 3, 1],
   [[['V0'], ['V0'], ['V0']], [['V0', 3], ['V1', 0]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: completion before quantum expiry',
   [[['V0', 0], ['V1', 6], ['V2', 3], ['V3', 4]], 2, 9, 3],
   [[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V3'], ['V1', 'V3'], ['V1', 'V3'], ['V3'], [],
     []],
    [['V0', 0], ['V1', 6], ['V2', 3], ['V3', 7]]]],
  ['regression: completion before quantum expiry (partial repair)', [[['V0', 3]], 3, 8, 2],
   [[['V0'], ['V0'], ['V0'], [], [], [], [], []], [['V0', 3]]]],
  ['control 1', [[['V0', 2], ['V1', 3], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 3]], 3, 3, 2],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', None], ['V4', 3], ['V5', None]]]],
  ['control 2', [[['V0', 2], ['V1', 6], ['V2', 6]], 1, 10, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V1'], ['V1'], ['V2'], ['V2']],
    [['V0', 2], ['V1', None], ['V2', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: completion before quantum expiry',
   [[['V0', 5], ['V1', 5], ['V2', 6], ['V3', 0], ['V4', 6]], 3, 8, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V4'],
     ['V0', 'V1', 'V4'], ['V2', 'V4'], ['V2', 'V4'], ['V2', 'V4']],
    [['V0', 5], ['V1', 5], ['V2', 8], ['V3', 0], ['V4', None]]]],
  ['regression: completion before quantum expiry (partial repair)', [[['V0', 3]], 2, 9, 1],
   [[['V0'], ['V0'], ['V0'], [], [], [], [], [], []], [['V0', 3]]]],
  ['control 1', [[['V0', 4], ['V1', 3], ['V2', 4], ['V3', 5], ['V4', 6]], 3, 3, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 4], ['V1', 0], ['V2', 0], ['V3', 4], ['V4', 2]], 1, 12, 1],
   [[['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V0'], ['V3'], [], []],
    [['V0', 9], ['V1', 0], ['V2', 0], ['V3', 10], ['V4', 6]]]]]]
for label, args, expected in fixtures[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 vehicle that finishes exactly at its quantum boundary is requeued and never reported done.

vehicles is [[id, need_slots]] in arrival order. Each slot, free ports are filled from the FIFO queue; a vehicle holds its port for quantum slots or until done, then goes to the back of the queue. Return [timeline of sorted charging ids per slot, [[id, finish]] sorted by id] where finish is the slot index after its last charging slot, 0 when nothing was needed, None if unfinished.

split: open-access


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

N = 1
observations = []
def solve(vehicles, ports, slots, quantum):
    queue = [[vid, need] for vid, need in vehicles if need > 0]
    done = {vid: (0 if need <= 0 else None) for vid, need in vehicles}
    active = []
    timeline = []
    for t in range(slots):
        if len(active) < ports and queue:
            v = queue.pop(0)
            active.append([v[0], v[1], quantum])
        timeline.append(sorted(a[0] for a in active))
        nxt = []
        for a in active:
            a[1] -= 1
            a[2] -= 1
            if a[1] == 0:
                done[a[0]] = t + 1
            elif a[2] == 0:
                queue.append([a[0], a[1]])
            else:
                nxt.append(a)
        active = nxt
    return [timeline, [[k, done[k]] for k in sorted(done)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: port refill loop', [[['V0', 2], ['V1', 0], ['V2', 3]], 3, 8, 1],
   [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]],
  ['regression: port refill loop (partial repair)',
   [[['V0', 4], ['V1', 4], ['V2', 0], ['V3', 5], ['V4', 6], ['V5', 0]], 1, 9, 1],
   [[['V0'], ['V1'], ['V3'], ['V4'], ['V0'], ['V1'], ['V3'], ['V4'], ['V0']],
    [['V0', None], ['V1', None], ['V2', 0], ['V3', None], ['V4', None], ['V5', 0]]]],
  ['control 1', [[['V0', 1], ['V1', 4], ['V2', 6], ['V3', 2], ['V4', 5], ['V5', 5]], 1, 10, 2],
   [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]],
  ['control 2', [[['V0', 5], ['V1', 3], ['V2', 2]], 1, 6, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: port refill loop',
   [[['V0', 1], ['V1', 3], ['V2', 2], ['V3', 6], ['V4', 0], ['V5', 0]], 2, 5, 3],
   [[['V0', 'V1'], ['V1', 'V2'], ['V1', 'V2'], ['V3'], ['V3']],
    [['V0', 1], ['V1', 3], ['V2', 3], ['V3', None], ['V4', 0], ['V5', 0]]]],
  ['regression: port refill loop (partial repair)',
   [[['V0', 5], ['V1', 2], ['V2', 5], ['V3', 1], ['V4', 2], ['V5', 5]], 1, 12, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V4'], ['V4'],
     ['V5']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', 9], ['V4', 11], ['V5', None]]]],
  ['control 1', [[['V0', 1], ['V1', 6], ['V2', 6], ['V3', 1], ['V4', 1]], 1, 7, 3],
   [[['V0'], ['V1'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 2], ['V1', 2], ['V2', 3], ['V3', 0], ['V4', 4], ['V5', 3]], 1, 3, 3],
   [[['V0'], ['V0'], ['V1']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', 0], ['V4', None], ['V5', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: port refill loop',
   [[['V0', 4], ['V1', 0], ['V2', 3], ['V3', 1], ['V4', 0], ['V5', 4]], 2, 8, 2],
   [[['V0', 'V2'], ['V0', 'V2'], ['V3', 'V5'], ['V0', 'V5'], ['V0', 'V2'], ['V5'], ['V5'], []],
    [['V0', 5], ['V1', 0], ['V2', 5], ['V3', 3], ['V4', 0], ['V5', 7]]]],
  ['regression: port refill loop (partial repair)',
   [[['V0', 4], ['V1', 2], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 6]], 1, 10, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V3']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['control 1', [[['V0', 0], ['V1', 6], ['V2', 4]], 2, 7, 3],
   [[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1'], ['V1'], []],
    [['V0', 0], ['V1', 6], ['V2', 4]]]],
  ['control 2', [[['V0', 3], ['V1', 0]], 1, 3, 1],
   [[['V0'], ['V0'], ['V0']], [['V0', 3], ['V1', 0]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: port refill loop',
   [[['V0', 4], ['V1', 6], ['V2', 2], ['V3', 2], ['V4', 5]], 3, 5, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V3'], ['V0', 'V3', 'V4'], ['V1', 'V4']],
    [['V0', 4], ['V1', None], ['V2', 2], ['V3', 4], ['V4', None]]]],
  ['regression: port refill loop (partial repair)', [[['V0', 6], ['V1', 6]], 1, 3, 2],
   [[['V0'], ['V0'], ['V1']], [['V0', None], ['V1', None]]]],
  ['control 1', [[['V0', 2], ['V1', 3], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 3]], 3, 3, 2],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', None], ['V4', 3], ['V5', None]]]],
  ['control 2', [[['V0', 2], ['V1', 6], ['V2', 6]], 1, 10, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V1'], ['V1'], ['V2'], ['V2']],
    [['V0', 2], ['V1', None], ['V2', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: port refill loop',
   [[['V0', 5], ['V1', 5], ['V2', 6], ['V3', 0], ['V4', 6]], 3, 8, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V4'],
     ['V0', 'V1', 'V4'], ['V2', 'V4'], ['V2', 'V4'], ['V2', 'V4']],
    [['V0', 5], ['V1', 5], ['V2', 8], ['V3', 0], ['V4', None]]]],
  ['regression: port refill loop (partial repair)',
   [[['V0', 3], ['V1', 1], ['V2', 1], ['V3', 1], ['V4', 5], ['V5', 2]], 1, 3, 2],
   [[['V0'], ['V0'], ['V1']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['control 1', [[['V0', 4], ['V1', 3], ['V2', 4], ['V3', 5], ['V4', 6]], 3, 3, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 4], ['V1', 0], ['V2', 0], ['V3', 4], ['V4', 2]], 1, 12, 1],
   [[['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V0'], ['V3'], [], []],
    [['V0', 9], ['V1', 0], ['V2', 0], ['V3', 10], ['V4', 6]]]]]]
for label, args, expected in fixtures[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(vehicles, ports, slots, quantum):
    queue = [[vid, need] for vid, need in vehicles if need > 0]
    done = {vid: (0 if need <= 0 else None) for vid, need in vehicles}
    active = []
    timeline = []
    for t in range(slots):
        while len(active) < ports - 1 and queue:
            v = queue.pop(0)
            active.append([v[0], v[1], quantum])
        timeline.append(sorted(a[0] for a in active))
        nxt = []
        for a in active:
            a[1] -= 1
            a[2] -= 1
            if a[1] == 0:
                done[a[0]] = t + 1
            elif a[2] == 0:
                queue.append([a[0], a[1]])
            else:
                nxt.append(a)
        active = nxt
    return [timeline, [[k, done[k]] for k in sorted(done)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: port refill loop', [[['V0', 2], ['V1', 0], ['V2', 3]], 3, 8, 1],
   [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]],
  ['regression: port refill loop (partial repair)',
   [[['V0', 4], ['V1', 4], ['V2', 0], ['V3', 5], ['V4', 6], ['V5', 0]], 1, 9, 1],
   [[['V0'], ['V1'], ['V3'], ['V4'], ['V0'], ['V1'], ['V3'], ['V4'], ['V0']],
    [['V0', None], ['V1', None], ['V2', 0], ['V3', None], ['V4', None], ['V5', 0]]]],
  ['control 1', [[['V0', 1], ['V1', 4], ['V2', 6], ['V3', 2], ['V4', 5], ['V5', 5]], 1, 10, 2],
   [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]],
  ['control 2', [[['V0', 5], ['V1', 3], ['V2', 2]], 1, 6, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: port refill loop',
   [[['V0', 1], ['V1', 3], ['V2', 2], ['V3', 6], ['V4', 0], ['V5', 0]], 2, 5, 3],
   [[['V0', 'V1'], ['V1', 'V2'], ['V1', 'V2'], ['V3'], ['V3']],
    [['V0', 1], ['V1', 3], ['V2', 3], ['V3', None], ['V4', 0], ['V5', 0]]]],
  ['regression: port refill loop (partial repair)',
   [[['V0', 5], ['V1', 2], ['V2', 5], ['V3', 1], ['V4', 2], ['V5', 5]], 1, 12, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V4'], ['V4'],
     ['V5']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', 9], ['V4', 11], ['V5', None]]]],
  ['control 1', [[['V0', 1], ['V1', 6], ['V2', 6], ['V3', 1], ['V4', 1]], 1, 7, 3],
   [[['V0'], ['V1'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 2], ['V1', 2], ['V2', 3], ['V3', 0], ['V4', 4], ['V5', 3]], 1, 3, 3],
   [[['V0'], ['V0'], ['V1']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', 0], ['V4', None], ['V5', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: port refill loop',
   [[['V0', 4], ['V1', 0], ['V2', 3], ['V3', 1], ['V4', 0], ['V5', 4]], 2, 8, 2],
   [[['V0', 'V2'], ['V0', 'V2'], ['V3', 'V5'], ['V0', 'V5'], ['V0', 'V2'], ['V5'], ['V5'], []],
    [['V0', 5], ['V1', 0], ['V2', 5], ['V3', 3], ['V4', 0], ['V5', 7]]]],
  ['regression: port refill loop (partial repair)',
   [[['V0', 4], ['V1', 2], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 6]], 1, 10, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V3']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['control 1', [[['V0', 0], ['V1', 6], ['V2', 4]], 2, 7, 3],
   [[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1'], ['V1'], []],
    [['V0', 0], ['V1', 6], ['V2', 4]]]],
  ['control 2', [[['V0', 3], ['V1', 0]], 1, 3, 1],
   [[['V0'], ['V0'], ['V0']], [['V0', 3], ['V1', 0]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: port refill loop',
   [[['V0', 4], ['V1', 6], ['V2', 2], ['V3', 2], ['V4', 5]], 3, 5, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V3'], ['V0', 'V3', 'V4'], ['V1', 'V4']],
    [['V0', 4], ['V1', None], ['V2', 2], ['V3', 4], ['V4', None]]]],
  ['regression: port refill loop (partial repair)', [[['V0', 6], ['V1', 6]], 1, 3, 2],
   [[['V0'], ['V0'], ['V1']], [['V0', None], ['V1', None]]]],
  ['control 1', [[['V0', 2], ['V1', 3], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 3]], 3, 3, 2],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', None], ['V4', 3], ['V5', None]]]],
  ['control 2', [[['V0', 2], ['V1', 6], ['V2', 6]], 1, 10, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V1'], ['V1'], ['V2'], ['V2']],
    [['V0', 2], ['V1', None], ['V2', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: port refill loop',
   [[['V0', 5], ['V1', 5], ['V2', 6], ['V3', 0], ['V4', 6]], 3, 8, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V4'],
     ['V0', 'V1', 'V4'], ['V2', 'V4'], ['V2', 'V4'], ['V2', 'V4']],
    [['V0', 5], ['V1', 5], ['V2', 8], ['V3', 0], ['V4', None]]]],
  ['regression: port refill loop (partial repair)',
   [[['V0', 3], ['V1', 1], ['V2', 1], ['V3', 1], ['V4', 5], ['V5', 2]], 1, 3, 2],
   [[['V0'], ['V0'], ['V1']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['control 1', [[['V0', 4], ['V1', 3], ['V2', 4], ['V3', 5], ['V4', 6]], 3, 3, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 4], ['V1', 0], ['V2', 0], ['V3', 4], ['V4', 2]], 1, 12, 1],
   [[['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V0'], ['V3'], [], []],
    [['V0', 9], ['V1', 0], ['V2', 0], ['V3', 10], ['V4', 6]]]]]]
for label, args, expected in fixtures[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:
Only one waiting vehicle is connected per slot even when several ports are free.

vehicles is [[id, need_slots]] in arrival order. Each slot, free ports are filled from the FIFO queue; a vehicle holds its port for quantum slots or until done, then goes to the back of the queue. Return [timeline of sorted charging ids per slot, [[id, finish]] sorted by id] where finish is the slot index after its last charging slot, 0 when nothing was needed, None if unfinished.

split: open-access


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

N = 1
observations = []
def solve(vehicles, ports, slots, quantum):
    queue = [[vid, need] for vid, need in vehicles if need > 0]
    done = {vid: (0 if need <= 0 else None) for vid, need in vehicles}
    active = []
    timeline = []
    for t in range(slots):
        while len(active) < ports and queue:
            v = queue.pop(0)
            active.append([v[0], v[1], quantum])
        timeline.append([a[0] for a in active])
        nxt = []
        for a in active:
            a[1] -= 1
            a[2] -= 1
            if a[1] == 0:
                done[a[0]] = t + 1
            elif a[2] == 0:
                queue.append([a[0], a[1]])
            else:
                nxt.append(a)
        active = nxt
    return [timeline, [[k, done[k]] for k in sorted(done)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: timeline membership',
   [[['V0', 0], ['V1', 6], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 1]], 2, 9, 2],
   [[['V1', 'V2'], ['V1', 'V2'], ['V3', 'V4'], ['V3', 'V5'], ['V1', 'V2'], ['V1', 'V2'],
     ['V1', 'V3'], ['V1', 'V3'], ['V2', 'V3']],
    [['V0', 0], ['V1', 8], ['V2', None], ['V3', None], ['V4', 3], ['V5', 4]]]],
  ['regression: timeline membership (partial repair)', [[['V0', 2], ['V1', 0], ['V2', 3]], 3, 8, 1],
   [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]],
  ['control 1', [[['V0', 1], ['V1', 4], ['V2', 6], ['V3', 2], ['V4', 5], ['V5', 5]], 1, 10, 2],
   [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]],
  ['control 2', [[['V0', 5], ['V1', 3], ['V2', 2]], 1, 6, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: timeline membership',
   [[['V0', 5], ['V1', 4], ['V2', 4], ['V3', 1], ['V4', 5], ['V5', 1]], 3, 12, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5'],
     ['V0', 'V1', 'V4'], ['V0', 'V2', 'V4'], ['V4'], ['V4'], [], [], [], []],
    [['V0', 6], ['V1', 5], ['V2', 6], ['V3', 4], ['V4', 8], ['V5', 4]]]],
  ['regression: timeline membership (partial repair)',
   [[['V0', 1], ['V1', 3], ['V2', 2], ['V3', 6], ['V4', 0], ['V5', 0]], 2, 5, 3],
   [[['V0', 'V1'], ['V1', 'V2'], ['V1', 'V2'], ['V3'], ['V3']],
    [['V0', 1], ['V1', 3], ['V2', 3], ['V3', None], ['V4', 0], ['V5', 0]]]],
  ['control 1', [[['V0', 1], ['V1', 6], ['V2', 6], ['V3', 1], ['V4', 1]], 1, 7, 3],
   [[['V0'], ['V1'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 2], ['V1', 2], ['V2', 3], ['V3', 0], ['V4', 4], ['V5', 3]], 1, 3, 3],
   [[['V0'], ['V0'], ['V1']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', 0], ['V4', None], ['V5', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: timeline membership',
   [[['V0', 4], ['V1', 0], ['V2', 3], ['V3', 1], ['V4', 0], ['V5', 4]], 2, 8, 2],
   [[['V0', 'V2'], ['V0', 'V2'], ['V3', 'V5'], ['V0', 'V5'], ['V0', 'V2'], ['V5'], ['V5'], []],
    [['V0', 5], ['V1', 0], ['V2', 5], ['V3', 3], ['V4', 0], ['V5', 7]]]],
  ['regression: timeline membership (partial repair)',
   [[['V0', 4], ['V1', 2], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 6]], 1, 10, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V3']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['control 1', [[['V0', 0], ['V1', 6], ['V2', 4]], 2, 7, 3],
   [[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1'], ['V1'], []],
    [['V0', 0], ['V1', 6], ['V2', 4]]]],
  ['control 2', [[['V0', 3], ['V1', 0]], 1, 3, 1],
   [[['V0'], ['V0'], ['V0']], [['V0', 3], ['V1', 0]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: timeline membership',
   [[['V0', 4], ['V1', 6], ['V2', 2], ['V3', 2], ['V4', 5]], 3, 5, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V3'], ['V0', 'V3', 'V4'], ['V1', 'V4']],
    [['V0', 4], ['V1', None], ['V2', 2], ['V3', 4], ['V4', None]]]],
  ['regression: timeline membership (partial repair)', [[['V0', 3]], 3, 8, 2],
   [[['V0'], ['V0'], ['V0'], [], [], [], [], []], [['V0', 3]]]],
  ['control 1', [[['V0', 2], ['V1', 3], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 3]], 3, 3, 2],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', None], ['V4', 3], ['V5', None]]]],
  ['control 2', [[['V0', 2], ['V1', 6], ['V2', 6]], 1, 10, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V1'], ['V1'], ['V2'], ['V2']],
    [['V0', 2], ['V1', None], ['V2', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: timeline membership',
   [[['V0', 5], ['V1', 5], ['V2', 6], ['V3', 0], ['V4', 6]], 3, 8, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V4'],
     ['V0', 'V1', 'V4'], ['V2', 'V4'], ['V2', 'V4'], ['V2', 'V4']],
    [['V0', 5], ['V1', 5], ['V2', 8], ['V3', 0], ['V4', None]]]],
  ['regression: timeline membership (partial repair)', [[['V0', 3]], 2, 9, 1],
   [[['V0'], ['V0'], ['V0'], [], [], [], [], [], []], [['V0', 3]]]],
  ['control 1', [[['V0', 4], ['V1', 3], ['V2', 4], ['V3', 5], ['V4', 6]], 3, 3, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 4], ['V1', 0], ['V2', 0], ['V3', 4], ['V4', 2]], 1, 12, 1],
   [[['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V0'], ['V3'], [], []],
    [['V0', 9], ['V1', 0], ['V2', 0], ['V3', 10], ['V4', 6]]]]]]
for label, args, expected in fixtures[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(vehicles, ports, slots, quantum):
    queue = [[vid, need] for vid, need in vehicles if need > 0]
    done = {vid: (0 if need <= 0 else None) for vid, need in vehicles}
    active = []
    timeline = []
    for t in range(slots):
        while len(active) < ports and queue:
            v = queue.pop(0)
            active.append([v[0], v[1], quantum])
        timeline.append(sorted(a[0] for a in active if a[1] > 1))
        nxt = []
        for a in active:
            a[1] -= 1
            a[2] -= 1
            if a[1] == 0:
                done[a[0]] = t + 1
            elif a[2] == 0:
                queue.append([a[0], a[1]])
            else:
                nxt.append(a)
        active = nxt
    return [timeline, [[k, done[k]] for k in sorted(done)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: timeline membership',
   [[['V0', 0], ['V1', 6], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 1]], 2, 9, 2],
   [[['V1', 'V2'], ['V1', 'V2'], ['V3', 'V4'], ['V3', 'V5'], ['V1', 'V2'], ['V1', 'V2'],
     ['V1', 'V3'], ['V1', 'V3'], ['V2', 'V3']],
    [['V0', 0], ['V1', 8], ['V2', None], ['V3', None], ['V4', 3], ['V5', 4]]]],
  ['regression: timeline membership (partial repair)', [[['V0', 2], ['V1', 0], ['V2', 3]], 3, 8, 1],
   [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]],
  ['control 1', [[['V0', 1], ['V1', 4], ['V2', 6], ['V3', 2], ['V4', 5], ['V5', 5]], 1, 10, 2],
   [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]],
  ['control 2', [[['V0', 5], ['V1', 3], ['V2', 2]], 1, 6, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: timeline membership',
   [[['V0', 5], ['V1', 4], ['V2', 4], ['V3', 1], ['V4', 5], ['V5', 1]], 3, 12, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5'],
     ['V0', 'V1', 'V4'], ['V0', 'V2', 'V4'], ['V4'], ['V4'], [], [], [], []],
    [['V0', 6], ['V1', 5], ['V2', 6], ['V3', 4], ['V4', 8], ['V5', 4]]]],
  ['regression: timeline membership (partial repair)',
   [[['V0', 1], ['V1', 3], ['V2', 2], ['V3', 6], ['V4', 0], ['V5', 0]], 2, 5, 3],
   [[['V0', 'V1'], ['V1', 'V2'], ['V1', 'V2'], ['V3'], ['V3']],
    [['V0', 1], ['V1', 3], ['V2', 3], ['V3', None], ['V4', 0], ['V5', 0]]]],
  ['control 1', [[['V0', 1], ['V1', 6], ['V2', 6], ['V3', 1], ['V4', 1]], 1, 7, 3],
   [[['V0'], ['V1'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 2], ['V1', 2], ['V2', 3], ['V3', 0], ['V4', 4], ['V5', 3]], 1, 3, 3],
   [[['V0'], ['V0'], ['V1']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', 0], ['V4', None], ['V5', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: timeline membership',
   [[['V0', 4], ['V1', 0], ['V2', 3], ['V3', 1], ['V4', 0], ['V5', 4]], 2, 8, 2],
   [[['V0', 'V2'], ['V0', 'V2'], ['V3', 'V5'], ['V0', 'V5'], ['V0', 'V2'], ['V5'], ['V5'], []],
    [['V0', 5], ['V1', 0], ['V2', 5], ['V3', 3], ['V4', 0], ['V5', 7]]]],
  ['regression: timeline membership (partial repair)',
   [[['V0', 4], ['V1', 2], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 6]], 1, 10, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V3']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['control 1', [[['V0', 0], ['V1', 6], ['V2', 4]], 2, 7, 3],
   [[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1'], ['V1'], []],
    [['V0', 0], ['V1', 6], ['V2', 4]]]],
  ['control 2', [[['V0', 3], ['V1', 0]], 1, 3, 1],
   [[['V0'], ['V0'], ['V0']], [['V0', 3], ['V1', 0]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: timeline membership',
   [[['V0', 4], ['V1', 6], ['V2', 2], ['V3', 2], ['V4', 5]], 3, 5, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V3'], ['V0', 'V3', 'V4'], ['V1', 'V4']],
    [['V0', 4], ['V1', None], ['V2', 2], ['V3', 4], ['V4', None]]]],
  ['regression: timeline membership (partial repair)', [[['V0', 3]], 3, 8, 2],
   [[['V0'], ['V0'], ['V0'], [], [], [], [], []], [['V0', 3]]]],
  ['control 1', [[['V0', 2], ['V1', 3], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 3]], 3, 3, 2],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', None], ['V4', 3], ['V5', None]]]],
  ['control 2', [[['V0', 2], ['V1', 6], ['V2', 6]], 1, 10, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V1'], ['V1'], ['V2'], ['V2']],
    [['V0', 2], ['V1', None], ['V2', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: timeline membership',
   [[['V0', 5], ['V1', 5], ['V2', 6], ['V3', 0], ['V4', 6]], 3, 8, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V4'],
     ['V0', 'V1', 'V4'], ['V2', 'V4'], ['V2', 'V4'], ['V2', 'V4']],
    [['V0', 5], ['V1', 5], ['V2', 8], ['V3', 0], ['V4', None]]]],
  ['regression: timeline membership (partial repair)', [[['V0', 3]], 2, 9, 1],
   [[['V0'], ['V0'], ['V0'], [], [], [], [], [], []], [['V0', 3]]]],
  ['control 1', [[['V0', 4], ['V1', 3], ['V2', 4], ['V3', 5], ['V4', 6]], 3, 3, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 4], ['V1', 0], ['V2', 0], ['V3', 4], ['V4', 2]], 1, 12, 1],
   [[['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V0'], ['V3'], [], []],
    [['V0', 9], ['V1', 0], ['V2', 0], ['V3', 10], ['V4', 6]]]]]]
for label, args, expected in fixtures[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:
Timeline rows are in port order and differ between identical fleets.

vehicles is [[id, need_slots]] in arrival order. Each slot, free ports are filled from the FIFO queue; a vehicle holds its port for quantum slots or until done, then goes to the back of the queue. Return [timeline of sorted charging ids per slot, [[id, finish]] sorted by id] where finish is the slot index after its last charging slot, 0 when nothing was needed, None if unfinished.

split: open-access


prompt:
Energy is granted to vehicles in the slot at which they have already left the depot.

fleet is [[id, need_units, depart_slot, max_units_per_slot]]. A vehicle is present in slots t < depart_slot. Each slot the site capacity site_units is granted in order of laxity (depart_slot - t - ceil(remaining/max_units)) ascending, ties by id; each vehicle gets min(max, remaining, capacity left). Return [[[id, remaining]] sorted by id, sorted ids with remaining > 0].

split: open-access


prompt:
A vehicle needing a partial final slot is treated as having spare time and misses its target.

fleet is [[id, need_units, depart_slot, max_units_per_slot]]. A vehicle is present in slots t < depart_slot. Each slot the site capacity site_units is granted in order of laxity (depart_slot - t - ceil(remaining/max_units)) ascending, ties by id; each vehicle gets min(max, remaining, capacity left). Return [[[id, remaining]] sorted by id, sorted ids with remaining > 0].

split: open-access


prompt:
Vehicles with the most slack are served first while urgent ones miss departure.

fleet is [[id, need_units, depart_slot, max_units_per_slot]]. A vehicle is present in slots t < depart_slot. Each slot the site capacity site_units is granted in order of laxity (depart_slot - t - ceil(remaining/max_units)) ascending, ties by id; each vehicle gets min(max, remaining, capacity left). Return [[[id, remaining]] sorted by id, sorted ids with remaining > 0].

split: open-access


prompt:
Vehicles end with negative remaining energy and capacity is wasted on them.

fleet is [[id, need_units, depart_slot, max_units_per_slot]]. A vehicle is present in slots t < depart_slot. Each slot the site capacity site_units is granted in order of laxity (depart_slot - t - ceil(remaining/max_units)) ascending, ties by id; each vehicle gets min(max, remaining, capacity left). Return [[[id, remaining]] sorted by id, sorted ids with remaining > 0].

split: open-access


prompt:
Which of two equally urgent vehicles charges depends on list order.

fleet is [[id, need_units, depart_slot, max_units_per_slot]]. A vehicle is present in slots t < depart_slot. Each slot the site capacity site_units is granted in order of laxity (depart_slot - t - ceil(remaining/max_units)) ascending, ties by id; each vehicle gets min(max, remaining, capacity left). Return [[[id, remaining]] sorted by id, sorted ids with remaining > 0].

split: open-access


prompt:
After the first slots the depot stops charging anyone.

fleet is [[id, need_units, depart_slot, max_units_per_slot]]. A vehicle is present in slots t < depart_slot. Each slot the site capacity site_units is granted in order of laxity (depart_slot - t - ceil(remaining/max_units)) ascending, ties by id; each vehicle gets min(max, remaining, capacity left). Return [[[id, remaining]] sorted by id, sorted ids with remaining > 0].

split: open-access


prompt:
A rule with equal start and end allows charging only around its start minute on two days.

rules are [day_mask, start, end] with bit 0 = Monday .. bit 6 = Sunday. start < end is a same-day window [start, end); start == end means the whole selected day; start > end crosses midnight and belongs to its start day (Sunday continues into Monday). Return the sorted indices of rules allowing charging at (day 0..6, minute 0..1439).

split: open-access


prompt:
Charging is allowed during the minute the window closes.

rules are [day_mask, start, end] with bit 0 = Monday .. bit 6 = Sunday. start < end is a same-day window [start, end); start == end means the whole selected day; start > end crosses midnight and belongs to its start day (Sunday continues into Monday). Return the sorted indices of rules allowing charging at (day 0..6, minute 0..1439).

split: open-access


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

N = 1
observations = []
def solve(rules, day, minute):
    hits = []
    for i, (mask, s, e) in enumerate(rules):
        today = mask >> day & 1
        yday = mask >> (day + 1) % 7 & 1
        if s == e:
            if today:
                hits.append(i)
        elif s < e:
            if today and s <= minute < e:
                hits.append(i)
        elif (today and minute >= s) or (yday and minute < e):
            hits.append(i)
    return hits
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: Monday morning after Sunday night window', [[[64, 1320, 360]], 0, 100], [0]],
  ['boundary: same-day window end minute', [[[127, 60, 360]], 3, 360], []],
  ['boundary: whole-day rule', [[[4, 420, 420]], 2, 5], [0]],
  ['regression: previous weekday wrap', [[[50, 1080, 60], [92, 0, 420], [118, 1080, 1320]], 0, 30],
   []],
  ['regression: previous weekday wrap (partial repair)',
   [[[72, 0, 1380], [114, 1380, 1080], [82, 1320, 60], [68, 1080, 1380]], 0, 900], [1]],
  ['control 1', [[[75, 1380, 360]], 0, 1379], []],
  ['control 2', [[[26, 1380, 420], [118, 360, 0], [104, 1080, 1080]], 3, 0], [2]]],
 [['boundary: Monday morning after Sunday night window', [[[64, 1320, 360]], 0, 100], [0]],
  ['boundary: same-day window end minute', [[[127, 60, 360]], 3, 360], []],
  ['boundary: whole-day rule', [[[4, 420, 420]], 2, 5], [0]],
  ['regression: previous weekday wrap',
   [[[18, 60, 0], [118, 1080, 0], [124, 60, 360], [93, 1080, 60]], 4, 0], [3]],
  ['regression: previous weekday wrap (partial repair)', [[[19, 1380, 1080]], 0, 61], []],
  ['control 1', [[[28, 1320, 1080], [123, 420, 1380], [9, 1380, 0]], 6, 359], []],
  ['control 2', [[[98, 1080, 0], [121, 1380, 360], [62, 360, 0], [52, 1080, 0]], 2, 1079], [2]]],
 [['boundary: Monday morning after Sunday night window', [[[64, 1320, 360]], 0, 100], [0]],
  ['boundary: same-day window end minute', [[[127, 60, 360]], 3, 360], []],
  ['boundary: whole-day rule', [[[4, 420, 420]], 2, 5], [0]],
  ['regression: previous weekday wrap', [[[4, 1380, 1320], [39, 0, 420], [94, 60, 1380]], 1, 900],
   [2]],
  ['regression: previous weekday wrap (partial repair)',
   [[[67, 1380, 420], [25, 60, 0], [87, 1320, 360], [82, 1320, 420]], 0, 359], [0, 1, 2, 3]],
  ['control 1', [[[103, 0, 360], [65, 360, 1380], [37, 1080, 1080]], 4, 60], []],
  ['control 2', [[[52, 420, 1320], [97, 1080, 360]], 0, 0], [1]]],
 [['boundary: Monday morning after Sunday night window', [[[64, 1320, 360]], 0, 100], [0]],
  ['boundary: same-day window end minute', [[[127, 60, 360]], 3, 360], []],
  ['boundary: whole-day rule', [[[4, 420, 420]], 2, 5], [0]],
  ['regression: previous weekday wrap', [[[124, 0, 0], [53, 1320, 360], [89, 60, 60]], 4, 30],
   [0, 2]],
  ['regression: previous weekday wrap (partial repair)',
   [[[67, 1380, 420], [25, 60, 0], [87, 1320, 360], [82, 1320, 420]], 0, 359], [0, 1, 2, 3]],
  ['control 1', [[[105, 420, 360], [31, 1380, 1320], [47, 1080, 1320]], 4, 60], [0, 1]],
  ['control 2', [[[59, 360, 60], [45, 420, 60]], 5, 360], [0]]],
 [['boundary: Monday morning after Sunday night window', [[[64, 1320, 360]], 0, 100], [0]],
  ['boundary: same-day window end minute', [[[127, 60, 360]], 3, 360], []],
  ['boundary: whole-day rule', [[[4, 420, 420]], 2, 5], [0]],
  ['regression: previous weekday wrap', [[[51, 360, 1080], [116, 1320, 420]], 0, 60], [1]],
  ['regression: previous weekday wrap (partial repair)',
   [[[68, 1320, 360], [42, 360, 360], [95, 0, 360], [40, 1380, 60]], 0, 359], [0, 2]],
  ['control 1', [[[51, 360, 60], [78, 1080, 1080], [25, 1320, 360], [11, 360, 0]], 2, 1380], [1]],
  ['control 2', [[[16, 1380, 0]], 1, 360], []]]]
for label, args, expected in fixtures[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(rules, day, minute):
    hits = []
    for i, (mask, s, e) in enumerate(rules):
        today = mask >> day & 1
        yday = mask >> max(day - 1, 0) & 1
        if s == e:
            if today:
                hits.append(i)
        elif s < e:
            if today and s <= minute < e:
                hits.append(i)
        elif (today and minute >= s) or (yday and minute < e):
            hits.append(i)
    return hits
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: Monday morning after Sunday night window', [[[64, 1320, 360]], 0, 100], [0]],
  ['boundary: same-day window end minute', [[[127, 60, 360]], 3, 360], []],
  ['boundary: whole-day rule', [[[4, 420, 420]], 2, 5], [0]],
  ['regression: previous weekday wrap', [[[50, 1080, 60], [92, 0, 420], [118, 1080, 1320]], 0, 30],
   []],
  ['regression: previous weekday wrap (partial repair)',
   [[[72, 0, 1380], [114, 1380, 1080], [82, 1320, 60], [68, 1080, 1380]], 0, 900], [1]],
  ['control 1', [[[75, 1380, 360]], 0, 1379], []],
  ['control 2', [[[26, 1380, 420], [118, 360, 0], [104, 1080, 1080]], 3, 0], [2]]],
 [['boundary: Monday morning after Sunday night window', [[[64, 1320, 360]], 0, 100], [0]],
  ['boundary: same-day window end minute', [[[127, 60, 360]], 3, 360], []],
  ['boundary: whole-day rule', [[[4, 420, 420]], 2, 5], [0]],
  ['regression: previous weekday wrap',
   [[[18, 60, 0], [118, 1080, 0], [124, 60, 360], [93, 1080, 60]], 4, 0], [3]],
  ['regression: previous weekday wrap (partial repair)', [[[19, 1380, 1080]], 0, 61], []],
  ['control 1', [[[28, 1320, 1080], [123, 420, 1380], [9, 1380, 0]], 6, 359], []],
  ['control 2', [[[98, 1080, 0], [121, 1380, 360], [62, 360, 0], [52, 1080, 0]], 2, 1079], [2]]],
 [['boundary: Monday morning after Sunday night window', [[[64, 1320, 360]], 0, 100], [0]],
  ['boundary: same-day window end minute', [[[127, 60, 360]], 3, 360], []],
  ['boundary: whole-day rule', [[[4, 420, 420]], 2, 5], [0]],
  ['regression: previous weekday wrap', [[[4, 1380, 1320], [39, 0, 420], [94, 60, 1380]], 1, 900],
   [2]],
  ['regression: previous weekday wrap (partial repair)',
   [[[67, 1380, 420], [25, 60, 0], [87, 1320, 360], [82, 1320, 420]], 0, 359], [0, 1, 2, 3]],
  ['control 1', [[[103, 0, 360], [65, 360, 1380], [37, 1080, 1080]], 4, 60], []],
  ['control 2', [[[52, 420, 1320], [97, 1080, 360]], 0, 0], [1]]],
 [['boundary: Monday morning after Sunday night window', [[[64, 1320, 360]], 0, 100], [0]],
  ['boundary: same-day window end minute', [[[127, 60, 360]], 3, 360], []],
  ['boundary: whole-day rule', [[[4, 420, 420]], 2, 5], [0]],
  ['regression: previous weekday wrap', [[[124, 0, 0], [53, 1320, 360], [89, 60, 60]], 4, 30],
   [0, 2]],
  ['regression: previous weekday wrap (partial repair)',
   [[[67, 1380, 420], [25, 60, 0], [87, 1320, 360], [82, 1320, 420]], 0, 359], [0, 1, 2, 3]],
  ['control 1', [[[105, 420, 360], [31, 1380, 1320], [47, 1080, 1320]], 4, 60], [0, 1]],
  ['control 2', [[[59, 360, 60], [45, 420, 60]], 5, 360], [0]]],
 [['boundary: Monday morning after Sunday night window', [[[64, 1320, 360]], 0, 100], [0]],
  ['boundary: same-day window end minute', [[[127, 60, 360]], 3, 360], []],
  ['boundary: whole-day rule', [[[4, 420, 420]], 2, 5], [0]],
  ['regression: previous weekday wrap', [[[51, 360, 1080], [116, 1320, 420]], 0, 60], [1]],
  ['regression: previous weekday wrap (partial repair)',
   [[[68, 1320, 360], [42, 360, 360], [95, 0, 360], [40, 1380, 60]], 0, 359], [0, 2]],
  ['control 1', [[[51, 360, 60], [78, 1080, 1080], [25, 1320, 360], [11, 360, 0]], 2, 1380], [1]],
  ['control 2', [[[16, 1380, 0]], 1, 360], []]]]
for label, args, expected in fixtures[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:
Overnight windows continue into the wrong morning.

rules are [day_mask, start, end] with bit 0 = Monday .. bit 6 = Sunday. start < end is a same-day window [start, end); start == end means the whole selected day; start > end crosses midnight and belongs to its start day (Sunday continues into Monday). Return the sorted indices of rules allowing charging at (day 0..6, minute 0..1439).

split: open-access


prompt:
Overnight windows stay open one minute past their end time.

rules are [day_mask, start, end] with bit 0 = Monday .. bit 6 = Sunday. start < end is a same-day window [start, end); start == end means the whole selected day; start > end crosses midnight and belongs to its start day (Sunday continues into Monday). Return the sorted indices of rules allowing charging at (day 0..6, minute 0..1439).

split: open-access


prompt:
The opening minute of an overnight window is refused.

rules are [day_mask, start, end] with bit 0 = Monday .. bit 6 = Sunday. start < end is a same-day window [start, end); start == end means the whole selected day; start > end crosses midnight and belongs to its start day (Sunday continues into Monday). Return the sorted indices of rules allowing charging at (day 0..6, minute 0..1439).

split: open-access


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

N = 1
observations = []
def solve(rules, day, minute):
    hits = []
    for i, (mask, s, e) in enumerate(rules):
        today = mask >> day & 1
        yday = mask >> day & 1
        if s == e:
            if today:
                hits.append(i)
        elif s < e:
            if today and s <= minute < e:
                hits.append(i)
        elif (today and minute >= s) or (yday and minute < e):
            hits.append(i)
    return hits
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: Monday morning after Sunday night window', [[[64, 1320, 360]], 0, 100], [0]],
  ['boundary: same-day window end minute', [[[127, 60, 360]], 3, 360], []],
  ['boundary: whole-day rule', [[[4, 420, 420]], 2, 5], [0]],
  ['regression: weekday bit order', [[[84, 60, 360]], 1, 60], []],
  ['regression: weekday bit order (partial repair)',
   [[[72, 0, 1380], [114, 1380, 1080], [82, 1320, 60], [68, 1080, 1380]], 0, 900], [1]],
  ['control 1', [[[75, 1380, 360]], 0, 1379], []],
  ['control 2', [[[26, 1380, 420], [118, 360, 0], [104, 1080, 1080]], 3, 0], [2]]],
 [['boundary: Monday morning after Sunday night window', [[[64, 1320, 360]], 0, 100], [0]],
  ['boundary: same-day window end minute', [[[127, 60, 360]], 3, 360], []],
  ['boundary: whole-day rule', [[[4, 420, 420]], 2, 5], [0]],
  ['regression: weekday bit order', [[[53, 1080, 0]], 0, 1320], [0]],
  ['regression: weekday bit order (partial repair)',
   [[[113, 360, 60], [87, 420, 0], [65, 1380, 1380], [90, 1380, 1320]], 5, 420], [0, 3]],
  ['control 1', [[[18, 60, 0], [118, 1080, 0], [124, 60, 360], [93, 1080, 60]], 4, 0], [3]],
  ['control 2', [[[28, 1320, 1080], [123, 420, 1380], [9, 1380, 0]], 6, 359], []]],
 [['boundary: Monday morning after Sunday night window', [[[64, 1320, 360]], 0, 100], [0]],
  ['boundary: same-day window end minute', [[[127, 60, 360]], 3, 360], []],
  ['boundary: whole-day rule', [[[4, 420, 420]], 2, 5], [0]],
  ['regression: weekday bit order', [[[28, 420, 60], [26, 0, 1320]], 1, 1380], []],
  ['regression: weekday bit order (partial repair)',
   [[[7, 0, 0], [6, 360, 1380], [33, 1080, 420], [76, 0, 1080]], 6, 59], [2, 3]],
  ['control 1', [[[103, 0, 360], [65, 360, 1380], [37, 1080, 1080]], 4, 60], []],
  ['control 2', [[[52, 420, 1320], [97, 1080, 360]], 0, 0], [1]]],
 [['boundary: Monday morning after Sunday night window', [[[64, 1320, 360]], 0, 100], [0]],
  ['boundary: same-day window end minute', [[[127, 60, 360]], 3, 360], []],
  ['boundary: whole-day rule', [[[4, 420, 420]], 2, 5], [0]],
  ['regression: weekday bit order',
   [[[33, 1080, 420], [17, 360, 360], [101, 1380, 1380], [116, 1380, 1080]], 2, 1379], [2]],
  ['regression: weekday bit order (partial repair)',
   [[[124, 0, 0], [53, 1320, 360], [89, 60, 60]], 4, 30], [0, 2]],
  ['control 1', [[[105, 420, 360], [31, 1380, 1320], [47, 1080, 1320]], 4, 60], [0, 1]],
  ['control 2', [[[59, 360, 60], [45, 420, 60]], 5, 360], [0]]],
 [['boundary: Monday morning after Sunday night window', [[[64, 1320, 360]], 0, 100], [0]],
  ['boundary: same-day window end minute', [[[127, 60, 360]], 3, 360], []],
  ['boundary: whole-day rule', [[[4, 420, 420]], 2, 5], [0]],
  ['regression: weekday bit order', [[[51, 360, 1080], [116, 1320, 420]], 0, 60], [1]],
  ['regression: weekday bit order (partial repair)',
   [[[68, 1320, 360], [42, 360, 360], [95, 0, 360], [40, 1380, 60]], 0, 359], [0, 2]],
  ['control 1', [[[51, 360, 60], [78, 1080, 1080], [25, 1320, 360], [11, 360, 0]], 2, 1380], [1]],
  ['control 2', [[[16, 1380, 0]], 1, 360], []]]]
for label, args, expected in fixtures[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:
Weekday-only schedules allow charging on Sunday and not on Friday.

rules are [day_mask, start, end] with bit 0 = Monday .. bit 6 = Sunday. start < end is a same-day window [start, end); start == end means the whole selected day; start > end crosses midnight and belongs to its start day (Sunday continues into Monday). Return the sorted indices of rules allowing charging at (day 0..6, minute 0..1439).

split: open-access


prompt:
Friday-night windows do not continue into Saturday morning, but Saturday mornings open when only Saturday night is scheduled.

rules are [day_mask, start, end] with bit 0 = Monday .. bit 6 = Sunday. start < end is a same-day window [start, end); start == end means the whole selected day; start > end crosses midnight and belongs to its start day (Sunday continues into Monday). Return the sorted indices of rules allowing charging at (day 0..6, minute 0..1439).

split: open-access