FA-93066 / EV charging session scheduling / Open access
Round-robin port rotation: already-satisfied finish marker · case 01
Vehicles that needed no charge are reported as unfinished.
ROOT CAUSE
The finish map is initialized to None for every vehicle regardless of need.
VERIFIED REPAIR
Mark zero-need vehicles finished at slot 0.
Unsuccessful approach: Marking them finished at slot 1 claims a charging slot that never happened.
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: 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: already-satisfied finish marker', [[['V0', 2], ['V1', 0], ['V2', 3]], 3, 8, 1],
[[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]],
['regression: already-satisfied finish marker (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: already-satisfied finish marker',
[[['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: already-satisfied finish marker (partial repair)', [[['V0', 0]], 1, 9, 3],
[[[], [], [], [], [], [], [], [], []], [['V0', 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: already-satisfied finish marker', [[['V0', 2], ['V1', 0]], 2, 9, 3],
[[['V0'], ['V0'], [], [], [], [], [], [], []], [['V0', 2], ['V1', 0]]]],
['regression: already-satisfied finish marker (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: already-satisfied finish marker',
[[['V0', 2], ['V1', 6], ['V2', 1], ['V3', 0]], 3, 3, 3],
[[['V0', 'V1', 'V2'], ['V0', 'V1'], ['V1']], [['V0', 2], ['V1', None], ['V2', 1], ['V3', 0]]]],
['regression: already-satisfied finish marker (partial repair)',
[[['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]]]],
['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: already-satisfied finish marker',
[[['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: already-satisfied finish marker (partial repair)',
[[['V0', 6], ['V1', 5], ['V2', 1], ['V3', 0], ['V4', 5], ['V5', 3]], 1, 9, 2],
[[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V4'], ['V4'], ['V5'], ['V5']],
[['V0', None], ['V1', None], ['V2', 5], ['V3', 0], ['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', None], ['B', 2]]] | [[['B'], ['B'], []], [['A', 0], ['B', 2]]] | Failed |
| 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: already-satisfied finish marker | [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', None], ['V2', 3]]] | [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]] | Failed |
| regression: already-satisfied finish marker (partial repair) | [[['V0'], ['V1'], ['V3'], ['V4'], ['V0'], ['V1'], ['V3'], ['V4'], ['V0']], [['V0', None], ['V1', None], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]] | [[['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'], ['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 / 809e2d4699d1c64e0295024ea1d4db61b78dc21173281f1e72cad7cf99693863
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: (1 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: already-satisfied finish marker', [[['V0', 2], ['V1', 0], ['V2', 3]], 3, 8, 1],
[[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]],
['regression: already-satisfied finish marker (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: already-satisfied finish marker',
[[['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: already-satisfied finish marker (partial repair)', [[['V0', 0]], 1, 9, 3],
[[[], [], [], [], [], [], [], [], []], [['V0', 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: already-satisfied finish marker', [[['V0', 2], ['V1', 0]], 2, 9, 3],
[[['V0'], ['V0'], [], [], [], [], [], [], []], [['V0', 2], ['V1', 0]]]],
['regression: already-satisfied finish marker (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: already-satisfied finish marker',
[[['V0', 2], ['V1', 6], ['V2', 1], ['V3', 0]], 3, 3, 3],
[[['V0', 'V1', 'V2'], ['V0', 'V1'], ['V1']], [['V0', 2], ['V1', None], ['V2', 1], ['V3', 0]]]],
['regression: already-satisfied finish marker (partial repair)',
[[['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]]]],
['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: already-satisfied finish marker',
[[['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: already-satisfied finish marker (partial repair)',
[[['V0', 6], ['V1', 5], ['V2', 1], ['V3', 0], ['V4', 5], ['V5', 3]], 1, 9, 2],
[[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V4'], ['V4'], ['V5'], ['V5']],
[['V0', None], ['V1', None], ['V2', 5], ['V3', 0], ['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', 1], ['B', 2]]] | [[['B'], ['B'], []], [['A', 0], ['B', 2]]] | Failed |
| 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: already-satisfied finish marker | [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 1], ['V2', 3]]] | [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]] | Failed |
| regression: already-satisfied finish marker (partial repair) | [[['V0'], ['V1'], ['V3'], ['V4'], ['V0'], ['V1'], ['V3'], ['V4'], ['V0']], [['V0', None], ['V1', None], ['V2', 1], ['V3', None], ['V4', None], ['V5', 1]]] | [[['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'], ['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 / 375f6b1ea205669063a75c0b34248a59a586076c843dc402f81e177c9ede4faf
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: already-satisfied finish marker', [[['V0', 2], ['V1', 0], ['V2', 3]], 3, 8, 1],
[[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]],
['regression: already-satisfied finish marker (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: already-satisfied finish marker',
[[['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: already-satisfied finish marker (partial repair)', [[['V0', 0]], 1, 9, 3],
[[[], [], [], [], [], [], [], [], []], [['V0', 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: already-satisfied finish marker', [[['V0', 2], ['V1', 0]], 2, 9, 3],
[[['V0'], ['V0'], [], [], [], [], [], [], []], [['V0', 2], ['V1', 0]]]],
['regression: already-satisfied finish marker (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: already-satisfied finish marker',
[[['V0', 2], ['V1', 6], ['V2', 1], ['V3', 0]], 3, 3, 3],
[[['V0', 'V1', 'V2'], ['V0', 'V1'], ['V1']], [['V0', 2], ['V1', None], ['V2', 1], ['V3', 0]]]],
['regression: already-satisfied finish marker (partial repair)',
[[['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]]]],
['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: already-satisfied finish marker',
[[['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: already-satisfied finish marker (partial repair)',
[[['V0', 6], ['V1', 5], ['V2', 1], ['V3', 0], ['V4', 5], ['V5', 3]], 1, 9, 2],
[[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V4'], ['V4'], ['V5'], ['V5']],
[['V0', None], ['V1', None], ['V2', 5], ['V3', 0], ['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: already-satisfied finish marker | [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]] | [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]] | Passed |
| regression: already-satisfied finish marker (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 / 4aed84bc47ab1b789898b6ba155e4d40d4e21ced00614575c8a3d3490d3a0a11
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.678086+00:00.
Case digest / 74673d54f4c507aa3850b560b9147e8b5196edb9f5886ee6da7e5a1090c5db71