FA-94496 / Exam timetabling constraints / Open access
Exclusive exam conflicts with itself · case 01
Every exclusive-room constraint is reported even when the exam is alone.
ROOT CAUSE
The count of exams in the period includes the exclusive exam itself and allows none.
THE FAILURE
The count of exams in the period includes the exclusive exam itself and allows none.
Unsuccessful approach: Allowing one other exam permits a shared period.
Case contract
timetable maps exam -> period index, exams exam -> duration, periods -> duration. Duration violations (exam longer than its period) are listed first by exam id; then for each constraint in order: after (a must be in a strictly later period than b), exclusion (different periods), coincidence (same period), exclusive (a must be alone in its period). Return violation rows.
Why this case matters
Hard-constraint validation gates every candidate exam timetable.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(timetable, exams, periods, cons):
out = []
for e in sorted(timetable):
if exams[e] > periods[timetable[e]]:
out.append(['duration', e])
for kind, a, b in cons:
pa, pb = timetable[a], timetable[b]
if kind == 'after' and not pa > pb:
out.append([kind, a, b])
elif kind == 'exclusion' and pa == pb:
out.append([kind, a, b])
elif kind == 'coincidence' and pa != pb:
out.append([kind, a, b])
elif kind == 'exclusive' and sum(1 for e in timetable if timetable[e] == pa) >= 1:
out.append([kind, a, b])
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: exclusive counts self 1',
[{'A': 1, 'B': 0}, {'A': 120, 'B': 90}, [90, 120], [['exclusive', 'A', 'B']]], []),
('regression variant: exclusive counts self 2',
[{'MATH101': 3, 'PHYS110': 0, 'MATH101H': 2}, {'MATH101': 120, 'MATH101H': 180, 'PHYS110': 180},
[180, 90, 180, 180], [['exclusive', 'PHYS110', 'MATH101'], ['coincidence', 'PHYS110', 'MATH101H']]],
[['coincidence', 'PHYS110', 'MATH101H']]),
('partial repair guard 3',
[{'CHEM120': 2, 'MATH101H': 2, 'PHYS110': 3, 'MATH101': 3},
{'MATH101': 90, 'MATH101H': 180, 'PHYS110': 180, 'CHEM120': 180}, [180, 90, 180, 180],
[['exclusive', 'MATH101H', 'PHYS110'], ['coincidence', 'CHEM120', 'PHYS110']]],
[['exclusive', 'MATH101H', 'PHYS110'], ['coincidence', 'CHEM120', 'PHYS110']]),
('normal control 4',
[{'PHYS110': 2, 'MATH101': 2, 'MATH101H': 1, 'CHEM120': 2},
{'MATH101': 180, 'MATH101H': 120, 'PHYS110': 180, 'CHEM120': 90}, [180, 120, 90, 90],
[['exclusive', 'CHEM120', 'MATH101'], ['coincidence', 'MATH101H', 'MATH101'],
['exclusion', 'MATH101H', 'MATH101']]],
[['duration', 'MATH101'], ['duration', 'PHYS110'], ['exclusive', 'CHEM120', 'MATH101'],
['coincidence', 'MATH101H', 'MATH101']]),
('normal control 5',
[{'PHYS110': 3, 'MATH101': 0, 'MATH101H': 3}, {'MATH101': 120, 'MATH101H': 120, 'PHYS110': 90},
[180, 90, 180, 90], [['coincidence', 'MATH101', 'PHYS110'], ['after', 'PHYS110', 'MATH101']]],
[['duration', 'MATH101H'], ['coincidence', 'MATH101', 'PHYS110']]),
('normal control 6',
[{'CHEM120': 0, 'MATH101': 3, 'MATH101H': 1, 'PHYS110': 1, 'BIO130': 2},
{'MATH101': 180, 'MATH101H': 180, 'PHYS110': 90, 'CHEM120': 180, 'BIO130': 120}, [90, 180, 90, 90],
[['coincidence', 'MATH101', 'CHEM120'], ['exclusive', 'CHEM120', 'MATH101'],
['coincidence', 'MATH101H', 'MATH101'], ['after', 'PHYS110', 'CHEM120']]],
[['duration', 'BIO130'], ['duration', 'CHEM120'], ['duration', 'MATH101'],
['coincidence', 'MATH101', 'CHEM120'], ['coincidence', 'MATH101H', 'MATH101']]),
('normal control 7',
[{'MATH101': 3, 'MATH101H': 3, 'CHEM120': 1, 'HIST140': 2, 'PHYS110': 1, 'BIO130': 0},
{'MATH101': 180, 'MATH101H': 120, 'PHYS110': 120, 'CHEM120': 180, 'BIO130': 90, 'HIST140': 180},
[120, 90, 180, 180], [['after', 'MATH101H', 'PHYS110'], ['coincidence', 'BIO130', 'MATH101']]],
[['duration', 'CHEM120'], ['duration', 'PHYS110'], ['coincidence', 'BIO130', 'MATH101']]),
('normal control 8',
[{'MATH101H': 1, 'PHYS110': 1, 'MATH101': 3}, {'MATH101': 180, 'MATH101H': 180, 'PHYS110': 120},
[90, 120, 120, 120],
[['after', 'PHYS110', 'MATH101H'], ['exclusion', 'MATH101H', 'PHYS110'],
['exclusive', 'MATH101H', 'MATH101']]],
[['duration', 'MATH101'], ['duration', 'MATH101H'], ['after', 'PHYS110', 'MATH101H'],
['exclusion', 'MATH101H', 'PHYS110'], ['exclusive', 'MATH101H', 'MATH101']])],
[('regression: exclusive counts self 1',
[{'MATH101H': 0, 'PHYS110': 0, 'CHEM120': 1, 'BIO130': 1, 'MATH101': 3},
{'MATH101': 120, 'MATH101H': 180, 'PHYS110': 90, 'CHEM120': 120, 'BIO130': 90}, [180, 120, 120, 90],
[['exclusive', 'MATH101', 'PHYS110']]],
[['duration', 'MATH101']]),
('regression variant: exclusive counts self 2',
[{'MATH101H': 3, 'PHYS110': 3, 'MATH101': 0}, {'MATH101': 120, 'MATH101H': 180, 'PHYS110': 180},
[120, 180, 180, 120], [['exclusive', 'MATH101', 'MATH101H']]],
[['duration', 'MATH101H'], ['duration', 'PHYS110']]),
('partial repair guard 3',
[{'CHEM120': 2, 'MATH101H': 3, 'PHYS110': 3, 'MATH101': 1},
{'MATH101': 180, 'MATH101H': 120, 'PHYS110': 90, 'CHEM120': 180}, [120, 90, 120, 120],
[['exclusive', 'PHYS110', 'MATH101'], ['exclusive', 'PHYS110', 'CHEM120']]],
[['duration', 'CHEM120'], ['duration', 'MATH101'], ['exclusive', 'PHYS110', 'MATH101'],
['exclusive', 'PHYS110', 'CHEM120']]),
('boundary control 4', [{'A': 2, 'B': 1}, {'A': 90, 'B': 90}, [90, 120, 120], [['after', 'A', 'B']]], []),
('normal control 5',
[{'MATH101': 0, 'PHYS110': 2, 'BIO130': 2, 'MATH101H': 3, 'CHEM120': 2},
{'MATH101': 180, 'MATH101H': 90, 'PHYS110': 120, 'CHEM120': 180, 'BIO130': 180}, [180, 90, 180, 90],
[['after', 'CHEM120', 'MATH101'], ['coincidence', 'MATH101', 'CHEM120'],
['exclusive', 'BIO130', 'MATH101']]],
[['coincidence', 'MATH101', 'CHEM120'], ['exclusive', 'BIO130', 'MATH101']]),
('normal control 6',
[{'MATH101': 0, 'MATH101H': 3, 'PHYS110': 0}, {'MATH101': 120, 'MATH101H': 90, 'PHYS110': 120},
[180, 90, 120, 180],
[['after', 'MATH101H', 'PHYS110'], ['coincidence', 'MATH101', 'MATH101H'],
['exclusion', 'PHYS110', 'MATH101']]],
[['coincidence', 'MATH101', 'MATH101H'], ['exclusion', 'PHYS110', 'MATH101']]),
('normal control 7',
[{'MATH101': 3, 'MATH101H': 3, 'CHEM120': 1, 'HIST140': 2, 'PHYS110': 1, 'BIO130': 0},
{'MATH101': 180, 'MATH101H': 120, 'PHYS110': 120, 'CHEM120': 180, 'BIO130': 90, 'HIST140': 180},
[120, 90, 180, 180], [['after', 'MATH101H', 'PHYS110'], ['coincidence', 'BIO130', 'MATH101']]],
[['duration', 'CHEM120'], ['duration', 'PHYS110'], ['coincidence', 'BIO130', 'MATH101']]),
('normal control 8',
[{'CHEM120': 0, 'MATH101H': 1, 'MATH101': 2, 'HIST140': 3, 'BIO130': 3, 'PHYS110': 1},
{'MATH101': 90, 'MATH101H': 120, 'PHYS110': 180, 'CHEM120': 90, 'BIO130': 90, 'HIST140': 180},
[180, 90, 120, 90], [['exclusive', 'HIST140', 'BIO130']]],
[['duration', 'HIST140'], ['duration', 'MATH101H'], ['duration', 'PHYS110'],
['exclusive', 'HIST140', 'BIO130']])],
[('regression: exclusive counts self 1',
[{'MATH101H': 3, 'MATH101': 2, 'PHYS110': 3}, {'MATH101': 120, 'MATH101H': 120, 'PHYS110': 90},
[90, 180, 90, 90],
[['exclusive', 'MATH101', 'PHYS110'], ['coincidence', 'PHYS110', 'MATH101'],
['after', 'MATH101H', 'PHYS110']]],
[['duration', 'MATH101'], ['duration', 'MATH101H'], ['coincidence', 'PHYS110', 'MATH101'],
['after', 'MATH101H', 'PHYS110']]),
('regression variant: exclusive counts self 2',
[{'PHYS110': 3, 'MATH101H': 0, 'CHEM120': 3, 'MATH101': 2},
{'MATH101': 120, 'MATH101H': 120, 'PHYS110': 180, 'CHEM120': 90}, [120, 180, 120, 180],
[['coincidence', 'MATH101H', 'PHYS110'], ['exclusive', 'MATH101H', 'MATH101'],
['exclusive', 'PHYS110', 'CHEM120']]],
[['coincidence', 'MATH101H', 'PHYS110'], ['exclusive', 'PHYS110', 'CHEM120']]),
('partial repair guard 3',
[{'PHYS110': 0, 'CHEM120': 3, 'MATH101H': 2, 'MATH101': 0},
{'MATH101': 120, 'MATH101H': 120, 'PHYS110': 120, 'CHEM120': 120}, [90, 180, 90, 120],
[['after', 'CHEM120', 'MATH101'], ['exclusive', 'MATH101', 'CHEM120']]],
[['duration', 'MATH101'], ['duration', 'MATH101H'], ['duration', 'PHYS110'],
['exclusive', 'MATH101', 'CHEM120']]),
('boundary control 4', [{'B': 0, 'A': 1}, {'A': 180, 'B': 180}, [120, 120], []],
[['duration', 'A'], ['duration', 'B']]),
('normal control 5',
[{'PHYS110': 2, 'MATH101': 3, 'MATH101H': 3}, {'MATH101': 120, 'MATH101H': 120, 'PHYS110': 180},
[90, 90, 180, 120], [['coincidence', 'MATH101', 'MATH101H']]],
[]),
('normal control 6',
[{'CHEM120': 0, 'MATH101H': 0, 'PHYS110': 1, 'MATH101': 1},
{'MATH101': 120, 'MATH101H': 120, 'PHYS110': 90, 'CHEM120': 120}, [120, 180, 180, 90],
[['exclusion', 'CHEM120', 'MATH101H']]],
[['exclusion', 'CHEM120', 'MATH101H']]),
('normal control 7',
[{'CHEM120': 2, 'MATH101': 1, 'PHYS110': 3, 'BIO130': 0, 'MATH101H': 3},
{'MATH101': 180, 'MATH101H': 90, 'PHYS110': 90, 'CHEM120': 120, 'BIO130': 90}, [90, 120, 120, 90],
[['exclusive', 'MATH101H', 'BIO130'], ['after', 'MATH101', 'BIO130'], ['after', 'MATH101H', 'CHEM120'],
['exclusive', 'MATH101H', 'CHEM120']]],
[['duration', 'MATH101'], ['exclusive', 'MATH101H', 'BIO130'], ['exclusive', 'MATH101H', 'CHEM120']]),
('normal control 8',
[{'CHEM120': 3, 'BIO130': 0, 'MATH101': 0, 'MATH101H': 3, 'PHYS110': 2},
{'MATH101': 180, 'MATH101H': 90, 'PHYS110': 120, 'CHEM120': 90, 'BIO130': 180}, [90, 120, 180, 90],
[['after', 'PHYS110', 'CHEM120']]],
[['duration', 'BIO130'], ['duration', 'MATH101'], ['after', 'PHYS110', 'CHEM120']])],
[('regression: exclusive counts self 1',
[{'MATH101': 2, 'MATH101H': 3, 'PHYS110': 1, 'CHEM120': 1},
{'MATH101': 120, 'MATH101H': 120, 'PHYS110': 180, 'CHEM120': 90}, [120, 180, 90, 120],
[['coincidence', 'MATH101H', 'PHYS110'], ['exclusive', 'MATH101H', 'MATH101'],
['coincidence', 'MATH101H', 'CHEM120']]],
[['duration', 'MATH101'], ['coincidence', 'MATH101H', 'PHYS110'], ['coincidence', 'MATH101H', 'CHEM120']]),
('regression variant: exclusive counts self 2',
[{'MATH101': 2, 'MATH101H': 1, 'CHEM120': 0, 'PHYS110': 3},
{'MATH101': 180, 'MATH101H': 120, 'PHYS110': 180, 'CHEM120': 180}, [120, 180, 90, 180],
[['exclusive', 'MATH101', 'CHEM120'], ['after', 'PHYS110', 'MATH101H'],
['exclusive', 'MATH101H', 'PHYS110'], ['exclusive', 'CHEM120', 'MATH101']]],
[['duration', 'CHEM120'], ['duration', 'MATH101']]),
('partial repair guard 3',
[{'MATH101': 0, 'MATH101H': 3, 'PHYS110': 0}, {'MATH101': 180, 'MATH101H': 90, 'PHYS110': 90},
[180, 90, 180, 180], [['exclusive', 'PHYS110', 'MATH101'], ['exclusion', 'MATH101H', 'PHYS110']]],
[['exclusive', 'PHYS110', 'MATH101']]),
('boundary control 4', [{'A': 0}, {'A': 120}, [120], []], []),
('normal control 5',
[{'PHYS110': 1, 'MATH101H': 3, 'MATH101': 2, 'CHEM120': 2, 'BIO130': 2},
{'MATH101': 180, 'MATH101H': 180, 'PHYS110': 180, 'CHEM120': 180, 'BIO130': 90}, [90, 90, 90, 180],
[['exclusive', 'BIO130', 'CHEM120'], ['exclusive', 'BIO130', 'MATH101'], ['after', 'MATH101H', 'PHYS110'],
['coincidence', 'PHYS110', 'CHEM120']]],
[['duration', 'CHEM120'], ['duration', 'MATH101'], ['duration', 'PHYS110'],
['exclusive', 'BIO130', 'CHEM120'], ['exclusive', 'BIO130', 'MATH101'],
['coincidence', 'PHYS110', 'CHEM120']]),
('normal control 6',
[{'BIO130': 1, 'MATH101H': 2, 'CHEM120': 2, 'PHYS110': 0, 'MATH101': 3},
{'MATH101': 180, 'MATH101H': 180, 'PHYS110': 90, 'CHEM120': 180, 'BIO130': 120}, [180, 120, 180, 90],
[['exclusive', 'CHEM120', 'BIO130']]],
[['duration', 'MATH101'], ['exclusive', 'CHEM120', 'BIO130']]),
('normal control 7',
[{'CHEM120': 3, 'MATH101H': 3, 'MATH101': 2, 'PHYS110': 0, 'BIO130': 0},
{'MATH101': 180, 'MATH101H': 90, 'PHYS110': 90, 'CHEM120': 180, 'BIO130': 120}, [180, 120, 90, 120],
[['exclusion', 'BIO130', 'CHEM120'], ['after', 'CHEM120', 'PHYS110'],
['exclusive', 'MATH101H', 'CHEM120']]],
[['duration', 'CHEM120'], ['duration', 'MATH101'], ['exclusive', 'MATH101H', 'CHEM120']]),
('normal control 8',
[{'MATH101H': 0, 'BIO130': 2, 'CHEM120': 3, 'MATH101': 2, 'PHYS110': 2, 'HIST140': 3},
{'MATH101': 180, 'MATH101H': 180, 'PHYS110': 90, 'CHEM120': 180, 'BIO130': 90, 'HIST140': 180},
[90, 120, 90, 180], [['after', 'BIO130', 'CHEM120'], ['exclusion', 'BIO130', 'MATH101']]],
[['duration', 'MATH101'], ['duration', 'MATH101H'], ['after', 'BIO130', 'CHEM120'],
['exclusion', 'BIO130', 'MATH101']])],
[('regression: exclusive counts self 1',
[{'MATH101H': 2, 'MATH101': 0, 'PHYS110': 3}, {'MATH101': 180, 'MATH101H': 90, 'PHYS110': 90},
[90, 120, 120, 180],
[['after', 'PHYS110', 'MATH101H'], ['exclusive', 'MATH101', 'PHYS110'],
['exclusion', 'MATH101H', 'MATH101']]],
[['duration', 'MATH101']]),
('regression variant: exclusive counts self 2',
[{'MATH101H': 2, 'PHYS110': 0, 'MATH101': 1}, {'MATH101': 180, 'MATH101H': 90, 'PHYS110': 180},
[120, 90, 180, 180], [['exclusive', 'MATH101H', 'PHYS110'], ['exclusive', 'MATH101', 'PHYS110']]],
[['duration', 'MATH101'], ['duration', 'PHYS110']]),
('partial repair guard 3',
[{'MATH101H': 1, 'PHYS110': 1, 'MATH101': 2}, {'MATH101': 90, 'MATH101H': 90, 'PHYS110': 120},
[180, 120, 120, 120],
[['coincidence', 'PHYS110', 'MATH101'], ['exclusive', 'PHYS110', 'MATH101H'],
['after', 'PHYS110', 'MATH101'], ['coincidence', 'MATH101', 'MATH101H']]],
[['coincidence', 'PHYS110', 'MATH101'], ['exclusive', 'PHYS110', 'MATH101H'],
['after', 'PHYS110', 'MATH101'], ['coincidence', 'MATH101', 'MATH101H']]),
('boundary control 4', [{'A': 1, 'B': 1}, {'A': 90, 'B': 90}, [90, 120], [['after', 'A', 'B']]],
[['after', 'A', 'B']]),
('normal control 5',
[{'HIST140': 0, 'BIO130': 1, 'MATH101H': 0, 'CHEM120': 3, 'PHYS110': 0, 'MATH101': 2},
{'MATH101': 90, 'MATH101H': 180, 'PHYS110': 180, 'CHEM120': 120, 'BIO130': 120, 'HIST140': 120},
[120, 180, 120, 90], [['coincidence', 'HIST140', 'MATH101H'], ['exclusive', 'BIO130', 'MATH101']]],
[['duration', 'CHEM120'], ['duration', 'MATH101H'], ['duration', 'PHYS110']]),
('normal control 6',
[{'BIO130': 0, 'MATH101': 2, 'CHEM120': 0, 'PHYS110': 3, 'MATH101H': 1, 'HIST140': 2},
{'MATH101': 120, 'MATH101H': 120, 'PHYS110': 180, 'CHEM120': 90, 'BIO130': 180, 'HIST140': 120},
[120, 180, 180, 180],
[['exclusion', 'PHYS110', 'BIO130'], ['exclusion', 'CHEM120', 'BIO130'], ['after', 'BIO130', 'MATH101'],
['after', 'BIO130', 'MATH101H']]],
[['duration', 'BIO130'], ['exclusion', 'CHEM120', 'BIO130'], ['after', 'BIO130', 'MATH101'],
['after', 'BIO130', 'MATH101H']]),
('normal control 7',
[{'CHEM120': 2, 'MATH101H': 2, 'PHYS110': 3, 'MATH101': 3},
{'MATH101': 90, 'MATH101H': 180, 'PHYS110': 180, 'CHEM120': 180}, [180, 90, 180, 180],
[['exclusive', 'MATH101H', 'PHYS110'], ['coincidence', 'CHEM120', 'PHYS110']]],
[['exclusive', 'MATH101H', 'PHYS110'], ['coincidence', 'CHEM120', 'PHYS110']]),
('normal control 8',
[{'PHYS110': 0, 'MATH101H': 3, 'MATH101': 3}, {'MATH101': 180, 'MATH101H': 180, 'PHYS110': 90},
[90, 180, 90, 180],
[['exclusive', 'PHYS110', 'MATH101'], ['after', 'PHYS110', 'MATH101'],
['exclusion', 'MATH101', 'PHYS110']]],
[['after', 'PHYS110', 'MATH101']])]]
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: exclusive counts self 1 | [['exclusive', 'A', 'B']] | [] | Failed |
| regression variant: exclusive counts self 2 | [['exclusive', 'PHYS110', 'MATH101'], ['coincidence', 'PHYS110', 'MATH101H']] | [['coincidence', 'PHYS110', 'MATH101H']] | Failed |
| partial repair guard 3 | [['exclusive', 'MATH101H', 'PHYS110'], ['coincidence', 'CHEM120', 'PHYS110']] | [['exclusive', 'MATH101H', 'PHYS110'], ['coincidence', 'CHEM120', 'PHYS110']] | Passed |
| normal control 4 | [['duration', 'MATH101'], ['duration', 'PHYS110'], ['exclusive', 'CHEM120', 'MATH101'], ['coincidence', 'MATH101H', 'MATH101']] | [['duration', 'MATH101'], ['duration', 'PHYS110'], ['exclusive', 'CHEM120', 'MATH101'], ['coincidence', 'MATH101H', 'MATH101']] | Passed |
| normal control 5 | [['duration', 'MATH101H'], ['coincidence', 'MATH101', 'PHYS110']] | [['duration', 'MATH101H'], ['coincidence', 'MATH101', 'PHYS110']] | Passed |
| normal control 6 | [['duration', 'BIO130'], ['duration', 'CHEM120'], ['duration', 'MATH101'], ['coincidence', 'MATH101', 'CHEM120'], ['exclusive', 'CHEM120', 'MATH101'], ['coincidence', 'MATH101H', 'MATH101']] | [['duration', 'BIO130'], ['duration', 'CHEM120'], ['duration', 'MATH101'], ['coincidence', 'MATH101', 'CHEM120'], ['coincidence', 'MATH101H', 'MATH101']] | Failed |
| normal control 7 | [['duration', 'CHEM120'], ['duration', 'PHYS110'], ['coincidence', 'BIO130', 'MATH101']] | [['duration', 'CHEM120'], ['duration', 'PHYS110'], ['coincidence', 'BIO130', 'MATH101']] | Passed |
| normal control 8 | [['duration', 'MATH101'], ['duration', 'MATH101H'], ['after', 'PHYS110', 'MATH101H'], ['exclusion', 'MATH101H', 'PHYS110'], ['exclusive', 'MATH101H', 'MATH101']] | [['duration', 'MATH101'], ['duration', 'MATH101H'], ['after', 'PHYS110', 'MATH101H'], ['exclusion', 'MATH101H', 'PHYS110'], ['exclusive', 'MATH101H', 'MATH101']] | Passed |
SHA-256 / cc3fb65d835377edbb8c1e57df93bf3fd8401c689d741dc6f8d5f2f0d5c1b9a9
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(timetable, exams, periods, cons):
out = []
for e in sorted(timetable):
if exams[e] > periods[timetable[e]]:
out.append(['duration', e])
for kind, a, b in cons:
pa, pb = timetable[a], timetable[b]
if kind == 'after' and not pa > pb:
out.append([kind, a, b])
elif kind == 'exclusion' and pa == pb:
out.append([kind, a, b])
elif kind == 'coincidence' and pa != pb:
out.append([kind, a, b])
elif kind == 'exclusive' and sum(1 for e in timetable if timetable[e] == pa) > 2:
out.append([kind, a, b])
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: exclusive counts self 1',
[{'A': 1, 'B': 0}, {'A': 120, 'B': 90}, [90, 120], [['exclusive', 'A', 'B']]], []),
('regression variant: exclusive counts self 2',
[{'MATH101': 3, 'PHYS110': 0, 'MATH101H': 2}, {'MATH101': 120, 'MATH101H': 180, 'PHYS110': 180},
[180, 90, 180, 180], [['exclusive', 'PHYS110', 'MATH101'], ['coincidence', 'PHYS110', 'MATH101H']]],
[['coincidence', 'PHYS110', 'MATH101H']]),
('partial repair guard 3',
[{'CHEM120': 2, 'MATH101H': 2, 'PHYS110': 3, 'MATH101': 3},
{'MATH101': 90, 'MATH101H': 180, 'PHYS110': 180, 'CHEM120': 180}, [180, 90, 180, 180],
[['exclusive', 'MATH101H', 'PHYS110'], ['coincidence', 'CHEM120', 'PHYS110']]],
[['exclusive', 'MATH101H', 'PHYS110'], ['coincidence', 'CHEM120', 'PHYS110']]),
('normal control 4',
[{'PHYS110': 2, 'MATH101': 2, 'MATH101H': 1, 'CHEM120': 2},
{'MATH101': 180, 'MATH101H': 120, 'PHYS110': 180, 'CHEM120': 90}, [180, 120, 90, 90],
[['exclusive', 'CHEM120', 'MATH101'], ['coincidence', 'MATH101H', 'MATH101'],
['exclusion', 'MATH101H', 'MATH101']]],
[['duration', 'MATH101'], ['duration', 'PHYS110'], ['exclusive', 'CHEM120', 'MATH101'],
['coincidence', 'MATH101H', 'MATH101']]),
('normal control 5',
[{'PHYS110': 3, 'MATH101': 0, 'MATH101H': 3}, {'MATH101': 120, 'MATH101H': 120, 'PHYS110': 90},
[180, 90, 180, 90], [['coincidence', 'MATH101', 'PHYS110'], ['after', 'PHYS110', 'MATH101']]],
[['duration', 'MATH101H'], ['coincidence', 'MATH101', 'PHYS110']]),
('normal control 6',
[{'CHEM120': 0, 'MATH101': 3, 'MATH101H': 1, 'PHYS110': 1, 'BIO130': 2},
{'MATH101': 180, 'MATH101H': 180, 'PHYS110': 90, 'CHEM120': 180, 'BIO130': 120}, [90, 180, 90, 90],
[['coincidence', 'MATH101', 'CHEM120'], ['exclusive', 'CHEM120', 'MATH101'],
['coincidence', 'MATH101H', 'MATH101'], ['after', 'PHYS110', 'CHEM120']]],
[['duration', 'BIO130'], ['duration', 'CHEM120'], ['duration', 'MATH101'],
['coincidence', 'MATH101', 'CHEM120'], ['coincidence', 'MATH101H', 'MATH101']]),
('normal control 7',
[{'MATH101': 3, 'MATH101H': 3, 'CHEM120': 1, 'HIST140': 2, 'PHYS110': 1, 'BIO130': 0},
{'MATH101': 180, 'MATH101H': 120, 'PHYS110': 120, 'CHEM120': 180, 'BIO130': 90, 'HIST140': 180},
[120, 90, 180, 180], [['after', 'MATH101H', 'PHYS110'], ['coincidence', 'BIO130', 'MATH101']]],
[['duration', 'CHEM120'], ['duration', 'PHYS110'], ['coincidence', 'BIO130', 'MATH101']]),
('normal control 8',
[{'MATH101H': 1, 'PHYS110': 1, 'MATH101': 3}, {'MATH101': 180, 'MATH101H': 180, 'PHYS110': 120},
[90, 120, 120, 120],
[['after', 'PHYS110', 'MATH101H'], ['exclusion', 'MATH101H', 'PHYS110'],
['exclusive', 'MATH101H', 'MATH101']]],
[['duration', 'MATH101'], ['duration', 'MATH101H'], ['after', 'PHYS110', 'MATH101H'],
['exclusion', 'MATH101H', 'PHYS110'], ['exclusive', 'MATH101H', 'MATH101']])],
[('regression: exclusive counts self 1',
[{'MATH101H': 0, 'PHYS110': 0, 'CHEM120': 1, 'BIO130': 1, 'MATH101': 3},
{'MATH101': 120, 'MATH101H': 180, 'PHYS110': 90, 'CHEM120': 120, 'BIO130': 90}, [180, 120, 120, 90],
[['exclusive', 'MATH101', 'PHYS110']]],
[['duration', 'MATH101']]),
('regression variant: exclusive counts self 2',
[{'MATH101H': 3, 'PHYS110': 3, 'MATH101': 0}, {'MATH101': 120, 'MATH101H': 180, 'PHYS110': 180},
[120, 180, 180, 120], [['exclusive', 'MATH101', 'MATH101H']]],
[['duration', 'MATH101H'], ['duration', 'PHYS110']]),
('partial repair guard 3',
[{'CHEM120': 2, 'MATH101H': 3, 'PHYS110': 3, 'MATH101': 1},
{'MATH101': 180, 'MATH101H': 120, 'PHYS110': 90, 'CHEM120': 180}, [120, 90, 120, 120],
[['exclusive', 'PHYS110', 'MATH101'], ['exclusive', 'PHYS110', 'CHEM120']]],
[['duration', 'CHEM120'], ['duration', 'MATH101'], ['exclusive', 'PHYS110', 'MATH101'],
['exclusive', 'PHYS110', 'CHEM120']]),
('boundary control 4', [{'A': 2, 'B': 1}, {'A': 90, 'B': 90}, [90, 120, 120], [['after', 'A', 'B']]], []),
('normal control 5',
[{'MATH101': 0, 'PHYS110': 2, 'BIO130': 2, 'MATH101H': 3, 'CHEM120': 2},
{'MATH101': 180, 'MATH101H': 90, 'PHYS110': 120, 'CHEM120': 180, 'BIO130': 180}, [180, 90, 180, 90],
[['after', 'CHEM120', 'MATH101'], ['coincidence', 'MATH101', 'CHEM120'],
['exclusive', 'BIO130', 'MATH101']]],
[['coincidence', 'MATH101', 'CHEM120'], ['exclusive', 'BIO130', 'MATH101']]),
('normal control 6',
[{'MATH101': 0, 'MATH101H': 3, 'PHYS110': 0}, {'MATH101': 120, 'MATH101H': 90, 'PHYS110': 120},
[180, 90, 120, 180],
[['after', 'MATH101H', 'PHYS110'], ['coincidence', 'MATH101', 'MATH101H'],
['exclusion', 'PHYS110', 'MATH101']]],
[['coincidence', 'MATH101', 'MATH101H'], ['exclusion', 'PHYS110', 'MATH101']]),
('normal control 7',
[{'MATH101': 3, 'MATH101H': 3, 'CHEM120': 1, 'HIST140': 2, 'PHYS110': 1, 'BIO130': 0},
{'MATH101': 180, 'MATH101H': 120, 'PHYS110': 120, 'CHEM120': 180, 'BIO130': 90, 'HIST140': 180},
[120, 90, 180, 180], [['after', 'MATH101H', 'PHYS110'], ['coincidence', 'BIO130', 'MATH101']]],
[['duration', 'CHEM120'], ['duration', 'PHYS110'], ['coincidence', 'BIO130', 'MATH101']]),
('normal control 8',
[{'CHEM120': 0, 'MATH101H': 1, 'MATH101': 2, 'HIST140': 3, 'BIO130': 3, 'PHYS110': 1},
{'MATH101': 90, 'MATH101H': 120, 'PHYS110': 180, 'CHEM120': 90, 'BIO130': 90, 'HIST140': 180},
[180, 90, 120, 90], [['exclusive', 'HIST140', 'BIO130']]],
[['duration', 'HIST140'], ['duration', 'MATH101H'], ['duration', 'PHYS110'],
['exclusive', 'HIST140', 'BIO130']])],
[('regression: exclusive counts self 1',
[{'MATH101H': 3, 'MATH101': 2, 'PHYS110': 3}, {'MATH101': 120, 'MATH101H': 120, 'PHYS110': 90},
[90, 180, 90, 90],
[['exclusive', 'MATH101', 'PHYS110'], ['coincidence', 'PHYS110', 'MATH101'],
['after', 'MATH101H', 'PHYS110']]],
[['duration', 'MATH101'], ['duration', 'MATH101H'], ['coincidence', 'PHYS110', 'MATH101'],
['after', 'MATH101H', 'PHYS110']]),
('regression variant: exclusive counts self 2',
[{'PHYS110': 3, 'MATH101H': 0, 'CHEM120': 3, 'MATH101': 2},
{'MATH101': 120, 'MATH101H': 120, 'PHYS110': 180, 'CHEM120': 90}, [120, 180, 120, 180],
[['coincidence', 'MATH101H', 'PHYS110'], ['exclusive', 'MATH101H', 'MATH101'],
['exclusive', 'PHYS110', 'CHEM120']]],
[['coincidence', 'MATH101H', 'PHYS110'], ['exclusive', 'PHYS110', 'CHEM120']]),
('partial repair guard 3',
[{'PHYS110': 0, 'CHEM120': 3, 'MATH101H': 2, 'MATH101': 0},
{'MATH101': 120, 'MATH101H': 120, 'PHYS110': 120, 'CHEM120': 120}, [90, 180, 90, 120],
[['after', 'CHEM120', 'MATH101'], ['exclusive', 'MATH101', 'CHEM120']]],
[['duration', 'MATH101'], ['duration', 'MATH101H'], ['duration', 'PHYS110'],
['exclusive', 'MATH101', 'CHEM120']]),
('boundary control 4', [{'B': 0, 'A': 1}, {'A': 180, 'B': 180}, [120, 120], []],
[['duration', 'A'], ['duration', 'B']]),
('normal control 5',
[{'PHYS110': 2, 'MATH101': 3, 'MATH101H': 3}, {'MATH101': 120, 'MATH101H': 120, 'PHYS110': 180},
[90, 90, 180, 120], [['coincidence', 'MATH101', 'MATH101H']]],
[]),
('normal control 6',
[{'CHEM120': 0, 'MATH101H': 0, 'PHYS110': 1, 'MATH101': 1},
{'MATH101': 120, 'MATH101H': 120, 'PHYS110': 90, 'CHEM120': 120}, [120, 180, 180, 90],
[['exclusion', 'CHEM120', 'MATH101H']]],
[['exclusion', 'CHEM120', 'MATH101H']]),
('normal control 7',
[{'CHEM120': 2, 'MATH101': 1, 'PHYS110': 3, 'BIO130': 0, 'MATH101H': 3},
{'MATH101': 180, 'MATH101H': 90, 'PHYS110': 90, 'CHEM120': 120, 'BIO130': 90}, [90, 120, 120, 90],
[['exclusive', 'MATH101H', 'BIO130'], ['after', 'MATH101', 'BIO130'], ['after', 'MATH101H', 'CHEM120'],
['exclusive', 'MATH101H', 'CHEM120']]],
[['duration', 'MATH101'], ['exclusive', 'MATH101H', 'BIO130'], ['exclusive', 'MATH101H', 'CHEM120']]),
('normal control 8',
[{'CHEM120': 3, 'BIO130': 0, 'MATH101': 0, 'MATH101H': 3, 'PHYS110': 2},
{'MATH101': 180, 'MATH101H': 90, 'PHYS110': 120, 'CHEM120': 90, 'BIO130': 180}, [90, 120, 180, 90],
[['after', 'PHYS110', 'CHEM120']]],
[['duration', 'BIO130'], ['duration', 'MATH101'], ['after', 'PHYS110', 'CHEM120']])],
[('regression: exclusive counts self 1',
[{'MATH101': 2, 'MATH101H': 3, 'PHYS110': 1, 'CHEM120': 1},
{'MATH101': 120, 'MATH101H': 120, 'PHYS110': 180, 'CHEM120': 90}, [120, 180, 90, 120],
[['coincidence', 'MATH101H', 'PHYS110'], ['exclusive', 'MATH101H', 'MATH101'],
['coincidence', 'MATH101H', 'CHEM120']]],
[['duration', 'MATH101'], ['coincidence', 'MATH101H', 'PHYS110'], ['coincidence', 'MATH101H', 'CHEM120']]),
('regression variant: exclusive counts self 2',
[{'MATH101': 2, 'MATH101H': 1, 'CHEM120': 0, 'PHYS110': 3},
{'MATH101': 180, 'MATH101H': 120, 'PHYS110': 180, 'CHEM120': 180}, [120, 180, 90, 180],
[['exclusive', 'MATH101', 'CHEM120'], ['after', 'PHYS110', 'MATH101H'],
['exclusive', 'MATH101H', 'PHYS110'], ['exclusive', 'CHEM120', 'MATH101']]],
[['duration', 'CHEM120'], ['duration', 'MATH101']]),
('partial repair guard 3',
[{'MATH101': 0, 'MATH101H': 3, 'PHYS110': 0}, {'MATH101': 180, 'MATH101H': 90, 'PHYS110': 90},
[180, 90, 180, 180], [['exclusive', 'PHYS110', 'MATH101'], ['exclusion', 'MATH101H', 'PHYS110']]],
[['exclusive', 'PHYS110', 'MATH101']]),
('boundary control 4', [{'A': 0}, {'A': 120}, [120], []], []),
('normal control 5',
[{'PHYS110': 1, 'MATH101H': 3, 'MATH101': 2, 'CHEM120': 2, 'BIO130': 2},
{'MATH101': 180, 'MATH101H': 180, 'PHYS110': 180, 'CHEM120': 180, 'BIO130': 90}, [90, 90, 90, 180],
[['exclusive', 'BIO130', 'CHEM120'], ['exclusive', 'BIO130', 'MATH101'], ['after', 'MATH101H', 'PHYS110'],
['coincidence', 'PHYS110', 'CHEM120']]],
[['duration', 'CHEM120'], ['duration', 'MATH101'], ['duration', 'PHYS110'],
['exclusive', 'BIO130', 'CHEM120'], ['exclusive', 'BIO130', 'MATH101'],
['coincidence', 'PHYS110', 'CHEM120']]),
('normal control 6',
[{'BIO130': 1, 'MATH101H': 2, 'CHEM120': 2, 'PHYS110': 0, 'MATH101': 3},
{'MATH101': 180, 'MATH101H': 180, 'PHYS110': 90, 'CHEM120': 180, 'BIO130': 120}, [180, 120, 180, 90],
[['exclusive', 'CHEM120', 'BIO130']]],
[['duration', 'MATH101'], ['exclusive', 'CHEM120', 'BIO130']]),
('normal control 7',
[{'CHEM120': 3, 'MATH101H': 3, 'MATH101': 2, 'PHYS110': 0, 'BIO130': 0},
{'MATH101': 180, 'MATH101H': 90, 'PHYS110': 90, 'CHEM120': 180, 'BIO130': 120}, [180, 120, 90, 120],
[['exclusion', 'BIO130', 'CHEM120'], ['after', 'CHEM120', 'PHYS110'],
['exclusive', 'MATH101H', 'CHEM120']]],
[['duration', 'CHEM120'], ['duration', 'MATH101'], ['exclusive', 'MATH101H', 'CHEM120']]),
('normal control 8',
[{'MATH101H': 0, 'BIO130': 2, 'CHEM120': 3, 'MATH101': 2, 'PHYS110': 2, 'HIST140': 3},
{'MATH101': 180, 'MATH101H': 180, 'PHYS110': 90, 'CHEM120': 180, 'BIO130': 90, 'HIST140': 180},
[90, 120, 90, 180], [['after', 'BIO130', 'CHEM120'], ['exclusion', 'BIO130', 'MATH101']]],
[['duration', 'MATH101'], ['duration', 'MATH101H'], ['after', 'BIO130', 'CHEM120'],
['exclusion', 'BIO130', 'MATH101']])],
[('regression: exclusive counts self 1',
[{'MATH101H': 2, 'MATH101': 0, 'PHYS110': 3}, {'MATH101': 180, 'MATH101H': 90, 'PHYS110': 90},
[90, 120, 120, 180],
[['after', 'PHYS110', 'MATH101H'], ['exclusive', 'MATH101', 'PHYS110'],
['exclusion', 'MATH101H', 'MATH101']]],
[['duration', 'MATH101']]),
('regression variant: exclusive counts self 2',
[{'MATH101H': 2, 'PHYS110': 0, 'MATH101': 1}, {'MATH101': 180, 'MATH101H': 90, 'PHYS110': 180},
[120, 90, 180, 180], [['exclusive', 'MATH101H', 'PHYS110'], ['exclusive', 'MATH101', 'PHYS110']]],
[['duration', 'MATH101'], ['duration', 'PHYS110']]),
('partial repair guard 3',
[{'MATH101H': 1, 'PHYS110': 1, 'MATH101': 2}, {'MATH101': 90, 'MATH101H': 90, 'PHYS110': 120},
[180, 120, 120, 120],
[['coincidence', 'PHYS110', 'MATH101'], ['exclusive', 'PHYS110', 'MATH101H'],
['after', 'PHYS110', 'MATH101'], ['coincidence', 'MATH101', 'MATH101H']]],
[['coincidence', 'PHYS110', 'MATH101'], ['exclusive', 'PHYS110', 'MATH101H'],
['after', 'PHYS110', 'MATH101'], ['coincidence', 'MATH101', 'MATH101H']]),
('boundary control 4', [{'A': 1, 'B': 1}, {'A': 90, 'B': 90}, [90, 120], [['after', 'A', 'B']]],
[['after', 'A', 'B']]),
('normal control 5',
[{'HIST140': 0, 'BIO130': 1, 'MATH101H': 0, 'CHEM120': 3, 'PHYS110': 0, 'MATH101': 2},
{'MATH101': 90, 'MATH101H': 180, 'PHYS110': 180, 'CHEM120': 120, 'BIO130': 120, 'HIST140': 120},
[120, 180, 120, 90], [['coincidence', 'HIST140', 'MATH101H'], ['exclusive', 'BIO130', 'MATH101']]],
[['duration', 'CHEM120'], ['duration', 'MATH101H'], ['duration', 'PHYS110']]),
('normal control 6',
[{'BIO130': 0, 'MATH101': 2, 'CHEM120': 0, 'PHYS110': 3, 'MATH101H': 1, 'HIST140': 2},
{'MATH101': 120, 'MATH101H': 120, 'PHYS110': 180, 'CHEM120': 90, 'BIO130': 180, 'HIST140': 120},
[120, 180, 180, 180],
[['exclusion', 'PHYS110', 'BIO130'], ['exclusion', 'CHEM120', 'BIO130'], ['after', 'BIO130', 'MATH101'],
['after', 'BIO130', 'MATH101H']]],
[['duration', 'BIO130'], ['exclusion', 'CHEM120', 'BIO130'], ['after', 'BIO130', 'MATH101'],
['after', 'BIO130', 'MATH101H']]),
('normal control 7',
[{'CHEM120': 2, 'MATH101H': 2, 'PHYS110': 3, 'MATH101': 3},
{'MATH101': 90, 'MATH101H': 180, 'PHYS110': 180, 'CHEM120': 180}, [180, 90, 180, 180],
[['exclusive', 'MATH101H', 'PHYS110'], ['coincidence', 'CHEM120', 'PHYS110']]],
[['exclusive', 'MATH101H', 'PHYS110'], ['coincidence', 'CHEM120', 'PHYS110']]),
('normal control 8',
[{'PHYS110': 0, 'MATH101H': 3, 'MATH101': 3}, {'MATH101': 180, 'MATH101H': 180, 'PHYS110': 90},
[90, 180, 90, 180],
[['exclusive', 'PHYS110', 'MATH101'], ['after', 'PHYS110', 'MATH101'],
['exclusion', 'MATH101', 'PHYS110']]],
[['after', 'PHYS110', 'MATH101']])]]
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: exclusive counts self 1 | [] | [] | Passed |
| regression variant: exclusive counts self 2 | [['coincidence', 'PHYS110', 'MATH101H']] | [['coincidence', 'PHYS110', 'MATH101H']] | Passed |
| partial repair guard 3 | [['coincidence', 'CHEM120', 'PHYS110']] | [['exclusive', 'MATH101H', 'PHYS110'], ['coincidence', 'CHEM120', 'PHYS110']] | Failed |
| normal control 4 | [['duration', 'MATH101'], ['duration', 'PHYS110'], ['exclusive', 'CHEM120', 'MATH101'], ['coincidence', 'MATH101H', 'MATH101']] | [['duration', 'MATH101'], ['duration', 'PHYS110'], ['exclusive', 'CHEM120', 'MATH101'], ['coincidence', 'MATH101H', 'MATH101']] | Passed |
| normal control 5 | [['duration', 'MATH101H'], ['coincidence', 'MATH101', 'PHYS110']] | [['duration', 'MATH101H'], ['coincidence', 'MATH101', 'PHYS110']] | Passed |
| normal control 6 | [['duration', 'BIO130'], ['duration', 'CHEM120'], ['duration', 'MATH101'], ['coincidence', 'MATH101', 'CHEM120'], ['coincidence', 'MATH101H', 'MATH101']] | [['duration', 'BIO130'], ['duration', 'CHEM120'], ['duration', 'MATH101'], ['coincidence', 'MATH101', 'CHEM120'], ['coincidence', 'MATH101H', 'MATH101']] | Passed |
| normal control 7 | [['duration', 'CHEM120'], ['duration', 'PHYS110'], ['coincidence', 'BIO130', 'MATH101']] | [['duration', 'CHEM120'], ['duration', 'PHYS110'], ['coincidence', 'BIO130', 'MATH101']] | Passed |
| normal control 8 | [['duration', 'MATH101'], ['duration', 'MATH101H'], ['after', 'PHYS110', 'MATH101H'], ['exclusion', 'MATH101H', 'PHYS110']] | [['duration', 'MATH101'], ['duration', 'MATH101H'], ['after', 'PHYS110', 'MATH101H'], ['exclusion', 'MATH101H', 'PHYS110'], ['exclusive', 'MATH101H', 'MATH101']] | Failed |
SHA-256 / f1c6c79535697e3a2f85c04cfb1bd807a88ee6d8b920737b92cea6dc9168b4e3
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗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:04.886474+00:00.
Case digest / 3ab6a7daebd0935755bc496c3336fdd471e44c2ecb5507d55ba91f4d5ce92681