FA-67741 / Elevator dispatch scheduling / Open access
Hospital code blue car selection: turn floor · case 01
The detour of a car moving away is underestimated.
ROOT CAUSE
The turn floor uses the extreme on the wrong side.
VERIFIED REPAIR
Use the highest call for up cars and the lowest for down cars.
Unsuccessful approach: Always using the highest call is wrong for down-travelling cars.
Case contract
Only cars in normal mode can answer a code blue at floor call. An idle car or one moving towards (or at) the call floor costs the floor distance. A car moving away first runs to its turn floor (the extreme of its calls and its floor in its direction) and back: |turn-floor| + |turn-call|. Lowest cost wins, ties to the lowest id. The winner cancels its car calls (reported sorted) and announces if it carries passengers.
Why this case matters
Lift group controllers make these decisions many times per minute; a wrong answer strands passengers, wastes trips or overrides a safety rule.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
best = None
for c in sorted(x['cars'], key=lambda c: c['id']):
if c['mode'] != 'normal':
continue
f = c['floor']
if c['dir'] == 'idle' or (c['dir'] == 'up' and x['call'] >= f) or (c['dir'] == 'down' and x['call'] <= f):
cost = abs(x['call'] - f)
else:
turn = min(c['calls'] + [f]) if c['dir'] == 'up' else max(c['calls'] + [f])
cost = abs(turn - f) + abs(turn - x['call'])
if best is None or cost < best[0]:
best = (cost, c)
if best is None:
return {'car': None, 'cancelled_calls': [], 'announce': False}
c = best[1]
return {'car': c['id'], 'cancelled_calls': sorted(c['calls']), 'announce': c['load'] > 0}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car moving down away', {'call': 10, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [1, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 26', {'call': 5, 'cars': [{'id': 'H3', 'floor': 6, 'dir': 'up', 'calls': [5, 12], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 8, 'dir': 'up', 'calls': [14], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 1, 'dir': 'down', 'calls': [13, 0], 'mode': 'independent', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': True}), ('sampled regression 14', {'call': 3, 'cars': [{'id': 'H3', 'floor': 12, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 9, 'dir': 'up', 'calls': [12, 9], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 10, 'dir': 'up', 'calls': [8, 11], 'mode': 'fire', 'load': 80}, {'id': 'H1', 'floor': 1, 'dir': 'down', 'calls': [10], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [10], 'announce': False}), ('boundary: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('control 1', {'call': 6, 'cars': [{'id': 'H2', 'floor': 3, 'dir': 'up', 'calls': [3], 'mode': 'fire', 'load': 0}, {'id': 'H3', 'floor': 12, 'dir': 'idle', 'calls': [6, 10], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 3, 'dir': 'idle', 'calls': [11], 'mode': 'normal', 'load': 80}]}, {'car': 'H4', 'cancelled_calls': [11], 'announce': True}), ('control 4', {'call': 3, 'cars': [{'id': 'H4', 'floor': 10, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 6, 'dir': 'idle', 'calls': [2], 'mode': 'independent', 'load': 80}, {'id': 'H3', 'floor': 0, 'dir': 'up', 'calls': [11, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 3, 'dir': 'up', 'calls': [3, 6, 4], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [3, 4, 6], 'announce': False}), ('control 7', {'call': 3, 'cars': [{'id': 'H1', 'floor': 2, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 2, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 13, 'dir': 'up', 'calls': [12, 1, 9], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 9, 'dir': 'idle', 'calls': [7], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False})], [('regression: car moving down away', {'call': 10, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [1, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('boundary: car moving away without calls', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False}), ('boundary: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('boundary: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('control 12', {'call': 8, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'idle', 'calls': [4, 9], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 10, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 4, 'dir': 'idle', 'calls': [6, 3], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 14, 'dir': 'up', 'calls': [5, 2], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [4, 9], 'announce': False}), ('control 15', {'call': 12, 'cars': [{'id': 'H3', 'floor': 1, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 14, 'dir': 'down', 'calls': [5, 3, 9], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [3, 5, 9], 'announce': True}), ('control 18', {'call': 14, 'cars': [{'id': 'H2', 'floor': 8, 'dir': 'idle', 'calls': [10, 6, 7], 'mode': 'independent', 'load': 0}, {'id': 'H4', 'floor': 8, 'dir': 'down', 'calls': [11, 14, 6], 'mode': 'normal', 'load': 0}, {'id': 'H1', 'floor': 1, 'dir': 'up', 'calls': [6, 7, 8], 'mode': 'fire', 'load': 80}]}, {'car': 'H4', 'cancelled_calls': [6, 11, 14], 'announce': False})], [('regression: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car moving down away', {'call': 10, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [1, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 14', {'call': 3, 'cars': [{'id': 'H3', 'floor': 12, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 9, 'dir': 'up', 'calls': [12, 9], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 10, 'dir': 'up', 'calls': [8, 11], 'mode': 'fire', 'load': 80}, {'id': 'H1', 'floor': 1, 'dir': 'down', 'calls': [10], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [10], 'announce': False}), ('boundary: car moving away without calls', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False}), ('boundary: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('control 23', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H3', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 4, 'dir': 'up', 'calls': [11], 'mode': 'fire', 'load': 0}]}, {'car': 'H3', 'cancelled_calls': [], 'announce': False}), ('sampled regression 26', {'call': 5, 'cars': [{'id': 'H3', 'floor': 6, 'dir': 'up', 'calls': [5, 12], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 8, 'dir': 'up', 'calls': [14], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 1, 'dir': 'down', 'calls': [13, 0], 'mode': 'independent', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': True}), ('control 29', {'call': 1, 'cars': [{'id': 'H3', 'floor': 9, 'dir': 'down', 'calls': [5], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 8, 'dir': 'down', 'calls': [2, 11, 14], 'mode': 'normal', 'load': 80}]}, {'car': 'H2', 'cancelled_calls': [2, 11, 14], 'announce': True})], [('regression: car moving down away', {'call': 10, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [1, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 27', {'call': 9, 'cars': [{'id': 'H1', 'floor': 11, 'dir': 'up', 'calls': [1, 11, 3], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 11, 'dir': 'down', 'calls': [12, 8, 10], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 5, 'dir': 'up', 'calls': [7, 12, 11], 'mode': 'fire', 'load': 80}, {'id': 'H3', 'floor': 11, 'dir': 'up', 'calls': [9, 13, 12], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [1, 3, 11], 'announce': True}), ('boundary: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('boundary: car moving away without calls', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False}), ('control 34', {'call': 9, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [14, 5], 'mode': 'independent', 'load': 80}]}, {'car': None, 'cancelled_calls': [], 'announce': False}), ('control 37', {'call': 2, 'cars': [{'id': 'H3', 'floor': 0, 'dir': 'up', 'calls': [2, 7, 11], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 11, 'dir': 'down', 'calls': [8], 'mode': 'fire', 'load': 0}]}, {'car': 'H3', 'cancelled_calls': [2, 7, 11], 'announce': False}), ('control 40', {'call': 6, 'cars': [{'id': 'H3', 'floor': 10, 'dir': 'up', 'calls': [14, 13, 4], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [2, 1], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 1, 'dir': 'down', 'calls': [2, 10, 14], 'mode': 'independent', 'load': 80}, {'id': 'H4', 'floor': 3, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}]}, {'car': 'H4', 'cancelled_calls': [12], 'announce': True})], [('regression: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car moving down away', {'call': 10, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [1, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 14', {'call': 3, 'cars': [{'id': 'H3', 'floor': 12, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 9, 'dir': 'up', 'calls': [12, 9], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 10, 'dir': 'up', 'calls': [8, 11], 'mode': 'fire', 'load': 80}, {'id': 'H1', 'floor': 1, 'dir': 'down', 'calls': [10], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [10], 'announce': False}), ('boundary: car moving away without calls', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False}), ('boundary: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('control 45', {'call': 0, 'cars': [{'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [14], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 10, 'dir': 'down', 'calls': [], 'mode': 'fire', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [14], 'announce': False}), ('control 48', {'call': 8, 'cars': [{'id': 'H4', 'floor': 14, 'dir': 'up', 'calls': [12, 2], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 5, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 0, 'dir': 'idle', 'calls': [12], 'mode': 'fire', 'load': 0}, {'id': 'H1', 'floor': 3, 'dir': 'up', 'calls': [3], 'mode': 'normal', 'load': 80}]}, {'car': 'H3', 'cancelled_calls': [], 'announce': False}), ('control 51', {'call': 11, 'cars': [{'id': 'H3', 'floor': 2, 'dir': 'down', 'calls': [11], 'mode': 'independent', 'load': 0}, {'id': 'H4', 'floor': 7, 'dir': 'idle', 'calls': [14, 7], 'mode': 'independent', 'load': 80}, {'id': 'H2', 'floor': 12, 'dir': 'up', 'calls': [10, 9, 13], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 11, 'dir': 'idle', 'calls': [0, 9], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [0, 9], 'announce': True})]]
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: car moving away with a far call | {'announce': True, 'cancelled_calls': [12], 'car': 'H1'} | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | Failed |
| regression: car moving down away | {'announce': False, 'cancelled_calls': [1, 6], 'car': 'H1'} | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | Failed |
| sampled regression 26 | {'announce': True, 'cancelled_calls': [5, 12], 'car': 'H3'} | {'announce': True, 'cancelled_calls': [], 'car': 'H2'} | Failed |
| sampled regression 14 | {'announce': True, 'cancelled_calls': [], 'car': 'H3'} | {'announce': False, 'cancelled_calls': [10], 'car': 'H1'} | Failed |
| boundary: car on independent service nearby | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | Passed |
| control 1 | {'announce': True, 'cancelled_calls': [11], 'car': 'H4'} | {'announce': True, 'cancelled_calls': [11], 'car': 'H4'} | Passed |
| control 4 | {'announce': False, 'cancelled_calls': [3, 4, 6], 'car': 'H2'} | {'announce': False, 'cancelled_calls': [3, 4, 6], 'car': 'H2'} | Passed |
| control 7 | {'announce': False, 'cancelled_calls': [], 'car': 'H1'} | {'announce': False, 'cancelled_calls': [], 'car': 'H1'} | Passed |
SHA-256 / 4595cf4c21abd1d459a54c43d0f91ae5010b7596dffd5b15fdd0aa3a0688efc3
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
best = None
for c in sorted(x['cars'], key=lambda c: c['id']):
if c['mode'] != 'normal':
continue
f = c['floor']
if c['dir'] == 'idle' or (c['dir'] == 'up' and x['call'] >= f) or (c['dir'] == 'down' and x['call'] <= f):
cost = abs(x['call'] - f)
else:
turn = max(c['calls'] + [f])
cost = abs(turn - f) + abs(turn - x['call'])
if best is None or cost < best[0]:
best = (cost, c)
if best is None:
return {'car': None, 'cancelled_calls': [], 'announce': False}
c = best[1]
return {'car': c['id'], 'cancelled_calls': sorted(c['calls']), 'announce': c['load'] > 0}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car moving down away', {'call': 10, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [1, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 26', {'call': 5, 'cars': [{'id': 'H3', 'floor': 6, 'dir': 'up', 'calls': [5, 12], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 8, 'dir': 'up', 'calls': [14], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 1, 'dir': 'down', 'calls': [13, 0], 'mode': 'independent', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': True}), ('sampled regression 14', {'call': 3, 'cars': [{'id': 'H3', 'floor': 12, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 9, 'dir': 'up', 'calls': [12, 9], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 10, 'dir': 'up', 'calls': [8, 11], 'mode': 'fire', 'load': 80}, {'id': 'H1', 'floor': 1, 'dir': 'down', 'calls': [10], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [10], 'announce': False}), ('boundary: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('control 1', {'call': 6, 'cars': [{'id': 'H2', 'floor': 3, 'dir': 'up', 'calls': [3], 'mode': 'fire', 'load': 0}, {'id': 'H3', 'floor': 12, 'dir': 'idle', 'calls': [6, 10], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 3, 'dir': 'idle', 'calls': [11], 'mode': 'normal', 'load': 80}]}, {'car': 'H4', 'cancelled_calls': [11], 'announce': True}), ('control 4', {'call': 3, 'cars': [{'id': 'H4', 'floor': 10, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 6, 'dir': 'idle', 'calls': [2], 'mode': 'independent', 'load': 80}, {'id': 'H3', 'floor': 0, 'dir': 'up', 'calls': [11, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 3, 'dir': 'up', 'calls': [3, 6, 4], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [3, 4, 6], 'announce': False}), ('control 7', {'call': 3, 'cars': [{'id': 'H1', 'floor': 2, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 2, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 13, 'dir': 'up', 'calls': [12, 1, 9], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 9, 'dir': 'idle', 'calls': [7], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False})], [('regression: car moving down away', {'call': 10, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [1, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('boundary: car moving away without calls', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False}), ('boundary: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('boundary: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('control 12', {'call': 8, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'idle', 'calls': [4, 9], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 10, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 4, 'dir': 'idle', 'calls': [6, 3], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 14, 'dir': 'up', 'calls': [5, 2], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [4, 9], 'announce': False}), ('control 15', {'call': 12, 'cars': [{'id': 'H3', 'floor': 1, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 14, 'dir': 'down', 'calls': [5, 3, 9], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [3, 5, 9], 'announce': True}), ('control 18', {'call': 14, 'cars': [{'id': 'H2', 'floor': 8, 'dir': 'idle', 'calls': [10, 6, 7], 'mode': 'independent', 'load': 0}, {'id': 'H4', 'floor': 8, 'dir': 'down', 'calls': [11, 14, 6], 'mode': 'normal', 'load': 0}, {'id': 'H1', 'floor': 1, 'dir': 'up', 'calls': [6, 7, 8], 'mode': 'fire', 'load': 80}]}, {'car': 'H4', 'cancelled_calls': [6, 11, 14], 'announce': False})], [('regression: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car moving down away', {'call': 10, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [1, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 14', {'call': 3, 'cars': [{'id': 'H3', 'floor': 12, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 9, 'dir': 'up', 'calls': [12, 9], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 10, 'dir': 'up', 'calls': [8, 11], 'mode': 'fire', 'load': 80}, {'id': 'H1', 'floor': 1, 'dir': 'down', 'calls': [10], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [10], 'announce': False}), ('boundary: car moving away without calls', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False}), ('boundary: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('control 23', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H3', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 4, 'dir': 'up', 'calls': [11], 'mode': 'fire', 'load': 0}]}, {'car': 'H3', 'cancelled_calls': [], 'announce': False}), ('sampled regression 26', {'call': 5, 'cars': [{'id': 'H3', 'floor': 6, 'dir': 'up', 'calls': [5, 12], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 8, 'dir': 'up', 'calls': [14], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 1, 'dir': 'down', 'calls': [13, 0], 'mode': 'independent', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': True}), ('control 29', {'call': 1, 'cars': [{'id': 'H3', 'floor': 9, 'dir': 'down', 'calls': [5], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 8, 'dir': 'down', 'calls': [2, 11, 14], 'mode': 'normal', 'load': 80}]}, {'car': 'H2', 'cancelled_calls': [2, 11, 14], 'announce': True})], [('regression: car moving down away', {'call': 10, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [1, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 27', {'call': 9, 'cars': [{'id': 'H1', 'floor': 11, 'dir': 'up', 'calls': [1, 11, 3], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 11, 'dir': 'down', 'calls': [12, 8, 10], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 5, 'dir': 'up', 'calls': [7, 12, 11], 'mode': 'fire', 'load': 80}, {'id': 'H3', 'floor': 11, 'dir': 'up', 'calls': [9, 13, 12], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [1, 3, 11], 'announce': True}), ('boundary: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('boundary: car moving away without calls', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False}), ('control 34', {'call': 9, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [14, 5], 'mode': 'independent', 'load': 80}]}, {'car': None, 'cancelled_calls': [], 'announce': False}), ('control 37', {'call': 2, 'cars': [{'id': 'H3', 'floor': 0, 'dir': 'up', 'calls': [2, 7, 11], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 11, 'dir': 'down', 'calls': [8], 'mode': 'fire', 'load': 0}]}, {'car': 'H3', 'cancelled_calls': [2, 7, 11], 'announce': False}), ('control 40', {'call': 6, 'cars': [{'id': 'H3', 'floor': 10, 'dir': 'up', 'calls': [14, 13, 4], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [2, 1], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 1, 'dir': 'down', 'calls': [2, 10, 14], 'mode': 'independent', 'load': 80}, {'id': 'H4', 'floor': 3, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}]}, {'car': 'H4', 'cancelled_calls': [12], 'announce': True})], [('regression: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car moving down away', {'call': 10, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [1, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 14', {'call': 3, 'cars': [{'id': 'H3', 'floor': 12, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 9, 'dir': 'up', 'calls': [12, 9], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 10, 'dir': 'up', 'calls': [8, 11], 'mode': 'fire', 'load': 80}, {'id': 'H1', 'floor': 1, 'dir': 'down', 'calls': [10], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [10], 'announce': False}), ('boundary: car moving away without calls', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False}), ('boundary: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('control 45', {'call': 0, 'cars': [{'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [14], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 10, 'dir': 'down', 'calls': [], 'mode': 'fire', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [14], 'announce': False}), ('control 48', {'call': 8, 'cars': [{'id': 'H4', 'floor': 14, 'dir': 'up', 'calls': [12, 2], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 5, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 0, 'dir': 'idle', 'calls': [12], 'mode': 'fire', 'load': 0}, {'id': 'H1', 'floor': 3, 'dir': 'up', 'calls': [3], 'mode': 'normal', 'load': 80}]}, {'car': 'H3', 'cancelled_calls': [], 'announce': False}), ('control 51', {'call': 11, 'cars': [{'id': 'H3', 'floor': 2, 'dir': 'down', 'calls': [11], 'mode': 'independent', 'load': 0}, {'id': 'H4', 'floor': 7, 'dir': 'idle', 'calls': [14, 7], 'mode': 'independent', 'load': 80}, {'id': 'H2', 'floor': 12, 'dir': 'up', 'calls': [10, 9, 13], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 11, 'dir': 'idle', 'calls': [0, 9], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [0, 9], 'announce': True})]]
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: car moving away with a far call | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | Passed |
| regression: car moving down away | {'announce': False, 'cancelled_calls': [1, 6], 'car': 'H1'} | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | Failed |
| sampled regression 26 | {'announce': True, 'cancelled_calls': [], 'car': 'H2'} | {'announce': True, 'cancelled_calls': [], 'car': 'H2'} | Passed |
| sampled regression 14 | {'announce': True, 'cancelled_calls': [], 'car': 'H3'} | {'announce': False, 'cancelled_calls': [10], 'car': 'H1'} | Failed |
| boundary: car on independent service nearby | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | Passed |
| control 1 | {'announce': True, 'cancelled_calls': [11], 'car': 'H4'} | {'announce': True, 'cancelled_calls': [11], 'car': 'H4'} | Passed |
| control 4 | {'announce': False, 'cancelled_calls': [3, 4, 6], 'car': 'H2'} | {'announce': False, 'cancelled_calls': [3, 4, 6], 'car': 'H2'} | Passed |
| control 7 | {'announce': False, 'cancelled_calls': [], 'car': 'H1'} | {'announce': False, 'cancelled_calls': [], 'car': 'H1'} | Passed |
SHA-256 / af78eb4e42bc4c04e5dbd6355cf187f6f10166702063f85d67998c0986ecff09
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
best = None
for c in sorted(x['cars'], key=lambda c: c['id']):
if c['mode'] != 'normal':
continue
f = c['floor']
if c['dir'] == 'idle' or (c['dir'] == 'up' and x['call'] >= f) or (c['dir'] == 'down' and x['call'] <= f):
cost = abs(x['call'] - f)
else:
turn = max(c['calls'] + [f]) if c['dir'] == 'up' else min(c['calls'] + [f])
cost = abs(turn - f) + abs(turn - x['call'])
if best is None or cost < best[0]:
best = (cost, c)
if best is None:
return {'car': None, 'cancelled_calls': [], 'announce': False}
c = best[1]
return {'car': c['id'], 'cancelled_calls': sorted(c['calls']), 'announce': c['load'] > 0}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car moving down away', {'call': 10, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [1, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 26', {'call': 5, 'cars': [{'id': 'H3', 'floor': 6, 'dir': 'up', 'calls': [5, 12], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 8, 'dir': 'up', 'calls': [14], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 1, 'dir': 'down', 'calls': [13, 0], 'mode': 'independent', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': True}), ('sampled regression 14', {'call': 3, 'cars': [{'id': 'H3', 'floor': 12, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 9, 'dir': 'up', 'calls': [12, 9], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 10, 'dir': 'up', 'calls': [8, 11], 'mode': 'fire', 'load': 80}, {'id': 'H1', 'floor': 1, 'dir': 'down', 'calls': [10], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [10], 'announce': False}), ('boundary: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('control 1', {'call': 6, 'cars': [{'id': 'H2', 'floor': 3, 'dir': 'up', 'calls': [3], 'mode': 'fire', 'load': 0}, {'id': 'H3', 'floor': 12, 'dir': 'idle', 'calls': [6, 10], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 3, 'dir': 'idle', 'calls': [11], 'mode': 'normal', 'load': 80}]}, {'car': 'H4', 'cancelled_calls': [11], 'announce': True}), ('control 4', {'call': 3, 'cars': [{'id': 'H4', 'floor': 10, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 6, 'dir': 'idle', 'calls': [2], 'mode': 'independent', 'load': 80}, {'id': 'H3', 'floor': 0, 'dir': 'up', 'calls': [11, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 3, 'dir': 'up', 'calls': [3, 6, 4], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [3, 4, 6], 'announce': False}), ('control 7', {'call': 3, 'cars': [{'id': 'H1', 'floor': 2, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 2, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 13, 'dir': 'up', 'calls': [12, 1, 9], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 9, 'dir': 'idle', 'calls': [7], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False})], [('regression: car moving down away', {'call': 10, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [1, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('boundary: car moving away without calls', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False}), ('boundary: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('boundary: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('control 12', {'call': 8, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'idle', 'calls': [4, 9], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 10, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 4, 'dir': 'idle', 'calls': [6, 3], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 14, 'dir': 'up', 'calls': [5, 2], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [4, 9], 'announce': False}), ('control 15', {'call': 12, 'cars': [{'id': 'H3', 'floor': 1, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 14, 'dir': 'down', 'calls': [5, 3, 9], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [3, 5, 9], 'announce': True}), ('control 18', {'call': 14, 'cars': [{'id': 'H2', 'floor': 8, 'dir': 'idle', 'calls': [10, 6, 7], 'mode': 'independent', 'load': 0}, {'id': 'H4', 'floor': 8, 'dir': 'down', 'calls': [11, 14, 6], 'mode': 'normal', 'load': 0}, {'id': 'H1', 'floor': 1, 'dir': 'up', 'calls': [6, 7, 8], 'mode': 'fire', 'load': 80}]}, {'car': 'H4', 'cancelled_calls': [6, 11, 14], 'announce': False})], [('regression: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car moving down away', {'call': 10, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [1, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 14', {'call': 3, 'cars': [{'id': 'H3', 'floor': 12, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 9, 'dir': 'up', 'calls': [12, 9], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 10, 'dir': 'up', 'calls': [8, 11], 'mode': 'fire', 'load': 80}, {'id': 'H1', 'floor': 1, 'dir': 'down', 'calls': [10], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [10], 'announce': False}), ('boundary: car moving away without calls', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False}), ('boundary: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('control 23', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H3', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 4, 'dir': 'up', 'calls': [11], 'mode': 'fire', 'load': 0}]}, {'car': 'H3', 'cancelled_calls': [], 'announce': False}), ('sampled regression 26', {'call': 5, 'cars': [{'id': 'H3', 'floor': 6, 'dir': 'up', 'calls': [5, 12], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 8, 'dir': 'up', 'calls': [14], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 1, 'dir': 'down', 'calls': [13, 0], 'mode': 'independent', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': True}), ('control 29', {'call': 1, 'cars': [{'id': 'H3', 'floor': 9, 'dir': 'down', 'calls': [5], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 8, 'dir': 'down', 'calls': [2, 11, 14], 'mode': 'normal', 'load': 80}]}, {'car': 'H2', 'cancelled_calls': [2, 11, 14], 'announce': True})], [('regression: car moving down away', {'call': 10, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [1, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 27', {'call': 9, 'cars': [{'id': 'H1', 'floor': 11, 'dir': 'up', 'calls': [1, 11, 3], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 11, 'dir': 'down', 'calls': [12, 8, 10], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 5, 'dir': 'up', 'calls': [7, 12, 11], 'mode': 'fire', 'load': 80}, {'id': 'H3', 'floor': 11, 'dir': 'up', 'calls': [9, 13, 12], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [1, 3, 11], 'announce': True}), ('boundary: car on fire service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('boundary: car moving away without calls', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False}), ('control 34', {'call': 9, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [14, 5], 'mode': 'independent', 'load': 80}]}, {'car': None, 'cancelled_calls': [], 'announce': False}), ('control 37', {'call': 2, 'cars': [{'id': 'H3', 'floor': 0, 'dir': 'up', 'calls': [2, 7, 11], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 11, 'dir': 'down', 'calls': [8], 'mode': 'fire', 'load': 0}]}, {'car': 'H3', 'cancelled_calls': [2, 7, 11], 'announce': False}), ('control 40', {'call': 6, 'cars': [{'id': 'H3', 'floor': 10, 'dir': 'up', 'calls': [14, 13, 4], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [2, 1], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 1, 'dir': 'down', 'calls': [2, 10, 14], 'mode': 'independent', 'load': 80}, {'id': 'H4', 'floor': 3, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}]}, {'car': 'H4', 'cancelled_calls': [12], 'announce': True})], [('regression: car moving away with a far call', {'call': 4, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'up', 'calls': [12], 'mode': 'normal', 'load': 80}, {'id': 'H2', 'floor': 11, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('regression: car moving down away', {'call': 10, 'cars': [{'id': 'H1', 'floor': 8, 'dir': 'down', 'calls': [1, 6], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('sampled regression 14', {'call': 3, 'cars': [{'id': 'H3', 'floor': 12, 'dir': 'down', 'calls': [], 'mode': 'normal', 'load': 80}, {'id': 'H4', 'floor': 9, 'dir': 'up', 'calls': [12, 9], 'mode': 'fire', 'load': 0}, {'id': 'H2', 'floor': 10, 'dir': 'up', 'calls': [8, 11], 'mode': 'fire', 'load': 80}, {'id': 'H1', 'floor': 1, 'dir': 'down', 'calls': [10], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [10], 'announce': False}), ('boundary: car moving away without calls', {'call': 2, 'cars': [{'id': 'H1', 'floor': 6, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H1', 'cancelled_calls': [], 'announce': False}), ('boundary: car on independent service nearby', {'call': 5, 'cars': [{'id': 'H1', 'floor': 5, 'dir': 'idle', 'calls': [], 'mode': 'independent', 'load': 0}, {'id': 'H2', 'floor': 9, 'dir': 'idle', 'calls': [], 'mode': 'normal', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [], 'announce': False}), ('control 45', {'call': 0, 'cars': [{'id': 'H2', 'floor': 14, 'dir': 'idle', 'calls': [14], 'mode': 'normal', 'load': 0}, {'id': 'H4', 'floor': 10, 'dir': 'down', 'calls': [], 'mode': 'fire', 'load': 0}]}, {'car': 'H2', 'cancelled_calls': [14], 'announce': False}), ('control 48', {'call': 8, 'cars': [{'id': 'H4', 'floor': 14, 'dir': 'up', 'calls': [12, 2], 'mode': 'normal', 'load': 0}, {'id': 'H3', 'floor': 5, 'dir': 'up', 'calls': [], 'mode': 'normal', 'load': 0}, {'id': 'H2', 'floor': 0, 'dir': 'idle', 'calls': [12], 'mode': 'fire', 'load': 0}, {'id': 'H1', 'floor': 3, 'dir': 'up', 'calls': [3], 'mode': 'normal', 'load': 80}]}, {'car': 'H3', 'cancelled_calls': [], 'announce': False}), ('control 51', {'call': 11, 'cars': [{'id': 'H3', 'floor': 2, 'dir': 'down', 'calls': [11], 'mode': 'independent', 'load': 0}, {'id': 'H4', 'floor': 7, 'dir': 'idle', 'calls': [14, 7], 'mode': 'independent', 'load': 80}, {'id': 'H2', 'floor': 12, 'dir': 'up', 'calls': [10, 9, 13], 'mode': 'normal', 'load': 80}, {'id': 'H1', 'floor': 11, 'dir': 'idle', 'calls': [0, 9], 'mode': 'normal', 'load': 80}]}, {'car': 'H1', 'cancelled_calls': [0, 9], 'announce': True})]]
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: car moving away with a far call | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | Passed |
| regression: car moving down away | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | Passed |
| sampled regression 26 | {'announce': True, 'cancelled_calls': [], 'car': 'H2'} | {'announce': True, 'cancelled_calls': [], 'car': 'H2'} | Passed |
| sampled regression 14 | {'announce': False, 'cancelled_calls': [10], 'car': 'H1'} | {'announce': False, 'cancelled_calls': [10], 'car': 'H1'} | Passed |
| boundary: car on independent service nearby | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | {'announce': False, 'cancelled_calls': [], 'car': 'H2'} | Passed |
| control 1 | {'announce': True, 'cancelled_calls': [11], 'car': 'H4'} | {'announce': True, 'cancelled_calls': [11], 'car': 'H4'} | Passed |
| control 4 | {'announce': False, 'cancelled_calls': [3, 4, 6], 'car': 'H2'} | {'announce': False, 'cancelled_calls': [3, 4, 6], 'car': 'H2'} | Passed |
| control 7 | {'announce': False, 'cancelled_calls': [], 'car': 'H1'} | {'announce': False, 'cancelled_calls': [], 'car': 'H1'} | Passed |
SHA-256 / ef7aa038bcf6606df0196f2955f4d8dd0c64c70996aa2ade9805d4ac43af5ee6
Verification & scope
Stipulated toy lift-control contract for a bounded teaching model; it makes no claim of conformance to any lift code or vendor dispatcher and omits real safety cases. 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:47:55.714528+00:00.
Case digest / 0d75b7a482e235221331a44b61fbfa9f73440a958d3c2b11d8734cfded8fb345