FA-94636 / Exam timetabling constraints / Open access
Touching room bookings reported as conflicts · case 01
Bookings that exactly meet after buffers are rejected.
ROOT CAUSE
The overlap test is inclusive at both ends.
VERIFIED REPAIR
Half-open intervals conflict only on strict overlap.
Unsuccessful approach: Making one side strict still rejects touching bookings in one order.
Case contract
bookings [room, exam, start, end, setup minutes]; each booking occupies [start - setup, end + cleanup). Two bookings in the same room conflict if their occupied intervals overlap (touching is fine). Return sorted [room, exam, exam] rows with the exam pair sorted.
Why this case matters
Exam rooms need setup and clearance time; conflicts must account for both buffers.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(bookings, cleanup):
by = {}
for r, ex, s, e, setup in bookings:
by.setdefault(r, []).append((s - setup, e + cleanup, ex))
out = []
for r in sorted(by):
bs = by[r]
for i in range(len(bs)):
for j in range(i + 1, len(bs)):
a, b = bs[i], bs[j]
if a[0] <= b[1] and b[0] <= a[1]:
out.append([r] + sorted([a[2], b[2]]))
return sorted(out)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: touching intervals 1', [[['R1', 'A', 540, 600, 30], ['R1', 'B', 645, 700, 30]], 15], []),
('regression variant: touching intervals 2',
[[['R2', 'ENG', 660, 750, 0], ['R2', 'LAW', 780, 840, 0], ['R1', 'CS', 540, 660, 0],
['R2', 'GEO', 540, 600, 0]],
30],
[]),
('partial repair guard 3',
[[['R1', 'ENG', 780, 870, 45], ['R2', 'MED', 720, 810, 0], ['R2', 'GEO', 540, 660, 15],
['R1', 'LAW', 660, 720, 0]],
15],
[]),
('boundary control 4', [[['R1', 'B', 540, 600, 15], ['R2', 'A', 540, 600, 15]], 15], []),
('boundary control 5', [[['R1', 'B', 540, 700, 15], ['R1', 'A', 600, 620, 15]], 15], [['R1', 'A', 'B']]),
('normal control 6',
[[['R1', 'GEO', 720, 810, 15], ['R2', 'MED', 600, 690, 15], ['R2', 'PHYS', 840, 900, 30],
['R2', 'ART', 600, 720, 0]],
15],
[['R2', 'ART', 'MED']]),
('normal control 7',
[[['R1', 'PHYS', 840, 900, 15], ['R2', 'ART', 720, 810, 0], ['R2', 'CS', 540, 630, 0]], 30], []),
('normal control 8',
[[['R1', 'ENG', 540, 660, 45], ['R2', 'ART', 780, 900, 0], ['R1', 'PHYS', 600, 660, 45],
['R2', 'LAW', 720, 810, 45], ['R2', 'CS', 840, 930, 45]],
30],
[['R1', 'ENG', 'PHYS'], ['R2', 'ART', 'CS'], ['R2', 'ART', 'LAW'], ['R2', 'CS', 'LAW']])],
[('regression: touching intervals 1',
[[['R1', 'ENG', 540, 660, 0], ['R2', 'GEO', 720, 810, 15], ['R1', 'ART', 780, 870, 30],
['R2', 'LAW', 840, 930, 0], ['R1', 'CS', 540, 600, 0]],
30],
[['R1', 'CS', 'ENG']]),
('regression variant: touching intervals 2',
[[['R1', 'LAW', 660, 720, 30], ['R1', 'PHYS', 660, 720, 15], ['R2', 'ENG', 720, 810, 15],
['R2', 'CS', 600, 690, 45], ['R2', 'ART', 780, 900, 45]],
15],
[['R1', 'LAW', 'PHYS'], ['R2', 'ART', 'ENG']]),
('partial repair guard 3',
[[['R2', 'ART', 660, 720, 45], ['R1', 'MED', 780, 870, 45], ['R1', 'GEO', 780, 840, 15],
['R1', 'LAW', 660, 750, 45], ['R2', 'CS', 720, 840, 30]],
15],
[['R1', 'GEO', 'MED'], ['R1', 'LAW', 'MED'], ['R2', 'ART', 'CS']]),
('boundary control 4', [[['R1', 'A', 540, 600, 30], ['R1', 'B', 645, 700, 30]], 15], []),
('boundary control 5', [[['R1', 'B', 540, 600, 45], ['R1', 'A', 610, 700, 0]], 15], [['R1', 'A', 'B']]),
('normal control 6',
[[['R2', 'ENG', 660, 720, 45], ['R2', 'MED', 600, 720, 0], ['R1', 'ART', 780, 900, 0],
['R1', 'GEO', 720, 780, 45]],
15],
[['R1', 'ART', 'GEO'], ['R2', 'ENG', 'MED']]),
('normal control 7',
[[['R1', 'ART', 540, 630, 15], ['R1', 'PHYS', 660, 750, 45], ['R1', 'LAW', 600, 690, 15],
['R1', 'CS', 780, 840, 45], ['R2', 'GEO', 720, 840, 0]],
30],
[['R1', 'ART', 'LAW'], ['R1', 'ART', 'PHYS'], ['R1', 'CS', 'PHYS'], ['R1', 'LAW', 'PHYS']]),
('normal control 8',
[[['R1', 'PHYS', 780, 900, 45], ['R2', 'GEO', 840, 900, 0], ['R2', 'LAW', 780, 900, 30],
['R1', 'MED', 540, 660, 15], ['R2', 'ART', 540, 660, 45]],
30],
[['R2', 'GEO', 'LAW']])],
[('regression: touching intervals 1',
[[['R1', 'MED', 660, 750, 30], ['R2', 'CS', 780, 870, 15], ['R1', 'ENG', 540, 660, 0],
['R1', 'GEO', 720, 810, 45]],
15],
[['R1', 'ENG', 'MED'], ['R1', 'GEO', 'MED']]),
('regression variant: touching intervals 2',
[[['R1', 'LAW', 600, 660, 0], ['R2', 'GEO', 720, 780, 45], ['R1', 'MED', 540, 630, 45],
['R1', 'ART', 720, 780, 45], ['R2', 'PHYS', 660, 720, 45]],
15],
[['R1', 'LAW', 'MED'], ['R2', 'GEO', 'PHYS']]),
('partial repair guard 3',
[[['R2', 'GEO', 540, 600, 45], ['R2', 'ENG', 660, 780, 15], ['R1', 'PHYS', 780, 870, 0],
['R2', 'CS', 600, 660, 0], ['R1', 'ART', 660, 750, 30]],
30],
[['R2', 'CS', 'ENG'], ['R2', 'CS', 'GEO']]),
('boundary control 4', [[['R1', 'B', 540, 600, 15], ['R2', 'A', 540, 600, 15]], 15], []),
('boundary control 5', [[['R1', 'B', 540, 700, 15], ['R1', 'A', 600, 620, 15]], 15], [['R1', 'A', 'B']]),
('normal control 6', [[['R1', 'GEO', 660, 750, 30], ['R1', 'MED', 720, 840, 15]], 10],
[['R1', 'GEO', 'MED']]),
('normal control 7',
[[['R1', 'LAW', 840, 960, 15], ['R2', 'ENG', 600, 690, 0], ['R2', 'CS', 540, 630, 0],
['R2', 'MED', 660, 750, 15]],
15],
[['R2', 'CS', 'ENG'], ['R2', 'ENG', 'MED']]),
('normal control 8', [[['R1', 'LAW', 660, 780, 0], ['R1', 'PHYS', 780, 870, 30]], 15],
[['R1', 'LAW', 'PHYS']])],
[('regression: touching intervals 1',
[[['R1', 'PHYS', 660, 720, 30], ['R1', 'GEO', 780, 870, 30], ['R1', 'ART', 540, 630, 45],
['R2', 'LAW', 840, 960, 0], ['R2', 'MED', 540, 660, 30]],
30],
[['R1', 'ART', 'PHYS']]),
('regression variant: touching intervals 2',
[[['R2', 'CS', 840, 930, 30], ['R2', 'ENG', 600, 660, 0], ['R2', 'PHYS', 780, 870, 30],
['R2', 'GEO', 720, 840, 30], ['R1', 'MED', 600, 720, 15]],
30],
[['R2', 'CS', 'GEO'], ['R2', 'CS', 'PHYS'], ['R2', 'GEO', 'PHYS']]),
('partial repair guard 3',
[[['R2', 'GEO', 540, 660, 15], ['R2', 'MED', 720, 840, 30], ['R1', 'CS', 720, 840, 45],
['R1', 'ART', 540, 660, 45], ['R1', 'PHYS', 660, 720, 15]],
15],
[['R1', 'ART', 'PHYS'], ['R1', 'CS', 'PHYS']]),
('boundary control 4', [[['R1', 'A', 540, 600, 30], ['R1', 'B', 645, 700, 30]], 15], []),
('boundary control 5', [[['R1', 'B', 540, 600, 45], ['R1', 'A', 610, 700, 0]], 15], [['R1', 'A', 'B']]),
('normal control 6',
[[['R2', 'GEO', 540, 660, 15], ['R2', 'LAW', 720, 810, 0], ['R2', 'ENG', 720, 780, 45]], 15],
[['R2', 'ENG', 'LAW']]),
('normal control 7',
[[['R1', 'GEO', 600, 720, 15], ['R2', 'MED', 540, 600, 45], ['R1', 'PHYS', 600, 660, 45],
['R1', 'CS', 840, 930, 15], ['R2', 'ART', 600, 660, 0]],
15],
[['R1', 'GEO', 'PHYS'], ['R2', 'ART', 'MED']]),
('normal control 8', [[['R1', 'MED', 780, 840, 15], ['R1', 'ENG', 660, 720, 45]], 15], [])],
[('regression: touching intervals 1',
[[['R2', 'GEO', 540, 600, 45], ['R2', 'ENG', 660, 780, 15], ['R1', 'PHYS', 780, 870, 0],
['R2', 'CS', 600, 660, 0], ['R1', 'ART', 660, 750, 30]],
30],
[['R2', 'CS', 'ENG'], ['R2', 'CS', 'GEO']]),
('regression variant: touching intervals 2',
[[['R1', 'MED', 540, 660, 0], ['R1', 'ENG', 720, 780, 30]], 30], []),
('partial repair guard 3',
[[['R2', 'GEO', 600, 720, 30], ['R2', 'ART', 840, 930, 45], ['R2', 'MED', 720, 780, 45],
['R2', 'PHYS', 660, 750, 0]],
15],
[['R2', 'GEO', 'MED'], ['R2', 'GEO', 'PHYS'], ['R2', 'MED', 'PHYS']]),
('boundary control 4', [[['R1', 'B', 540, 600, 15], ['R2', 'A', 540, 600, 15]], 15], []),
('boundary control 5', [[['R1', 'B', 540, 700, 15], ['R1', 'A', 600, 620, 15]], 15], [['R1', 'A', 'B']]),
('normal control 6',
[[['R1', 'LAW', 840, 960, 15], ['R2', 'ENG', 600, 690, 0], ['R2', 'CS', 540, 630, 0],
['R2', 'MED', 660, 750, 15]],
15],
[['R2', 'CS', 'ENG'], ['R2', 'ENG', 'MED']]),
('normal control 7',
[[['R2', 'PHYS', 840, 960, 45], ['R1', 'ENG', 660, 780, 30], ['R2', 'MED', 540, 660, 30],
['R2', 'GEO', 600, 720, 15], ['R2', 'ART', 540, 600, 30]],
10],
[['R2', 'ART', 'GEO'], ['R2', 'ART', 'MED'], ['R2', 'GEO', 'MED']]),
('normal control 8', [[['R1', 'ENG', 540, 660, 45], ['R1', 'ART', 720, 810, 0]], 10], [])]]
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: touching intervals 1 | [['R1', 'A', 'B']] | [] | Failed |
| regression variant: touching intervals 2 | [['R2', 'ENG', 'LAW']] | [] | Failed |
| partial repair guard 3 | [['R1', 'ENG', 'LAW']] | [] | Failed |
| boundary control 4 | [] | [] | Passed |
| boundary control 5 | [['R1', 'A', 'B']] | [['R1', 'A', 'B']] | Passed |
| normal control 6 | [['R2', 'ART', 'MED']] | [['R2', 'ART', 'MED']] | Passed |
| normal control 7 | [] | [] | Passed |
| normal control 8 | [['R1', 'ENG', 'PHYS'], ['R2', 'ART', 'CS'], ['R2', 'ART', 'LAW'], ['R2', 'CS', 'LAW']] | [['R1', 'ENG', 'PHYS'], ['R2', 'ART', 'CS'], ['R2', 'ART', 'LAW'], ['R2', 'CS', 'LAW']] | Passed |
SHA-256 / 492b61edcfce821d1cfb23e9dd42aee0b6a8a26142f7a811fa19a75e7ac430bb
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(bookings, cleanup):
by = {}
for r, ex, s, e, setup in bookings:
by.setdefault(r, []).append((s - setup, e + cleanup, ex))
out = []
for r in sorted(by):
bs = by[r]
for i in range(len(bs)):
for j in range(i + 1, len(bs)):
a, b = bs[i], bs[j]
if a[0] <= b[1] and b[0] < a[1]:
out.append([r] + sorted([a[2], b[2]]))
return sorted(out)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: touching intervals 1', [[['R1', 'A', 540, 600, 30], ['R1', 'B', 645, 700, 30]], 15], []),
('regression variant: touching intervals 2',
[[['R2', 'ENG', 660, 750, 0], ['R2', 'LAW', 780, 840, 0], ['R1', 'CS', 540, 660, 0],
['R2', 'GEO', 540, 600, 0]],
30],
[]),
('partial repair guard 3',
[[['R1', 'ENG', 780, 870, 45], ['R2', 'MED', 720, 810, 0], ['R2', 'GEO', 540, 660, 15],
['R1', 'LAW', 660, 720, 0]],
15],
[]),
('boundary control 4', [[['R1', 'B', 540, 600, 15], ['R2', 'A', 540, 600, 15]], 15], []),
('boundary control 5', [[['R1', 'B', 540, 700, 15], ['R1', 'A', 600, 620, 15]], 15], [['R1', 'A', 'B']]),
('normal control 6',
[[['R1', 'GEO', 720, 810, 15], ['R2', 'MED', 600, 690, 15], ['R2', 'PHYS', 840, 900, 30],
['R2', 'ART', 600, 720, 0]],
15],
[['R2', 'ART', 'MED']]),
('normal control 7',
[[['R1', 'PHYS', 840, 900, 15], ['R2', 'ART', 720, 810, 0], ['R2', 'CS', 540, 630, 0]], 30], []),
('normal control 8',
[[['R1', 'ENG', 540, 660, 45], ['R2', 'ART', 780, 900, 0], ['R1', 'PHYS', 600, 660, 45],
['R2', 'LAW', 720, 810, 45], ['R2', 'CS', 840, 930, 45]],
30],
[['R1', 'ENG', 'PHYS'], ['R2', 'ART', 'CS'], ['R2', 'ART', 'LAW'], ['R2', 'CS', 'LAW']])],
[('regression: touching intervals 1',
[[['R1', 'ENG', 540, 660, 0], ['R2', 'GEO', 720, 810, 15], ['R1', 'ART', 780, 870, 30],
['R2', 'LAW', 840, 930, 0], ['R1', 'CS', 540, 600, 0]],
30],
[['R1', 'CS', 'ENG']]),
('regression variant: touching intervals 2',
[[['R1', 'LAW', 660, 720, 30], ['R1', 'PHYS', 660, 720, 15], ['R2', 'ENG', 720, 810, 15],
['R2', 'CS', 600, 690, 45], ['R2', 'ART', 780, 900, 45]],
15],
[['R1', 'LAW', 'PHYS'], ['R2', 'ART', 'ENG']]),
('partial repair guard 3',
[[['R2', 'ART', 660, 720, 45], ['R1', 'MED', 780, 870, 45], ['R1', 'GEO', 780, 840, 15],
['R1', 'LAW', 660, 750, 45], ['R2', 'CS', 720, 840, 30]],
15],
[['R1', 'GEO', 'MED'], ['R1', 'LAW', 'MED'], ['R2', 'ART', 'CS']]),
('boundary control 4', [[['R1', 'A', 540, 600, 30], ['R1', 'B', 645, 700, 30]], 15], []),
('boundary control 5', [[['R1', 'B', 540, 600, 45], ['R1', 'A', 610, 700, 0]], 15], [['R1', 'A', 'B']]),
('normal control 6',
[[['R2', 'ENG', 660, 720, 45], ['R2', 'MED', 600, 720, 0], ['R1', 'ART', 780, 900, 0],
['R1', 'GEO', 720, 780, 45]],
15],
[['R1', 'ART', 'GEO'], ['R2', 'ENG', 'MED']]),
('normal control 7',
[[['R1', 'ART', 540, 630, 15], ['R1', 'PHYS', 660, 750, 45], ['R1', 'LAW', 600, 690, 15],
['R1', 'CS', 780, 840, 45], ['R2', 'GEO', 720, 840, 0]],
30],
[['R1', 'ART', 'LAW'], ['R1', 'ART', 'PHYS'], ['R1', 'CS', 'PHYS'], ['R1', 'LAW', 'PHYS']]),
('normal control 8',
[[['R1', 'PHYS', 780, 900, 45], ['R2', 'GEO', 840, 900, 0], ['R2', 'LAW', 780, 900, 30],
['R1', 'MED', 540, 660, 15], ['R2', 'ART', 540, 660, 45]],
30],
[['R2', 'GEO', 'LAW']])],
[('regression: touching intervals 1',
[[['R1', 'MED', 660, 750, 30], ['R2', 'CS', 780, 870, 15], ['R1', 'ENG', 540, 660, 0],
['R1', 'GEO', 720, 810, 45]],
15],
[['R1', 'ENG', 'MED'], ['R1', 'GEO', 'MED']]),
('regression variant: touching intervals 2',
[[['R1', 'LAW', 600, 660, 0], ['R2', 'GEO', 720, 780, 45], ['R1', 'MED', 540, 630, 45],
['R1', 'ART', 720, 780, 45], ['R2', 'PHYS', 660, 720, 45]],
15],
[['R1', 'LAW', 'MED'], ['R2', 'GEO', 'PHYS']]),
('partial repair guard 3',
[[['R2', 'GEO', 540, 600, 45], ['R2', 'ENG', 660, 780, 15], ['R1', 'PHYS', 780, 870, 0],
['R2', 'CS', 600, 660, 0], ['R1', 'ART', 660, 750, 30]],
30],
[['R2', 'CS', 'ENG'], ['R2', 'CS', 'GEO']]),
('boundary control 4', [[['R1', 'B', 540, 600, 15], ['R2', 'A', 540, 600, 15]], 15], []),
('boundary control 5', [[['R1', 'B', 540, 700, 15], ['R1', 'A', 600, 620, 15]], 15], [['R1', 'A', 'B']]),
('normal control 6', [[['R1', 'GEO', 660, 750, 30], ['R1', 'MED', 720, 840, 15]], 10],
[['R1', 'GEO', 'MED']]),
('normal control 7',
[[['R1', 'LAW', 840, 960, 15], ['R2', 'ENG', 600, 690, 0], ['R2', 'CS', 540, 630, 0],
['R2', 'MED', 660, 750, 15]],
15],
[['R2', 'CS', 'ENG'], ['R2', 'ENG', 'MED']]),
('normal control 8', [[['R1', 'LAW', 660, 780, 0], ['R1', 'PHYS', 780, 870, 30]], 15],
[['R1', 'LAW', 'PHYS']])],
[('regression: touching intervals 1',
[[['R1', 'PHYS', 660, 720, 30], ['R1', 'GEO', 780, 870, 30], ['R1', 'ART', 540, 630, 45],
['R2', 'LAW', 840, 960, 0], ['R2', 'MED', 540, 660, 30]],
30],
[['R1', 'ART', 'PHYS']]),
('regression variant: touching intervals 2',
[[['R2', 'CS', 840, 930, 30], ['R2', 'ENG', 600, 660, 0], ['R2', 'PHYS', 780, 870, 30],
['R2', 'GEO', 720, 840, 30], ['R1', 'MED', 600, 720, 15]],
30],
[['R2', 'CS', 'GEO'], ['R2', 'CS', 'PHYS'], ['R2', 'GEO', 'PHYS']]),
('partial repair guard 3',
[[['R2', 'GEO', 540, 660, 15], ['R2', 'MED', 720, 840, 30], ['R1', 'CS', 720, 840, 45],
['R1', 'ART', 540, 660, 45], ['R1', 'PHYS', 660, 720, 15]],
15],
[['R1', 'ART', 'PHYS'], ['R1', 'CS', 'PHYS']]),
('boundary control 4', [[['R1', 'A', 540, 600, 30], ['R1', 'B', 645, 700, 30]], 15], []),
('boundary control 5', [[['R1', 'B', 540, 600, 45], ['R1', 'A', 610, 700, 0]], 15], [['R1', 'A', 'B']]),
('normal control 6',
[[['R2', 'GEO', 540, 660, 15], ['R2', 'LAW', 720, 810, 0], ['R2', 'ENG', 720, 780, 45]], 15],
[['R2', 'ENG', 'LAW']]),
('normal control 7',
[[['R1', 'GEO', 600, 720, 15], ['R2', 'MED', 540, 600, 45], ['R1', 'PHYS', 600, 660, 45],
['R1', 'CS', 840, 930, 15], ['R2', 'ART', 600, 660, 0]],
15],
[['R1', 'GEO', 'PHYS'], ['R2', 'ART', 'MED']]),
('normal control 8', [[['R1', 'MED', 780, 840, 15], ['R1', 'ENG', 660, 720, 45]], 15], [])],
[('regression: touching intervals 1',
[[['R2', 'GEO', 540, 600, 45], ['R2', 'ENG', 660, 780, 15], ['R1', 'PHYS', 780, 870, 0],
['R2', 'CS', 600, 660, 0], ['R1', 'ART', 660, 750, 30]],
30],
[['R2', 'CS', 'ENG'], ['R2', 'CS', 'GEO']]),
('regression variant: touching intervals 2',
[[['R1', 'MED', 540, 660, 0], ['R1', 'ENG', 720, 780, 30]], 30], []),
('partial repair guard 3',
[[['R2', 'GEO', 600, 720, 30], ['R2', 'ART', 840, 930, 45], ['R2', 'MED', 720, 780, 45],
['R2', 'PHYS', 660, 750, 0]],
15],
[['R2', 'GEO', 'MED'], ['R2', 'GEO', 'PHYS'], ['R2', 'MED', 'PHYS']]),
('boundary control 4', [[['R1', 'B', 540, 600, 15], ['R2', 'A', 540, 600, 15]], 15], []),
('boundary control 5', [[['R1', 'B', 540, 700, 15], ['R1', 'A', 600, 620, 15]], 15], [['R1', 'A', 'B']]),
('normal control 6',
[[['R1', 'LAW', 840, 960, 15], ['R2', 'ENG', 600, 690, 0], ['R2', 'CS', 540, 630, 0],
['R2', 'MED', 660, 750, 15]],
15],
[['R2', 'CS', 'ENG'], ['R2', 'ENG', 'MED']]),
('normal control 7',
[[['R2', 'PHYS', 840, 960, 45], ['R1', 'ENG', 660, 780, 30], ['R2', 'MED', 540, 660, 30],
['R2', 'GEO', 600, 720, 15], ['R2', 'ART', 540, 600, 30]],
10],
[['R2', 'ART', 'GEO'], ['R2', 'ART', 'MED'], ['R2', 'GEO', 'MED']]),
('normal control 8', [[['R1', 'ENG', 540, 660, 45], ['R1', 'ART', 720, 810, 0]], 10], [])]]
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: touching intervals 1 | [] | [] | Passed |
| regression variant: touching intervals 2 | [] | [] | Passed |
| partial repair guard 3 | [['R1', 'ENG', 'LAW']] | [] | Failed |
| boundary control 4 | [] | [] | Passed |
| boundary control 5 | [['R1', 'A', 'B']] | [['R1', 'A', 'B']] | Passed |
| normal control 6 | [['R2', 'ART', 'MED']] | [['R2', 'ART', 'MED']] | Passed |
| normal control 7 | [] | [] | Passed |
| normal control 8 | [['R1', 'ENG', 'PHYS'], ['R2', 'ART', 'CS'], ['R2', 'ART', 'LAW'], ['R2', 'CS', 'LAW']] | [['R1', 'ENG', 'PHYS'], ['R2', 'ART', 'CS'], ['R2', 'ART', 'LAW'], ['R2', 'CS', 'LAW']] | Passed |
SHA-256 / f8fb59886bfbe86c959ff2d9acf57d0cdce66a2f3266c3bd2422822cd02ed062
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(bookings, cleanup):
by = {}
for r, ex, s, e, setup in bookings:
by.setdefault(r, []).append((s - setup, e + cleanup, ex))
out = []
for r in sorted(by):
bs = by[r]
for i in range(len(bs)):
for j in range(i + 1, len(bs)):
a, b = bs[i], bs[j]
if a[0] < b[1] and b[0] < a[1]:
out.append([r] + sorted([a[2], b[2]]))
return sorted(out)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: touching intervals 1', [[['R1', 'A', 540, 600, 30], ['R1', 'B', 645, 700, 30]], 15], []),
('regression variant: touching intervals 2',
[[['R2', 'ENG', 660, 750, 0], ['R2', 'LAW', 780, 840, 0], ['R1', 'CS', 540, 660, 0],
['R2', 'GEO', 540, 600, 0]],
30],
[]),
('partial repair guard 3',
[[['R1', 'ENG', 780, 870, 45], ['R2', 'MED', 720, 810, 0], ['R2', 'GEO', 540, 660, 15],
['R1', 'LAW', 660, 720, 0]],
15],
[]),
('boundary control 4', [[['R1', 'B', 540, 600, 15], ['R2', 'A', 540, 600, 15]], 15], []),
('boundary control 5', [[['R1', 'B', 540, 700, 15], ['R1', 'A', 600, 620, 15]], 15], [['R1', 'A', 'B']]),
('normal control 6',
[[['R1', 'GEO', 720, 810, 15], ['R2', 'MED', 600, 690, 15], ['R2', 'PHYS', 840, 900, 30],
['R2', 'ART', 600, 720, 0]],
15],
[['R2', 'ART', 'MED']]),
('normal control 7',
[[['R1', 'PHYS', 840, 900, 15], ['R2', 'ART', 720, 810, 0], ['R2', 'CS', 540, 630, 0]], 30], []),
('normal control 8',
[[['R1', 'ENG', 540, 660, 45], ['R2', 'ART', 780, 900, 0], ['R1', 'PHYS', 600, 660, 45],
['R2', 'LAW', 720, 810, 45], ['R2', 'CS', 840, 930, 45]],
30],
[['R1', 'ENG', 'PHYS'], ['R2', 'ART', 'CS'], ['R2', 'ART', 'LAW'], ['R2', 'CS', 'LAW']])],
[('regression: touching intervals 1',
[[['R1', 'ENG', 540, 660, 0], ['R2', 'GEO', 720, 810, 15], ['R1', 'ART', 780, 870, 30],
['R2', 'LAW', 840, 930, 0], ['R1', 'CS', 540, 600, 0]],
30],
[['R1', 'CS', 'ENG']]),
('regression variant: touching intervals 2',
[[['R1', 'LAW', 660, 720, 30], ['R1', 'PHYS', 660, 720, 15], ['R2', 'ENG', 720, 810, 15],
['R2', 'CS', 600, 690, 45], ['R2', 'ART', 780, 900, 45]],
15],
[['R1', 'LAW', 'PHYS'], ['R2', 'ART', 'ENG']]),
('partial repair guard 3',
[[['R2', 'ART', 660, 720, 45], ['R1', 'MED', 780, 870, 45], ['R1', 'GEO', 780, 840, 15],
['R1', 'LAW', 660, 750, 45], ['R2', 'CS', 720, 840, 30]],
15],
[['R1', 'GEO', 'MED'], ['R1', 'LAW', 'MED'], ['R2', 'ART', 'CS']]),
('boundary control 4', [[['R1', 'A', 540, 600, 30], ['R1', 'B', 645, 700, 30]], 15], []),
('boundary control 5', [[['R1', 'B', 540, 600, 45], ['R1', 'A', 610, 700, 0]], 15], [['R1', 'A', 'B']]),
('normal control 6',
[[['R2', 'ENG', 660, 720, 45], ['R2', 'MED', 600, 720, 0], ['R1', 'ART', 780, 900, 0],
['R1', 'GEO', 720, 780, 45]],
15],
[['R1', 'ART', 'GEO'], ['R2', 'ENG', 'MED']]),
('normal control 7',
[[['R1', 'ART', 540, 630, 15], ['R1', 'PHYS', 660, 750, 45], ['R1', 'LAW', 600, 690, 15],
['R1', 'CS', 780, 840, 45], ['R2', 'GEO', 720, 840, 0]],
30],
[['R1', 'ART', 'LAW'], ['R1', 'ART', 'PHYS'], ['R1', 'CS', 'PHYS'], ['R1', 'LAW', 'PHYS']]),
('normal control 8',
[[['R1', 'PHYS', 780, 900, 45], ['R2', 'GEO', 840, 900, 0], ['R2', 'LAW', 780, 900, 30],
['R1', 'MED', 540, 660, 15], ['R2', 'ART', 540, 660, 45]],
30],
[['R2', 'GEO', 'LAW']])],
[('regression: touching intervals 1',
[[['R1', 'MED', 660, 750, 30], ['R2', 'CS', 780, 870, 15], ['R1', 'ENG', 540, 660, 0],
['R1', 'GEO', 720, 810, 45]],
15],
[['R1', 'ENG', 'MED'], ['R1', 'GEO', 'MED']]),
('regression variant: touching intervals 2',
[[['R1', 'LAW', 600, 660, 0], ['R2', 'GEO', 720, 780, 45], ['R1', 'MED', 540, 630, 45],
['R1', 'ART', 720, 780, 45], ['R2', 'PHYS', 660, 720, 45]],
15],
[['R1', 'LAW', 'MED'], ['R2', 'GEO', 'PHYS']]),
('partial repair guard 3',
[[['R2', 'GEO', 540, 600, 45], ['R2', 'ENG', 660, 780, 15], ['R1', 'PHYS', 780, 870, 0],
['R2', 'CS', 600, 660, 0], ['R1', 'ART', 660, 750, 30]],
30],
[['R2', 'CS', 'ENG'], ['R2', 'CS', 'GEO']]),
('boundary control 4', [[['R1', 'B', 540, 600, 15], ['R2', 'A', 540, 600, 15]], 15], []),
('boundary control 5', [[['R1', 'B', 540, 700, 15], ['R1', 'A', 600, 620, 15]], 15], [['R1', 'A', 'B']]),
('normal control 6', [[['R1', 'GEO', 660, 750, 30], ['R1', 'MED', 720, 840, 15]], 10],
[['R1', 'GEO', 'MED']]),
('normal control 7',
[[['R1', 'LAW', 840, 960, 15], ['R2', 'ENG', 600, 690, 0], ['R2', 'CS', 540, 630, 0],
['R2', 'MED', 660, 750, 15]],
15],
[['R2', 'CS', 'ENG'], ['R2', 'ENG', 'MED']]),
('normal control 8', [[['R1', 'LAW', 660, 780, 0], ['R1', 'PHYS', 780, 870, 30]], 15],
[['R1', 'LAW', 'PHYS']])],
[('regression: touching intervals 1',
[[['R1', 'PHYS', 660, 720, 30], ['R1', 'GEO', 780, 870, 30], ['R1', 'ART', 540, 630, 45],
['R2', 'LAW', 840, 960, 0], ['R2', 'MED', 540, 660, 30]],
30],
[['R1', 'ART', 'PHYS']]),
('regression variant: touching intervals 2',
[[['R2', 'CS', 840, 930, 30], ['R2', 'ENG', 600, 660, 0], ['R2', 'PHYS', 780, 870, 30],
['R2', 'GEO', 720, 840, 30], ['R1', 'MED', 600, 720, 15]],
30],
[['R2', 'CS', 'GEO'], ['R2', 'CS', 'PHYS'], ['R2', 'GEO', 'PHYS']]),
('partial repair guard 3',
[[['R2', 'GEO', 540, 660, 15], ['R2', 'MED', 720, 840, 30], ['R1', 'CS', 720, 840, 45],
['R1', 'ART', 540, 660, 45], ['R1', 'PHYS', 660, 720, 15]],
15],
[['R1', 'ART', 'PHYS'], ['R1', 'CS', 'PHYS']]),
('boundary control 4', [[['R1', 'A', 540, 600, 30], ['R1', 'B', 645, 700, 30]], 15], []),
('boundary control 5', [[['R1', 'B', 540, 600, 45], ['R1', 'A', 610, 700, 0]], 15], [['R1', 'A', 'B']]),
('normal control 6',
[[['R2', 'GEO', 540, 660, 15], ['R2', 'LAW', 720, 810, 0], ['R2', 'ENG', 720, 780, 45]], 15],
[['R2', 'ENG', 'LAW']]),
('normal control 7',
[[['R1', 'GEO', 600, 720, 15], ['R2', 'MED', 540, 600, 45], ['R1', 'PHYS', 600, 660, 45],
['R1', 'CS', 840, 930, 15], ['R2', 'ART', 600, 660, 0]],
15],
[['R1', 'GEO', 'PHYS'], ['R2', 'ART', 'MED']]),
('normal control 8', [[['R1', 'MED', 780, 840, 15], ['R1', 'ENG', 660, 720, 45]], 15], [])],
[('regression: touching intervals 1',
[[['R2', 'GEO', 540, 600, 45], ['R2', 'ENG', 660, 780, 15], ['R1', 'PHYS', 780, 870, 0],
['R2', 'CS', 600, 660, 0], ['R1', 'ART', 660, 750, 30]],
30],
[['R2', 'CS', 'ENG'], ['R2', 'CS', 'GEO']]),
('regression variant: touching intervals 2',
[[['R1', 'MED', 540, 660, 0], ['R1', 'ENG', 720, 780, 30]], 30], []),
('partial repair guard 3',
[[['R2', 'GEO', 600, 720, 30], ['R2', 'ART', 840, 930, 45], ['R2', 'MED', 720, 780, 45],
['R2', 'PHYS', 660, 750, 0]],
15],
[['R2', 'GEO', 'MED'], ['R2', 'GEO', 'PHYS'], ['R2', 'MED', 'PHYS']]),
('boundary control 4', [[['R1', 'B', 540, 600, 15], ['R2', 'A', 540, 600, 15]], 15], []),
('boundary control 5', [[['R1', 'B', 540, 700, 15], ['R1', 'A', 600, 620, 15]], 15], [['R1', 'A', 'B']]),
('normal control 6',
[[['R1', 'LAW', 840, 960, 15], ['R2', 'ENG', 600, 690, 0], ['R2', 'CS', 540, 630, 0],
['R2', 'MED', 660, 750, 15]],
15],
[['R2', 'CS', 'ENG'], ['R2', 'ENG', 'MED']]),
('normal control 7',
[[['R2', 'PHYS', 840, 960, 45], ['R1', 'ENG', 660, 780, 30], ['R2', 'MED', 540, 660, 30],
['R2', 'GEO', 600, 720, 15], ['R2', 'ART', 540, 600, 30]],
10],
[['R2', 'ART', 'GEO'], ['R2', 'ART', 'MED'], ['R2', 'GEO', 'MED']]),
('normal control 8', [[['R1', 'ENG', 540, 660, 45], ['R1', 'ART', 720, 810, 0]], 10], [])]]
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: touching intervals 1 | [] | [] | Passed |
| regression variant: touching intervals 2 | [] | [] | Passed |
| partial repair guard 3 | [] | [] | Passed |
| boundary control 4 | [] | [] | Passed |
| boundary control 5 | [['R1', 'A', 'B']] | [['R1', 'A', 'B']] | Passed |
| normal control 6 | [['R2', 'ART', 'MED']] | [['R2', 'ART', 'MED']] | Passed |
| normal control 7 | [] | [] | Passed |
| normal control 8 | [['R1', 'ENG', 'PHYS'], ['R2', 'ART', 'CS'], ['R2', 'ART', 'LAW'], ['R2', 'CS', 'LAW']] | [['R1', 'ENG', 'PHYS'], ['R2', 'ART', 'CS'], ['R2', 'ART', 'LAW'], ['R2', 'CS', 'LAW']] | Passed |
SHA-256 / 5d667ba4e2d41dc7877bdc45e24adb0416686560dfcec00d2b0cee67fbd3fcb1
Verification & scope
Stipulated toy exam-timetabling rule set for a bounded model; it does not claim conformance with any institution's regulations or a benchmark specification, and it performs no search or optimisation. 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:06.175506+00:00.
Case digest / 4bea16f0b7f85e5e989af1465cc630602e927f0abf870b00bfd47678ce31f561