FA-93086 / EV charging session scheduling / Open access
Round-robin port rotation: port refill loop · case 01
Only one waiting vehicle is connected per slot even when several ports are free.
ROOT CAUSE
Port refill admits at most one vehicle per slot.
VERIFIED REPAIR
Keep admitting until every port is busy or the queue is empty.
Unsuccessful approach: Holding one port in reserve leaves capacity idle.
Case contract
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.
Why this case matters
Depot, workplace and public EV chargers schedule sessions against prices, circuit limits and departure deadlines; a wrong decision silently strands a driver or overloads a feeder.
1 / The failure
Exit 1"""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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| boundary: vehicle needing nothing | [[['B'], ['B'], []], [['A', 0], ['B', 2]]] | [[['B'], ['B'], []], [['A', 0], ['B', 2]]] | Passed |
| boundary: finishes exactly at quantum end | [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]] | [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]] | Passed |
| boundary: more ports than vehicles | [[['A'], ['A'], ['A'], []], [['A', 3]]] | [[['A'], ['A'], ['A'], []], [['A', 3]]] | Passed |
| regression: port refill loop | [[['V0'], ['V2'], ['V0'], ['V2'], ['V2'], [], [], []], [['V0', 3], ['V1', 0], ['V2', 5]]] | [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]] | Failed |
| regression: port refill loop (partial repair) | [[['V0'], ['V1'], ['V3'], ['V4'], ['V0'], ['V1'], ['V3'], ['V4'], ['V0']], [['V0', None], ['V1', None], ['V2', 0], ['V3', None], ['V4', None], ['V5', 0]]] | [[['V0'], ['V1'], ['V3'], ['V4'], ['V0'], ['V1'], ['V3'], ['V4'], ['V0']], [['V0', None], ['V1', None], ['V2', 0], ['V3', None], ['V4', None], ['V5', 0]]] | Passed |
| control 1 | [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']], [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]] | [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']], [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]] | Passed |
| control 2 | [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]] | [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]] | Passed |
SHA-256 / bf8e0bca8072d20ae1280f050a3f167284ce7dc156c662f81dd4d511350f7291
2 / The unsuccessful fix
Exit 1"""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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| boundary: vehicle needing nothing | [[[], [], []], [['A', 0], ['B', None]]] | [[['B'], ['B'], []], [['A', 0], ['B', 2]]] | Failed |
| boundary: finishes exactly at quantum end | [[[], [], [], [], []], [['A', None], ['B', None]]] | [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]] | Failed |
| boundary: more ports than vehicles | [[['A'], ['A'], ['A'], []], [['A', 3]]] | [[['A'], ['A'], ['A'], []], [['A', 3]]] | Passed |
| regression: port refill loop | [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]] | [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]] | Passed |
| regression: port refill loop (partial repair) | [[[], [], [], [], [], [], [], [], []], [['V0', None], ['V1', None], ['V2', 0], ['V3', None], ['V4', None], ['V5', 0]]] | [[['V0'], ['V1'], ['V3'], ['V4'], ['V0'], ['V1'], ['V3'], ['V4'], ['V0']], [['V0', None], ['V1', None], ['V2', 0], ['V3', None], ['V4', None], ['V5', 0]]] | Failed |
| control 1 | [[[], [], [], [], [], [], [], [], [], []], [['V0', None], ['V1', None], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]] | [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']], [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]] | Failed |
| control 2 | [[[], [], [], [], [], []], [['V0', None], ['V1', None], ['V2', None]]] | [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]] | Failed |
SHA-256 / cc5532df5a04008f887b8d7e903e9db76311d82da99ff8eb3b6a3198db22ee76
3 / The verified repair
Exit 0"""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.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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| boundary: vehicle needing nothing | [[['B'], ['B'], []], [['A', 0], ['B', 2]]] | [[['B'], ['B'], []], [['A', 0], ['B', 2]]] | Passed |
| boundary: finishes exactly at quantum end | [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]] | [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]] | Passed |
| boundary: more ports than vehicles | [[['A'], ['A'], ['A'], []], [['A', 3]]] | [[['A'], ['A'], ['A'], []], [['A', 3]]] | Passed |
| regression: port refill loop | [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]] | [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]] | Passed |
| regression: port refill loop (partial repair) | [[['V0'], ['V1'], ['V3'], ['V4'], ['V0'], ['V1'], ['V3'], ['V4'], ['V0']], [['V0', None], ['V1', None], ['V2', 0], ['V3', None], ['V4', None], ['V5', 0]]] | [[['V0'], ['V1'], ['V3'], ['V4'], ['V0'], ['V1'], ['V3'], ['V4'], ['V0']], [['V0', None], ['V1', None], ['V2', 0], ['V3', None], ['V4', None], ['V5', 0]]] | Passed |
| control 1 | [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']], [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]] | [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']], [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]] | Passed |
| control 2 | [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]] | [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]] | Passed |
SHA-256 / aa4f76fbc186b050a90ecd2197e11baa1b428400710755bbf45f166e9a4a2355
Verification & scope
Deterministic stipulated toy contract for teaching; no claim of conformance with any standard, vendor protocol or production controller. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:51:51.853019+00:00.
Case digest / d76f76a349c87e7b56eb80dd7b15eb2aadef351794a2d7261adf20ffd23522d3