broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    smoke = set(x['smoke'])
    des, alt = x['designated'], x['alternate']
    recall = alt if des in smoke else des
    res = {}
    for c in x['cars']:
        f = c['floor']
        if not c['moving']:
            res[c['id']] = ['open', recall] if f == recall else ['travel', recall]
        elif (c['dir'] == 'up' and recall > f) or (c['dir'] == 'down' and recall < f):
            res[c['id']] = ['nonstop', recall]
        else:
            nxt = f + 1 if c['dir'] == 'up' else f - 1
            res[c['id']] = ['reverse', min(max(nxt, 0), x['top'])]
    return {'recall': recall, 'cars': res}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: smoke at both recall floors', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0, 5], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}}), ('boundary: smoke elsewhere only', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [7], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('boundary: smoke at the designated floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 5, 'cars': {'L1': ['travel', 5]}}), ('boundary: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('boundary: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('control 1', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [11], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 10, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 9, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 1], 'L2': ['travel', 0], 'L3': ['nonstop', 0]}}), ('control 4', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [6, 11], 'cars': [{'id': 'L1', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('control 7', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 7, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 1, 'cars': {'L1': ['reverse', 8], 'L2': ['reverse', 0]}})], [('regression: smoke at both recall floors', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0, 5], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}}), ('boundary: smoke elsewhere only', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [7], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('sampled regression 16', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [0, 2, 0], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 1]}}), ('control 18', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [8], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 6, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 2, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['nonstop', 0], 'L3': ['travel', 0]}}), ('boundary: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('control 12', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}]}, {'recall': 2, 'cars': {'L1': ['travel', 2], 'L2': ['reverse', 11]}}), ('control 15', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [7, 0], 'cars': [{'id': 'L1', 'floor': 4, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 5, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 8, 'moving': True, 'dir': 'down'}]}, {'recall': 1, 'cars': {'L1': ['travel', 1], 'L2': ['travel', 1], 'L3': ['nonstop', 1]}}), ('control 21', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}})], [('regression: smoke at both recall floors', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0, 5], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}}), ('sampled regression 40', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [5, 3, 0], 'cars': [{'id': 'L1', 'floor': 3, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 4], 'L2': ['reverse', 11]}}), ('control 28', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [9], 'cars': [{'id': 'L1', 'floor': 8, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 2, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 1, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 9], 'L2': ['nonstop', 0], 'L3': ['reverse', 2]}}), ('boundary: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('boundary: moving away at the top', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11]}}), ('control 23', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 3, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 8, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 1, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['nonstop', 0], 'L3': ['reverse', 2]}}), ('control 26', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [10, 11], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 7, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['nonstop', 0]}}), ('control 29', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [6], 'cars': [{'id': 'L1', 'floor': 9, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}})], [('regression: smoke at both recall floors', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0, 5], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}}), ('boundary: smoke elsewhere only', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [7], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('sampled regression 40', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [5, 3, 0], 'cars': [{'id': 'L1', 'floor': 3, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 4], 'L2': ['reverse', 11]}}), ('boundary: moving up towards the alternate floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 2, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['nonstop', 5]}}), ('boundary: parked at the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['open', 0]}}), ('control 34', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 11, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 11], 'L2': ['travel', 0], 'L3': ['reverse', 11]}}), ('control 37', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [9, 8], 'cars': [{'id': 'L1', 'floor': 1, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 2], 'L2': ['travel', 0]}}), ('control 43', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [3, 0], 'cars': [{'id': 'L1', 'floor': 8, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 9, 'moving': False, 'dir': 'idle'}]}, {'recall': 2, 'cars': {'L1': ['travel', 2], 'L2': ['travel', 2]}})], [('regression: smoke at both recall floors', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0, 5], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}}), ('sampled regression 16', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [0, 2, 0], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 1]}}), ('control 50', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [9], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 10], 'L2': ['nonstop', 0], 'L3': ['travel', 0]}}), ('boundary: smoke at the designated floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 5, 'cars': {'L1': ['travel', 5]}}), ('boundary: smoke elsewhere only', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [7], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('control 45', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [4, 11], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 0, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['reverse', 1]}}), ('control 48', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [1], 'cars': [{'id': 'L1', 'floor': 4, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 5, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['travel', 0]}}), ('control 51', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 4, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 10], 'L2': ['travel', 0]}})]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    smoke = set(x['smoke'])
    des, alt = x['designated'], x['alternate']
    recall = alt if smoke else des
    res = {}
    for c in x['cars']:
        f = c['floor']
        if not c['moving']:
            res[c['id']] = ['open', recall] if f == recall else ['travel', recall]
        elif (c['dir'] == 'up' and recall > f) or (c['dir'] == 'down' and recall < f):
            res[c['id']] = ['nonstop', recall]
        else:
            nxt = f + 1 if c['dir'] == 'up' else f - 1
            res[c['id']] = ['reverse', min(max(nxt, 0), x['top'])]
    return {'recall': recall, 'cars': res}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: smoke at both recall floors', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0, 5], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}}), ('boundary: smoke elsewhere only', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [7], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('boundary: smoke at the designated floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 5, 'cars': {'L1': ['travel', 5]}}), ('boundary: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('boundary: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('control 1', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [11], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 10, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 9, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 1], 'L2': ['travel', 0], 'L3': ['nonstop', 0]}}), ('control 4', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [6, 11], 'cars': [{'id': 'L1', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('control 7', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 7, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 1, 'cars': {'L1': ['reverse', 8], 'L2': ['reverse', 0]}})], [('regression: smoke at both recall floors', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0, 5], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}}), ('boundary: smoke elsewhere only', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [7], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('sampled regression 16', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [0, 2, 0], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 1]}}), ('control 18', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [8], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 6, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 2, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['nonstop', 0], 'L3': ['travel', 0]}}), ('boundary: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('control 12', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}]}, {'recall': 2, 'cars': {'L1': ['travel', 2], 'L2': ['reverse', 11]}}), ('control 15', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [7, 0], 'cars': [{'id': 'L1', 'floor': 4, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 5, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 8, 'moving': True, 'dir': 'down'}]}, {'recall': 1, 'cars': {'L1': ['travel', 1], 'L2': ['travel', 1], 'L3': ['nonstop', 1]}}), ('control 21', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}})], [('regression: smoke at both recall floors', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0, 5], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}}), ('sampled regression 40', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [5, 3, 0], 'cars': [{'id': 'L1', 'floor': 3, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 4], 'L2': ['reverse', 11]}}), ('control 28', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [9], 'cars': [{'id': 'L1', 'floor': 8, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 2, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 1, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 9], 'L2': ['nonstop', 0], 'L3': ['reverse', 2]}}), ('boundary: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('boundary: moving away at the top', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11]}}), ('control 23', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 3, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 8, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 1, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['nonstop', 0], 'L3': ['reverse', 2]}}), ('control 26', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [10, 11], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 7, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['nonstop', 0]}}), ('control 29', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [6], 'cars': [{'id': 'L1', 'floor': 9, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}})], [('regression: smoke at both recall floors', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0, 5], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}}), ('boundary: smoke elsewhere only', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [7], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('sampled regression 40', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [5, 3, 0], 'cars': [{'id': 'L1', 'floor': 3, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 4], 'L2': ['reverse', 11]}}), ('boundary: moving up towards the alternate floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 2, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['nonstop', 5]}}), ('boundary: parked at the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['open', 0]}}), ('control 34', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 11, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 11], 'L2': ['travel', 0], 'L3': ['reverse', 11]}}), ('control 37', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [9, 8], 'cars': [{'id': 'L1', 'floor': 1, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 2], 'L2': ['travel', 0]}}), ('control 43', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [3, 0], 'cars': [{'id': 'L1', 'floor': 8, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 9, 'moving': False, 'dir': 'idle'}]}, {'recall': 2, 'cars': {'L1': ['travel', 2], 'L2': ['travel', 2]}})], [('regression: smoke at both recall floors', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0, 5], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}}), ('sampled regression 16', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [0, 2, 0], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 1]}}), ('control 50', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [9], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 10], 'L2': ['nonstop', 0], 'L3': ['travel', 0]}}), ('boundary: smoke at the designated floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 5, 'cars': {'L1': ['travel', 5]}}), ('boundary: smoke elsewhere only', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [7], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('control 45', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [4, 11], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 0, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['reverse', 1]}}), ('control 48', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [1], 'cars': [{'id': 'L1', 'floor': 4, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 5, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['travel', 0]}}), ('control 51', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 4, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 10], 'L2': ['travel', 0]}})]]
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)

prompt:
Cars are recalled to a smoke-filled floor.

The recall floor is the designated floor unless smoke is detected there and not at the alternate floor. Each car: stationary at the recall floor -> open; stationary elsewhere -> travel to recall; moving towards the recall floor (strictly) -> nonstop to it; otherwise (moving away, or passing the recall floor) -> reverse after stopping at the next floor in its direction, clipped to 0..top.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    smoke = set(x['smoke'])
    des, alt = x['designated'], x['alternate']
    recall = alt if des in smoke and alt not in smoke else des
    res = {}
    for c in x['cars']:
        f = c['floor']
        if not c['moving']:
            res[c['id']] = ['open', recall] if f == recall else ['travel', recall]
        elif (c['dir'] == 'up' and recall >= f) or (c['dir'] == 'down' and recall <= f):
            res[c['id']] = ['nonstop', recall]
        else:
            nxt = f + 1 if c['dir'] == 'up' else f - 1
            res[c['id']] = ['reverse', min(max(nxt, 0), x['top'])]
    return {'recall': recall, 'cars': res}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 16', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [0, 2, 0], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 1]}}), ('sampled regression 7', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 7, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 1, 'cars': {'L1': ['reverse', 8], 'L2': ['reverse', 0]}}), ('boundary: smoke at the designated floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 5, 'cars': {'L1': ['travel', 5]}}), ('boundary: smoke at both recall floors', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0, 5], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}}), ('sampled regression 1', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [11], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 10, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 9, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 1], 'L2': ['travel', 0], 'L3': ['nonstop', 0]}}), ('control 4', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [6, 11], 'cars': [{'id': 'L1', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('control 10', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': False, 'dir': 'idle'}]}, {'recall': 1, 'cars': {'L1': ['travel', 1]}})], [('regression: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 79', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 7, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 4, 'moving': True, 'dir': 'up'}, {'id': 'L3', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['reverse', 5], 'L3': ['reverse', 0]}}), ('boundary: smoke elsewhere only', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [7], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('boundary: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('boundary: moving away at the top', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11]}}), ('control 12', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}]}, {'recall': 2, 'cars': {'L1': ['travel', 2], 'L2': ['reverse', 11]}}), ('control 15', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [7, 0], 'cars': [{'id': 'L1', 'floor': 4, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 5, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 8, 'moving': True, 'dir': 'down'}]}, {'recall': 1, 'cars': {'L1': ['travel', 1], 'L2': ['travel', 1], 'L3': ['nonstop', 1]}}), ('control 18', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [8], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 6, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 2, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['nonstop', 0], 'L3': ['travel', 0]}})], [('regression: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 52', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 1]}}), ('sampled regression 79', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 7, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 4, 'moving': True, 'dir': 'up'}, {'id': 'L3', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['reverse', 5], 'L3': ['reverse', 0]}}), ('boundary: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('boundary: moving away at the top', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11]}}), ('control 23', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 3, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 8, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 1, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['nonstop', 0], 'L3': ['reverse', 2]}}), ('control 26', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [10, 11], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 7, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['nonstop', 0]}}), ('control 29', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [6], 'cars': [{'id': 'L1', 'floor': 9, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}})], [('regression: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 7', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 7, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 1, 'cars': {'L1': ['reverse', 8], 'L2': ['reverse', 0]}}), ('sampled regression 76', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [9], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('boundary: moving up towards the alternate floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 2, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['nonstop', 5]}}), ('boundary: parked at the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['open', 0]}}), ('control 34', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 11, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 11], 'L2': ['travel', 0], 'L3': ['reverse', 11]}}), ('control 37', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [9, 8], 'cars': [{'id': 'L1', 'floor': 1, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 2], 'L2': ['travel', 0]}}), ('control 40', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [5, 3, 0], 'cars': [{'id': 'L1', 'floor': 3, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 4], 'L2': ['reverse', 11]}})], [('regression: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 76', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [9], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 69', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5], 'L2': ['reverse', 0]}}), ('boundary: smoke at the designated floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 5, 'cars': {'L1': ['travel', 5]}}), ('boundary: smoke at both recall floors', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0, 5], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}}), ('sampled regression 45', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [4, 11], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 0, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['reverse', 1]}}), ('control 48', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [1], 'cars': [{'id': 'L1', 'floor': 4, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 5, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['travel', 0]}}), ('control 51', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 4, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 10], 'L2': ['travel', 0]}})]]
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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    smoke = set(x['smoke'])
    des, alt = x['designated'], x['alternate']
    recall = alt if des in smoke and alt not in smoke else des
    res = {}
    for c in x['cars']:
        f = c['floor']
        if not c['moving']:
            res[c['id']] = ['open', recall] if f == recall else ['travel', recall]
        elif (c['dir'] == 'up') == (recall > f):
            res[c['id']] = ['nonstop', recall]
        else:
            nxt = f + 1 if c['dir'] == 'up' else f - 1
            res[c['id']] = ['reverse', min(max(nxt, 0), x['top'])]
    return {'recall': recall, 'cars': res}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 16', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [0, 2, 0], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 1]}}), ('sampled regression 7', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 7, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 1, 'cars': {'L1': ['reverse', 8], 'L2': ['reverse', 0]}}), ('boundary: smoke at the designated floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 5, 'cars': {'L1': ['travel', 5]}}), ('boundary: smoke at both recall floors', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0, 5], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}}), ('sampled regression 1', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [11], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 10, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 9, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 1], 'L2': ['travel', 0], 'L3': ['nonstop', 0]}}), ('control 4', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [6, 11], 'cars': [{'id': 'L1', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('control 10', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': False, 'dir': 'idle'}]}, {'recall': 1, 'cars': {'L1': ['travel', 1]}})], [('regression: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 79', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 7, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 4, 'moving': True, 'dir': 'up'}, {'id': 'L3', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['reverse', 5], 'L3': ['reverse', 0]}}), ('boundary: smoke elsewhere only', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [7], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('boundary: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('boundary: moving away at the top', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11]}}), ('control 12', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}]}, {'recall': 2, 'cars': {'L1': ['travel', 2], 'L2': ['reverse', 11]}}), ('control 15', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [7, 0], 'cars': [{'id': 'L1', 'floor': 4, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 5, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 8, 'moving': True, 'dir': 'down'}]}, {'recall': 1, 'cars': {'L1': ['travel', 1], 'L2': ['travel', 1], 'L3': ['nonstop', 1]}}), ('control 18', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [8], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 6, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 2, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['nonstop', 0], 'L3': ['travel', 0]}})], [('regression: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 52', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 1]}}), ('sampled regression 79', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 7, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 4, 'moving': True, 'dir': 'up'}, {'id': 'L3', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['reverse', 5], 'L3': ['reverse', 0]}}), ('boundary: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('boundary: moving away at the top', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11]}}), ('control 23', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 3, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 8, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 1, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['nonstop', 0], 'L3': ['reverse', 2]}}), ('control 26', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [10, 11], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 7, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['nonstop', 0]}}), ('control 29', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [6], 'cars': [{'id': 'L1', 'floor': 9, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}})], [('regression: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 7', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 7, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 1, 'cars': {'L1': ['reverse', 8], 'L2': ['reverse', 0]}}), ('sampled regression 76', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [9], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('boundary: moving up towards the alternate floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 2, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['nonstop', 5]}}), ('boundary: parked at the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['open', 0]}}), ('control 34', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 11, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 11], 'L2': ['travel', 0], 'L3': ['reverse', 11]}}), ('control 37', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [9, 8], 'cars': [{'id': 'L1', 'floor': 1, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 2], 'L2': ['travel', 0]}}), ('control 40', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [5, 3, 0], 'cars': [{'id': 'L1', 'floor': 3, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 4], 'L2': ['reverse', 11]}})], [('regression: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 76', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [9], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 69', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5], 'L2': ['reverse', 0]}}), ('boundary: smoke at the designated floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 5, 'cars': {'L1': ['travel', 5]}}), ('boundary: smoke at both recall floors', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0, 5], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}}), ('sampled regression 45', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [4, 11], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 0, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['reverse', 1]}}), ('control 48', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [1], 'cars': [{'id': 'L1', 'floor': 4, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 5, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['travel', 0]}}), ('control 51', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 4, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 10], 'L2': ['travel', 0]}})]]
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)

prompt:
A car passing the recall floor is told to run nonstop to where it already is.

The recall floor is the designated floor unless smoke is detected there and not at the alternate floor. Each car: stationary at the recall floor -> open; stationary elsewhere -> travel to recall; moving towards the recall floor (strictly) -> nonstop to it; otherwise (moving away, or passing the recall floor) -> reverse after stopping at the next floor in its direction, clipped to 0..top.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    smoke = set(x['smoke'])
    des, alt = x['designated'], x['alternate']
    recall = alt if des in smoke and alt not in smoke else des
    res = {}
    for c in x['cars']:
        f = c['floor']
        if not c['moving']:
            res[c['id']] = ['open', recall] if f == recall else ['travel', recall]
        elif (c['dir'] == 'up' and recall > f) or (c['dir'] == 'down' and recall < f):
            res[c['id']] = ['nonstop', recall]
        else:
            nxt = f
            res[c['id']] = ['reverse', min(max(nxt, 0), x['top'])]
    return {'recall': recall, 'cars': res}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('boundary: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 6', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 10, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 2, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 0, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 11], 'L2': ['travel', 0], 'L3': ['open', 0]}}), ('sampled regression 5', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [10, 0], 'cars': [{'id': 'L1', 'floor': 1, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 9, 'moving': False, 'dir': 'idle'}]}, {'recall': 2, 'cars': {'L1': ['reverse', 0], 'L2': ['travel', 2]}}), ('boundary: smoke at the designated floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 5, 'cars': {'L1': ['travel', 5]}}), ('sampled regression 1', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [11], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 10, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 9, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 1], 'L2': ['travel', 0], 'L3': ['nonstop', 0]}}), ('control 4', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [6, 11], 'cars': [{'id': 'L1', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('sampled regression 7', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 7, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 1, 'cars': {'L1': ['reverse', 8], 'L2': ['reverse', 0]}})], [('regression: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('boundary: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 23', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 3, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 8, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 1, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['nonstop', 0], 'L3': ['reverse', 2]}}), ('control 63', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 0, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11], 'L2': ['reverse', 0], 'L3': ['nonstop', 5]}}), ('boundary: smoke elsewhere only', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [7], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('sampled regression 12', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}]}, {'recall': 2, 'cars': {'L1': ['travel', 2], 'L2': ['reverse', 11]}}), ('control 15', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [7, 0], 'cars': [{'id': 'L1', 'floor': 4, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 5, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 8, 'moving': True, 'dir': 'down'}]}, {'recall': 1, 'cars': {'L1': ['travel', 1], 'L2': ['travel', 1], 'L3': ['nonstop', 1]}}), ('control 18', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [8], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 6, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 2, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['nonstop', 0], 'L3': ['travel', 0]}})], [('regression: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('boundary: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 38', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 1, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}, {'id': 'L3', 'floor': 7, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['reverse', 11], 'L3': ['nonstop', 0]}}), ('sampled regression 80', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 4, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 8, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 5, 'cars': {'L1': ['travel', 5], 'L2': ['nonstop', 5], 'L3': ['reverse', 0]}}), ('boundary: moving away at the top', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11]}}), ('sampled regression 23', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 3, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 8, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 1, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['nonstop', 0], 'L3': ['reverse', 2]}}), ('control 26', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [10, 11], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 7, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['nonstop', 0]}}), ('control 29', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [6], 'cars': [{'id': 'L1', 'floor': 9, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}})], [('regression: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('boundary: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 50', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [9], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 10], 'L2': ['nonstop', 0], 'L3': ['travel', 0]}}), ('sampled regression 36', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [3, 0], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 11, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 2, 'cars': {'L1': ['reverse', 0], 'L2': ['nonstop', 2], 'L3': ['reverse', 0]}}), ('boundary: moving up towards the alternate floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 2, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['nonstop', 5]}}), ('control 34', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 11, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 11], 'L2': ['travel', 0], 'L3': ['reverse', 11]}}), ('sampled regression 37', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [9, 8], 'cars': [{'id': 'L1', 'floor': 1, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 2], 'L2': ['travel', 0]}}), ('sampled regression 40', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [5, 3, 0], 'cars': [{'id': 'L1', 'floor': 3, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 4], 'L2': ['reverse', 11]}})], [('regression: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('boundary: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 69', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5], 'L2': ['reverse', 0]}}), ('control 76', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [9], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('boundary: smoke at the designated floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 5, 'cars': {'L1': ['travel', 5]}}), ('sampled regression 45', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [4, 11], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 0, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['reverse', 1]}}), ('control 48', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [1], 'cars': [{'id': 'L1', 'floor': 4, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 5, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['travel', 0]}}), ('sampled regression 51', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 4, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 10], 'L2': ['travel', 0]}})]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    smoke = set(x['smoke'])
    des, alt = x['designated'], x['alternate']
    recall = alt if des in smoke and alt not in smoke else des
    res = {}
    for c in x['cars']:
        f = c['floor']
        if not c['moving']:
            res[c['id']] = ['open', recall] if f == recall else ['travel', recall]
        elif (c['dir'] == 'up' and recall > f) or (c['dir'] == 'down' and recall < f):
            res[c['id']] = ['nonstop', recall]
        else:
            nxt = f + 1
            res[c['id']] = ['reverse', min(max(nxt, 0), x['top'])]
    return {'recall': recall, 'cars': res}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('boundary: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 6', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 10, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 2, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 0, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 11], 'L2': ['travel', 0], 'L3': ['open', 0]}}), ('sampled regression 5', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [10, 0], 'cars': [{'id': 'L1', 'floor': 1, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 9, 'moving': False, 'dir': 'idle'}]}, {'recall': 2, 'cars': {'L1': ['reverse', 0], 'L2': ['travel', 2]}}), ('boundary: smoke at the designated floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 5, 'cars': {'L1': ['travel', 5]}}), ('sampled regression 1', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [11], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 10, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 9, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 1], 'L2': ['travel', 0], 'L3': ['nonstop', 0]}}), ('control 4', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [6, 11], 'cars': [{'id': 'L1', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('sampled regression 7', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 7, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 1, 'cars': {'L1': ['reverse', 8], 'L2': ['reverse', 0]}})], [('regression: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('boundary: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 23', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 3, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 8, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 1, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['nonstop', 0], 'L3': ['reverse', 2]}}), ('control 63', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 0, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11], 'L2': ['reverse', 0], 'L3': ['nonstop', 5]}}), ('boundary: smoke elsewhere only', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [7], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('sampled regression 12', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}]}, {'recall': 2, 'cars': {'L1': ['travel', 2], 'L2': ['reverse', 11]}}), ('control 15', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [7, 0], 'cars': [{'id': 'L1', 'floor': 4, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 5, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 8, 'moving': True, 'dir': 'down'}]}, {'recall': 1, 'cars': {'L1': ['travel', 1], 'L2': ['travel', 1], 'L3': ['nonstop', 1]}}), ('control 18', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [8], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 6, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 2, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['nonstop', 0], 'L3': ['travel', 0]}})], [('regression: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('boundary: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 38', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 1, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}, {'id': 'L3', 'floor': 7, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['reverse', 11], 'L3': ['nonstop', 0]}}), ('sampled regression 80', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 4, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 8, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 5, 'cars': {'L1': ['travel', 5], 'L2': ['nonstop', 5], 'L3': ['reverse', 0]}}), ('boundary: moving away at the top', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11]}}), ('sampled regression 23', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 3, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 8, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 1, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['nonstop', 0], 'L3': ['reverse', 2]}}), ('control 26', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [10, 11], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 7, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['nonstop', 0]}}), ('control 29', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [6], 'cars': [{'id': 'L1', 'floor': 9, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}})], [('regression: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('boundary: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 50', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [9], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 10], 'L2': ['nonstop', 0], 'L3': ['travel', 0]}}), ('sampled regression 36', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [3, 0], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 11, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 2, 'cars': {'L1': ['reverse', 0], 'L2': ['nonstop', 2], 'L3': ['reverse', 0]}}), ('boundary: moving up towards the alternate floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 2, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['nonstop', 5]}}), ('control 34', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 11, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 11], 'L2': ['travel', 0], 'L3': ['reverse', 11]}}), ('sampled regression 37', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [9, 8], 'cars': [{'id': 'L1', 'floor': 1, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 2], 'L2': ['travel', 0]}}), ('sampled regression 40', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [5, 3, 0], 'cars': [{'id': 'L1', 'floor': 3, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 4], 'L2': ['reverse', 11]}})], [('regression: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('boundary: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 69', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5], 'L2': ['reverse', 0]}}), ('control 76', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [9], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('boundary: smoke at the designated floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 5, 'cars': {'L1': ['travel', 5]}}), ('sampled regression 45', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [4, 11], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 0, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['reverse', 1]}}), ('control 48', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [1], 'cars': [{'id': 'L1', 'floor': 4, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 5, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['travel', 0]}}), ('sampled regression 51', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 4, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 10], 'L2': ['travel', 0]}})]]
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)

prompt:
A car moving away is told to stop at the floor it is passing.

The recall floor is the designated floor unless smoke is detected there and not at the alternate floor. Each car: stationary at the recall floor -> open; stationary elsewhere -> travel to recall; moving towards the recall floor (strictly) -> nonstop to it; otherwise (moving away, or passing the recall floor) -> reverse after stopping at the next floor in its direction, clipped to 0..top.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    smoke = set(x['smoke'])
    des, alt = x['designated'], x['alternate']
    recall = alt if des in smoke and alt not in smoke else des
    res = {}
    for c in x['cars']:
        f = c['floor']
        if not c['moving']:
            res[c['id']] = ['open', recall] if f == recall else ['travel', recall]
        elif (c['dir'] == 'up' and recall > f) or (c['dir'] == 'down' and recall < f):
            res[c['id']] = ['nonstop', recall]
        else:
            nxt = f + 1 if c['dir'] == 'up' else f - 1
            res[c['id']] = ['reverse', nxt]
    return {'recall': recall, 'cars': res}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('regression: moving away at the top', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11]}}), ('sampled regression 33', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [8], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 2, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 7], 'L2': ['travel', 0], 'L3': ['reverse', 11]}}), ('sampled regression 30', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 7, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 2, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 1, 'cars': {'L1': ['nonstop', 1], 'L2': ['nonstop', 1], 'L3': ['reverse', 11]}}), ('boundary: smoke at the designated floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 5, 'cars': {'L1': ['travel', 5]}}), ('control 1', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [11], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 10, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 9, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 1], 'L2': ['travel', 0], 'L3': ['nonstop', 0]}}), ('control 4', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [6, 11], 'cars': [{'id': 'L1', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('control 7', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 7, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 1, 'cars': {'L1': ['reverse', 8], 'L2': ['reverse', 0]}})], [('regression: moving away at the top', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11]}}), ('sampled regression 69', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5], 'L2': ['reverse', 0]}}), ('sampled regression 65', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [2, 11], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 11]}}), ('boundary: smoke elsewhere only', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [7], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('regression: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('control 12', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}]}, {'recall': 2, 'cars': {'L1': ['travel', 2], 'L2': ['reverse', 11]}}), ('control 15', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [7, 0], 'cars': [{'id': 'L1', 'floor': 4, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 5, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 8, 'moving': True, 'dir': 'down'}]}, {'recall': 1, 'cars': {'L1': ['travel', 1], 'L2': ['travel', 1], 'L3': ['nonstop', 1]}}), ('control 18', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [8], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 6, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 2, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['nonstop', 0], 'L3': ['travel', 0]}})], [('regression: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('regression: moving away at the top', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11]}}), ('sampled regression 34', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 11, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 11], 'L2': ['travel', 0], 'L3': ['reverse', 11]}}), ('sampled regression 42', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [10], 'cars': [{'id': 'L1', 'floor': 8, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['reverse', 11]}}), ('boundary: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('control 23', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 3, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 8, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 1, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['nonstop', 0], 'L3': ['reverse', 2]}}), ('control 26', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [10, 11], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 7, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['nonstop', 0]}}), ('control 29', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [6], 'cars': [{'id': 'L1', 'floor': 9, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}})], [('regression: moving away at the top', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11]}}), ('sampled regression 76', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [9], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 33', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [8], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 2, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 7], 'L2': ['travel', 0], 'L3': ['reverse', 11]}}), ('boundary: moving up towards the alternate floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 2, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['nonstop', 5]}}), ('boundary: parked at the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['open', 0]}}), ('sampled regression 34', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 11, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 11], 'L2': ['travel', 0], 'L3': ['reverse', 11]}}), ('control 37', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [9, 8], 'cars': [{'id': 'L1', 'floor': 1, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 2], 'L2': ['travel', 0]}}), ('control 40', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [5, 3, 0], 'cars': [{'id': 'L1', 'floor': 3, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 4], 'L2': ['reverse', 11]}})], [('regression: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('regression: moving away at the top', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11]}}), ('sampled regression 36', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [3, 0], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 11, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 2, 'cars': {'L1': ['reverse', 0], 'L2': ['nonstop', 2], 'L3': ['reverse', 0]}}), ('boundary: smoke at the designated floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 5, 'cars': {'L1': ['travel', 5]}}), ('boundary: smoke at both recall floors', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0, 5], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}}), ('control 45', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [4, 11], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 0, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['reverse', 1]}}), ('control 48', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [1], 'cars': [{'id': 'L1', 'floor': 4, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 5, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['travel', 0]}}), ('control 51', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 4, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 10], 'L2': ['travel', 0]}})]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    smoke = set(x['smoke'])
    des, alt = x['designated'], x['alternate']
    recall = alt if des in smoke and alt not in smoke else des
    res = {}
    for c in x['cars']:
        f = c['floor']
        if not c['moving']:
            res[c['id']] = ['open', recall] if f == recall else ['travel', recall]
        elif (c['dir'] == 'up' and recall > f) or (c['dir'] == 'down' and recall < f):
            res[c['id']] = ['nonstop', recall]
        else:
            nxt = f + 1 if c['dir'] == 'up' else f - 1
            res[c['id']] = ['reverse', max(nxt, 0)]
    return {'recall': recall, 'cars': res}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('regression: moving away at the top', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11]}}), ('sampled regression 33', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [8], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 2, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 7], 'L2': ['travel', 0], 'L3': ['reverse', 11]}}), ('sampled regression 30', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 7, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 2, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 1, 'cars': {'L1': ['nonstop', 1], 'L2': ['nonstop', 1], 'L3': ['reverse', 11]}}), ('boundary: smoke at the designated floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 5, 'cars': {'L1': ['travel', 5]}}), ('control 1', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [11], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 10, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 9, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 1], 'L2': ['travel', 0], 'L3': ['nonstop', 0]}}), ('control 4', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [6, 11], 'cars': [{'id': 'L1', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('control 7', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 7, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 1, 'cars': {'L1': ['reverse', 8], 'L2': ['reverse', 0]}})], [('regression: moving away at the top', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11]}}), ('sampled regression 69', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5], 'L2': ['reverse', 0]}}), ('sampled regression 65', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [2, 11], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 11]}}), ('boundary: smoke elsewhere only', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [7], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0]}}), ('regression: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('control 12', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}]}, {'recall': 2, 'cars': {'L1': ['travel', 2], 'L2': ['reverse', 11]}}), ('control 15', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [7, 0], 'cars': [{'id': 'L1', 'floor': 4, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 5, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 8, 'moving': True, 'dir': 'down'}]}, {'recall': 1, 'cars': {'L1': ['travel', 1], 'L2': ['travel', 1], 'L3': ['nonstop', 1]}}), ('control 18', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [8], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 6, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 2, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['nonstop', 0], 'L3': ['travel', 0]}})], [('regression: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('regression: moving away at the top', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11]}}), ('sampled regression 34', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 11, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 11], 'L2': ['travel', 0], 'L3': ['reverse', 11]}}), ('sampled regression 42', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [10], 'cars': [{'id': 'L1', 'floor': 8, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['reverse', 11]}}), ('boundary: moving away upwards', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 4, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 5]}}), ('control 23', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 3, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 8, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 1, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['nonstop', 0], 'L3': ['reverse', 2]}}), ('control 26', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [10, 11], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 7, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['nonstop', 0]}}), ('control 29', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [6], 'cars': [{'id': 'L1', 'floor': 9, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}})], [('regression: moving away at the top', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11]}}), ('sampled regression 76', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [9], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('sampled regression 33', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [8], 'cars': [{'id': 'L1', 'floor': 6, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 2, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 7], 'L2': ['travel', 0], 'L3': ['reverse', 11]}}), ('boundary: moving up towards the alternate floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 2, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['nonstop', 5]}}), ('boundary: parked at the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['open', 0]}}), ('sampled regression 34', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 11, 'moving': False, 'dir': 'idle'}, {'id': 'L3', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 11], 'L2': ['travel', 0], 'L3': ['reverse', 11]}}), ('control 37', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [9, 8], 'cars': [{'id': 'L1', 'floor': 1, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 2], 'L2': ['travel', 0]}}), ('control 40', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [5, 3, 0], 'cars': [{'id': 'L1', 'floor': 3, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 10, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 4], 'L2': ['reverse', 11]}})], [('regression: passing the recall floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 0]}}), ('regression: moving away at the top', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 11, 'moving': True, 'dir': 'up'}]}, {'recall': 5, 'cars': {'L1': ['reverse', 11]}}), ('sampled regression 36', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [3, 0], 'cars': [{'id': 'L1', 'floor': 0, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 11, 'moving': True, 'dir': 'down'}, {'id': 'L3', 'floor': 1, 'moving': True, 'dir': 'down'}]}, {'recall': 2, 'cars': {'L1': ['reverse', 0], 'L2': ['nonstop', 2], 'L3': ['reverse', 0]}}), ('boundary: smoke at the designated floor', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 5, 'cars': {'L1': ['travel', 5]}}), ('boundary: smoke at both recall floors', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [0, 5], 'cars': [{'id': 'L1', 'floor': 6, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0]}}), ('control 45', {'designated': 0, 'alternate': 5, 'top': 11, 'smoke': [4, 11], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'down'}, {'id': 'L2', 'floor': 0, 'moving': True, 'dir': 'up'}]}, {'recall': 0, 'cars': {'L1': ['nonstop', 0], 'L2': ['reverse', 1]}}), ('control 48', {'designated': 0, 'alternate': 2, 'top': 11, 'smoke': [1], 'cars': [{'id': 'L1', 'floor': 4, 'moving': False, 'dir': 'idle'}, {'id': 'L2', 'floor': 5, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['travel', 0], 'L2': ['travel', 0]}}), ('control 51', {'designated': 0, 'alternate': 1, 'top': 11, 'smoke': [], 'cars': [{'id': 'L1', 'floor': 9, 'moving': True, 'dir': 'up'}, {'id': 'L2', 'floor': 4, 'moving': False, 'dir': 'idle'}]}, {'recall': 0, 'cars': {'L1': ['reverse', 10], 'L2': ['travel', 0]}})]]
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)

prompt:
A car moving away at the top or bottom is sent to a floor that does not exist.

The recall floor is the designated floor unless smoke is detected there and not at the alternate floor. Each car: stationary at the recall floor -> open; stationary elsewhere -> travel to recall; moving towards the recall floor (strictly) -> nonstop to it; otherwise (moving away, or passing the recall floor) -> reverse after stopping at the next floor in its direction, clipped to 0..top.

split: open-access