FA-94091 / Shift rostering labor rules / Open access
Trainees counted as full heads · case 01
Slots staffed only by trainees appear fully covered.
ROOT CAUSE
Every role is weighted as a full head.
VERIFIED REPAIR
Trainees count as half a head.
Unsuccessful approach: Also halving supervisors undercounts qualified staff.
Case contract
Shifts [worker, role, start, end], a list of required headcount per slot and a slot length. A shift covers slot k only if it spans the whole slot [k*slot, (k+1)*slot). Coverage is counted in half-heads: trainees 1, staff and supervisors 2; a worker counts once per slot at their best role weight. Return [slot, have, need] (half-heads) for every understaffed slot.
Why this case matters
Coverage checks decide whether a roster meets minimum staffing ratios.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(shifts, need, slot):
out = []
for k, req in enumerate(need):
a, b = k * slot, (k + 1) * slot
seen = {}
for w, role, s, e in shifts:
if s <= a and e >= b:
seen[w] = max(seen.get(w, 0), 2)
have = sum(seen.values())
if have < 2 * req:
out.append([k, have, 2 * req])
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: trainee weight 1', [[['w1', 'supervisor', 0, 60], ['w2', 'trainee', 0, 60]], [2], 60],
[[0, 3, 4]]),
('regression variant: trainee weight 2',
[[['w1', 'staff', 180, 270], ['w2', 'supervisor', 0, 180], ['w1', 'trainee', 60, 300],
['w3', 'supervisor', 120, 210], ['w1', 'trainee', 60, 90], ['w2', 'supervisor', 180, 270]],
[2, 2, 2, 1], 60],
[[0, 2, 4], [1, 3, 4]]),
('partial repair guard 3',
[[['w2', 'staff', 180, 240], ['w1', 'staff', 30, 90], ['w3', 'supervisor', 60, 240]], [2, 2, 0], 60],
[[0, 0, 4], [1, 2, 4]]),
('boundary control 4', [[['w1', 'staff', 0, 120], ['w1', 'trainee', 0, 60]], [2, 1], 60], [[0, 2, 4]]),
('normal control 5',
[[['w1', 'supervisor', 0, 120], ['w3', 'trainee', 120, 240], ['w1', 'staff', 60, 150],
['w3', 'trainee', 0, 120], ['w2', 'supervisor', 60, 240], ['w1', 'staff', 60, 300],
['w1', 'staff', 30, 60]],
[1, 3, 2, 1, 3], 60],
[[1, 5, 6], [4, 2, 6]]),
('normal control 6',
[[['w2', 'staff', 60, 240], ['w1', 'staff', 90, 270], ['w2', 'supervisor', 30, 60],
['w4', 'supervisor', 30, 60]],
[1, 1, 3, 3], 60],
[[0, 0, 2], [2, 4, 6], [3, 4, 6]]),
('normal control 7',
[[['w3', 'staff', 30, 150], ['w3', 'trainee', 60, 150], ['w4', 'supervisor', 0, 30],
['w1', 'staff', 90, 270], ['w1', 'trainee', 90, 330], ['w4', 'staff', 30, 90],
['w1', 'supervisor', 180, 210]],
[1, 2, 0, 2], 60],
[[0, 0, 2], [1, 2, 4], [3, 2, 4]]),
('normal control 8', [[['w3', 'trainee', 90, 120], ['w3', 'staff', 120, 210]], [1, 2, 3, 0, 3], 60],
[[0, 0, 2], [1, 0, 4], [2, 2, 6], [4, 0, 6]])],
[('regression: trainee weight 1',
[[['w4', 'supervisor', 120, 360], ['w3', 'supervisor', 30, 270], ['w2', 'trainee', 120, 180],
['w2', 'trainee', 0, 120], ['w2', 'trainee', 180, 420], ['w3', 'trainee', 30, 210]],
[2, 1, 3, 3], 60],
[[0, 1, 4], [2, 5, 6], [3, 5, 6]]),
('regression variant: trainee weight 2',
[[['w2', 'staff', 90, 270], ['w4', 'trainee', 90, 270], ['w1', 'staff', 180, 420],
['w4', 'trainee', 90, 210], ['w1', 'supervisor', 180, 360], ['w3', 'staff', 60, 180],
['w2', 'trainee', 180, 360]],
[0, 0, 2, 0, 3], 60],
[[4, 3, 6]]),
('partial repair guard 3',
[[['w1', 'staff', 180, 270], ['w2', 'supervisor', 0, 180], ['w1', 'trainee', 60, 300],
['w3', 'supervisor', 120, 210], ['w1', 'trainee', 60, 90], ['w2', 'supervisor', 180, 270]],
[2, 2, 2, 1], 60],
[[0, 2, 4], [1, 3, 4]]),
('boundary control 4', [[['w1', 'staff', 30, 120]], [1, 1], 60], [[0, 0, 2]]),
('normal control 5',
[[['w3', 'staff', 0, 180], ['w1', 'staff', 60, 180], ['w1', 'trainee', 30, 270],
['w3', 'supervisor', 180, 240], ['w2', 'staff', 60, 180], ['w1', 'staff', 30, 120],
['w4', 'trainee', 0, 180]],
[0, 2, 2, 0], 60],
[]),
('normal control 6',
[[['w2', 'staff', 30, 60], ['w3', 'staff', 120, 210], ['w3', 'staff', 60, 300], ['w3', 'staff', 120, 360],
['w1', 'supervisor', 120, 240]],
[3, 0, 3, 0, 3], 60],
[[0, 0, 6], [2, 4, 6], [4, 2, 6]]),
('normal control 7',
[[['w2', 'staff', 30, 270], ['w3', 'staff', 90, 180], ['w3', 'staff', 180, 420], ['w4', 'staff', 120, 300],
['w1', 'staff', 120, 180]],
[0, 0, 2, 0], 60],
[]),
('normal control 8',
[[['w3', 'staff', 60, 300], ['w4', 'supervisor', 180, 210], ['w4', 'staff', 120, 180],
['w1', 'staff', 30, 270], ['w1', 'supervisor', 180, 240]],
[2, 0, 2, 1, 1, 0], 60],
[[0, 0, 4]])],
[('regression: trainee weight 1',
[[['w3', 'staff', 120, 240], ['w4', 'supervisor', 90, 330], ['w2', 'staff', 60, 150],
['w1', 'staff', 180, 270], ['w1', 'trainee', 90, 180], ['w1', 'staff', 30, 90]],
[1, 3, 3], 60],
[[0, 0, 2], [1, 2, 6], [2, 5, 6]]),
('regression variant: trainee weight 2',
[[['w2', 'trainee', 0, 60], ['w2', 'staff', 30, 120], ['w4', 'supervisor', 0, 90],
['w1', 'supervisor', 0, 90], ['w3', 'staff', 120, 300], ['w2', 'staff', 180, 360],
['w4', 'supervisor', 0, 60]],
[3, 3, 2, 0, 3, 0], 60],
[[0, 5, 6], [1, 2, 6], [2, 2, 4], [4, 4, 6]]),
('partial repair guard 3',
[[['w1', 'staff', 180, 210], ['w4', 'staff', 60, 300], ['w2', 'trainee', 120, 180],
['w4', 'staff', 180, 360], ['w4', 'supervisor', 30, 210], ['w2', 'supervisor', 60, 180]],
[3, 1, 2, 3, 3, 1], 60],
[[0, 0, 6], [3, 2, 6], [4, 2, 6]]),
('boundary control 4', [[['w1', 'supervisor', 0, 60], ['w2', 'trainee', 0, 60]], [2], 60], [[0, 3, 4]]),
('normal control 5',
[[['w3', 'trainee', 120, 360], ['w2', 'staff', 30, 150], ['w4', 'trainee', 0, 180]], [1, 0, 2, 3, 1, 1],
60],
[[0, 1, 2], [2, 2, 4], [3, 1, 6], [4, 1, 2], [5, 1, 2]]),
('normal control 6',
[[['w1', 'staff', 120, 210], ['w4', 'staff', 60, 240], ['w1', 'trainee', 60, 120],
['w3', 'trainee', 60, 300], ['w4', 'staff', 180, 360]],
[1, 3, 1, 1, 0], 60],
[[0, 0, 2], [1, 4, 6]]),
('normal control 7',
[[['w2', 'supervisor', 120, 150], ['w2', 'staff', 60, 150], ['w3', 'supervisor', 180, 270],
['w4', 'trainee', 90, 120], ['w2', 'trainee', 60, 150], ['w1', 'supervisor', 30, 210]],
[3, 3, 1, 2, 3, 0], 60],
[[0, 0, 6], [1, 4, 6], [3, 2, 4], [4, 0, 6]]),
('normal control 8',
[[['w1', 'supervisor', 90, 270], ['w1', 'staff', 0, 60], ['w4', 'staff', 180, 360],
['w4', 'supervisor', 90, 210], ['w3', 'staff', 120, 240], ['w1', 'staff', 0, 60]],
[3, 3, 2], 60],
[[0, 2, 6], [1, 0, 6]])],
[('regression: trainee weight 1',
[[['w2', 'trainee', 0, 90], ['w3', 'trainee', 120, 240], ['w4', 'staff', 0, 90],
['w3', 'supervisor', 0, 180], ['w3', 'supervisor', 120, 180], ['w4', 'staff', 120, 360]],
[1, 3, 2, 3, 3, 2], 60],
[[1, 2, 6], [3, 3, 6], [4, 2, 6], [5, 2, 4]]),
('regression variant: trainee weight 2',
[[['w2', 'staff', 30, 210], ['w1', 'trainee', 0, 240], ['w2', 'staff', 30, 120], ['w4', 'staff', 60, 300]],
[2, 3, 1], 60],
[[0, 1, 4], [1, 5, 6]]),
('partial repair guard 3',
[[['w4', 'trainee', 180, 270], ['w1', 'supervisor', 90, 180], ['w3', 'staff', 0, 90]], [2, 2, 3], 60],
[[0, 2, 4], [1, 0, 4], [2, 2, 6]]),
('boundary control 4', [[['w1', 'trainee', 0, 60], ['w2', 'trainee', 0, 60]], [1], 60], []),
('normal control 5',
[[['w3', 'staff', 30, 210], ['w4', 'trainee', 30, 210], ['w3', 'trainee', 90, 180],
['w1', 'staff', 0, 90]],
[0, 1, 1, 2], 60],
[[3, 0, 4]]),
('normal control 6',
[[['w3', 'staff', 60, 300], ['w4', 'supervisor', 180, 210], ['w4', 'staff', 120, 180],
['w1', 'staff', 30, 270], ['w1', 'supervisor', 180, 240]],
[2, 0, 2, 1, 1, 0], 60],
[[0, 0, 4]]),
('normal control 7',
[[['w4', 'staff', 0, 60], ['w4', 'staff', 60, 90], ['w2', 'trainee', 60, 240], ['w1', 'staff', 60, 90],
['w4', 'supervisor', 0, 90], ['w3', 'staff', 30, 120], ['w1', 'trainee', 180, 360]],
[3, 3, 0], 60],
[[0, 2, 6], [1, 3, 6]]),
('normal control 8', [[['w2', 'supervisor', 0, 240], ['w3', 'supervisor', 90, 180]], [2, 0, 0], 60],
[[0, 2, 4]])],
[('regression: trainee weight 1',
[[['w4', 'trainee', 60, 240], ['w4', 'staff', 90, 120], ['w4', 'staff', 120, 240],
['w1', 'staff', 120, 240]],
[3, 1, 0, 2, 0], 60],
[[0, 0, 6], [1, 1, 2]]),
('regression variant: trainee weight 2',
[[['w4', 'supervisor', 180, 360], ['w1', 'staff', 180, 360], ['w3', 'supervisor', 60, 150],
['w2', 'staff', 180, 240], ['w3', 'staff', 30, 270], ['w4', 'trainee', 0, 90],
['w4', 'supervisor', 120, 300]],
[3, 1, 3, 0], 60],
[[0, 1, 6], [2, 4, 6]]),
('partial repair guard 3',
[[['w3', 'staff', 30, 270], ['w4', 'supervisor', 90, 210], ['w3', 'trainee', 60, 300],
['w4', 'trainee', 90, 150]],
[1, 0, 2, 3, 0], 60],
[[0, 0, 2], [3, 2, 6]]),
('boundary control 4', [[['w1', 'staff', 0, 60]], [1, 1], 60], [[1, 0, 2]]),
('normal control 5',
[[['w4', 'staff', 0, 30], ['w2', 'staff', 90, 210], ['w1', 'trainee', 30, 60], ['w3', 'staff', 120, 300],
['w2', 'supervisor', 90, 270], ['w2', 'trainee', 30, 150]],
[0, 0, 2, 1], 60],
[]),
('normal control 6',
[[['w2', 'staff', 90, 210], ['w1', 'supervisor', 60, 300], ['w1', 'staff', 60, 90],
['w4', 'staff', 180, 270], ['w4', 'staff', 30, 210]],
[2, 0, 0, 0], 60],
[[0, 0, 4]]),
('normal control 7',
[[['w4', 'supervisor', 180, 420], ['w4', 'trainee', 90, 270], ['w3', 'staff', 30, 90],
['w3', 'staff', 30, 270], ['w1', 'supervisor', 60, 300]],
[1, 3, 2], 60],
[[0, 0, 2], [1, 4, 6]]),
('normal control 8',
[[['w3', 'staff', 30, 210], ['w4', 'trainee', 30, 210], ['w3', 'trainee', 90, 180],
['w1', 'staff', 0, 90]],
[0, 1, 1, 2], 60],
[[3, 0, 4]])]]
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 |
|---|---|---|---|
| regression: trainee weight 1 | [] | [[0, 3, 4]] | Failed |
| regression variant: trainee weight 2 | [[0, 2, 4]] | [[0, 2, 4], [1, 3, 4]] | Failed |
| partial repair guard 3 | [[0, 0, 4], [1, 2, 4]] | [[0, 0, 4], [1, 2, 4]] | Passed |
| boundary control 4 | [[0, 2, 4]] | [[0, 2, 4]] | Passed |
| normal control 5 | [[4, 2, 6]] | [[1, 5, 6], [4, 2, 6]] | Failed |
| normal control 6 | [[0, 0, 2], [2, 4, 6], [3, 4, 6]] | [[0, 0, 2], [2, 4, 6], [3, 4, 6]] | Passed |
| normal control 7 | [[0, 0, 2], [1, 2, 4], [3, 2, 4]] | [[0, 0, 2], [1, 2, 4], [3, 2, 4]] | Passed |
| normal control 8 | [[0, 0, 2], [1, 0, 4], [2, 2, 6], [4, 0, 6]] | [[0, 0, 2], [1, 0, 4], [2, 2, 6], [4, 0, 6]] | Passed |
SHA-256 / c2ae2db900311b5a13b1bfa5d5ab9f344cf6d36fc03a0b310114cbb76a9ce3a5
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(shifts, need, slot):
out = []
for k, req in enumerate(need):
a, b = k * slot, (k + 1) * slot
seen = {}
for w, role, s, e in shifts:
if s <= a and e >= b:
seen[w] = max(seen.get(w, 0), 1 if role != 'staff' else 2)
have = sum(seen.values())
if have < 2 * req:
out.append([k, have, 2 * req])
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: trainee weight 1', [[['w1', 'supervisor', 0, 60], ['w2', 'trainee', 0, 60]], [2], 60],
[[0, 3, 4]]),
('regression variant: trainee weight 2',
[[['w1', 'staff', 180, 270], ['w2', 'supervisor', 0, 180], ['w1', 'trainee', 60, 300],
['w3', 'supervisor', 120, 210], ['w1', 'trainee', 60, 90], ['w2', 'supervisor', 180, 270]],
[2, 2, 2, 1], 60],
[[0, 2, 4], [1, 3, 4]]),
('partial repair guard 3',
[[['w2', 'staff', 180, 240], ['w1', 'staff', 30, 90], ['w3', 'supervisor', 60, 240]], [2, 2, 0], 60],
[[0, 0, 4], [1, 2, 4]]),
('boundary control 4', [[['w1', 'staff', 0, 120], ['w1', 'trainee', 0, 60]], [2, 1], 60], [[0, 2, 4]]),
('normal control 5',
[[['w1', 'supervisor', 0, 120], ['w3', 'trainee', 120, 240], ['w1', 'staff', 60, 150],
['w3', 'trainee', 0, 120], ['w2', 'supervisor', 60, 240], ['w1', 'staff', 60, 300],
['w1', 'staff', 30, 60]],
[1, 3, 2, 1, 3], 60],
[[1, 5, 6], [4, 2, 6]]),
('normal control 6',
[[['w2', 'staff', 60, 240], ['w1', 'staff', 90, 270], ['w2', 'supervisor', 30, 60],
['w4', 'supervisor', 30, 60]],
[1, 1, 3, 3], 60],
[[0, 0, 2], [2, 4, 6], [3, 4, 6]]),
('normal control 7',
[[['w3', 'staff', 30, 150], ['w3', 'trainee', 60, 150], ['w4', 'supervisor', 0, 30],
['w1', 'staff', 90, 270], ['w1', 'trainee', 90, 330], ['w4', 'staff', 30, 90],
['w1', 'supervisor', 180, 210]],
[1, 2, 0, 2], 60],
[[0, 0, 2], [1, 2, 4], [3, 2, 4]]),
('normal control 8', [[['w3', 'trainee', 90, 120], ['w3', 'staff', 120, 210]], [1, 2, 3, 0, 3], 60],
[[0, 0, 2], [1, 0, 4], [2, 2, 6], [4, 0, 6]])],
[('regression: trainee weight 1',
[[['w4', 'supervisor', 120, 360], ['w3', 'supervisor', 30, 270], ['w2', 'trainee', 120, 180],
['w2', 'trainee', 0, 120], ['w2', 'trainee', 180, 420], ['w3', 'trainee', 30, 210]],
[2, 1, 3, 3], 60],
[[0, 1, 4], [2, 5, 6], [3, 5, 6]]),
('regression variant: trainee weight 2',
[[['w2', 'staff', 90, 270], ['w4', 'trainee', 90, 270], ['w1', 'staff', 180, 420],
['w4', 'trainee', 90, 210], ['w1', 'supervisor', 180, 360], ['w3', 'staff', 60, 180],
['w2', 'trainee', 180, 360]],
[0, 0, 2, 0, 3], 60],
[[4, 3, 6]]),
('partial repair guard 3',
[[['w1', 'staff', 180, 270], ['w2', 'supervisor', 0, 180], ['w1', 'trainee', 60, 300],
['w3', 'supervisor', 120, 210], ['w1', 'trainee', 60, 90], ['w2', 'supervisor', 180, 270]],
[2, 2, 2, 1], 60],
[[0, 2, 4], [1, 3, 4]]),
('boundary control 4', [[['w1', 'staff', 30, 120]], [1, 1], 60], [[0, 0, 2]]),
('normal control 5',
[[['w3', 'staff', 0, 180], ['w1', 'staff', 60, 180], ['w1', 'trainee', 30, 270],
['w3', 'supervisor', 180, 240], ['w2', 'staff', 60, 180], ['w1', 'staff', 30, 120],
['w4', 'trainee', 0, 180]],
[0, 2, 2, 0], 60],
[]),
('normal control 6',
[[['w2', 'staff', 30, 60], ['w3', 'staff', 120, 210], ['w3', 'staff', 60, 300], ['w3', 'staff', 120, 360],
['w1', 'supervisor', 120, 240]],
[3, 0, 3, 0, 3], 60],
[[0, 0, 6], [2, 4, 6], [4, 2, 6]]),
('normal control 7',
[[['w2', 'staff', 30, 270], ['w3', 'staff', 90, 180], ['w3', 'staff', 180, 420], ['w4', 'staff', 120, 300],
['w1', 'staff', 120, 180]],
[0, 0, 2, 0], 60],
[]),
('normal control 8',
[[['w3', 'staff', 60, 300], ['w4', 'supervisor', 180, 210], ['w4', 'staff', 120, 180],
['w1', 'staff', 30, 270], ['w1', 'supervisor', 180, 240]],
[2, 0, 2, 1, 1, 0], 60],
[[0, 0, 4]])],
[('regression: trainee weight 1',
[[['w3', 'staff', 120, 240], ['w4', 'supervisor', 90, 330], ['w2', 'staff', 60, 150],
['w1', 'staff', 180, 270], ['w1', 'trainee', 90, 180], ['w1', 'staff', 30, 90]],
[1, 3, 3], 60],
[[0, 0, 2], [1, 2, 6], [2, 5, 6]]),
('regression variant: trainee weight 2',
[[['w2', 'trainee', 0, 60], ['w2', 'staff', 30, 120], ['w4', 'supervisor', 0, 90],
['w1', 'supervisor', 0, 90], ['w3', 'staff', 120, 300], ['w2', 'staff', 180, 360],
['w4', 'supervisor', 0, 60]],
[3, 3, 2, 0, 3, 0], 60],
[[0, 5, 6], [1, 2, 6], [2, 2, 4], [4, 4, 6]]),
('partial repair guard 3',
[[['w1', 'staff', 180, 210], ['w4', 'staff', 60, 300], ['w2', 'trainee', 120, 180],
['w4', 'staff', 180, 360], ['w4', 'supervisor', 30, 210], ['w2', 'supervisor', 60, 180]],
[3, 1, 2, 3, 3, 1], 60],
[[0, 0, 6], [3, 2, 6], [4, 2, 6]]),
('boundary control 4', [[['w1', 'supervisor', 0, 60], ['w2', 'trainee', 0, 60]], [2], 60], [[0, 3, 4]]),
('normal control 5',
[[['w3', 'trainee', 120, 360], ['w2', 'staff', 30, 150], ['w4', 'trainee', 0, 180]], [1, 0, 2, 3, 1, 1],
60],
[[0, 1, 2], [2, 2, 4], [3, 1, 6], [4, 1, 2], [5, 1, 2]]),
('normal control 6',
[[['w1', 'staff', 120, 210], ['w4', 'staff', 60, 240], ['w1', 'trainee', 60, 120],
['w3', 'trainee', 60, 300], ['w4', 'staff', 180, 360]],
[1, 3, 1, 1, 0], 60],
[[0, 0, 2], [1, 4, 6]]),
('normal control 7',
[[['w2', 'supervisor', 120, 150], ['w2', 'staff', 60, 150], ['w3', 'supervisor', 180, 270],
['w4', 'trainee', 90, 120], ['w2', 'trainee', 60, 150], ['w1', 'supervisor', 30, 210]],
[3, 3, 1, 2, 3, 0], 60],
[[0, 0, 6], [1, 4, 6], [3, 2, 4], [4, 0, 6]]),
('normal control 8',
[[['w1', 'supervisor', 90, 270], ['w1', 'staff', 0, 60], ['w4', 'staff', 180, 360],
['w4', 'supervisor', 90, 210], ['w3', 'staff', 120, 240], ['w1', 'staff', 0, 60]],
[3, 3, 2], 60],
[[0, 2, 6], [1, 0, 6]])],
[('regression: trainee weight 1',
[[['w2', 'trainee', 0, 90], ['w3', 'trainee', 120, 240], ['w4', 'staff', 0, 90],
['w3', 'supervisor', 0, 180], ['w3', 'supervisor', 120, 180], ['w4', 'staff', 120, 360]],
[1, 3, 2, 3, 3, 2], 60],
[[1, 2, 6], [3, 3, 6], [4, 2, 6], [5, 2, 4]]),
('regression variant: trainee weight 2',
[[['w2', 'staff', 30, 210], ['w1', 'trainee', 0, 240], ['w2', 'staff', 30, 120], ['w4', 'staff', 60, 300]],
[2, 3, 1], 60],
[[0, 1, 4], [1, 5, 6]]),
('partial repair guard 3',
[[['w4', 'trainee', 180, 270], ['w1', 'supervisor', 90, 180], ['w3', 'staff', 0, 90]], [2, 2, 3], 60],
[[0, 2, 4], [1, 0, 4], [2, 2, 6]]),
('boundary control 4', [[['w1', 'trainee', 0, 60], ['w2', 'trainee', 0, 60]], [1], 60], []),
('normal control 5',
[[['w3', 'staff', 30, 210], ['w4', 'trainee', 30, 210], ['w3', 'trainee', 90, 180],
['w1', 'staff', 0, 90]],
[0, 1, 1, 2], 60],
[[3, 0, 4]]),
('normal control 6',
[[['w3', 'staff', 60, 300], ['w4', 'supervisor', 180, 210], ['w4', 'staff', 120, 180],
['w1', 'staff', 30, 270], ['w1', 'supervisor', 180, 240]],
[2, 0, 2, 1, 1, 0], 60],
[[0, 0, 4]]),
('normal control 7',
[[['w4', 'staff', 0, 60], ['w4', 'staff', 60, 90], ['w2', 'trainee', 60, 240], ['w1', 'staff', 60, 90],
['w4', 'supervisor', 0, 90], ['w3', 'staff', 30, 120], ['w1', 'trainee', 180, 360]],
[3, 3, 0], 60],
[[0, 2, 6], [1, 3, 6]]),
('normal control 8', [[['w2', 'supervisor', 0, 240], ['w3', 'supervisor', 90, 180]], [2, 0, 0], 60],
[[0, 2, 4]])],
[('regression: trainee weight 1',
[[['w4', 'trainee', 60, 240], ['w4', 'staff', 90, 120], ['w4', 'staff', 120, 240],
['w1', 'staff', 120, 240]],
[3, 1, 0, 2, 0], 60],
[[0, 0, 6], [1, 1, 2]]),
('regression variant: trainee weight 2',
[[['w4', 'supervisor', 180, 360], ['w1', 'staff', 180, 360], ['w3', 'supervisor', 60, 150],
['w2', 'staff', 180, 240], ['w3', 'staff', 30, 270], ['w4', 'trainee', 0, 90],
['w4', 'supervisor', 120, 300]],
[3, 1, 3, 0], 60],
[[0, 1, 6], [2, 4, 6]]),
('partial repair guard 3',
[[['w3', 'staff', 30, 270], ['w4', 'supervisor', 90, 210], ['w3', 'trainee', 60, 300],
['w4', 'trainee', 90, 150]],
[1, 0, 2, 3, 0], 60],
[[0, 0, 2], [3, 2, 6]]),
('boundary control 4', [[['w1', 'staff', 0, 60]], [1, 1], 60], [[1, 0, 2]]),
('normal control 5',
[[['w4', 'staff', 0, 30], ['w2', 'staff', 90, 210], ['w1', 'trainee', 30, 60], ['w3', 'staff', 120, 300],
['w2', 'supervisor', 90, 270], ['w2', 'trainee', 30, 150]],
[0, 0, 2, 1], 60],
[]),
('normal control 6',
[[['w2', 'staff', 90, 210], ['w1', 'supervisor', 60, 300], ['w1', 'staff', 60, 90],
['w4', 'staff', 180, 270], ['w4', 'staff', 30, 210]],
[2, 0, 0, 0], 60],
[[0, 0, 4]]),
('normal control 7',
[[['w4', 'supervisor', 180, 420], ['w4', 'trainee', 90, 270], ['w3', 'staff', 30, 90],
['w3', 'staff', 30, 270], ['w1', 'supervisor', 60, 300]],
[1, 3, 2], 60],
[[0, 0, 2], [1, 4, 6]]),
('normal control 8',
[[['w3', 'staff', 30, 210], ['w4', 'trainee', 30, 210], ['w3', 'trainee', 90, 180],
['w1', 'staff', 0, 90]],
[0, 1, 1, 2], 60],
[[3, 0, 4]])]]
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 |
|---|---|---|---|
| regression: trainee weight 1 | [[0, 2, 4]] | [[0, 3, 4]] | Failed |
| regression variant: trainee weight 2 | [[0, 1, 4], [1, 2, 4], [2, 3, 4]] | [[0, 2, 4], [1, 3, 4]] | Failed |
| partial repair guard 3 | [[0, 0, 4], [1, 1, 4]] | [[0, 0, 4], [1, 2, 4]] | Failed |
| boundary control 4 | [[0, 2, 4]] | [[0, 2, 4]] | Passed |
| normal control 5 | [[1, 4, 6], [4, 2, 6]] | [[1, 5, 6], [4, 2, 6]] | Failed |
| normal control 6 | [[0, 0, 2], [2, 4, 6], [3, 4, 6]] | [[0, 0, 2], [2, 4, 6], [3, 4, 6]] | Passed |
| normal control 7 | [[0, 0, 2], [1, 2, 4], [3, 2, 4]] | [[0, 0, 2], [1, 2, 4], [3, 2, 4]] | Passed |
| normal control 8 | [[0, 0, 2], [1, 0, 4], [2, 2, 6], [4, 0, 6]] | [[0, 0, 2], [1, 0, 4], [2, 2, 6], [4, 0, 6]] | Passed |
SHA-256 / 7d3fc891bd62236efb12b18895374e114846af1e457a7425e7653d3cd7e4c5fd
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(shifts, need, slot):
out = []
for k, req in enumerate(need):
a, b = k * slot, (k + 1) * slot
seen = {}
for w, role, s, e in shifts:
if s <= a and e >= b:
seen[w] = max(seen.get(w, 0), 1 if role == 'trainee' else 2)
have = sum(seen.values())
if have < 2 * req:
out.append([k, have, 2 * req])
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: trainee weight 1', [[['w1', 'supervisor', 0, 60], ['w2', 'trainee', 0, 60]], [2], 60],
[[0, 3, 4]]),
('regression variant: trainee weight 2',
[[['w1', 'staff', 180, 270], ['w2', 'supervisor', 0, 180], ['w1', 'trainee', 60, 300],
['w3', 'supervisor', 120, 210], ['w1', 'trainee', 60, 90], ['w2', 'supervisor', 180, 270]],
[2, 2, 2, 1], 60],
[[0, 2, 4], [1, 3, 4]]),
('partial repair guard 3',
[[['w2', 'staff', 180, 240], ['w1', 'staff', 30, 90], ['w3', 'supervisor', 60, 240]], [2, 2, 0], 60],
[[0, 0, 4], [1, 2, 4]]),
('boundary control 4', [[['w1', 'staff', 0, 120], ['w1', 'trainee', 0, 60]], [2, 1], 60], [[0, 2, 4]]),
('normal control 5',
[[['w1', 'supervisor', 0, 120], ['w3', 'trainee', 120, 240], ['w1', 'staff', 60, 150],
['w3', 'trainee', 0, 120], ['w2', 'supervisor', 60, 240], ['w1', 'staff', 60, 300],
['w1', 'staff', 30, 60]],
[1, 3, 2, 1, 3], 60],
[[1, 5, 6], [4, 2, 6]]),
('normal control 6',
[[['w2', 'staff', 60, 240], ['w1', 'staff', 90, 270], ['w2', 'supervisor', 30, 60],
['w4', 'supervisor', 30, 60]],
[1, 1, 3, 3], 60],
[[0, 0, 2], [2, 4, 6], [3, 4, 6]]),
('normal control 7',
[[['w3', 'staff', 30, 150], ['w3', 'trainee', 60, 150], ['w4', 'supervisor', 0, 30],
['w1', 'staff', 90, 270], ['w1', 'trainee', 90, 330], ['w4', 'staff', 30, 90],
['w1', 'supervisor', 180, 210]],
[1, 2, 0, 2], 60],
[[0, 0, 2], [1, 2, 4], [3, 2, 4]]),
('normal control 8', [[['w3', 'trainee', 90, 120], ['w3', 'staff', 120, 210]], [1, 2, 3, 0, 3], 60],
[[0, 0, 2], [1, 0, 4], [2, 2, 6], [4, 0, 6]])],
[('regression: trainee weight 1',
[[['w4', 'supervisor', 120, 360], ['w3', 'supervisor', 30, 270], ['w2', 'trainee', 120, 180],
['w2', 'trainee', 0, 120], ['w2', 'trainee', 180, 420], ['w3', 'trainee', 30, 210]],
[2, 1, 3, 3], 60],
[[0, 1, 4], [2, 5, 6], [3, 5, 6]]),
('regression variant: trainee weight 2',
[[['w2', 'staff', 90, 270], ['w4', 'trainee', 90, 270], ['w1', 'staff', 180, 420],
['w4', 'trainee', 90, 210], ['w1', 'supervisor', 180, 360], ['w3', 'staff', 60, 180],
['w2', 'trainee', 180, 360]],
[0, 0, 2, 0, 3], 60],
[[4, 3, 6]]),
('partial repair guard 3',
[[['w1', 'staff', 180, 270], ['w2', 'supervisor', 0, 180], ['w1', 'trainee', 60, 300],
['w3', 'supervisor', 120, 210], ['w1', 'trainee', 60, 90], ['w2', 'supervisor', 180, 270]],
[2, 2, 2, 1], 60],
[[0, 2, 4], [1, 3, 4]]),
('boundary control 4', [[['w1', 'staff', 30, 120]], [1, 1], 60], [[0, 0, 2]]),
('normal control 5',
[[['w3', 'staff', 0, 180], ['w1', 'staff', 60, 180], ['w1', 'trainee', 30, 270],
['w3', 'supervisor', 180, 240], ['w2', 'staff', 60, 180], ['w1', 'staff', 30, 120],
['w4', 'trainee', 0, 180]],
[0, 2, 2, 0], 60],
[]),
('normal control 6',
[[['w2', 'staff', 30, 60], ['w3', 'staff', 120, 210], ['w3', 'staff', 60, 300], ['w3', 'staff', 120, 360],
['w1', 'supervisor', 120, 240]],
[3, 0, 3, 0, 3], 60],
[[0, 0, 6], [2, 4, 6], [4, 2, 6]]),
('normal control 7',
[[['w2', 'staff', 30, 270], ['w3', 'staff', 90, 180], ['w3', 'staff', 180, 420], ['w4', 'staff', 120, 300],
['w1', 'staff', 120, 180]],
[0, 0, 2, 0], 60],
[]),
('normal control 8',
[[['w3', 'staff', 60, 300], ['w4', 'supervisor', 180, 210], ['w4', 'staff', 120, 180],
['w1', 'staff', 30, 270], ['w1', 'supervisor', 180, 240]],
[2, 0, 2, 1, 1, 0], 60],
[[0, 0, 4]])],
[('regression: trainee weight 1',
[[['w3', 'staff', 120, 240], ['w4', 'supervisor', 90, 330], ['w2', 'staff', 60, 150],
['w1', 'staff', 180, 270], ['w1', 'trainee', 90, 180], ['w1', 'staff', 30, 90]],
[1, 3, 3], 60],
[[0, 0, 2], [1, 2, 6], [2, 5, 6]]),
('regression variant: trainee weight 2',
[[['w2', 'trainee', 0, 60], ['w2', 'staff', 30, 120], ['w4', 'supervisor', 0, 90],
['w1', 'supervisor', 0, 90], ['w3', 'staff', 120, 300], ['w2', 'staff', 180, 360],
['w4', 'supervisor', 0, 60]],
[3, 3, 2, 0, 3, 0], 60],
[[0, 5, 6], [1, 2, 6], [2, 2, 4], [4, 4, 6]]),
('partial repair guard 3',
[[['w1', 'staff', 180, 210], ['w4', 'staff', 60, 300], ['w2', 'trainee', 120, 180],
['w4', 'staff', 180, 360], ['w4', 'supervisor', 30, 210], ['w2', 'supervisor', 60, 180]],
[3, 1, 2, 3, 3, 1], 60],
[[0, 0, 6], [3, 2, 6], [4, 2, 6]]),
('boundary control 4', [[['w1', 'supervisor', 0, 60], ['w2', 'trainee', 0, 60]], [2], 60], [[0, 3, 4]]),
('normal control 5',
[[['w3', 'trainee', 120, 360], ['w2', 'staff', 30, 150], ['w4', 'trainee', 0, 180]], [1, 0, 2, 3, 1, 1],
60],
[[0, 1, 2], [2, 2, 4], [3, 1, 6], [4, 1, 2], [5, 1, 2]]),
('normal control 6',
[[['w1', 'staff', 120, 210], ['w4', 'staff', 60, 240], ['w1', 'trainee', 60, 120],
['w3', 'trainee', 60, 300], ['w4', 'staff', 180, 360]],
[1, 3, 1, 1, 0], 60],
[[0, 0, 2], [1, 4, 6]]),
('normal control 7',
[[['w2', 'supervisor', 120, 150], ['w2', 'staff', 60, 150], ['w3', 'supervisor', 180, 270],
['w4', 'trainee', 90, 120], ['w2', 'trainee', 60, 150], ['w1', 'supervisor', 30, 210]],
[3, 3, 1, 2, 3, 0], 60],
[[0, 0, 6], [1, 4, 6], [3, 2, 4], [4, 0, 6]]),
('normal control 8',
[[['w1', 'supervisor', 90, 270], ['w1', 'staff', 0, 60], ['w4', 'staff', 180, 360],
['w4', 'supervisor', 90, 210], ['w3', 'staff', 120, 240], ['w1', 'staff', 0, 60]],
[3, 3, 2], 60],
[[0, 2, 6], [1, 0, 6]])],
[('regression: trainee weight 1',
[[['w2', 'trainee', 0, 90], ['w3', 'trainee', 120, 240], ['w4', 'staff', 0, 90],
['w3', 'supervisor', 0, 180], ['w3', 'supervisor', 120, 180], ['w4', 'staff', 120, 360]],
[1, 3, 2, 3, 3, 2], 60],
[[1, 2, 6], [3, 3, 6], [4, 2, 6], [5, 2, 4]]),
('regression variant: trainee weight 2',
[[['w2', 'staff', 30, 210], ['w1', 'trainee', 0, 240], ['w2', 'staff', 30, 120], ['w4', 'staff', 60, 300]],
[2, 3, 1], 60],
[[0, 1, 4], [1, 5, 6]]),
('partial repair guard 3',
[[['w4', 'trainee', 180, 270], ['w1', 'supervisor', 90, 180], ['w3', 'staff', 0, 90]], [2, 2, 3], 60],
[[0, 2, 4], [1, 0, 4], [2, 2, 6]]),
('boundary control 4', [[['w1', 'trainee', 0, 60], ['w2', 'trainee', 0, 60]], [1], 60], []),
('normal control 5',
[[['w3', 'staff', 30, 210], ['w4', 'trainee', 30, 210], ['w3', 'trainee', 90, 180],
['w1', 'staff', 0, 90]],
[0, 1, 1, 2], 60],
[[3, 0, 4]]),
('normal control 6',
[[['w3', 'staff', 60, 300], ['w4', 'supervisor', 180, 210], ['w4', 'staff', 120, 180],
['w1', 'staff', 30, 270], ['w1', 'supervisor', 180, 240]],
[2, 0, 2, 1, 1, 0], 60],
[[0, 0, 4]]),
('normal control 7',
[[['w4', 'staff', 0, 60], ['w4', 'staff', 60, 90], ['w2', 'trainee', 60, 240], ['w1', 'staff', 60, 90],
['w4', 'supervisor', 0, 90], ['w3', 'staff', 30, 120], ['w1', 'trainee', 180, 360]],
[3, 3, 0], 60],
[[0, 2, 6], [1, 3, 6]]),
('normal control 8', [[['w2', 'supervisor', 0, 240], ['w3', 'supervisor', 90, 180]], [2, 0, 0], 60],
[[0, 2, 4]])],
[('regression: trainee weight 1',
[[['w4', 'trainee', 60, 240], ['w4', 'staff', 90, 120], ['w4', 'staff', 120, 240],
['w1', 'staff', 120, 240]],
[3, 1, 0, 2, 0], 60],
[[0, 0, 6], [1, 1, 2]]),
('regression variant: trainee weight 2',
[[['w4', 'supervisor', 180, 360], ['w1', 'staff', 180, 360], ['w3', 'supervisor', 60, 150],
['w2', 'staff', 180, 240], ['w3', 'staff', 30, 270], ['w4', 'trainee', 0, 90],
['w4', 'supervisor', 120, 300]],
[3, 1, 3, 0], 60],
[[0, 1, 6], [2, 4, 6]]),
('partial repair guard 3',
[[['w3', 'staff', 30, 270], ['w4', 'supervisor', 90, 210], ['w3', 'trainee', 60, 300],
['w4', 'trainee', 90, 150]],
[1, 0, 2, 3, 0], 60],
[[0, 0, 2], [3, 2, 6]]),
('boundary control 4', [[['w1', 'staff', 0, 60]], [1, 1], 60], [[1, 0, 2]]),
('normal control 5',
[[['w4', 'staff', 0, 30], ['w2', 'staff', 90, 210], ['w1', 'trainee', 30, 60], ['w3', 'staff', 120, 300],
['w2', 'supervisor', 90, 270], ['w2', 'trainee', 30, 150]],
[0, 0, 2, 1], 60],
[]),
('normal control 6',
[[['w2', 'staff', 90, 210], ['w1', 'supervisor', 60, 300], ['w1', 'staff', 60, 90],
['w4', 'staff', 180, 270], ['w4', 'staff', 30, 210]],
[2, 0, 0, 0], 60],
[[0, 0, 4]]),
('normal control 7',
[[['w4', 'supervisor', 180, 420], ['w4', 'trainee', 90, 270], ['w3', 'staff', 30, 90],
['w3', 'staff', 30, 270], ['w1', 'supervisor', 60, 300]],
[1, 3, 2], 60],
[[0, 0, 2], [1, 4, 6]]),
('normal control 8',
[[['w3', 'staff', 30, 210], ['w4', 'trainee', 30, 210], ['w3', 'trainee', 90, 180],
['w1', 'staff', 0, 90]],
[0, 1, 1, 2], 60],
[[3, 0, 4]])]]
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 |
|---|---|---|---|
| regression: trainee weight 1 | [[0, 3, 4]] | [[0, 3, 4]] | Passed |
| regression variant: trainee weight 2 | [[0, 2, 4], [1, 3, 4]] | [[0, 2, 4], [1, 3, 4]] | Passed |
| partial repair guard 3 | [[0, 0, 4], [1, 2, 4]] | [[0, 0, 4], [1, 2, 4]] | Passed |
| boundary control 4 | [[0, 2, 4]] | [[0, 2, 4]] | Passed |
| normal control 5 | [[1, 5, 6], [4, 2, 6]] | [[1, 5, 6], [4, 2, 6]] | Passed |
| normal control 6 | [[0, 0, 2], [2, 4, 6], [3, 4, 6]] | [[0, 0, 2], [2, 4, 6], [3, 4, 6]] | Passed |
| normal control 7 | [[0, 0, 2], [1, 2, 4], [3, 2, 4]] | [[0, 0, 2], [1, 2, 4], [3, 2, 4]] | Passed |
| normal control 8 | [[0, 0, 2], [1, 0, 4], [2, 2, 6], [4, 0, 6]] | [[0, 0, 2], [1, 0, 4], [2, 2, 6], [4, 0, 6]] | Passed |
SHA-256 / 3520ca59cf3ea5864a70abdbdc7da1f21498d6107332fe13abc137c72497c2b4
Verification & scope
Stipulated toy labor rule for a bounded roster model; it is not legal advice and does not claim conformance with any jurisdiction, award, or collective agreement. 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:52:01.260730+00:00.
Case digest / f8e5c95336073cf7ed29df27c139074ac2bfbdb984dcec5704b760e710bbe5f6