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

N = 1
observations = []
def solve(x):
    n = x['floors']
    k = x['zones']
    size = n // k
    bases = [z * size for z in range(k) if z * size < n]
    if x['period'] == 'up-peak':
        targets = [0] + bases
    elif x['period'] == 'down-peak':
        targets = sorted(bases, reverse=True)
    else:
        targets = bases
    free = dict(x['cars'])
    plan = {}
    for t in targets:
        if not free:
            break
        cid = min(free, key=lambda c: (abs(free[c] - t), c))
        plan[cid] = t
        del free[cid]
    return plan
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: twelve floors in three zones', {'floors': 12, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 11], ['C2', 6], ['C3', 2]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('sampled regression 6', {'floors': 30, 'zones': 4, 'period': 'up-peak', 'cars': [['C5', 9], ['C2', 3], ['C4', 5], ['C3', 18]]}, {'C2': 0, 'C4': 0, 'C5': 8, 'C3': 16}), ('boundary: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 1', {'floors': 8, 'zones': 3, 'period': 'off-peak', 'cars': [['C2', 3], ['C1', 7], ['C5', 4]]}, {'C2': 0, 'C5': 3, 'C1': 6}), ('sampled regression 4', {'floors': 27, 'zones': 2, 'period': 'down-peak', 'cars': [['C3', 14], ['C5', 10]]}, {'C3': 14, 'C5': 0}), ('sampled regression 7', {'floors': 14, 'zones': 3, 'period': 'down-peak', 'cars': [['C5', 13], ['C4', 0], ['C2', 11], ['C3', 5], ['C1', 11]]}, {'C1': 10, 'C3': 5, 'C4': 0})], [('regression: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('sampled regression 24', {'floors': 8, 'zones': 3, 'period': 'up-peak', 'cars': [['C5', 4], ['C4', 6], ['C1', 0], ['C2', 1], ['C3', 2]]}, {'C1': 0, 'C2': 0, 'C3': 3, 'C4': 6}), ('control 14', {'floors': 8, 'zones': 4, 'period': 'off-peak', 'cars': [['C2', 1], ['C3', 4], ['C5', 1], ['C1', 1]]}, {'C1': 0, 'C2': 2, 'C3': 4, 'C5': 6}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('control 12', {'floors': 14, 'zones': 2, 'period': 'off-peak', 'cars': [['C3', 9], ['C5', 5]]}, {'C5': 0, 'C3': 7}), ('control 15', {'floors': 22, 'zones': 1, 'period': 'off-peak', 'cars': [['C5', 11]]}, {'C5': 0}), ('control 18', {'floors': 10, 'zones': 2, 'period': 'down-peak', 'cars': [['C4', 7], ['C2', 2], ['C1', 0], ['C5', 0], ['C3', 5]]}, {'C3': 5, 'C1': 0})], [('regression: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 37', {'floors': 9, 'zones': 2, 'period': 'down-peak', 'cars': [['C1', 3], ['C5', 8], ['C4', 7]]}, {'C1': 5, 'C4': 0}), ('control 46', {'floors': 12, 'zones': 2, 'period': 'down-peak', 'cars': [['C1', 7]]}, {'C1': 6}), ('boundary: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('control 23', {'floors': 8, 'zones': 4, 'period': 'down-peak', 'cars': [['C3', 5], ['C4', 7]]}, {'C3': 6, 'C4': 4}), ('sampled regression 26', {'floors': 9, 'zones': 2, 'period': 'down-peak', 'cars': [['C2', 1], ['C4', 8], ['C1', 0], ['C5', 8], ['C3', 6]]}, {'C3': 5, 'C1': 0}), ('control 29', {'floors': 30, 'zones': 3, 'period': 'down-peak', 'cars': [['C3', 28], ['C5', 0], ['C2', 17], ['C4', 12], ['C1', 29]]}, {'C2': 20, 'C4': 10, 'C5': 0})], [('regression: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: twelve floors in three zones', {'floors': 12, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 11], ['C2', 6], ['C3', 2]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('sampled regression 53', {'floors': 17, 'zones': 2, 'period': 'off-peak', 'cars': [['C2', 1], ['C5', 4]]}, {'C2': 0, 'C5': 9}), ('control 71', {'floors': 9, 'zones': 3, 'period': 'down-peak', 'cars': [['C1', 3], ['C3', 8], ['C2', 0], ['C4', 8], ['C5', 4]]}, {'C3': 6, 'C1': 3, 'C2': 0}), ('boundary: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('sampled regression 34', {'floors': 17, 'zones': 2, 'period': 'off-peak', 'cars': [['C5', 2], ['C2', 7], ['C1', 0]]}, {'C1': 0, 'C2': 9}), ('sampled regression 37', {'floors': 9, 'zones': 2, 'period': 'down-peak', 'cars': [['C1', 3], ['C5', 8], ['C4', 7]]}, {'C1': 5, 'C4': 0}), ('control 40', {'floors': 24, 'zones': 1, 'period': 'off-peak', 'cars': [['C4', 6]]}, {'C4': 0})], [('regression: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('sampled regression 79', {'floors': 9, 'zones': 4, 'period': 'off-peak', 'cars': [['C5', 0], ['C3', 3], ['C4', 5], ['C1', 0]]}, {'C1': 0, 'C3': 3, 'C4': 6}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('boundary: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('control 45', {'floors': 9, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 6], ['C4', 1], ['C5', 0], ['C2', 1], ['C1', 7]]}, {'C5': 0}), ('sampled regression 48', {'floors': 16, 'zones': 3, 'period': 'up-peak', 'cars': [['C4', 9], ['C3', 7], ['C2', 14], ['C1', 7]]}, {'C1': 0, 'C3': 0, 'C4': 6, 'C2': 12}), ('control 51', {'floors': 18, 'zones': 4, 'period': 'off-peak', 'cars': [['C5', 11]]}, {'C5': 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):
    n = x['floors']
    k = x['zones']
    size = n // k + 1
    bases = [z * size for z in range(k) if z * size < n]
    if x['period'] == 'up-peak':
        targets = [0] + bases
    elif x['period'] == 'down-peak':
        targets = sorted(bases, reverse=True)
    else:
        targets = bases
    free = dict(x['cars'])
    plan = {}
    for t in targets:
        if not free:
            break
        cid = min(free, key=lambda c: (abs(free[c] - t), c))
        plan[cid] = t
        del free[cid]
    return plan
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: twelve floors in three zones', {'floors': 12, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 11], ['C2', 6], ['C3', 2]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('sampled regression 6', {'floors': 30, 'zones': 4, 'period': 'up-peak', 'cars': [['C5', 9], ['C2', 3], ['C4', 5], ['C3', 18]]}, {'C2': 0, 'C4': 0, 'C5': 8, 'C3': 16}), ('boundary: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 1', {'floors': 8, 'zones': 3, 'period': 'off-peak', 'cars': [['C2', 3], ['C1', 7], ['C5', 4]]}, {'C2': 0, 'C5': 3, 'C1': 6}), ('sampled regression 4', {'floors': 27, 'zones': 2, 'period': 'down-peak', 'cars': [['C3', 14], ['C5', 10]]}, {'C3': 14, 'C5': 0}), ('sampled regression 7', {'floors': 14, 'zones': 3, 'period': 'down-peak', 'cars': [['C5', 13], ['C4', 0], ['C2', 11], ['C3', 5], ['C1', 11]]}, {'C1': 10, 'C3': 5, 'C4': 0})], [('regression: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('sampled regression 24', {'floors': 8, 'zones': 3, 'period': 'up-peak', 'cars': [['C5', 4], ['C4', 6], ['C1', 0], ['C2', 1], ['C3', 2]]}, {'C1': 0, 'C2': 0, 'C3': 3, 'C4': 6}), ('control 14', {'floors': 8, 'zones': 4, 'period': 'off-peak', 'cars': [['C2', 1], ['C3', 4], ['C5', 1], ['C1', 1]]}, {'C1': 0, 'C2': 2, 'C3': 4, 'C5': 6}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('control 12', {'floors': 14, 'zones': 2, 'period': 'off-peak', 'cars': [['C3', 9], ['C5', 5]]}, {'C5': 0, 'C3': 7}), ('control 15', {'floors': 22, 'zones': 1, 'period': 'off-peak', 'cars': [['C5', 11]]}, {'C5': 0}), ('control 18', {'floors': 10, 'zones': 2, 'period': 'down-peak', 'cars': [['C4', 7], ['C2', 2], ['C1', 0], ['C5', 0], ['C3', 5]]}, {'C3': 5, 'C1': 0})], [('regression: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 37', {'floors': 9, 'zones': 2, 'period': 'down-peak', 'cars': [['C1', 3], ['C5', 8], ['C4', 7]]}, {'C1': 5, 'C4': 0}), ('control 46', {'floors': 12, 'zones': 2, 'period': 'down-peak', 'cars': [['C1', 7]]}, {'C1': 6}), ('boundary: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('control 23', {'floors': 8, 'zones': 4, 'period': 'down-peak', 'cars': [['C3', 5], ['C4', 7]]}, {'C3': 6, 'C4': 4}), ('sampled regression 26', {'floors': 9, 'zones': 2, 'period': 'down-peak', 'cars': [['C2', 1], ['C4', 8], ['C1', 0], ['C5', 8], ['C3', 6]]}, {'C3': 5, 'C1': 0}), ('control 29', {'floors': 30, 'zones': 3, 'period': 'down-peak', 'cars': [['C3', 28], ['C5', 0], ['C2', 17], ['C4', 12], ['C1', 29]]}, {'C2': 20, 'C4': 10, 'C5': 0})], [('regression: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: twelve floors in three zones', {'floors': 12, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 11], ['C2', 6], ['C3', 2]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('sampled regression 53', {'floors': 17, 'zones': 2, 'period': 'off-peak', 'cars': [['C2', 1], ['C5', 4]]}, {'C2': 0, 'C5': 9}), ('control 71', {'floors': 9, 'zones': 3, 'period': 'down-peak', 'cars': [['C1', 3], ['C3', 8], ['C2', 0], ['C4', 8], ['C5', 4]]}, {'C3': 6, 'C1': 3, 'C2': 0}), ('boundary: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('sampled regression 34', {'floors': 17, 'zones': 2, 'period': 'off-peak', 'cars': [['C5', 2], ['C2', 7], ['C1', 0]]}, {'C1': 0, 'C2': 9}), ('sampled regression 37', {'floors': 9, 'zones': 2, 'period': 'down-peak', 'cars': [['C1', 3], ['C5', 8], ['C4', 7]]}, {'C1': 5, 'C4': 0}), ('control 40', {'floors': 24, 'zones': 1, 'period': 'off-peak', 'cars': [['C4', 6]]}, {'C4': 0})], [('regression: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('sampled regression 79', {'floors': 9, 'zones': 4, 'period': 'off-peak', 'cars': [['C5', 0], ['C3', 3], ['C4', 5], ['C1', 0]]}, {'C1': 0, 'C3': 3, 'C4': 6}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('boundary: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('control 45', {'floors': 9, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 6], ['C4', 1], ['C5', 0], ['C2', 1], ['C1', 7]]}, {'C5': 0}), ('sampled regression 48', {'floors': 16, 'zones': 3, 'period': 'up-peak', 'cars': [['C4', 9], ['C3', 7], ['C2', 14], ['C1', 7]]}, {'C1': 0, 'C3': 0, 'C4': 6, 'C2': 12}), ('control 51', {'floors': 18, 'zones': 4, 'period': 'off-peak', 'cars': [['C5', 11]]}, {'C5': 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:
An extra tiny zone appears at the top, or zones are too large when floors divide evenly.

The building is split into zones of ceil(floors/zones) floors; each zone base floor is a parking target. Up-peak adds an extra lobby target first (lobby gets two cars); down-peak orders the bases from the top down; otherwise bases ascend. Each target in order takes the nearest free car (ties to the lowest car id); leftover targets stay empty.

split: open-access


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

N = 1
observations = []
def solve(x):
    n = x['floors']
    k = x['zones']
    size = -(-n // k)
    bases = [z * size for z in range(k) if z * size < n]
    if x['period'] == 'up-peak':
        targets = bases
    elif x['period'] == 'down-peak':
        targets = sorted(bases, reverse=True)
    else:
        targets = bases
    free = dict(x['cars'])
    plan = {}
    for t in targets:
        if not free:
            break
        cid = min(free, key=lambda c: (abs(free[c] - t), c))
        plan[cid] = t
        del free[cid]
    return plan
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('sampled regression 19', {'floors': 19, 'zones': 1, 'period': 'up-peak', 'cars': [['C4', 1], ['C3', 13], ['C1', 7], ['C5', 12]]}, {'C4': 0, 'C1': 0}), ('sampled regression 6', {'floors': 30, 'zones': 4, 'period': 'up-peak', 'cars': [['C5', 9], ['C2', 3], ['C4', 5], ['C3', 18]]}, {'C2': 0, 'C4': 0, 'C5': 8, 'C3': 16}), ('boundary: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: twelve floors in three zones', {'floors': 12, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 11], ['C2', 6], ['C3', 2]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('control 1', {'floors': 8, 'zones': 3, 'period': 'off-peak', 'cars': [['C2', 3], ['C1', 7], ['C5', 4]]}, {'C2': 0, 'C5': 3, 'C1': 6}), ('control 4', {'floors': 27, 'zones': 2, 'period': 'down-peak', 'cars': [['C3', 14], ['C5', 10]]}, {'C3': 14, 'C5': 0}), ('control 7', {'floors': 14, 'zones': 3, 'period': 'down-peak', 'cars': [['C5', 13], ['C4', 0], ['C2', 11], ['C3', 5], ['C1', 11]]}, {'C1': 10, 'C3': 5, 'C4': 0})], [('regression: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('sampled regression 56', {'floors': 22, 'zones': 4, 'period': 'up-peak', 'cars': [['C5', 4], ['C4', 1]]}, {'C4': 0, 'C5': 0}), ('sampled regression 65', {'floors': 16, 'zones': 3, 'period': 'up-peak', 'cars': [['C3', 10], ['C1', 0]]}, {'C1': 0, 'C3': 0}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('boundary: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('control 12', {'floors': 14, 'zones': 2, 'period': 'off-peak', 'cars': [['C3', 9], ['C5', 5]]}, {'C5': 0, 'C3': 7}), ('control 15', {'floors': 22, 'zones': 1, 'period': 'off-peak', 'cars': [['C5', 11]]}, {'C5': 0}), ('control 18', {'floors': 10, 'zones': 2, 'period': 'down-peak', 'cars': [['C4', 7], ['C2', 2], ['C1', 0], ['C5', 0], ['C3', 5]]}, {'C3': 5, 'C1': 0})], [('regression: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('sampled regression 24', {'floors': 8, 'zones': 3, 'period': 'up-peak', 'cars': [['C5', 4], ['C4', 6], ['C1', 0], ['C2', 1], ['C3', 2]]}, {'C1': 0, 'C2': 0, 'C3': 3, 'C4': 6}), ('sampled regression 48', {'floors': 16, 'zones': 3, 'period': 'up-peak', 'cars': [['C4', 9], ['C3', 7], ['C2', 14], ['C1', 7]]}, {'C1': 0, 'C3': 0, 'C4': 6, 'C2': 12}), ('boundary: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('boundary: fewer cars than targets', {'floors': 20, 'zones': 4, 'period': 'up-peak', 'cars': [['C2', 7]]}, {'C2': 0}), ('control 23', {'floors': 8, 'zones': 4, 'period': 'down-peak', 'cars': [['C3', 5], ['C4', 7]]}, {'C3': 6, 'C4': 4}), ('control 26', {'floors': 9, 'zones': 2, 'period': 'down-peak', 'cars': [['C2', 1], ['C4', 8], ['C1', 0], ['C5', 8], ['C3', 6]]}, {'C3': 5, 'C1': 0}), ('control 29', {'floors': 30, 'zones': 3, 'period': 'down-peak', 'cars': [['C3', 28], ['C5', 0], ['C2', 17], ['C4', 12], ['C1', 29]]}, {'C2': 20, 'C4': 10, 'C5': 0})], [('regression: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('sampled regression 65', {'floors': 16, 'zones': 3, 'period': 'up-peak', 'cars': [['C3', 10], ['C1', 0]]}, {'C1': 0, 'C3': 0}), ('sampled regression 25', {'floors': 17, 'zones': 3, 'period': 'up-peak', 'cars': [['C4', 8], ['C2', 15], ['C3', 12], ['C5', 10]]}, {'C4': 0, 'C5': 0, 'C3': 6, 'C2': 12}), ('boundary: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: twelve floors in three zones', {'floors': 12, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 11], ['C2', 6], ['C3', 2]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('control 34', {'floors': 17, 'zones': 2, 'period': 'off-peak', 'cars': [['C5', 2], ['C2', 7], ['C1', 0]]}, {'C1': 0, 'C2': 9}), ('control 37', {'floors': 9, 'zones': 2, 'period': 'down-peak', 'cars': [['C1', 3], ['C5', 8], ['C4', 7]]}, {'C1': 5, 'C4': 0}), ('control 40', {'floors': 24, 'zones': 1, 'period': 'off-peak', 'cars': [['C4', 6]]}, {'C4': 0})], [('regression: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('sampled regression 25', {'floors': 17, 'zones': 3, 'period': 'up-peak', 'cars': [['C4', 8], ['C2', 15], ['C3', 12], ['C5', 10]]}, {'C4': 0, 'C5': 0, 'C3': 6, 'C2': 12}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('boundary: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('boundary: fewer cars than targets', {'floors': 20, 'zones': 4, 'period': 'up-peak', 'cars': [['C2', 7]]}, {'C2': 0}), ('control 45', {'floors': 9, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 6], ['C4', 1], ['C5', 0], ['C2', 1], ['C1', 7]]}, {'C5': 0}), ('sampled regression 48', {'floors': 16, 'zones': 3, 'period': 'up-peak', 'cars': [['C4', 9], ['C3', 7], ['C2', 14], ['C1', 7]]}, {'C1': 0, 'C3': 0, 'C4': 6, 'C2': 12}), ('control 51', {'floors': 18, 'zones': 4, 'period': 'off-peak', 'cars': [['C5', 11]]}, {'C5': 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):
    n = x['floors']
    k = x['zones']
    size = -(-n // k)
    bases = [z * size for z in range(k) if z * size < n]
    if x['period'] == 'up-peak':
        targets = bases + [0]
    elif x['period'] == 'down-peak':
        targets = sorted(bases, reverse=True)
    else:
        targets = bases
    free = dict(x['cars'])
    plan = {}
    for t in targets:
        if not free:
            break
        cid = min(free, key=lambda c: (abs(free[c] - t), c))
        plan[cid] = t
        del free[cid]
    return plan
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('sampled regression 19', {'floors': 19, 'zones': 1, 'period': 'up-peak', 'cars': [['C4', 1], ['C3', 13], ['C1', 7], ['C5', 12]]}, {'C4': 0, 'C1': 0}), ('sampled regression 6', {'floors': 30, 'zones': 4, 'period': 'up-peak', 'cars': [['C5', 9], ['C2', 3], ['C4', 5], ['C3', 18]]}, {'C2': 0, 'C4': 0, 'C5': 8, 'C3': 16}), ('boundary: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: twelve floors in three zones', {'floors': 12, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 11], ['C2', 6], ['C3', 2]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('control 1', {'floors': 8, 'zones': 3, 'period': 'off-peak', 'cars': [['C2', 3], ['C1', 7], ['C5', 4]]}, {'C2': 0, 'C5': 3, 'C1': 6}), ('control 4', {'floors': 27, 'zones': 2, 'period': 'down-peak', 'cars': [['C3', 14], ['C5', 10]]}, {'C3': 14, 'C5': 0}), ('control 7', {'floors': 14, 'zones': 3, 'period': 'down-peak', 'cars': [['C5', 13], ['C4', 0], ['C2', 11], ['C3', 5], ['C1', 11]]}, {'C1': 10, 'C3': 5, 'C4': 0})], [('regression: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('sampled regression 56', {'floors': 22, 'zones': 4, 'period': 'up-peak', 'cars': [['C5', 4], ['C4', 1]]}, {'C4': 0, 'C5': 0}), ('sampled regression 65', {'floors': 16, 'zones': 3, 'period': 'up-peak', 'cars': [['C3', 10], ['C1', 0]]}, {'C1': 0, 'C3': 0}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('boundary: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('control 12', {'floors': 14, 'zones': 2, 'period': 'off-peak', 'cars': [['C3', 9], ['C5', 5]]}, {'C5': 0, 'C3': 7}), ('control 15', {'floors': 22, 'zones': 1, 'period': 'off-peak', 'cars': [['C5', 11]]}, {'C5': 0}), ('control 18', {'floors': 10, 'zones': 2, 'period': 'down-peak', 'cars': [['C4', 7], ['C2', 2], ['C1', 0], ['C5', 0], ['C3', 5]]}, {'C3': 5, 'C1': 0})], [('regression: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('sampled regression 24', {'floors': 8, 'zones': 3, 'period': 'up-peak', 'cars': [['C5', 4], ['C4', 6], ['C1', 0], ['C2', 1], ['C3', 2]]}, {'C1': 0, 'C2': 0, 'C3': 3, 'C4': 6}), ('sampled regression 48', {'floors': 16, 'zones': 3, 'period': 'up-peak', 'cars': [['C4', 9], ['C3', 7], ['C2', 14], ['C1', 7]]}, {'C1': 0, 'C3': 0, 'C4': 6, 'C2': 12}), ('boundary: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('boundary: fewer cars than targets', {'floors': 20, 'zones': 4, 'period': 'up-peak', 'cars': [['C2', 7]]}, {'C2': 0}), ('control 23', {'floors': 8, 'zones': 4, 'period': 'down-peak', 'cars': [['C3', 5], ['C4', 7]]}, {'C3': 6, 'C4': 4}), ('control 26', {'floors': 9, 'zones': 2, 'period': 'down-peak', 'cars': [['C2', 1], ['C4', 8], ['C1', 0], ['C5', 8], ['C3', 6]]}, {'C3': 5, 'C1': 0}), ('control 29', {'floors': 30, 'zones': 3, 'period': 'down-peak', 'cars': [['C3', 28], ['C5', 0], ['C2', 17], ['C4', 12], ['C1', 29]]}, {'C2': 20, 'C4': 10, 'C5': 0})], [('regression: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('sampled regression 65', {'floors': 16, 'zones': 3, 'period': 'up-peak', 'cars': [['C3', 10], ['C1', 0]]}, {'C1': 0, 'C3': 0}), ('sampled regression 25', {'floors': 17, 'zones': 3, 'period': 'up-peak', 'cars': [['C4', 8], ['C2', 15], ['C3', 12], ['C5', 10]]}, {'C4': 0, 'C5': 0, 'C3': 6, 'C2': 12}), ('boundary: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: twelve floors in three zones', {'floors': 12, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 11], ['C2', 6], ['C3', 2]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('control 34', {'floors': 17, 'zones': 2, 'period': 'off-peak', 'cars': [['C5', 2], ['C2', 7], ['C1', 0]]}, {'C1': 0, 'C2': 9}), ('control 37', {'floors': 9, 'zones': 2, 'period': 'down-peak', 'cars': [['C1', 3], ['C5', 8], ['C4', 7]]}, {'C1': 5, 'C4': 0}), ('control 40', {'floors': 24, 'zones': 1, 'period': 'off-peak', 'cars': [['C4', 6]]}, {'C4': 0})], [('regression: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('sampled regression 25', {'floors': 17, 'zones': 3, 'period': 'up-peak', 'cars': [['C4', 8], ['C2', 15], ['C3', 12], ['C5', 10]]}, {'C4': 0, 'C5': 0, 'C3': 6, 'C2': 12}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('boundary: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('boundary: fewer cars than targets', {'floors': 20, 'zones': 4, 'period': 'up-peak', 'cars': [['C2', 7]]}, {'C2': 0}), ('control 45', {'floors': 9, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 6], ['C4', 1], ['C5', 0], ['C2', 1], ['C1', 7]]}, {'C5': 0}), ('sampled regression 48', {'floors': 16, 'zones': 3, 'period': 'up-peak', 'cars': [['C4', 9], ['C3', 7], ['C2', 14], ['C1', 7]]}, {'C1': 0, 'C3': 0, 'C4': 6, 'C2': 12}), ('control 51', {'floors': 18, 'zones': 4, 'period': 'off-peak', 'cars': [['C5', 11]]}, {'C5': 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:
During up-peak only one car waits at the lobby.

The building is split into zones of ceil(floors/zones) floors; each zone base floor is a parking target. Up-peak adds an extra lobby target first (lobby gets two cars); down-peak orders the bases from the top down; otherwise bases ascend. Each target in order takes the nearest free car (ties to the lowest car id); leftover targets stay empty.

split: open-access


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

N = 1
observations = []
def solve(x):
    n = x['floors']
    k = x['zones']
    size = -(-n // k)
    bases = [z * size for z in range(k) if z * size < n]
    if x['period'] == 'up-peak':
        targets = [0] + bases
    elif x['period'] == 'down-peak':
        targets = bases
    else:
        targets = bases
    free = dict(x['cars'])
    plan = {}
    for t in targets:
        if not free:
            break
        cid = min(free, key=lambda c: (abs(free[c] - t), c))
        plan[cid] = t
        del free[cid]
    return plan
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 20', {'floors': 23, 'zones': 3, 'period': 'down-peak', 'cars': [['C4', 10], ['C3', 10], ['C5', 4]]}, {'C3': 16, 'C4': 8, 'C5': 0}), ('sampled regression 2', {'floors': 24, 'zones': 3, 'period': 'down-peak', 'cars': [['C5', 23], ['C4', 9]]}, {'C4': 16, 'C5': 8}), ('boundary: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: twelve floors in three zones', {'floors': 12, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 11], ['C2', 6], ['C3', 2]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('control 1', {'floors': 8, 'zones': 3, 'period': 'off-peak', 'cars': [['C2', 3], ['C1', 7], ['C5', 4]]}, {'C2': 0, 'C5': 3, 'C1': 6}), ('control 4', {'floors': 27, 'zones': 2, 'period': 'down-peak', 'cars': [['C3', 14], ['C5', 10]]}, {'C3': 14, 'C5': 0}), ('control 7', {'floors': 14, 'zones': 3, 'period': 'down-peak', 'cars': [['C5', 13], ['C4', 0], ['C2', 11], ['C3', 5], ['C1', 11]]}, {'C1': 10, 'C3': 5, 'C4': 0})], [('regression: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 46', {'floors': 12, 'zones': 2, 'period': 'down-peak', 'cars': [['C1', 7]]}, {'C1': 6}), ('sampled regression 42', {'floors': 26, 'zones': 3, 'period': 'down-peak', 'cars': [['C3', 23], ['C4', 7], ['C1', 21], ['C5', 24], ['C2', 14]]}, {'C1': 18, 'C4': 9, 'C2': 0}), ('boundary: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('boundary: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('control 12', {'floors': 14, 'zones': 2, 'period': 'off-peak', 'cars': [['C3', 9], ['C5', 5]]}, {'C5': 0, 'C3': 7}), ('control 15', {'floors': 22, 'zones': 1, 'period': 'off-peak', 'cars': [['C5', 11]]}, {'C5': 0}), ('control 18', {'floors': 10, 'zones': 2, 'period': 'down-peak', 'cars': [['C4', 7], ['C2', 2], ['C1', 0], ['C5', 0], ['C3', 5]]}, {'C3': 5, 'C1': 0})], [('regression: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 23', {'floors': 8, 'zones': 4, 'period': 'down-peak', 'cars': [['C3', 5], ['C4', 7]]}, {'C3': 6, 'C4': 4}), ('sampled regression 33', {'floors': 29, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 4], ['C5', 12], ['C2', 15], ['C4', 23]]}, {'C4': 24, 'C2': 16, 'C1': 8, 'C5': 0}), ('boundary: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('boundary: fewer cars than targets', {'floors': 20, 'zones': 4, 'period': 'up-peak', 'cars': [['C2', 7]]}, {'C2': 0}), ('control 26', {'floors': 9, 'zones': 2, 'period': 'down-peak', 'cars': [['C2', 1], ['C4', 8], ['C1', 0], ['C5', 8], ['C3', 6]]}, {'C3': 5, 'C1': 0}), ('control 29', {'floors': 30, 'zones': 3, 'period': 'down-peak', 'cars': [['C3', 28], ['C5', 0], ['C2', 17], ['C4', 12], ['C1', 29]]}, {'C2': 20, 'C4': 10, 'C5': 0}), ('control 32', {'floors': 12, 'zones': 1, 'period': 'down-peak', 'cars': [['C4', 3], ['C5', 0], ['C2', 11]]}, {'C5': 0})], [('regression: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 52', {'floors': 21, 'zones': 3, 'period': 'down-peak', 'cars': [['C4', 6]]}, {'C4': 14}), ('boundary: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: twelve floors in three zones', {'floors': 12, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 11], ['C2', 6], ['C3', 2]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('control 34', {'floors': 17, 'zones': 2, 'period': 'off-peak', 'cars': [['C5', 2], ['C2', 7], ['C1', 0]]}, {'C1': 0, 'C2': 9}), ('sampled regression 37', {'floors': 9, 'zones': 2, 'period': 'down-peak', 'cars': [['C1', 3], ['C5', 8], ['C4', 7]]}, {'C1': 5, 'C4': 0}), ('control 40', {'floors': 24, 'zones': 1, 'period': 'off-peak', 'cars': [['C4', 6]]}, {'C4': 0})], [('regression: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 33', {'floors': 29, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 4], ['C5', 12], ['C2', 15], ['C4', 23]]}, {'C4': 24, 'C2': 16, 'C1': 8, 'C5': 0}), ('sampled regression 41', {'floors': 28, 'zones': 3, 'period': 'down-peak', 'cars': [['C5', 22], ['C3', 15]]}, {'C5': 20, 'C3': 10}), ('boundary: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('boundary: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('control 45', {'floors': 9, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 6], ['C4', 1], ['C5', 0], ['C2', 1], ['C1', 7]]}, {'C5': 0}), ('control 48', {'floors': 16, 'zones': 3, 'period': 'up-peak', 'cars': [['C4', 9], ['C3', 7], ['C2', 14], ['C1', 7]]}, {'C1': 0, 'C3': 0, 'C4': 6, 'C2': 12}), ('control 51', {'floors': 18, 'zones': 4, 'period': 'off-peak', 'cars': [['C5', 11]]}, {'C5': 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):
    n = x['floors']
    k = x['zones']
    size = -(-n // k)
    bases = [z * size for z in range(k) if z * size < n]
    if x['period'] == 'up-peak':
        targets = [0] + bases
    elif x['period'] == 'down-peak':
        targets = [bases[-1]] + bases[:-1]
    else:
        targets = bases
    free = dict(x['cars'])
    plan = {}
    for t in targets:
        if not free:
            break
        cid = min(free, key=lambda c: (abs(free[c] - t), c))
        plan[cid] = t
        del free[cid]
    return plan
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 20', {'floors': 23, 'zones': 3, 'period': 'down-peak', 'cars': [['C4', 10], ['C3', 10], ['C5', 4]]}, {'C3': 16, 'C4': 8, 'C5': 0}), ('sampled regression 2', {'floors': 24, 'zones': 3, 'period': 'down-peak', 'cars': [['C5', 23], ['C4', 9]]}, {'C4': 16, 'C5': 8}), ('boundary: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: twelve floors in three zones', {'floors': 12, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 11], ['C2', 6], ['C3', 2]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('control 1', {'floors': 8, 'zones': 3, 'period': 'off-peak', 'cars': [['C2', 3], ['C1', 7], ['C5', 4]]}, {'C2': 0, 'C5': 3, 'C1': 6}), ('control 4', {'floors': 27, 'zones': 2, 'period': 'down-peak', 'cars': [['C3', 14], ['C5', 10]]}, {'C3': 14, 'C5': 0}), ('control 7', {'floors': 14, 'zones': 3, 'period': 'down-peak', 'cars': [['C5', 13], ['C4', 0], ['C2', 11], ['C3', 5], ['C1', 11]]}, {'C1': 10, 'C3': 5, 'C4': 0})], [('regression: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 46', {'floors': 12, 'zones': 2, 'period': 'down-peak', 'cars': [['C1', 7]]}, {'C1': 6}), ('sampled regression 42', {'floors': 26, 'zones': 3, 'period': 'down-peak', 'cars': [['C3', 23], ['C4', 7], ['C1', 21], ['C5', 24], ['C2', 14]]}, {'C1': 18, 'C4': 9, 'C2': 0}), ('boundary: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('boundary: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('control 12', {'floors': 14, 'zones': 2, 'period': 'off-peak', 'cars': [['C3', 9], ['C5', 5]]}, {'C5': 0, 'C3': 7}), ('control 15', {'floors': 22, 'zones': 1, 'period': 'off-peak', 'cars': [['C5', 11]]}, {'C5': 0}), ('control 18', {'floors': 10, 'zones': 2, 'period': 'down-peak', 'cars': [['C4', 7], ['C2', 2], ['C1', 0], ['C5', 0], ['C3', 5]]}, {'C3': 5, 'C1': 0})], [('regression: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 23', {'floors': 8, 'zones': 4, 'period': 'down-peak', 'cars': [['C3', 5], ['C4', 7]]}, {'C3': 6, 'C4': 4}), ('sampled regression 33', {'floors': 29, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 4], ['C5', 12], ['C2', 15], ['C4', 23]]}, {'C4': 24, 'C2': 16, 'C1': 8, 'C5': 0}), ('boundary: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('boundary: fewer cars than targets', {'floors': 20, 'zones': 4, 'period': 'up-peak', 'cars': [['C2', 7]]}, {'C2': 0}), ('control 26', {'floors': 9, 'zones': 2, 'period': 'down-peak', 'cars': [['C2', 1], ['C4', 8], ['C1', 0], ['C5', 8], ['C3', 6]]}, {'C3': 5, 'C1': 0}), ('control 29', {'floors': 30, 'zones': 3, 'period': 'down-peak', 'cars': [['C3', 28], ['C5', 0], ['C2', 17], ['C4', 12], ['C1', 29]]}, {'C2': 20, 'C4': 10, 'C5': 0}), ('control 32', {'floors': 12, 'zones': 1, 'period': 'down-peak', 'cars': [['C4', 3], ['C5', 0], ['C2', 11]]}, {'C5': 0})], [('regression: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 52', {'floors': 21, 'zones': 3, 'period': 'down-peak', 'cars': [['C4', 6]]}, {'C4': 14}), ('boundary: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: twelve floors in three zones', {'floors': 12, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 11], ['C2', 6], ['C3', 2]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('boundary: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('control 34', {'floors': 17, 'zones': 2, 'period': 'off-peak', 'cars': [['C5', 2], ['C2', 7], ['C1', 0]]}, {'C1': 0, 'C2': 9}), ('sampled regression 37', {'floors': 9, 'zones': 2, 'period': 'down-peak', 'cars': [['C1', 3], ['C5', 8], ['C4', 7]]}, {'C1': 5, 'C4': 0}), ('control 40', {'floors': 24, 'zones': 1, 'period': 'off-peak', 'cars': [['C4', 6]]}, {'C4': 0})], [('regression: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 33', {'floors': 29, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 4], ['C5', 12], ['C2', 15], ['C4', 23]]}, {'C4': 24, 'C2': 16, 'C1': 8, 'C5': 0}), ('sampled regression 41', {'floors': 28, 'zones': 3, 'period': 'down-peak', 'cars': [['C5', 22], ['C3', 15]]}, {'C5': 20, 'C3': 10}), ('boundary: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('boundary: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('control 45', {'floors': 9, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 6], ['C4', 1], ['C5', 0], ['C2', 1], ['C1', 7]]}, {'C5': 0}), ('control 48', {'floors': 16, 'zones': 3, 'period': 'up-peak', 'cars': [['C4', 9], ['C3', 7], ['C2', 14], ['C1', 7]]}, {'C1': 0, 'C3': 0, 'C4': 6, 'C2': 12}), ('control 51', {'floors': 18, 'zones': 4, 'period': 'off-peak', 'cars': [['C5', 11]]}, {'C5': 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:
In down-peak the upper zones are left without cars.

The building is split into zones of ceil(floors/zones) floors; each zone base floor is a parking target. Up-peak adds an extra lobby target first (lobby gets two cars); down-peak orders the bases from the top down; otherwise bases ascend. Each target in order takes the nearest free car (ties to the lowest car id); leftover targets stay empty.

split: open-access


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

N = 1
observations = []
def solve(x):
    n = x['floors']
    k = x['zones']
    size = -(-n // k)
    bases = [z * size for z in range(k) if z * size < n]
    if x['period'] == 'up-peak':
        targets = [0] + bases
    elif x['period'] == 'down-peak':
        targets = sorted(bases, reverse=True)
    else:
        targets = bases
    free = dict(x['cars'])
    plan = {}
    for t in targets:
        if not free:
            break
        cid = min(free, key=lambda c: abs(free[c] - t))
        plan[cid] = t
        del free[cid]
    return plan
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 11', {'floors': 10, 'zones': 1, 'period': 'up-peak', 'cars': [['C2', 7], ['C5', 9], ['C3', 0], ['C4', 7], ['C1', 7]]}, {'C3': 0, 'C1': 0}), ('control 3', {'floors': 12, 'zones': 2, 'period': 'down-peak', 'cars': [['C1', 6], ['C2', 1], ['C5', 2], ['C3', 10], ['C4', 4]]}, {'C1': 6, 'C2': 0}), ('boundary: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('control 1', {'floors': 8, 'zones': 3, 'period': 'off-peak', 'cars': [['C2', 3], ['C1', 7], ['C5', 4]]}, {'C2': 0, 'C5': 3, 'C1': 6}), ('control 4', {'floors': 27, 'zones': 2, 'period': 'down-peak', 'cars': [['C3', 14], ['C5', 10]]}, {'C3': 14, 'C5': 0}), ('sampled regression 7', {'floors': 14, 'zones': 3, 'period': 'down-peak', 'cars': [['C5', 13], ['C4', 0], ['C2', 11], ['C3', 5], ['C1', 11]]}, {'C1': 10, 'C3': 5, 'C4': 0})], [('regression: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('control 16', {'floors': 14, 'zones': 4, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 2], ['C3', 12], ['C4', 0], ['C5', 3]]}, {'C4': 0, 'C5': 4, 'C1': 8, 'C3': 12}), ('boundary: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('boundary: fewer cars than targets', {'floors': 20, 'zones': 4, 'period': 'up-peak', 'cars': [['C2', 7]]}, {'C2': 0}), ('control 12', {'floors': 14, 'zones': 2, 'period': 'off-peak', 'cars': [['C3', 9], ['C5', 5]]}, {'C5': 0, 'C3': 7}), ('control 15', {'floors': 22, 'zones': 1, 'period': 'off-peak', 'cars': [['C5', 11]]}, {'C5': 0}), ('control 18', {'floors': 10, 'zones': 2, 'period': 'down-peak', 'cars': [['C4', 7], ['C2', 2], ['C1', 0], ['C5', 0], ['C3', 5]]}, {'C3': 5, 'C1': 0})], [('regression: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 44', {'floors': 9, 'zones': 2, 'period': 'up-peak', 'cars': [['C3', 4], ['C2', 2], ['C5', 8], ['C1', 4]]}, {'C2': 0, 'C1': 0, 'C3': 5}), ('control 26', {'floors': 9, 'zones': 2, 'period': 'down-peak', 'cars': [['C2', 1], ['C4', 8], ['C1', 0], ['C5', 8], ['C3', 6]]}, {'C3': 5, 'C1': 0}), ('boundary: fewer cars than targets', {'floors': 20, 'zones': 4, 'period': 'up-peak', 'cars': [['C2', 7]]}, {'C2': 0}), ('control 23', {'floors': 8, 'zones': 4, 'period': 'down-peak', 'cars': [['C3', 5], ['C4', 7]]}, {'C3': 6, 'C4': 4}), ('control 29', {'floors': 30, 'zones': 3, 'period': 'down-peak', 'cars': [['C3', 28], ['C5', 0], ['C2', 17], ['C4', 12], ['C1', 29]]}, {'C2': 20, 'C4': 10, 'C5': 0}), ('control 32', {'floors': 12, 'zones': 1, 'period': 'down-peak', 'cars': [['C4', 3], ['C5', 0], ['C2', 11]]}, {'C5': 0})], [('regression: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 14', {'floors': 8, 'zones': 4, 'period': 'off-peak', 'cars': [['C2', 1], ['C3', 4], ['C5', 1], ['C1', 1]]}, {'C1': 0, 'C2': 2, 'C3': 4, 'C5': 6}), ('control 39', {'floors': 25, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 11], ['C5', 15]]}, {'C5': 21, 'C1': 14}), ('boundary: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('control 34', {'floors': 17, 'zones': 2, 'period': 'off-peak', 'cars': [['C5', 2], ['C2', 7], ['C1', 0]]}, {'C1': 0, 'C2': 9}), ('control 37', {'floors': 9, 'zones': 2, 'period': 'down-peak', 'cars': [['C1', 3], ['C5', 8], ['C4', 7]]}, {'C1': 5, 'C4': 0}), ('control 40', {'floors': 24, 'zones': 1, 'period': 'off-peak', 'cars': [['C4', 6]]}, {'C4': 0})], [('regression: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 2', {'floors': 24, 'zones': 3, 'period': 'down-peak', 'cars': [['C5', 23], ['C4', 9]]}, {'C4': 16, 'C5': 8}), ('control 57', {'floors': 13, 'zones': 2, 'period': 'down-peak', 'cars': [['C1', 11], ['C2', 8], ['C4', 5]]}, {'C2': 7, 'C4': 0}), ('boundary: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('control 45', {'floors': 9, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 6], ['C4', 1], ['C5', 0], ['C2', 1], ['C1', 7]]}, {'C5': 0}), ('control 48', {'floors': 16, 'zones': 3, 'period': 'up-peak', 'cars': [['C4', 9], ['C3', 7], ['C2', 14], ['C1', 7]]}, {'C1': 0, 'C3': 0, 'C4': 6, 'C2': 12}), ('control 51', {'floors': 18, 'zones': 4, 'period': 'off-peak', 'cars': [['C5', 11]]}, {'C5': 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):
    n = x['floors']
    k = x['zones']
    size = -(-n // k)
    bases = [z * size for z in range(k) if z * size < n]
    if x['period'] == 'up-peak':
        targets = [0] + bases
    elif x['period'] == 'down-peak':
        targets = sorted(bases, reverse=True)
    else:
        targets = bases
    free = dict(x['cars'])
    plan = {}
    for t in targets:
        if not free:
            break
        cid = min(free, key=lambda c: (free[c], c))
        plan[cid] = t
        del free[cid]
    return plan
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 11', {'floors': 10, 'zones': 1, 'period': 'up-peak', 'cars': [['C2', 7], ['C5', 9], ['C3', 0], ['C4', 7], ['C1', 7]]}, {'C3': 0, 'C1': 0}), ('control 3', {'floors': 12, 'zones': 2, 'period': 'down-peak', 'cars': [['C1', 6], ['C2', 1], ['C5', 2], ['C3', 10], ['C4', 4]]}, {'C1': 6, 'C2': 0}), ('boundary: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('control 1', {'floors': 8, 'zones': 3, 'period': 'off-peak', 'cars': [['C2', 3], ['C1', 7], ['C5', 4]]}, {'C2': 0, 'C5': 3, 'C1': 6}), ('control 4', {'floors': 27, 'zones': 2, 'period': 'down-peak', 'cars': [['C3', 14], ['C5', 10]]}, {'C3': 14, 'C5': 0}), ('sampled regression 7', {'floors': 14, 'zones': 3, 'period': 'down-peak', 'cars': [['C5', 13], ['C4', 0], ['C2', 11], ['C3', 5], ['C1', 11]]}, {'C1': 10, 'C3': 5, 'C4': 0})], [('regression: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('control 16', {'floors': 14, 'zones': 4, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 2], ['C3', 12], ['C4', 0], ['C5', 3]]}, {'C4': 0, 'C5': 4, 'C1': 8, 'C3': 12}), ('boundary: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('boundary: fewer cars than targets', {'floors': 20, 'zones': 4, 'period': 'up-peak', 'cars': [['C2', 7]]}, {'C2': 0}), ('control 12', {'floors': 14, 'zones': 2, 'period': 'off-peak', 'cars': [['C3', 9], ['C5', 5]]}, {'C5': 0, 'C3': 7}), ('control 15', {'floors': 22, 'zones': 1, 'period': 'off-peak', 'cars': [['C5', 11]]}, {'C5': 0}), ('control 18', {'floors': 10, 'zones': 2, 'period': 'down-peak', 'cars': [['C4', 7], ['C2', 2], ['C1', 0], ['C5', 0], ['C3', 5]]}, {'C3': 5, 'C1': 0})], [('regression: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 44', {'floors': 9, 'zones': 2, 'period': 'up-peak', 'cars': [['C3', 4], ['C2', 2], ['C5', 8], ['C1', 4]]}, {'C2': 0, 'C1': 0, 'C3': 5}), ('control 26', {'floors': 9, 'zones': 2, 'period': 'down-peak', 'cars': [['C2', 1], ['C4', 8], ['C1', 0], ['C5', 8], ['C3', 6]]}, {'C3': 5, 'C1': 0}), ('boundary: fewer cars than targets', {'floors': 20, 'zones': 4, 'period': 'up-peak', 'cars': [['C2', 7]]}, {'C2': 0}), ('control 23', {'floors': 8, 'zones': 4, 'period': 'down-peak', 'cars': [['C3', 5], ['C4', 7]]}, {'C3': 6, 'C4': 4}), ('control 29', {'floors': 30, 'zones': 3, 'period': 'down-peak', 'cars': [['C3', 28], ['C5', 0], ['C2', 17], ['C4', 12], ['C1', 29]]}, {'C2': 20, 'C4': 10, 'C5': 0}), ('control 32', {'floors': 12, 'zones': 1, 'period': 'down-peak', 'cars': [['C4', 3], ['C5', 0], ['C2', 11]]}, {'C5': 0})], [('regression: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 14', {'floors': 8, 'zones': 4, 'period': 'off-peak', 'cars': [['C2', 1], ['C3', 4], ['C5', 1], ['C1', 1]]}, {'C1': 0, 'C2': 2, 'C3': 4, 'C5': 6}), ('control 39', {'floors': 25, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 11], ['C5', 15]]}, {'C5': 21, 'C1': 14}), ('boundary: ten floors in three zones', {'floors': 10, 'zones': 3, 'period': 'off-peak', 'cars': [['C1', 9], ['C2', 5], ['C3', 1]]}, {'C3': 0, 'C2': 4, 'C1': 8}), ('control 34', {'floors': 17, 'zones': 2, 'period': 'off-peak', 'cars': [['C5', 2], ['C2', 7], ['C1', 0]]}, {'C1': 0, 'C2': 9}), ('control 37', {'floors': 9, 'zones': 2, 'period': 'down-peak', 'cars': [['C1', 3], ['C5', 8], ['C4', 7]]}, {'C1': 5, 'C4': 0}), ('control 40', {'floors': 24, 'zones': 1, 'period': 'off-peak', 'cars': [['C4', 6]]}, {'C4': 0})], [('regression: equidistant cars listed out of order', {'floors': 10, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 2], ['C1', 2]]}, {'C1': 0}), ('boundary: down-peak top first', {'floors': 20, 'zones': 4, 'period': 'down-peak', 'cars': [['C1', 16], ['C2', 13], ['C3', 2]]}, {'C1': 15, 'C2': 10, 'C3': 5}), ('sampled regression 2', {'floors': 24, 'zones': 3, 'period': 'down-peak', 'cars': [['C5', 23], ['C4', 9]]}, {'C4': 16, 'C5': 8}), ('control 57', {'floors': 13, 'zones': 2, 'period': 'down-peak', 'cars': [['C1', 11], ['C2', 8], ['C4', 5]]}, {'C2': 7, 'C4': 0}), ('boundary: up-peak lobby pair', {'floors': 12, 'zones': 2, 'period': 'up-peak', 'cars': [['C1', 3], ['C2', 8], ['C3', 11]]}, {'C1': 0, 'C2': 0, 'C3': 6}), ('control 45', {'floors': 9, 'zones': 1, 'period': 'off-peak', 'cars': [['C3', 6], ['C4', 1], ['C5', 0], ['C2', 1], ['C1', 7]]}, {'C5': 0}), ('control 48', {'floors': 16, 'zones': 3, 'period': 'up-peak', 'cars': [['C4', 9], ['C3', 7], ['C2', 14], ['C1', 7]]}, {'C1': 0, 'C3': 0, 'C4': 6, 'C2': 12}), ('control 51', {'floors': 18, 'zones': 4, 'period': 'off-peak', 'cars': [['C5', 11]]}, {'C5': 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:
Equally near cars are chosen by listing order, or a far car is chosen.

The building is split into zones of ceil(floors/zones) floors; each zone base floor is a parking target. Up-peak adds an extra lobby target first (lobby gets two cars); down-peak orders the bases from the top down; otherwise bases ascend. Each target in order takes the nearest free car (ties to the lowest car id); leftover targets stay empty.

split: open-access


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

N = 1
observations = []
def solve(x):
    calls = []
    log = []
    for f in x['presses']:
        if f == x['floor']:
            log.append('reopen')
        elif f < 0 or f >= x['floors']:
            log.append('invalid')
        elif f in calls:
            if len(calls) > 1:
                calls.remove(f)
                log.append('cancelled')
            else:
                log.append('kept')
        elif x['load_kg'] < 20 and len(calls) >= 5:
            log.append('nuisance')
        else:
            calls.append(f)
            log.append('registered')
    return {'calls': sorted(calls), 'log': log}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: own floor with doors closed', {'floors': 10, 'floor': 4, 'doors_open': False, 'load_kg': 80, 'presses': [4, 6]}, {'calls': [4, 6], 'log': ['registered', 'registered']}), ('control 3', {'floors': 7, 'floor': 3, 'doors_open': True, 'load_kg': 20, 'presses': [0, 5, 5, 0, 3, 3, -1]}, {'calls': [0], 'log': ['registered', 'registered', 'cancelled', 'kept', 'reopen', 'reopen', 'invalid']}), ('sampled regression 8', {'floors': 7, 'floor': 0, 'doors_open': False, 'load_kg': 21, 'presses': [1, 0, 0, 6, -1, 5]}, {'calls': [1, 5, 6], 'log': ['registered', 'registered', 'cancelled', 'registered', 'invalid', 'registered']}), ('control 13', {'floors': 14, 'floor': 12, 'doors_open': True, 'load_kg': 80, 'presses': [8, 0, 1, 12, 1, 13, 2, 5, -1]}, {'calls': [0, 2, 5, 8, 13], 'log': ['registered', 'registered', 'registered', 'reopen', 'cancelled', 'registered', 'registered', 'registered', 'invalid']}), ('boundary: own floor with doors open', {'floors': 10, 'floor': 4, 'doors_open': True, 'load_kg': 80, 'presses': [4, 6]}, {'calls': [6], 'log': ['reopen', 'registered']}), ('control 1', {'floors': 12, 'floor': 6, 'doors_open': True, 'load_kg': 19, 'presses': [7, 7, -1, 8, 7]}, {'calls': [8], 'log': ['registered', 'kept', 'invalid', 'registered', 'cancelled']}), ('sampled regression 4', {'floors': 7, 'floor': 6, 'doors_open': False, 'load_kg': 19, 'presses': [0, 6, 6, 6, 4, 6]}, {'calls': [0, 4], 'log': ['registered', 'registered', 'cancelled', 'registered', 'registered', 'cancelled']}), ('control 7', {'floors': 7, 'floor': 1, 'doors_open': False, 'load_kg': 19, 'presses': [2, 0, 2, 5, 4, 6]}, {'calls': [0, 4, 5, 6], 'log': ['registered', 'registered', 'cancelled', 'registered', 'registered', 'registered']})], [('regression: own floor with doors closed', {'floors': 10, 'floor': 4, 'doors_open': False, 'load_kg': 80, 'presses': [4, 6]}, {'calls': [4, 6], 'log': ['registered', 'registered']}), ('control 13', {'floors': 14, 'floor': 12, 'doors_open': True, 'load_kg': 80, 'presses': [8, 0, 1, 12, 1, 13, 2, 5, -1]}, {'calls': [0, 2, 5, 8, 13], 'log': ['registered', 'registered', 'registered', 'reopen', 'cancelled', 'registered', 'registered', 'registered', 'invalid']}), ('sampled regression 39', {'floors': 7, 'floor': 3, 'doors_open': False, 'load_kg': 300, 'presses': [-1, 0, -1, 0, 3, 6, 1]}, {'calls': [0, 1, 3, 6], 'log': ['invalid', 'registered', 'invalid', 'kept', 'registered', 'registered', 'registered']}), ('control 33', {'floors': 11, 'floor': 8, 'doors_open': True, 'load_kg': 15, 'presses': [9, 10, 6, 5, 10, 10, 8, 2, 9]}, {'calls': [2, 5, 6, 10], 'log': ['registered', 'registered', 'registered', 'registered', 'cancelled', 'registered', 'reopen', 'registered', 'cancelled']}), ('boundary: basement button that does not exist', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [-1, 3]}, {'calls': [3], 'log': ['invalid', 'registered']}), ('control 12', {'floors': 13, 'floor': 5, 'doors_open': True, 'load_kg': 21, 'presses': [2, 3, 11]}, {'calls': [2, 3, 11], 'log': ['registered', 'registered', 'registered']}), ('sampled regression 15', {'floors': 12, 'floor': 10, 'doors_open': False, 'load_kg': 21, 'presses': [10, 4, 1, 4, 5, 6]}, {'calls': [1, 5, 6, 10], 'log': ['registered', 'registered', 'registered', 'cancelled', 'registered', 'registered']}), ('control 18', {'floors': 9, 'floor': 4, 'doors_open': True, 'load_kg': 19, 'presses': [3, 0, 5, 2, 7, 7, -1, 0]}, {'calls': [2, 3, 5], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'cancelled', 'invalid', 'cancelled']})], [('regression: own floor with doors closed', {'floors': 10, 'floor': 4, 'doors_open': False, 'load_kg': 80, 'presses': [4, 6]}, {'calls': [4, 6], 'log': ['registered', 'registered']}), ('control 16', {'floors': 14, 'floor': 9, 'doors_open': True, 'load_kg': 20, 'presses': [10, 12, 9, 2, 2]}, {'calls': [10, 12], 'log': ['registered', 'registered', 'reopen', 'registered', 'cancelled']}), ('sampled regression 72', {'floors': 6, 'floor': 4, 'doors_open': False, 'load_kg': 300, 'presses': [3, 0, 2, 0, 4]}, {'calls': [2, 3, 4], 'log': ['registered', 'registered', 'registered', 'cancelled', 'registered']}), ('control 46', {'floors': 10, 'floor': 3, 'doors_open': True, 'load_kg': 80, 'presses': [0, 9, 4, 7, 3, 6, 9, 7, 9]}, {'calls': [0, 4, 6, 9], 'log': ['registered', 'registered', 'registered', 'registered', 'reopen', 'registered', 'cancelled', 'cancelled', 'registered']}), ('boundary: double press cancels', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 5, 3]}, {'calls': [5], 'log': ['registered', 'registered', 'cancelled']}), ('sampled regression 23', {'floors': 14, 'floor': 2, 'doors_open': False, 'load_kg': 15, 'presses': [2, 14, 1, 0, -1, 14, 5, 13]}, {'calls': [0, 1, 2, 5, 13], 'log': ['registered', 'invalid', 'registered', 'registered', 'invalid', 'invalid', 'registered', 'registered']}), ('control 26', {'floors': 10, 'floor': 9, 'doors_open': True, 'load_kg': 15, 'presses': [2, 4, 5, 9, 6, 1, 7, 9]}, {'calls': [1, 2, 4, 5, 6], 'log': ['registered', 'registered', 'registered', 'reopen', 'registered', 'registered', 'nuisance', 'reopen']}), ('control 29', {'floors': 10, 'floor': 8, 'doors_open': False, 'load_kg': 20, 'presses': [10, 0, 1]}, {'calls': [0, 1], 'log': ['invalid', 'registered', 'registered']})], [('regression: own floor with doors closed', {'floors': 10, 'floor': 4, 'doors_open': False, 'load_kg': 80, 'presses': [4, 6]}, {'calls': [4, 6], 'log': ['registered', 'registered']}), ('control 26', {'floors': 10, 'floor': 9, 'doors_open': True, 'load_kg': 15, 'presses': [2, 4, 5, 9, 6, 1, 7, 9]}, {'calls': [1, 2, 4, 5, 6], 'log': ['registered', 'registered', 'registered', 'reopen', 'registered', 'registered', 'nuisance', 'reopen']}), ('sampled regression 15', {'floors': 12, 'floor': 10, 'doors_open': False, 'load_kg': 21, 'presses': [10, 4, 1, 4, 5, 6]}, {'calls': [1, 5, 6, 10], 'log': ['registered', 'registered', 'registered', 'cancelled', 'registered', 'registered']}), ('control 63', {'floors': 13, 'floor': 3, 'doors_open': True, 'load_kg': 80, 'presses': [3, 3, 0, 3, 5]}, {'calls': [0, 5], 'log': ['reopen', 'reopen', 'registered', 'reopen', 'registered']}), ('boundary: cancel an earlier call', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 5, 7, 5]}, {'calls': [3, 7], 'log': ['registered', 'registered', 'registered', 'cancelled']}), ('sampled regression 34', {'floors': 11, 'floor': 9, 'doors_open': False, 'load_kg': 0, 'presses': [10, 0, 5, 6, 0, 5, 9, 10, 9]}, {'calls': [6], 'log': ['registered', 'registered', 'registered', 'registered', 'cancelled', 'cancelled', 'registered', 'cancelled', 'cancelled']}), ('control 37', {'floors': 10, 'floor': 7, 'doors_open': True, 'load_kg': 80, 'presses': [10, 0, -1, -1, 5]}, {'calls': [0, 5], 'log': ['invalid', 'registered', 'invalid', 'invalid', 'registered']}), ('control 40', {'floors': 13, 'floor': 0, 'doors_open': True, 'load_kg': 15, 'presses': [0, -1, 8, 3]}, {'calls': [3, 8], 'log': ['reopen', 'invalid', 'registered', 'registered']})], [('regression: own floor with doors closed', {'floors': 10, 'floor': 4, 'doors_open': False, 'load_kg': 80, 'presses': [4, 6]}, {'calls': [4, 6], 'log': ['registered', 'registered']}), ('control 28', {'floors': 11, 'floor': 4, 'doors_open': True, 'load_kg': 21, 'presses': [9, 7, 9, 4, 10, 1, -1, 10]}, {'calls': [1, 7], 'log': ['registered', 'registered', 'cancelled', 'reopen', 'registered', 'registered', 'invalid', 'cancelled']}), ('sampled regression 60', {'floors': 12, 'floor': 11, 'doors_open': False, 'load_kg': 21, 'presses': [11, 3]}, {'calls': [3, 11], 'log': ['registered', 'registered']}), ('control 78', {'floors': 14, 'floor': 9, 'doors_open': True, 'load_kg': 0, 'presses': [8, 3, 2, 9, 13, 9, 5, 6, 0]}, {'calls': [2, 3, 5, 8, 13], 'log': ['registered', 'registered', 'registered', 'reopen', 'registered', 'reopen', 'registered', 'nuisance', 'nuisance']}), ('boundary: exactly twenty kilograms', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 20, 'presses': [1, 2, 3, 4, 5, 6]}, {'calls': [1, 2, 3, 4, 5, 6], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'registered']}), ('control 45', {'floors': 10, 'floor': 6, 'doors_open': False, 'load_kg': 20, 'presses': [10, 9, 0, 0, 5, 7, 2, 3, 3]}, {'calls': [2, 5, 7, 9], 'log': ['invalid', 'registered', 'registered', 'cancelled', 'registered', 'registered', 'registered', 'registered', 'cancelled']}), ('sampled regression 48', {'floors': 10, 'floor': 2, 'doors_open': False, 'load_kg': 0, 'presses': [6, 10, 7, 2, 7, 4, 9]}, {'calls': [2, 4, 6, 9], 'log': ['registered', 'invalid', 'registered', 'registered', 'cancelled', 'registered', 'registered']}), ('control 51', {'floors': 15, 'floor': 9, 'doors_open': True, 'load_kg': 21, 'presses': [13, 6, 9, 10, 9]}, {'calls': [6, 10, 13], 'log': ['registered', 'registered', 'reopen', 'registered', 'reopen']})]]
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):
    calls = []
    log = []
    for f in x['presses']:
        if f == x['floor'] and x['doors_open'] and not calls:
            log.append('reopen')
        elif f < 0 or f >= x['floors']:
            log.append('invalid')
        elif f in calls:
            if len(calls) > 1:
                calls.remove(f)
                log.append('cancelled')
            else:
                log.append('kept')
        elif x['load_kg'] < 20 and len(calls) >= 5:
            log.append('nuisance')
        else:
            calls.append(f)
            log.append('registered')
    return {'calls': sorted(calls), 'log': log}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: own floor with doors closed', {'floors': 10, 'floor': 4, 'doors_open': False, 'load_kg': 80, 'presses': [4, 6]}, {'calls': [4, 6], 'log': ['registered', 'registered']}), ('control 3', {'floors': 7, 'floor': 3, 'doors_open': True, 'load_kg': 20, 'presses': [0, 5, 5, 0, 3, 3, -1]}, {'calls': [0], 'log': ['registered', 'registered', 'cancelled', 'kept', 'reopen', 'reopen', 'invalid']}), ('sampled regression 8', {'floors': 7, 'floor': 0, 'doors_open': False, 'load_kg': 21, 'presses': [1, 0, 0, 6, -1, 5]}, {'calls': [1, 5, 6], 'log': ['registered', 'registered', 'cancelled', 'registered', 'invalid', 'registered']}), ('control 13', {'floors': 14, 'floor': 12, 'doors_open': True, 'load_kg': 80, 'presses': [8, 0, 1, 12, 1, 13, 2, 5, -1]}, {'calls': [0, 2, 5, 8, 13], 'log': ['registered', 'registered', 'registered', 'reopen', 'cancelled', 'registered', 'registered', 'registered', 'invalid']}), ('boundary: own floor with doors open', {'floors': 10, 'floor': 4, 'doors_open': True, 'load_kg': 80, 'presses': [4, 6]}, {'calls': [6], 'log': ['reopen', 'registered']}), ('control 1', {'floors': 12, 'floor': 6, 'doors_open': True, 'load_kg': 19, 'presses': [7, 7, -1, 8, 7]}, {'calls': [8], 'log': ['registered', 'kept', 'invalid', 'registered', 'cancelled']}), ('sampled regression 4', {'floors': 7, 'floor': 6, 'doors_open': False, 'load_kg': 19, 'presses': [0, 6, 6, 6, 4, 6]}, {'calls': [0, 4], 'log': ['registered', 'registered', 'cancelled', 'registered', 'registered', 'cancelled']}), ('control 7', {'floors': 7, 'floor': 1, 'doors_open': False, 'load_kg': 19, 'presses': [2, 0, 2, 5, 4, 6]}, {'calls': [0, 4, 5, 6], 'log': ['registered', 'registered', 'cancelled', 'registered', 'registered', 'registered']})], [('regression: own floor with doors closed', {'floors': 10, 'floor': 4, 'doors_open': False, 'load_kg': 80, 'presses': [4, 6]}, {'calls': [4, 6], 'log': ['registered', 'registered']}), ('control 13', {'floors': 14, 'floor': 12, 'doors_open': True, 'load_kg': 80, 'presses': [8, 0, 1, 12, 1, 13, 2, 5, -1]}, {'calls': [0, 2, 5, 8, 13], 'log': ['registered', 'registered', 'registered', 'reopen', 'cancelled', 'registered', 'registered', 'registered', 'invalid']}), ('sampled regression 39', {'floors': 7, 'floor': 3, 'doors_open': False, 'load_kg': 300, 'presses': [-1, 0, -1, 0, 3, 6, 1]}, {'calls': [0, 1, 3, 6], 'log': ['invalid', 'registered', 'invalid', 'kept', 'registered', 'registered', 'registered']}), ('control 33', {'floors': 11, 'floor': 8, 'doors_open': True, 'load_kg': 15, 'presses': [9, 10, 6, 5, 10, 10, 8, 2, 9]}, {'calls': [2, 5, 6, 10], 'log': ['registered', 'registered', 'registered', 'registered', 'cancelled', 'registered', 'reopen', 'registered', 'cancelled']}), ('boundary: basement button that does not exist', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [-1, 3]}, {'calls': [3], 'log': ['invalid', 'registered']}), ('control 12', {'floors': 13, 'floor': 5, 'doors_open': True, 'load_kg': 21, 'presses': [2, 3, 11]}, {'calls': [2, 3, 11], 'log': ['registered', 'registered', 'registered']}), ('sampled regression 15', {'floors': 12, 'floor': 10, 'doors_open': False, 'load_kg': 21, 'presses': [10, 4, 1, 4, 5, 6]}, {'calls': [1, 5, 6, 10], 'log': ['registered', 'registered', 'registered', 'cancelled', 'registered', 'registered']}), ('control 18', {'floors': 9, 'floor': 4, 'doors_open': True, 'load_kg': 19, 'presses': [3, 0, 5, 2, 7, 7, -1, 0]}, {'calls': [2, 3, 5], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'cancelled', 'invalid', 'cancelled']})], [('regression: own floor with doors closed', {'floors': 10, 'floor': 4, 'doors_open': False, 'load_kg': 80, 'presses': [4, 6]}, {'calls': [4, 6], 'log': ['registered', 'registered']}), ('control 16', {'floors': 14, 'floor': 9, 'doors_open': True, 'load_kg': 20, 'presses': [10, 12, 9, 2, 2]}, {'calls': [10, 12], 'log': ['registered', 'registered', 'reopen', 'registered', 'cancelled']}), ('sampled regression 72', {'floors': 6, 'floor': 4, 'doors_open': False, 'load_kg': 300, 'presses': [3, 0, 2, 0, 4]}, {'calls': [2, 3, 4], 'log': ['registered', 'registered', 'registered', 'cancelled', 'registered']}), ('control 46', {'floors': 10, 'floor': 3, 'doors_open': True, 'load_kg': 80, 'presses': [0, 9, 4, 7, 3, 6, 9, 7, 9]}, {'calls': [0, 4, 6, 9], 'log': ['registered', 'registered', 'registered', 'registered', 'reopen', 'registered', 'cancelled', 'cancelled', 'registered']}), ('boundary: double press cancels', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 5, 3]}, {'calls': [5], 'log': ['registered', 'registered', 'cancelled']}), ('sampled regression 23', {'floors': 14, 'floor': 2, 'doors_open': False, 'load_kg': 15, 'presses': [2, 14, 1, 0, -1, 14, 5, 13]}, {'calls': [0, 1, 2, 5, 13], 'log': ['registered', 'invalid', 'registered', 'registered', 'invalid', 'invalid', 'registered', 'registered']}), ('control 26', {'floors': 10, 'floor': 9, 'doors_open': True, 'load_kg': 15, 'presses': [2, 4, 5, 9, 6, 1, 7, 9]}, {'calls': [1, 2, 4, 5, 6], 'log': ['registered', 'registered', 'registered', 'reopen', 'registered', 'registered', 'nuisance', 'reopen']}), ('control 29', {'floors': 10, 'floor': 8, 'doors_open': False, 'load_kg': 20, 'presses': [10, 0, 1]}, {'calls': [0, 1], 'log': ['invalid', 'registered', 'registered']})], [('regression: own floor with doors closed', {'floors': 10, 'floor': 4, 'doors_open': False, 'load_kg': 80, 'presses': [4, 6]}, {'calls': [4, 6], 'log': ['registered', 'registered']}), ('control 26', {'floors': 10, 'floor': 9, 'doors_open': True, 'load_kg': 15, 'presses': [2, 4, 5, 9, 6, 1, 7, 9]}, {'calls': [1, 2, 4, 5, 6], 'log': ['registered', 'registered', 'registered', 'reopen', 'registered', 'registered', 'nuisance', 'reopen']}), ('sampled regression 15', {'floors': 12, 'floor': 10, 'doors_open': False, 'load_kg': 21, 'presses': [10, 4, 1, 4, 5, 6]}, {'calls': [1, 5, 6, 10], 'log': ['registered', 'registered', 'registered', 'cancelled', 'registered', 'registered']}), ('control 63', {'floors': 13, 'floor': 3, 'doors_open': True, 'load_kg': 80, 'presses': [3, 3, 0, 3, 5]}, {'calls': [0, 5], 'log': ['reopen', 'reopen', 'registered', 'reopen', 'registered']}), ('boundary: cancel an earlier call', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 5, 7, 5]}, {'calls': [3, 7], 'log': ['registered', 'registered', 'registered', 'cancelled']}), ('sampled regression 34', {'floors': 11, 'floor': 9, 'doors_open': False, 'load_kg': 0, 'presses': [10, 0, 5, 6, 0, 5, 9, 10, 9]}, {'calls': [6], 'log': ['registered', 'registered', 'registered', 'registered', 'cancelled', 'cancelled', 'registered', 'cancelled', 'cancelled']}), ('control 37', {'floors': 10, 'floor': 7, 'doors_open': True, 'load_kg': 80, 'presses': [10, 0, -1, -1, 5]}, {'calls': [0, 5], 'log': ['invalid', 'registered', 'invalid', 'invalid', 'registered']}), ('control 40', {'floors': 13, 'floor': 0, 'doors_open': True, 'load_kg': 15, 'presses': [0, -1, 8, 3]}, {'calls': [3, 8], 'log': ['reopen', 'invalid', 'registered', 'registered']})], [('regression: own floor with doors closed', {'floors': 10, 'floor': 4, 'doors_open': False, 'load_kg': 80, 'presses': [4, 6]}, {'calls': [4, 6], 'log': ['registered', 'registered']}), ('control 28', {'floors': 11, 'floor': 4, 'doors_open': True, 'load_kg': 21, 'presses': [9, 7, 9, 4, 10, 1, -1, 10]}, {'calls': [1, 7], 'log': ['registered', 'registered', 'cancelled', 'reopen', 'registered', 'registered', 'invalid', 'cancelled']}), ('sampled regression 60', {'floors': 12, 'floor': 11, 'doors_open': False, 'load_kg': 21, 'presses': [11, 3]}, {'calls': [3, 11], 'log': ['registered', 'registered']}), ('control 78', {'floors': 14, 'floor': 9, 'doors_open': True, 'load_kg': 0, 'presses': [8, 3, 2, 9, 13, 9, 5, 6, 0]}, {'calls': [2, 3, 5, 8, 13], 'log': ['registered', 'registered', 'registered', 'reopen', 'registered', 'reopen', 'registered', 'nuisance', 'nuisance']}), ('boundary: exactly twenty kilograms', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 20, 'presses': [1, 2, 3, 4, 5, 6]}, {'calls': [1, 2, 3, 4, 5, 6], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'registered']}), ('control 45', {'floors': 10, 'floor': 6, 'doors_open': False, 'load_kg': 20, 'presses': [10, 9, 0, 0, 5, 7, 2, 3, 3]}, {'calls': [2, 5, 7, 9], 'log': ['invalid', 'registered', 'registered', 'cancelled', 'registered', 'registered', 'registered', 'registered', 'cancelled']}), ('sampled regression 48', {'floors': 10, 'floor': 2, 'doors_open': False, 'load_kg': 0, 'presses': [6, 10, 7, 2, 7, 4, 9]}, {'calls': [2, 4, 6, 9], 'log': ['registered', 'invalid', 'registered', 'registered', 'cancelled', 'registered', 'registered']}), ('control 51', {'floors': 15, 'floor': 9, 'doors_open': True, 'load_kg': 21, 'presses': [13, 6, 9, 10, 9]}, {'calls': [6, 10, 13], 'log': ['registered', 'registered', 'reopen', 'registered', 'reopen']})]]
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:
Pressing the current floor with doors closed is swallowed instead of registered.

Car buttons are processed in order. Pressing the current floor with doors open reopens the doors. Floors outside 0..floors-1 are invalid. Pressing an already registered floor cancels it, unless it is the only call (kept). With load under 20 kg, a new call is refused as nuisance once five calls are registered. Otherwise the call is registered. Return the sorted calls and the per-press log.

split: open-access


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

N = 1
observations = []
def solve(x):
    calls = []
    log = []
    for f in x['presses']:
        if f == x['floor'] and x['doors_open']:
            log.append('reopen')
        elif f >= x['floors']:
            log.append('invalid')
        elif f in calls:
            if len(calls) > 1:
                calls.remove(f)
                log.append('cancelled')
            else:
                log.append('kept')
        elif x['load_kg'] < 20 and len(calls) >= 5:
            log.append('nuisance')
        else:
            calls.append(f)
            log.append('registered')
    return {'calls': sorted(calls), 'log': log}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: basement button that does not exist', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [-1, 3]}, {'calls': [3], 'log': ['invalid', 'registered']}), ('boundary: button one above the top', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [10, 9]}, {'calls': [9], 'log': ['invalid', 'registered']}), ('sampled regression 3', {'floors': 7, 'floor': 3, 'doors_open': True, 'load_kg': 20, 'presses': [0, 5, 5, 0, 3, 3, -1]}, {'calls': [0], 'log': ['registered', 'registered', 'cancelled', 'kept', 'reopen', 'reopen', 'invalid']}), ('sampled regression 9', {'floors': 10, 'floor': 9, 'doors_open': False, 'load_kg': 0, 'presses': [10, 3, -1, 0]}, {'calls': [0, 3], 'log': ['invalid', 'registered', 'invalid', 'registered']}), ('boundary: own floor with doors closed', {'floors': 10, 'floor': 4, 'doors_open': False, 'load_kg': 80, 'presses': [4, 6]}, {'calls': [4, 6], 'log': ['registered', 'registered']}), ('sampled regression 1', {'floors': 12, 'floor': 6, 'doors_open': True, 'load_kg': 19, 'presses': [7, 7, -1, 8, 7]}, {'calls': [8], 'log': ['registered', 'kept', 'invalid', 'registered', 'cancelled']}), ('control 4', {'floors': 7, 'floor': 6, 'doors_open': False, 'load_kg': 19, 'presses': [0, 6, 6, 6, 4, 6]}, {'calls': [0, 4], 'log': ['registered', 'registered', 'cancelled', 'registered', 'registered', 'cancelled']}), ('control 7', {'floors': 7, 'floor': 1, 'doors_open': False, 'load_kg': 19, 'presses': [2, 0, 2, 5, 4, 6]}, {'calls': [0, 4, 5, 6], 'log': ['registered', 'registered', 'cancelled', 'registered', 'registered', 'registered']})], [('regression: basement button that does not exist', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [-1, 3]}, {'calls': [3], 'log': ['invalid', 'registered']}), ('boundary: button one above the top', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [10, 9]}, {'calls': [9], 'log': ['invalid', 'registered']}), ('sampled regression 20', {'floors': 8, 'floor': 1, 'doors_open': False, 'load_kg': 300, 'presses': [-1, 7, 4, 8, 7, 6]}, {'calls': [4, 6], 'log': ['invalid', 'registered', 'registered', 'invalid', 'cancelled', 'registered']}), ('sampled regression 23', {'floors': 14, 'floor': 2, 'doors_open': False, 'load_kg': 15, 'presses': [2, 14, 1, 0, -1, 14, 5, 13]}, {'calls': [0, 1, 2, 5, 13], 'log': ['registered', 'invalid', 'registered', 'registered', 'invalid', 'invalid', 'registered', 'registered']}), ('boundary: double press cancels', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 5, 3]}, {'calls': [5], 'log': ['registered', 'registered', 'cancelled']}), ('control 12', {'floors': 13, 'floor': 5, 'doors_open': True, 'load_kg': 21, 'presses': [2, 3, 11]}, {'calls': [2, 3, 11], 'log': ['registered', 'registered', 'registered']}), ('control 15', {'floors': 12, 'floor': 10, 'doors_open': False, 'load_kg': 21, 'presses': [10, 4, 1, 4, 5, 6]}, {'calls': [1, 5, 6, 10], 'log': ['registered', 'registered', 'registered', 'cancelled', 'registered', 'registered']}), ('sampled regression 18', {'floors': 9, 'floor': 4, 'doors_open': True, 'load_kg': 19, 'presses': [3, 0, 5, 2, 7, 7, -1, 0]}, {'calls': [2, 3, 5], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'cancelled', 'invalid', 'cancelled']})], [('regression: basement button that does not exist', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [-1, 3]}, {'calls': [3], 'log': ['invalid', 'registered']}), ('boundary: button one above the top', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [10, 9]}, {'calls': [9], 'log': ['invalid', 'registered']}), ('sampled regression 40', {'floors': 13, 'floor': 0, 'doors_open': True, 'load_kg': 15, 'presses': [0, -1, 8, 3]}, {'calls': [3, 8], 'log': ['reopen', 'invalid', 'registered', 'registered']}), ('control 32', {'floors': 12, 'floor': 10, 'doors_open': False, 'load_kg': 300, 'presses': [8, 7, 2, 11, 12]}, {'calls': [2, 7, 8, 11], 'log': ['registered', 'registered', 'registered', 'registered', 'invalid']}), ('boundary: double press cancels', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 5, 3]}, {'calls': [5], 'log': ['registered', 'registered', 'cancelled']}), ('sampled regression 23', {'floors': 14, 'floor': 2, 'doors_open': False, 'load_kg': 15, 'presses': [2, 14, 1, 0, -1, 14, 5, 13]}, {'calls': [0, 1, 2, 5, 13], 'log': ['registered', 'invalid', 'registered', 'registered', 'invalid', 'invalid', 'registered', 'registered']}), ('control 26', {'floors': 10, 'floor': 9, 'doors_open': True, 'load_kg': 15, 'presses': [2, 4, 5, 9, 6, 1, 7, 9]}, {'calls': [1, 2, 4, 5, 6], 'log': ['registered', 'registered', 'registered', 'reopen', 'registered', 'registered', 'nuisance', 'reopen']}), ('control 29', {'floors': 10, 'floor': 8, 'doors_open': False, 'load_kg': 20, 'presses': [10, 0, 1]}, {'calls': [0, 1], 'log': ['invalid', 'registered', 'registered']})], [('regression: basement button that does not exist', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [-1, 3]}, {'calls': [3], 'log': ['invalid', 'registered']}), ('boundary: button one above the top', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [10, 9]}, {'calls': [9], 'log': ['invalid', 'registered']}), ('sampled regression 68', {'floors': 10, 'floor': 0, 'doors_open': True, 'load_kg': 300, 'presses': [0, 0, -1, 10, 3]}, {'calls': [3], 'log': ['reopen', 'reopen', 'invalid', 'invalid', 'registered']}), ('control 48', {'floors': 10, 'floor': 2, 'doors_open': False, 'load_kg': 0, 'presses': [6, 10, 7, 2, 7, 4, 9]}, {'calls': [2, 4, 6, 9], 'log': ['registered', 'invalid', 'registered', 'registered', 'cancelled', 'registered', 'registered']}), ('boundary: cancel an earlier call', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 5, 7, 5]}, {'calls': [3, 7], 'log': ['registered', 'registered', 'registered', 'cancelled']}), ('control 34', {'floors': 11, 'floor': 9, 'doors_open': False, 'load_kg': 0, 'presses': [10, 0, 5, 6, 0, 5, 9, 10, 9]}, {'calls': [6], 'log': ['registered', 'registered', 'registered', 'registered', 'cancelled', 'cancelled', 'registered', 'cancelled', 'cancelled']}), ('sampled regression 37', {'floors': 10, 'floor': 7, 'doors_open': True, 'load_kg': 80, 'presses': [10, 0, -1, -1, 5]}, {'calls': [0, 5], 'log': ['invalid', 'registered', 'invalid', 'invalid', 'registered']}), ('sampled regression 40', {'floors': 13, 'floor': 0, 'doors_open': True, 'load_kg': 15, 'presses': [0, -1, 8, 3]}, {'calls': [3, 8], 'log': ['reopen', 'invalid', 'registered', 'registered']})], [('regression: basement button that does not exist', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [-1, 3]}, {'calls': [3], 'log': ['invalid', 'registered']}), ('boundary: button one above the top', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [10, 9]}, {'calls': [9], 'log': ['invalid', 'registered']}), ('sampled regression 1', {'floors': 12, 'floor': 6, 'doors_open': True, 'load_kg': 19, 'presses': [7, 7, -1, 8, 7]}, {'calls': [8], 'log': ['registered', 'kept', 'invalid', 'registered', 'cancelled']}), ('sampled regression 75', {'floors': 12, 'floor': 8, 'doors_open': False, 'load_kg': 300, 'presses': [8, 9, 1, 1, 12, -1, 4, 0, 10]}, {'calls': [0, 4, 8, 9, 10], 'log': ['registered', 'registered', 'registered', 'cancelled', 'invalid', 'invalid', 'registered', 'registered', 'registered']}), ('boundary: exactly twenty kilograms', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 20, 'presses': [1, 2, 3, 4, 5, 6]}, {'calls': [1, 2, 3, 4, 5, 6], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'registered']}), ('control 45', {'floors': 10, 'floor': 6, 'doors_open': False, 'load_kg': 20, 'presses': [10, 9, 0, 0, 5, 7, 2, 3, 3]}, {'calls': [2, 5, 7, 9], 'log': ['invalid', 'registered', 'registered', 'cancelled', 'registered', 'registered', 'registered', 'registered', 'cancelled']}), ('control 48', {'floors': 10, 'floor': 2, 'doors_open': False, 'load_kg': 0, 'presses': [6, 10, 7, 2, 7, 4, 9]}, {'calls': [2, 4, 6, 9], 'log': ['registered', 'invalid', 'registered', 'registered', 'cancelled', 'registered', 'registered']}), ('control 51', {'floors': 15, 'floor': 9, 'doors_open': True, 'load_kg': 21, 'presses': [13, 6, 9, 10, 9]}, {'calls': [6, 10, 13], 'log': ['registered', 'registered', 'reopen', 'registered', 'reopen']})]]
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):
    calls = []
    log = []
    for f in x['presses']:
        if f == x['floor'] and x['doors_open']:
            log.append('reopen')
        elif f < 0 or f > x['floors']:
            log.append('invalid')
        elif f in calls:
            if len(calls) > 1:
                calls.remove(f)
                log.append('cancelled')
            else:
                log.append('kept')
        elif x['load_kg'] < 20 and len(calls) >= 5:
            log.append('nuisance')
        else:
            calls.append(f)
            log.append('registered')
    return {'calls': sorted(calls), 'log': log}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: basement button that does not exist', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [-1, 3]}, {'calls': [3], 'log': ['invalid', 'registered']}), ('boundary: button one above the top', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [10, 9]}, {'calls': [9], 'log': ['invalid', 'registered']}), ('sampled regression 3', {'floors': 7, 'floor': 3, 'doors_open': True, 'load_kg': 20, 'presses': [0, 5, 5, 0, 3, 3, -1]}, {'calls': [0], 'log': ['registered', 'registered', 'cancelled', 'kept', 'reopen', 'reopen', 'invalid']}), ('sampled regression 9', {'floors': 10, 'floor': 9, 'doors_open': False, 'load_kg': 0, 'presses': [10, 3, -1, 0]}, {'calls': [0, 3], 'log': ['invalid', 'registered', 'invalid', 'registered']}), ('boundary: own floor with doors closed', {'floors': 10, 'floor': 4, 'doors_open': False, 'load_kg': 80, 'presses': [4, 6]}, {'calls': [4, 6], 'log': ['registered', 'registered']}), ('sampled regression 1', {'floors': 12, 'floor': 6, 'doors_open': True, 'load_kg': 19, 'presses': [7, 7, -1, 8, 7]}, {'calls': [8], 'log': ['registered', 'kept', 'invalid', 'registered', 'cancelled']}), ('control 4', {'floors': 7, 'floor': 6, 'doors_open': False, 'load_kg': 19, 'presses': [0, 6, 6, 6, 4, 6]}, {'calls': [0, 4], 'log': ['registered', 'registered', 'cancelled', 'registered', 'registered', 'cancelled']}), ('control 7', {'floors': 7, 'floor': 1, 'doors_open': False, 'load_kg': 19, 'presses': [2, 0, 2, 5, 4, 6]}, {'calls': [0, 4, 5, 6], 'log': ['registered', 'registered', 'cancelled', 'registered', 'registered', 'registered']})], [('regression: basement button that does not exist', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [-1, 3]}, {'calls': [3], 'log': ['invalid', 'registered']}), ('boundary: button one above the top', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [10, 9]}, {'calls': [9], 'log': ['invalid', 'registered']}), ('sampled regression 20', {'floors': 8, 'floor': 1, 'doors_open': False, 'load_kg': 300, 'presses': [-1, 7, 4, 8, 7, 6]}, {'calls': [4, 6], 'log': ['invalid', 'registered', 'registered', 'invalid', 'cancelled', 'registered']}), ('sampled regression 23', {'floors': 14, 'floor': 2, 'doors_open': False, 'load_kg': 15, 'presses': [2, 14, 1, 0, -1, 14, 5, 13]}, {'calls': [0, 1, 2, 5, 13], 'log': ['registered', 'invalid', 'registered', 'registered', 'invalid', 'invalid', 'registered', 'registered']}), ('boundary: double press cancels', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 5, 3]}, {'calls': [5], 'log': ['registered', 'registered', 'cancelled']}), ('control 12', {'floors': 13, 'floor': 5, 'doors_open': True, 'load_kg': 21, 'presses': [2, 3, 11]}, {'calls': [2, 3, 11], 'log': ['registered', 'registered', 'registered']}), ('control 15', {'floors': 12, 'floor': 10, 'doors_open': False, 'load_kg': 21, 'presses': [10, 4, 1, 4, 5, 6]}, {'calls': [1, 5, 6, 10], 'log': ['registered', 'registered', 'registered', 'cancelled', 'registered', 'registered']}), ('sampled regression 18', {'floors': 9, 'floor': 4, 'doors_open': True, 'load_kg': 19, 'presses': [3, 0, 5, 2, 7, 7, -1, 0]}, {'calls': [2, 3, 5], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'cancelled', 'invalid', 'cancelled']})], [('regression: basement button that does not exist', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [-1, 3]}, {'calls': [3], 'log': ['invalid', 'registered']}), ('boundary: button one above the top', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [10, 9]}, {'calls': [9], 'log': ['invalid', 'registered']}), ('sampled regression 40', {'floors': 13, 'floor': 0, 'doors_open': True, 'load_kg': 15, 'presses': [0, -1, 8, 3]}, {'calls': [3, 8], 'log': ['reopen', 'invalid', 'registered', 'registered']}), ('control 32', {'floors': 12, 'floor': 10, 'doors_open': False, 'load_kg': 300, 'presses': [8, 7, 2, 11, 12]}, {'calls': [2, 7, 8, 11], 'log': ['registered', 'registered', 'registered', 'registered', 'invalid']}), ('boundary: double press cancels', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 5, 3]}, {'calls': [5], 'log': ['registered', 'registered', 'cancelled']}), ('sampled regression 23', {'floors': 14, 'floor': 2, 'doors_open': False, 'load_kg': 15, 'presses': [2, 14, 1, 0, -1, 14, 5, 13]}, {'calls': [0, 1, 2, 5, 13], 'log': ['registered', 'invalid', 'registered', 'registered', 'invalid', 'invalid', 'registered', 'registered']}), ('control 26', {'floors': 10, 'floor': 9, 'doors_open': True, 'load_kg': 15, 'presses': [2, 4, 5, 9, 6, 1, 7, 9]}, {'calls': [1, 2, 4, 5, 6], 'log': ['registered', 'registered', 'registered', 'reopen', 'registered', 'registered', 'nuisance', 'reopen']}), ('control 29', {'floors': 10, 'floor': 8, 'doors_open': False, 'load_kg': 20, 'presses': [10, 0, 1]}, {'calls': [0, 1], 'log': ['invalid', 'registered', 'registered']})], [('regression: basement button that does not exist', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [-1, 3]}, {'calls': [3], 'log': ['invalid', 'registered']}), ('boundary: button one above the top', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [10, 9]}, {'calls': [9], 'log': ['invalid', 'registered']}), ('sampled regression 68', {'floors': 10, 'floor': 0, 'doors_open': True, 'load_kg': 300, 'presses': [0, 0, -1, 10, 3]}, {'calls': [3], 'log': ['reopen', 'reopen', 'invalid', 'invalid', 'registered']}), ('control 48', {'floors': 10, 'floor': 2, 'doors_open': False, 'load_kg': 0, 'presses': [6, 10, 7, 2, 7, 4, 9]}, {'calls': [2, 4, 6, 9], 'log': ['registered', 'invalid', 'registered', 'registered', 'cancelled', 'registered', 'registered']}), ('boundary: cancel an earlier call', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 5, 7, 5]}, {'calls': [3, 7], 'log': ['registered', 'registered', 'registered', 'cancelled']}), ('control 34', {'floors': 11, 'floor': 9, 'doors_open': False, 'load_kg': 0, 'presses': [10, 0, 5, 6, 0, 5, 9, 10, 9]}, {'calls': [6], 'log': ['registered', 'registered', 'registered', 'registered', 'cancelled', 'cancelled', 'registered', 'cancelled', 'cancelled']}), ('sampled regression 37', {'floors': 10, 'floor': 7, 'doors_open': True, 'load_kg': 80, 'presses': [10, 0, -1, -1, 5]}, {'calls': [0, 5], 'log': ['invalid', 'registered', 'invalid', 'invalid', 'registered']}), ('sampled regression 40', {'floors': 13, 'floor': 0, 'doors_open': True, 'load_kg': 15, 'presses': [0, -1, 8, 3]}, {'calls': [3, 8], 'log': ['reopen', 'invalid', 'registered', 'registered']})], [('regression: basement button that does not exist', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [-1, 3]}, {'calls': [3], 'log': ['invalid', 'registered']}), ('boundary: button one above the top', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [10, 9]}, {'calls': [9], 'log': ['invalid', 'registered']}), ('sampled regression 1', {'floors': 12, 'floor': 6, 'doors_open': True, 'load_kg': 19, 'presses': [7, 7, -1, 8, 7]}, {'calls': [8], 'log': ['registered', 'kept', 'invalid', 'registered', 'cancelled']}), ('sampled regression 75', {'floors': 12, 'floor': 8, 'doors_open': False, 'load_kg': 300, 'presses': [8, 9, 1, 1, 12, -1, 4, 0, 10]}, {'calls': [0, 4, 8, 9, 10], 'log': ['registered', 'registered', 'registered', 'cancelled', 'invalid', 'invalid', 'registered', 'registered', 'registered']}), ('boundary: exactly twenty kilograms', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 20, 'presses': [1, 2, 3, 4, 5, 6]}, {'calls': [1, 2, 3, 4, 5, 6], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'registered']}), ('control 45', {'floors': 10, 'floor': 6, 'doors_open': False, 'load_kg': 20, 'presses': [10, 9, 0, 0, 5, 7, 2, 3, 3]}, {'calls': [2, 5, 7, 9], 'log': ['invalid', 'registered', 'registered', 'cancelled', 'registered', 'registered', 'registered', 'registered', 'cancelled']}), ('control 48', {'floors': 10, 'floor': 2, 'doors_open': False, 'load_kg': 0, 'presses': [6, 10, 7, 2, 7, 4, 9]}, {'calls': [2, 4, 6, 9], 'log': ['registered', 'invalid', 'registered', 'registered', 'cancelled', 'registered', 'registered']}), ('control 51', {'floors': 15, 'floor': 9, 'doors_open': True, 'load_kg': 21, 'presses': [13, 6, 9, 10, 9]}, {'calls': [6, 10, 13], 'log': ['registered', 'registered', 'reopen', 'registered', 'reopen']})]]
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 non-existent floor is registered as a car call.

Car buttons are processed in order. Pressing the current floor with doors open reopens the doors. Floors outside 0..floors-1 are invalid. Pressing an already registered floor cancels it, unless it is the only call (kept). With load under 20 kg, a new call is refused as nuisance once five calls are registered. Otherwise the call is registered. Return the sorted calls and the per-press log.

split: open-access