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

N = 1
observations = []
def solve(x):
    cars = {c['id']: {'ready': c['ready_s'], 'stops': set(c['stops']), 'load': c['load'], 'cap': c['cap']} for c in x['cars']}
    out = []
    for req in x['requests']:
        best = None
        for cid in sorted(cars):
            c = cars[cid]
            if c['load'] + req['n'] > c['cap']:
                continue
            new_stop = 0 if req['dest'] in c['stops'] else 1
            cost = c['ready'] + x['per_stop_s'] * len(c['stops']) + x['stop_penalty_s'] * new_stop
            if best is None or cost < best[0]:
                best = (cost, cid)
        if best is None:
            out.append(None)
            continue
        c = cars[best[1]]
        c['stops'].add(req['dest'])
        out.append(best[1])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: capacity used up by earlier groups', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 6, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 8, 'n': 3}, {'dest': 9, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'B']), ('sampled regression 9', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [3, 9], 'load': 4, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [8, 6, 12], 'load': 11, 'cap': 13}], 'requests': [{'dest': 10, 'n': 3}, {'dest': 3, 'n': 3}, {'dest': 13, 'n': 1}, {'dest': 2, 'n': 1}, {'dest': 5, 'n': 5}], 'stop_penalty_s': 10, 'per_stop_s': 3}, ['A', 'A', 'A', 'B', None]), ('sampled regression 3', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [8, 13, 9], 'load': 0, 'cap': 13}], 'requests': [{'dest': 13, 'n': 5}, {'dest': 11, 'n': 1}, {'dest': 12, 'n': 5}, {'dest': 3, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['A', 'B', 'B', 'B']), ('boundary: group exactly fills the car', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 10, 'cap': 12}, {'id': 'B', 'ready_s': 30, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 5, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A']), ('boundary: coincident destination beats an idle car', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 0, 'stops': [7], 'load': 0, 'cap': 12}], 'requests': [{'dest': 7, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['B']), ('sampled regression 1', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [10, 11], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [9], 'load': 11, 'cap': 12}, {'id': 'C', 'ready_s': 0, 'stops': [13, 14, 2], 'load': 11, 'cap': 13}], 'requests': [{'dest': 10, 'n': 1}, {'dest': 9, 'n': 5}], 'stop_penalty_s': 10, 'per_stop_s': 3}, ['A', None]), ('control 4', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [], 'load': 11, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [3], 'load': 4, 'cap': 12}, {'id': 'C', 'ready_s': 5, 'stops': [], 'load': 11, 'cap': 13}], 'requests': [{'dest': 7, 'n': 2}, {'dest': 3, 'n': 1}, {'dest': 8, 'n': 1}, {'dest': 3, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['C', 'B', 'A', 'B']), ('control 7', {'cars': [{'id': 'A', 'ready_s': 5, 'stops': [11, 6], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [7], 'load': 8, 'cap': 12}, {'id': 'C', 'ready_s': 10, 'stops': [5], 'load': 0, 'cap': 12}], 'requests': [{'dest': 2, 'n': 1}, {'dest': 8, 'n': 5}, {'dest': 11, 'n': 3}, {'dest': 3, 'n': 1}], 'stop_penalty_s': 15, 'per_stop_s': 5}, ['A', 'C', 'A', 'A'])], [('regression: capacity used up by earlier groups', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 6, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 8, 'n': 3}, {'dest': 9, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'B']), ('sampled regression 38', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 5, 'stops': [2, 13, 9], 'load': 0, 'cap': 13}], 'requests': [{'dest': 13, 'n': 1}, {'dest': 8, 'n': 2}, {'dest': 5, 'n': 3}, {'dest': 13, 'n': 3}, {'dest': 14, 'n': 5}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['A', 'A', 'B', 'B', 'B']), ('sampled regression 22', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [7, 5, 11], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [], 'load': 8, 'cap': 13}, {'id': 'C', 'ready_s': 0, 'stops': [10, 8], 'load': 0, 'cap': 13}], 'requests': [{'dest': 12, 'n': 2}, {'dest': 11, 'n': 5}, {'dest': 13, 'n': 2}, {'dest': 13, 'n': 1}, {'dest': 7, 'n': 5}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['C', 'A', 'A', 'A', 'C']), ('boundary: empty car earns no discount', {'cars': [{'id': 'A', 'ready_s': 4, 'stops': [], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 0, 'stops': [9], 'load': 0, 'cap': 12}], 'requests': [{'dest': 3, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A']), ('boundary: equal cost cars', {'cars': [{'id': 'A', 'ready_s': 5, 'stops': [], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 5, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 4, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A']), ('control 12', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [6, 3], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [], 'load': 4, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [10, 8], 'load': 11, 'cap': 13}], 'requests': [{'dest': 10, 'n': 1}, {'dest': 2, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['A', 'A']), ('control 15', {'cars': [{'id': 'A', 'ready_s': 5, 'stops': [3], 'load': 0, 'cap': 13}, {'id': 'B', 'ready_s': 5, 'stops': [7, 2], 'load': 0, 'cap': 13}, {'id': 'C', 'ready_s': 5, 'stops': [12], 'load': 0, 'cap': 12}], 'requests': [{'dest': 2, 'n': 3}, {'dest': 13, 'n': 5}, {'dest': 11, 'n': 1}, {'dest': 2, 'n': 1}, {'dest': 12, 'n': 3}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['B', 'A', 'C', 'B', 'C']), ('control 18', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [2, 7, 5], 'load': 0, 'cap': 12}], 'requests': [{'dest': 10, 'n': 5}, {'dest': 2, 'n': 1}, {'dest': 6, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'A'])], [('regression: capacity used up by earlier groups', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 6, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 8, 'n': 3}, {'dest': 9, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'B']), ('sampled regression 63', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 4, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [12, 11], 'load': 4, 'cap': 12}], 'requests': [{'dest': 3, 'n': 5}, {'dest': 4, 'n': 5}, {'dest': 11, 'n': 1}, {'dest': 14, 'n': 3}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['A', 'B', 'A', 'A']), ('sampled regression 42', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [3, 8, 13], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [6], 'load': 8, 'cap': 13}, {'id': 'C', 'ready_s': 5, 'stops': [12], 'load': 8, 'cap': 13}], 'requests': [{'dest': 10, 'n': 3}, {'dest': 12, 'n': 3}, {'dest': 3, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['C', 'A', 'A']), ('boundary: second group sees the first allocation', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 2, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 6, 'n': 3}, {'dest': 6, 'n': 3}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'A']), ('boundary: no eligible car', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 11, 'cap': 12}], 'requests': [{'dest': 5, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, [None]), ('control 23', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [2], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [9, 8], 'load': 4, 'cap': 13}, {'id': 'C', 'ready_s': 10, 'stops': [], 'load': 0, 'cap': 13}], 'requests': [{'dest': 8, 'n': 3}, {'dest': 13, 'n': 1}, {'dest': 9, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['C', 'C', 'B']), ('sampled regression 26', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [9], 'load': 8, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [11, 14, 4], 'load': 8, 'cap': 13}], 'requests': [{'dest': 13, 'n': 1}, {'dest': 5, 'n': 1}, {'dest': 12, 'n': 1}, {'dest': 9, 'n': 1}, {'dest': 7, 'n': 3}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'A', 'A', 'B']), ('control 29', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [], 'load': 0, 'cap': 13}, {'id': 'B', 'ready_s': 10, 'stops': [2, 5, 7], 'load': 8, 'cap': 13}, {'id': 'C', 'ready_s': 20, 'stops': [2], 'load': 4, 'cap': 12}], 'requests': [{'dest': 6, 'n': 1}, {'dest': 3, 'n': 5}], 'stop_penalty_s': 15, 'per_stop_s': 5}, ['A', 'A'])], [('regression: capacity used up by earlier groups', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 6, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 8, 'n': 3}, {'dest': 9, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'B']), ('sampled regression 77', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [11, 9, 14], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [6, 3], 'load': 4, 'cap': 12}, {'id': 'C', 'ready_s': 0, 'stops': [5, 13, 12], 'load': 8, 'cap': 13}], 'requests': [{'dest': 5, 'n': 3}, {'dest': 2, 'n': 1}, {'dest': 14, 'n': 3}, {'dest': 5, 'n': 5}, {'dest': 5, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['C', 'C', 'A', 'B', 'C']), ('sampled regression 64', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [11, 7, 3], 'load': 8, 'cap': 13}, {'id': 'C', 'ready_s': 0, 'stops': [8, 3], 'load': 8, 'cap': 13}], 'requests': [{'dest': 6, 'n': 1}, {'dest': 3, 'n': 3}, {'dest': 7, 'n': 3}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['A', 'C', 'A']), ('boundary: no eligible car', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 11, 'cap': 12}], 'requests': [{'dest': 5, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, [None]), ('boundary: group exactly fills the car', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 10, 'cap': 12}, {'id': 'B', 'ready_s': 30, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 5, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A']), ('control 34', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [8], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 10, 'stops': [2], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 1}, {'dest': 11, 'n': 3}, {'dest': 5, 'n': 1}, {'dest': 9, 'n': 1}, {'dest': 10, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['B', 'B', 'A', 'B', 'A']), ('control 37', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [], 'load': 8, 'cap': 12}, {'id': 'B', 'ready_s': 5, 'stops': [9, 14, 8], 'load': 8, 'cap': 12}], 'requests': [{'dest': 5, 'n': 1}, {'dest': 8, 'n': 1}, {'dest': 2, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'B', 'A']), ('sampled regression 40', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 4, 'cap': 13}, {'id': 'B', 'ready_s': 0, 'stops': [10, 5, 7], 'load': 0, 'cap': 12}], 'requests': [{'dest': 5, 'n': 5}, {'dest': 5, 'n': 5}, {'dest': 7, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['A', 'B', 'A'])], [('regression: capacity used up by earlier groups', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 6, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 8, 'n': 3}, {'dest': 9, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'B']), ('sampled regression 19', {'cars': [{'id': 'A', 'ready_s': 5, 'stops': [], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 5, 'stops': [14, 11], 'load': 0, 'cap': 12}], 'requests': [{'dest': 13, 'n': 5}, {'dest': 7, 'n': 1}], 'stop_penalty_s': 15, 'per_stop_s': 5}, ['A', 'B']), ('sampled regression 3', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [8, 13, 9], 'load': 0, 'cap': 13}], 'requests': [{'dest': 13, 'n': 5}, {'dest': 11, 'n': 1}, {'dest': 12, 'n': 5}, {'dest': 3, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['A', 'B', 'B', 'B']), ('boundary: coincident destination beats an idle car', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 0, 'stops': [7], 'load': 0, 'cap': 12}], 'requests': [{'dest': 7, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['B']), ('boundary: empty car earns no discount', {'cars': [{'id': 'A', 'ready_s': 4, 'stops': [], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 0, 'stops': [9], 'load': 0, 'cap': 12}], 'requests': [{'dest': 3, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A']), ('control 45', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [5], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 0, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 5}, {'dest': 9, 'n': 5}, {'dest': 13, 'n': 1}, {'dest': 9, 'n': 2}, {'dest': 8, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['B', 'A', 'B', 'A', 'A']), ('control 48', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [7], 'load': 11, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [2, 13], 'load': 11, 'cap': 13}, {'id': 'C', 'ready_s': 20, 'stops': [10, 12], 'load': 11, 'cap': 12}], 'requests': [{'dest': 6, 'n': 2}, {'dest': 14, 'n': 5}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['B', None]), ('control 51', {'cars': [{'id': 'A', 'ready_s': 5, 'stops': [3], 'load': 8, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [12, 8], 'load': 0, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [10], 'load': 0, 'cap': 13}], 'requests': [{'dest': 14, 'n': 1}, {'dest': 13, 'n': 2}, {'dest': 5, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['A', 'A', 'A'])]]
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):
    cars = {c['id']: {'ready': c['ready_s'], 'stops': set(c['stops']), 'load': c['load'], 'cap': c['cap']} for c in x['cars']}
    out = []
    for req in x['requests']:
        best = None
        for cid in sorted(cars):
            c = cars[cid]
            if c['load'] + req['n'] > c['cap']:
                continue
            new_stop = 0 if req['dest'] in c['stops'] else 1
            cost = c['ready'] + x['per_stop_s'] * len(c['stops']) + x['stop_penalty_s'] * new_stop
            if best is None or cost < best[0]:
                best = (cost, cid)
        if best is None:
            out.append(None)
            continue
        c = cars[best[1]]
        c['stops'].add(req['dest'])
        c['load'] += 1
        out.append(best[1])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: capacity used up by earlier groups', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 6, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 8, 'n': 3}, {'dest': 9, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'B']), ('sampled regression 9', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [3, 9], 'load': 4, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [8, 6, 12], 'load': 11, 'cap': 13}], 'requests': [{'dest': 10, 'n': 3}, {'dest': 3, 'n': 3}, {'dest': 13, 'n': 1}, {'dest': 2, 'n': 1}, {'dest': 5, 'n': 5}], 'stop_penalty_s': 10, 'per_stop_s': 3}, ['A', 'A', 'A', 'B', None]), ('sampled regression 3', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [8, 13, 9], 'load': 0, 'cap': 13}], 'requests': [{'dest': 13, 'n': 5}, {'dest': 11, 'n': 1}, {'dest': 12, 'n': 5}, {'dest': 3, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['A', 'B', 'B', 'B']), ('boundary: group exactly fills the car', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 10, 'cap': 12}, {'id': 'B', 'ready_s': 30, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 5, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A']), ('boundary: coincident destination beats an idle car', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 0, 'stops': [7], 'load': 0, 'cap': 12}], 'requests': [{'dest': 7, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['B']), ('sampled regression 1', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [10, 11], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [9], 'load': 11, 'cap': 12}, {'id': 'C', 'ready_s': 0, 'stops': [13, 14, 2], 'load': 11, 'cap': 13}], 'requests': [{'dest': 10, 'n': 1}, {'dest': 9, 'n': 5}], 'stop_penalty_s': 10, 'per_stop_s': 3}, ['A', None]), ('control 4', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [], 'load': 11, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [3], 'load': 4, 'cap': 12}, {'id': 'C', 'ready_s': 5, 'stops': [], 'load': 11, 'cap': 13}], 'requests': [{'dest': 7, 'n': 2}, {'dest': 3, 'n': 1}, {'dest': 8, 'n': 1}, {'dest': 3, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['C', 'B', 'A', 'B']), ('control 7', {'cars': [{'id': 'A', 'ready_s': 5, 'stops': [11, 6], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [7], 'load': 8, 'cap': 12}, {'id': 'C', 'ready_s': 10, 'stops': [5], 'load': 0, 'cap': 12}], 'requests': [{'dest': 2, 'n': 1}, {'dest': 8, 'n': 5}, {'dest': 11, 'n': 3}, {'dest': 3, 'n': 1}], 'stop_penalty_s': 15, 'per_stop_s': 5}, ['A', 'C', 'A', 'A'])], [('regression: capacity used up by earlier groups', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 6, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 8, 'n': 3}, {'dest': 9, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'B']), ('sampled regression 38', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 5, 'stops': [2, 13, 9], 'load': 0, 'cap': 13}], 'requests': [{'dest': 13, 'n': 1}, {'dest': 8, 'n': 2}, {'dest': 5, 'n': 3}, {'dest': 13, 'n': 3}, {'dest': 14, 'n': 5}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['A', 'A', 'B', 'B', 'B']), ('sampled regression 22', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [7, 5, 11], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [], 'load': 8, 'cap': 13}, {'id': 'C', 'ready_s': 0, 'stops': [10, 8], 'load': 0, 'cap': 13}], 'requests': [{'dest': 12, 'n': 2}, {'dest': 11, 'n': 5}, {'dest': 13, 'n': 2}, {'dest': 13, 'n': 1}, {'dest': 7, 'n': 5}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['C', 'A', 'A', 'A', 'C']), ('boundary: empty car earns no discount', {'cars': [{'id': 'A', 'ready_s': 4, 'stops': [], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 0, 'stops': [9], 'load': 0, 'cap': 12}], 'requests': [{'dest': 3, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A']), ('boundary: equal cost cars', {'cars': [{'id': 'A', 'ready_s': 5, 'stops': [], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 5, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 4, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A']), ('control 12', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [6, 3], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [], 'load': 4, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [10, 8], 'load': 11, 'cap': 13}], 'requests': [{'dest': 10, 'n': 1}, {'dest': 2, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['A', 'A']), ('control 15', {'cars': [{'id': 'A', 'ready_s': 5, 'stops': [3], 'load': 0, 'cap': 13}, {'id': 'B', 'ready_s': 5, 'stops': [7, 2], 'load': 0, 'cap': 13}, {'id': 'C', 'ready_s': 5, 'stops': [12], 'load': 0, 'cap': 12}], 'requests': [{'dest': 2, 'n': 3}, {'dest': 13, 'n': 5}, {'dest': 11, 'n': 1}, {'dest': 2, 'n': 1}, {'dest': 12, 'n': 3}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['B', 'A', 'C', 'B', 'C']), ('control 18', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [2, 7, 5], 'load': 0, 'cap': 12}], 'requests': [{'dest': 10, 'n': 5}, {'dest': 2, 'n': 1}, {'dest': 6, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'A'])], [('regression: capacity used up by earlier groups', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 6, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 8, 'n': 3}, {'dest': 9, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'B']), ('sampled regression 63', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 4, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [12, 11], 'load': 4, 'cap': 12}], 'requests': [{'dest': 3, 'n': 5}, {'dest': 4, 'n': 5}, {'dest': 11, 'n': 1}, {'dest': 14, 'n': 3}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['A', 'B', 'A', 'A']), ('sampled regression 42', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [3, 8, 13], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [6], 'load': 8, 'cap': 13}, {'id': 'C', 'ready_s': 5, 'stops': [12], 'load': 8, 'cap': 13}], 'requests': [{'dest': 10, 'n': 3}, {'dest': 12, 'n': 3}, {'dest': 3, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['C', 'A', 'A']), ('boundary: second group sees the first allocation', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 2, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 6, 'n': 3}, {'dest': 6, 'n': 3}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'A']), ('boundary: no eligible car', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 11, 'cap': 12}], 'requests': [{'dest': 5, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, [None]), ('control 23', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [2], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [9, 8], 'load': 4, 'cap': 13}, {'id': 'C', 'ready_s': 10, 'stops': [], 'load': 0, 'cap': 13}], 'requests': [{'dest': 8, 'n': 3}, {'dest': 13, 'n': 1}, {'dest': 9, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['C', 'C', 'B']), ('sampled regression 26', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [9], 'load': 8, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [11, 14, 4], 'load': 8, 'cap': 13}], 'requests': [{'dest': 13, 'n': 1}, {'dest': 5, 'n': 1}, {'dest': 12, 'n': 1}, {'dest': 9, 'n': 1}, {'dest': 7, 'n': 3}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'A', 'A', 'B']), ('control 29', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [], 'load': 0, 'cap': 13}, {'id': 'B', 'ready_s': 10, 'stops': [2, 5, 7], 'load': 8, 'cap': 13}, {'id': 'C', 'ready_s': 20, 'stops': [2], 'load': 4, 'cap': 12}], 'requests': [{'dest': 6, 'n': 1}, {'dest': 3, 'n': 5}], 'stop_penalty_s': 15, 'per_stop_s': 5}, ['A', 'A'])], [('regression: capacity used up by earlier groups', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 6, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 8, 'n': 3}, {'dest': 9, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'B']), ('sampled regression 77', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [11, 9, 14], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [6, 3], 'load': 4, 'cap': 12}, {'id': 'C', 'ready_s': 0, 'stops': [5, 13, 12], 'load': 8, 'cap': 13}], 'requests': [{'dest': 5, 'n': 3}, {'dest': 2, 'n': 1}, {'dest': 14, 'n': 3}, {'dest': 5, 'n': 5}, {'dest': 5, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['C', 'C', 'A', 'B', 'C']), ('sampled regression 64', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [11, 7, 3], 'load': 8, 'cap': 13}, {'id': 'C', 'ready_s': 0, 'stops': [8, 3], 'load': 8, 'cap': 13}], 'requests': [{'dest': 6, 'n': 1}, {'dest': 3, 'n': 3}, {'dest': 7, 'n': 3}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['A', 'C', 'A']), ('boundary: no eligible car', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 11, 'cap': 12}], 'requests': [{'dest': 5, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, [None]), ('boundary: group exactly fills the car', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 10, 'cap': 12}, {'id': 'B', 'ready_s': 30, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 5, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A']), ('control 34', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [8], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 10, 'stops': [2], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 1}, {'dest': 11, 'n': 3}, {'dest': 5, 'n': 1}, {'dest': 9, 'n': 1}, {'dest': 10, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['B', 'B', 'A', 'B', 'A']), ('control 37', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [], 'load': 8, 'cap': 12}, {'id': 'B', 'ready_s': 5, 'stops': [9, 14, 8], 'load': 8, 'cap': 12}], 'requests': [{'dest': 5, 'n': 1}, {'dest': 8, 'n': 1}, {'dest': 2, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'B', 'A']), ('sampled regression 40', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 4, 'cap': 13}, {'id': 'B', 'ready_s': 0, 'stops': [10, 5, 7], 'load': 0, 'cap': 12}], 'requests': [{'dest': 5, 'n': 5}, {'dest': 5, 'n': 5}, {'dest': 7, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['A', 'B', 'A'])], [('regression: capacity used up by earlier groups', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 6, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 8, 'n': 3}, {'dest': 9, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'B']), ('sampled regression 19', {'cars': [{'id': 'A', 'ready_s': 5, 'stops': [], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 5, 'stops': [14, 11], 'load': 0, 'cap': 12}], 'requests': [{'dest': 13, 'n': 5}, {'dest': 7, 'n': 1}], 'stop_penalty_s': 15, 'per_stop_s': 5}, ['A', 'B']), ('sampled regression 3', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [8, 13, 9], 'load': 0, 'cap': 13}], 'requests': [{'dest': 13, 'n': 5}, {'dest': 11, 'n': 1}, {'dest': 12, 'n': 5}, {'dest': 3, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['A', 'B', 'B', 'B']), ('boundary: coincident destination beats an idle car', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 0, 'stops': [7], 'load': 0, 'cap': 12}], 'requests': [{'dest': 7, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['B']), ('boundary: empty car earns no discount', {'cars': [{'id': 'A', 'ready_s': 4, 'stops': [], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 0, 'stops': [9], 'load': 0, 'cap': 12}], 'requests': [{'dest': 3, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A']), ('control 45', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [5], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 0, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 5}, {'dest': 9, 'n': 5}, {'dest': 13, 'n': 1}, {'dest': 9, 'n': 2}, {'dest': 8, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['B', 'A', 'B', 'A', 'A']), ('control 48', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [7], 'load': 11, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [2, 13], 'load': 11, 'cap': 13}, {'id': 'C', 'ready_s': 20, 'stops': [10, 12], 'load': 11, 'cap': 12}], 'requests': [{'dest': 6, 'n': 2}, {'dest': 14, 'n': 5}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['B', None]), ('control 51', {'cars': [{'id': 'A', 'ready_s': 5, 'stops': [3], 'load': 8, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [12, 8], 'load': 0, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [10], 'load': 0, 'cap': 13}], 'requests': [{'dest': 14, 'n': 1}, {'dest': 13, 'n': 2}, {'dest': 5, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['A', 'A', 'A'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A car keeps being allocated groups beyond its capacity.

Requests (destination, group size) are allocated one by one. A car is eligible if load + group size <= capacity. Cost = ready time + per_stop_s * existing stops + stop_penalty_s if the destination is not already a stop. The lowest cost wins, ties to the lowest car id. The chosen car adds the destination to its stops and the group to its load. None if no car is eligible.

split: open-access


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

N = 1
observations = []
def solve(x):
    cars = {c['id']: {'ready': c['ready_s'], 'stops': set(c['stops']), 'load': c['load'], 'cap': c['cap']} for c in x['cars']}
    out = []
    for req in x['requests']:
        best = None
        for cid in sorted(cars):
            c = cars[cid]
            if c['load'] + req['n'] > c['cap']:
                continue
            new_stop = 0 if req['dest'] in c['stops'] else 1
            cost = c['ready'] + x['per_stop_s'] * len(c['stops']) + x['stop_penalty_s'] * new_stop
            if best is None or cost < best[0]:
                best = (cost, cid)
        if best is None:
            out.append(None)
            continue
        c = cars[best[1]]
        c['load'] += req['n']
        out.append(best[1])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('sampled regression 5', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [3, 6, 5], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 0, 'stops': [2, 3], 'load': 8, 'cap': 12}, {'id': 'C', 'ready_s': 5, 'stops': [], 'load': 4, 'cap': 12}], 'requests': [{'dest': 2, 'n': 5}, {'dest': 9, 'n': 1}, {'dest': 3, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['C', 'B', 'B']), ('sampled regression 6', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [14, 11, 6], 'load': 11, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [13], 'load': 0, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [11], 'load': 4, 'cap': 13}], 'requests': [{'dest': 8, 'n': 5}, {'dest': 9, 'n': 3}, {'dest': 3, 'n': 1}, {'dest': 2, 'n': 2}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['B', 'C', 'B', 'C']), ('sampled regression 9', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [3, 9], 'load': 4, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [8, 6, 12], 'load': 11, 'cap': 13}], 'requests': [{'dest': 10, 'n': 3}, {'dest': 3, 'n': 3}, {'dest': 13, 'n': 1}, {'dest': 2, 'n': 1}, {'dest': 5, 'n': 5}], 'stop_penalty_s': 10, 'per_stop_s': 3}, ['A', 'A', 'A', 'B', None]), ('sampled regression 8', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [12], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [], 'load': 8, 'cap': 13}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 4, 'n': 1}, {'dest': 7, 'n': 1}, {'dest': 6, 'n': 2}, {'dest': 14, 'n': 2}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['A', 'A', 'B', 'A', 'A']), ('boundary: group exactly fills the car', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 10, 'cap': 12}, {'id': 'B', 'ready_s': 30, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 5, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A']), ('control 1', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [10, 11], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [9], 'load': 11, 'cap': 12}, {'id': 'C', 'ready_s': 0, 'stops': [13, 14, 2], 'load': 11, 'cap': 13}], 'requests': [{'dest': 10, 'n': 1}, {'dest': 9, 'n': 5}], 'stop_penalty_s': 10, 'per_stop_s': 3}, ['A', None]), ('control 4', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [], 'load': 11, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [3], 'load': 4, 'cap': 12}, {'id': 'C', 'ready_s': 5, 'stops': [], 'load': 11, 'cap': 13}], 'requests': [{'dest': 7, 'n': 2}, {'dest': 3, 'n': 1}, {'dest': 8, 'n': 1}, {'dest': 3, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['C', 'B', 'A', 'B']), ('control 7', {'cars': [{'id': 'A', 'ready_s': 5, 'stops': [11, 6], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [7], 'load': 8, 'cap': 12}, {'id': 'C', 'ready_s': 10, 'stops': [5], 'load': 0, 'cap': 12}], 'requests': [{'dest': 2, 'n': 1}, {'dest': 8, 'n': 5}, {'dest': 11, 'n': 3}, {'dest': 3, 'n': 1}], 'stop_penalty_s': 15, 'per_stop_s': 5}, ['A', 'C', 'A', 'A'])], [('sampled regression 6', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [14, 11, 6], 'load': 11, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [13], 'load': 0, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [11], 'load': 4, 'cap': 13}], 'requests': [{'dest': 8, 'n': 5}, {'dest': 9, 'n': 3}, {'dest': 3, 'n': 1}, {'dest': 2, 'n': 2}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['B', 'C', 'B', 'C']), ('sampled regression 8', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [12], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [], 'load': 8, 'cap': 13}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 4, 'n': 1}, {'dest': 7, 'n': 1}, {'dest': 6, 'n': 2}, {'dest': 14, 'n': 2}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['A', 'A', 'B', 'A', 'A']), ('sampled regression 31', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [], 'load': 11, 'cap': 13}, {'id': 'B', 'ready_s': 0, 'stops': [], 'load': 8, 'cap': 12}, {'id': 'C', 'ready_s': 0, 'stops': [], 'load': 11, 'cap': 12}], 'requests': [{'dest': 3, 'n': 2}, {'dest': 14, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 3}, ['B', 'C']), ('sampled regression 30', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [2], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [], 'load': 0, 'cap': 13}], 'requests': [{'dest': 13, 'n': 1}, {'dest': 11, 'n': 1}, {'dest': 12, 'n': 5}, {'dest': 8, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 3}, ['B', 'A', 'B', 'A']), ('boundary: empty car earns no discount', {'cars': [{'id': 'A', 'ready_s': 4, 'stops': [], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 0, 'stops': [9], 'load': 0, 'cap': 12}], 'requests': [{'dest': 3, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A']), ('control 12', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [6, 3], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [], 'load': 4, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [10, 8], 'load': 11, 'cap': 13}], 'requests': [{'dest': 10, 'n': 1}, {'dest': 2, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['A', 'A']), ('sampled regression 15', {'cars': [{'id': 'A', 'ready_s': 5, 'stops': [3], 'load': 0, 'cap': 13}, {'id': 'B', 'ready_s': 5, 'stops': [7, 2], 'load': 0, 'cap': 13}, {'id': 'C', 'ready_s': 5, 'stops': [12], 'load': 0, 'cap': 12}], 'requests': [{'dest': 2, 'n': 3}, {'dest': 13, 'n': 5}, {'dest': 11, 'n': 1}, {'dest': 2, 'n': 1}, {'dest': 12, 'n': 3}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['B', 'A', 'C', 'B', 'C']), ('control 18', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [2, 7, 5], 'load': 0, 'cap': 12}], 'requests': [{'dest': 10, 'n': 5}, {'dest': 2, 'n': 1}, {'dest': 6, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'A'])], [('sampled regression 8', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [12], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [], 'load': 8, 'cap': 13}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 4, 'n': 1}, {'dest': 7, 'n': 1}, {'dest': 6, 'n': 2}, {'dest': 14, 'n': 2}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['A', 'A', 'B', 'A', 'A']), ('sampled regression 9', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [3, 9], 'load': 4, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [8, 6, 12], 'load': 11, 'cap': 13}], 'requests': [{'dest': 10, 'n': 3}, {'dest': 3, 'n': 3}, {'dest': 13, 'n': 1}, {'dest': 2, 'n': 1}, {'dest': 5, 'n': 5}], 'stop_penalty_s': 10, 'per_stop_s': 3}, ['A', 'A', 'A', 'B', None]), ('sampled regression 49', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [11, 9, 3], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 10, 'stops': [6, 14], 'load': 4, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [5, 7, 9], 'load': 4, 'cap': 13}], 'requests': [{'dest': 5, 'n': 5}, {'dest': 4, 'n': 1}, {'dest': 8, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['B', 'A', 'B']), ('sampled regression 46', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [], 'load': 0, 'cap': 13}, {'id': 'B', 'ready_s': 5, 'stops': [13], 'load': 4, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [7], 'load': 4, 'cap': 12}], 'requests': [{'dest': 3, 'n': 2}, {'dest': 14, 'n': 1}, {'dest': 2, 'n': 1}, {'dest': 5, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 3}, ['B', 'A', 'B', 'A']), ('boundary: second group sees the first allocation', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 2, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 6, 'n': 3}, {'dest': 6, 'n': 3}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'A']), ('sampled regression 23', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [2], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [9, 8], 'load': 4, 'cap': 13}, {'id': 'C', 'ready_s': 10, 'stops': [], 'load': 0, 'cap': 13}], 'requests': [{'dest': 8, 'n': 3}, {'dest': 13, 'n': 1}, {'dest': 9, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['C', 'C', 'B']), ('control 26', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [9], 'load': 8, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [11, 14, 4], 'load': 8, 'cap': 13}], 'requests': [{'dest': 13, 'n': 1}, {'dest': 5, 'n': 1}, {'dest': 12, 'n': 1}, {'dest': 9, 'n': 1}, {'dest': 7, 'n': 3}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'A', 'A', 'B']), ('control 29', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [], 'load': 0, 'cap': 13}, {'id': 'B', 'ready_s': 10, 'stops': [2, 5, 7], 'load': 8, 'cap': 13}, {'id': 'C', 'ready_s': 20, 'stops': [2], 'load': 4, 'cap': 12}], 'requests': [{'dest': 6, 'n': 1}, {'dest': 3, 'n': 5}], 'stop_penalty_s': 15, 'per_stop_s': 5}, ['A', 'A'])], [('sampled regression 9', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [3, 9], 'load': 4, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [8, 6, 12], 'load': 11, 'cap': 13}], 'requests': [{'dest': 10, 'n': 3}, {'dest': 3, 'n': 3}, {'dest': 13, 'n': 1}, {'dest': 2, 'n': 1}, {'dest': 5, 'n': 5}], 'stop_penalty_s': 10, 'per_stop_s': 3}, ['A', 'A', 'A', 'B', None]), ('sampled regression 15', {'cars': [{'id': 'A', 'ready_s': 5, 'stops': [3], 'load': 0, 'cap': 13}, {'id': 'B', 'ready_s': 5, 'stops': [7, 2], 'load': 0, 'cap': 13}, {'id': 'C', 'ready_s': 5, 'stops': [12], 'load': 0, 'cap': 12}], 'requests': [{'dest': 2, 'n': 3}, {'dest': 13, 'n': 5}, {'dest': 11, 'n': 1}, {'dest': 2, 'n': 1}, {'dest': 12, 'n': 3}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['B', 'A', 'C', 'B', 'C']), ('sampled regression 6', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [14, 11, 6], 'load': 11, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [13], 'load': 0, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [11], 'load': 4, 'cap': 13}], 'requests': [{'dest': 8, 'n': 5}, {'dest': 9, 'n': 3}, {'dest': 3, 'n': 1}, {'dest': 2, 'n': 2}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['B', 'C', 'B', 'C']), ('control 60', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [13, 4, 8], 'load': 0, 'cap': 13}, {'id': 'B', 'ready_s': 10, 'stops': [7, 6], 'load': 4, 'cap': 13}, {'id': 'C', 'ready_s': 10, 'stops': [], 'load': 4, 'cap': 12}], 'requests': [{'dest': 4, 'n': 3}, {'dest': 12, 'n': 5}, {'dest': 7, 'n': 5}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['A', 'A', 'B']), ('boundary: no eligible car', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 11, 'cap': 12}], 'requests': [{'dest': 5, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, [None]), ('sampled regression 34', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [8], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 10, 'stops': [2], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 1}, {'dest': 11, 'n': 3}, {'dest': 5, 'n': 1}, {'dest': 9, 'n': 1}, {'dest': 10, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['B', 'B', 'A', 'B', 'A']), ('sampled regression 37', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [], 'load': 8, 'cap': 12}, {'id': 'B', 'ready_s': 5, 'stops': [9, 14, 8], 'load': 8, 'cap': 12}], 'requests': [{'dest': 5, 'n': 1}, {'dest': 8, 'n': 1}, {'dest': 2, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'B', 'A']), ('control 40', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 4, 'cap': 13}, {'id': 'B', 'ready_s': 0, 'stops': [10, 5, 7], 'load': 0, 'cap': 12}], 'requests': [{'dest': 5, 'n': 5}, {'dest': 5, 'n': 5}, {'dest': 7, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['A', 'B', 'A'])], [('sampled regression 10', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 5, 'stops': [5], 'load': 0, 'cap': 12}], 'requests': [{'dest': 12, 'n': 1}, {'dest': 8, 'n': 3}], 'stop_penalty_s': 15, 'per_stop_s': 5}, ['A', 'B']), ('sampled regression 23', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [2], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [9, 8], 'load': 4, 'cap': 13}, {'id': 'C', 'ready_s': 10, 'stops': [], 'load': 0, 'cap': 13}], 'requests': [{'dest': 8, 'n': 3}, {'dest': 13, 'n': 1}, {'dest': 9, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['C', 'C', 'B']), ('sampled regression 27', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [12, 6, 13], 'load': 0, 'cap': 13}, {'id': 'B', 'ready_s': 10, 'stops': [6, 14, 5], 'load': 8, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [], 'load': 4, 'cap': 12}], 'requests': [{'dest': 12, 'n': 3}, {'dest': 2, 'n': 2}, {'dest': 8, 'n': 5}, {'dest': 11, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['C', 'B', 'C', 'B']), ('sampled regression 8', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [12], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [], 'load': 8, 'cap': 13}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 4, 'n': 1}, {'dest': 7, 'n': 1}, {'dest': 6, 'n': 2}, {'dest': 14, 'n': 2}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['A', 'A', 'B', 'A', 'A']), ('boundary: coincident destination beats an idle car', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 0, 'stops': [7], 'load': 0, 'cap': 12}], 'requests': [{'dest': 7, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['B']), ('sampled regression 45', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [5], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 0, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 5}, {'dest': 9, 'n': 5}, {'dest': 13, 'n': 1}, {'dest': 9, 'n': 2}, {'dest': 8, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['B', 'A', 'B', 'A', 'A']), ('control 48', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [7], 'load': 11, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [2, 13], 'load': 11, 'cap': 13}, {'id': 'C', 'ready_s': 20, 'stops': [10, 12], 'load': 11, 'cap': 12}], 'requests': [{'dest': 6, 'n': 2}, {'dest': 14, 'n': 5}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['B', None]), ('control 51', {'cars': [{'id': 'A', 'ready_s': 5, 'stops': [3], 'load': 8, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [12, 8], 'load': 0, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [10], 'load': 0, 'cap': 13}], 'requests': [{'dest': 14, 'n': 1}, {'dest': 13, 'n': 2}, {'dest': 5, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['A', 'A', 'A'])]]
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):
    cars = {c['id']: {'ready': c['ready_s'], 'stops': set(c['stops']), 'load': c['load'], 'cap': c['cap']} for c in x['cars']}
    out = []
    for req in x['requests']:
        best = None
        for cid in sorted(cars):
            c = cars[cid]
            if c['load'] + req['n'] > c['cap']:
                continue
            new_stop = 0 if req['dest'] in c['stops'] else 1
            cost = c['ready'] + x['per_stop_s'] * len(c['stops']) + x['stop_penalty_s'] * new_stop
            if best is None or cost < best[0]:
                best = (cost, cid)
        if best is None:
            out.append(None)
            continue
        c = cars[best[1]]
        c['stops'] = {req['dest']}
        c['load'] += req['n']
        out.append(best[1])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('sampled regression 5', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [3, 6, 5], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 0, 'stops': [2, 3], 'load': 8, 'cap': 12}, {'id': 'C', 'ready_s': 5, 'stops': [], 'load': 4, 'cap': 12}], 'requests': [{'dest': 2, 'n': 5}, {'dest': 9, 'n': 1}, {'dest': 3, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['C', 'B', 'B']), ('sampled regression 6', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [14, 11, 6], 'load': 11, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [13], 'load': 0, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [11], 'load': 4, 'cap': 13}], 'requests': [{'dest': 8, 'n': 5}, {'dest': 9, 'n': 3}, {'dest': 3, 'n': 1}, {'dest': 2, 'n': 2}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['B', 'C', 'B', 'C']), ('sampled regression 9', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [3, 9], 'load': 4, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [8, 6, 12], 'load': 11, 'cap': 13}], 'requests': [{'dest': 10, 'n': 3}, {'dest': 3, 'n': 3}, {'dest': 13, 'n': 1}, {'dest': 2, 'n': 1}, {'dest': 5, 'n': 5}], 'stop_penalty_s': 10, 'per_stop_s': 3}, ['A', 'A', 'A', 'B', None]), ('sampled regression 8', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [12], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [], 'load': 8, 'cap': 13}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 4, 'n': 1}, {'dest': 7, 'n': 1}, {'dest': 6, 'n': 2}, {'dest': 14, 'n': 2}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['A', 'A', 'B', 'A', 'A']), ('boundary: group exactly fills the car', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 10, 'cap': 12}, {'id': 'B', 'ready_s': 30, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 5, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A']), ('control 1', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [10, 11], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [9], 'load': 11, 'cap': 12}, {'id': 'C', 'ready_s': 0, 'stops': [13, 14, 2], 'load': 11, 'cap': 13}], 'requests': [{'dest': 10, 'n': 1}, {'dest': 9, 'n': 5}], 'stop_penalty_s': 10, 'per_stop_s': 3}, ['A', None]), ('control 4', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [], 'load': 11, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [3], 'load': 4, 'cap': 12}, {'id': 'C', 'ready_s': 5, 'stops': [], 'load': 11, 'cap': 13}], 'requests': [{'dest': 7, 'n': 2}, {'dest': 3, 'n': 1}, {'dest': 8, 'n': 1}, {'dest': 3, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['C', 'B', 'A', 'B']), ('control 7', {'cars': [{'id': 'A', 'ready_s': 5, 'stops': [11, 6], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [7], 'load': 8, 'cap': 12}, {'id': 'C', 'ready_s': 10, 'stops': [5], 'load': 0, 'cap': 12}], 'requests': [{'dest': 2, 'n': 1}, {'dest': 8, 'n': 5}, {'dest': 11, 'n': 3}, {'dest': 3, 'n': 1}], 'stop_penalty_s': 15, 'per_stop_s': 5}, ['A', 'C', 'A', 'A'])], [('sampled regression 6', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [14, 11, 6], 'load': 11, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [13], 'load': 0, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [11], 'load': 4, 'cap': 13}], 'requests': [{'dest': 8, 'n': 5}, {'dest': 9, 'n': 3}, {'dest': 3, 'n': 1}, {'dest': 2, 'n': 2}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['B', 'C', 'B', 'C']), ('sampled regression 8', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [12], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [], 'load': 8, 'cap': 13}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 4, 'n': 1}, {'dest': 7, 'n': 1}, {'dest': 6, 'n': 2}, {'dest': 14, 'n': 2}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['A', 'A', 'B', 'A', 'A']), ('sampled regression 31', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [], 'load': 11, 'cap': 13}, {'id': 'B', 'ready_s': 0, 'stops': [], 'load': 8, 'cap': 12}, {'id': 'C', 'ready_s': 0, 'stops': [], 'load': 11, 'cap': 12}], 'requests': [{'dest': 3, 'n': 2}, {'dest': 14, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 3}, ['B', 'C']), ('sampled regression 30', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [2], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [], 'load': 0, 'cap': 13}], 'requests': [{'dest': 13, 'n': 1}, {'dest': 11, 'n': 1}, {'dest': 12, 'n': 5}, {'dest': 8, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 3}, ['B', 'A', 'B', 'A']), ('boundary: empty car earns no discount', {'cars': [{'id': 'A', 'ready_s': 4, 'stops': [], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 0, 'stops': [9], 'load': 0, 'cap': 12}], 'requests': [{'dest': 3, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A']), ('control 12', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [6, 3], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [], 'load': 4, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [10, 8], 'load': 11, 'cap': 13}], 'requests': [{'dest': 10, 'n': 1}, {'dest': 2, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['A', 'A']), ('sampled regression 15', {'cars': [{'id': 'A', 'ready_s': 5, 'stops': [3], 'load': 0, 'cap': 13}, {'id': 'B', 'ready_s': 5, 'stops': [7, 2], 'load': 0, 'cap': 13}, {'id': 'C', 'ready_s': 5, 'stops': [12], 'load': 0, 'cap': 12}], 'requests': [{'dest': 2, 'n': 3}, {'dest': 13, 'n': 5}, {'dest': 11, 'n': 1}, {'dest': 2, 'n': 1}, {'dest': 12, 'n': 3}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['B', 'A', 'C', 'B', 'C']), ('control 18', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [2, 7, 5], 'load': 0, 'cap': 12}], 'requests': [{'dest': 10, 'n': 5}, {'dest': 2, 'n': 1}, {'dest': 6, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'A'])], [('sampled regression 8', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [12], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [], 'load': 8, 'cap': 13}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 4, 'n': 1}, {'dest': 7, 'n': 1}, {'dest': 6, 'n': 2}, {'dest': 14, 'n': 2}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['A', 'A', 'B', 'A', 'A']), ('sampled regression 9', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [3, 9], 'load': 4, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [8, 6, 12], 'load': 11, 'cap': 13}], 'requests': [{'dest': 10, 'n': 3}, {'dest': 3, 'n': 3}, {'dest': 13, 'n': 1}, {'dest': 2, 'n': 1}, {'dest': 5, 'n': 5}], 'stop_penalty_s': 10, 'per_stop_s': 3}, ['A', 'A', 'A', 'B', None]), ('sampled regression 49', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [11, 9, 3], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 10, 'stops': [6, 14], 'load': 4, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [5, 7, 9], 'load': 4, 'cap': 13}], 'requests': [{'dest': 5, 'n': 5}, {'dest': 4, 'n': 1}, {'dest': 8, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['B', 'A', 'B']), ('sampled regression 46', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [], 'load': 0, 'cap': 13}, {'id': 'B', 'ready_s': 5, 'stops': [13], 'load': 4, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [7], 'load': 4, 'cap': 12}], 'requests': [{'dest': 3, 'n': 2}, {'dest': 14, 'n': 1}, {'dest': 2, 'n': 1}, {'dest': 5, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 3}, ['B', 'A', 'B', 'A']), ('boundary: second group sees the first allocation', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 2, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 6, 'n': 3}, {'dest': 6, 'n': 3}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'A']), ('sampled regression 23', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [2], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [9, 8], 'load': 4, 'cap': 13}, {'id': 'C', 'ready_s': 10, 'stops': [], 'load': 0, 'cap': 13}], 'requests': [{'dest': 8, 'n': 3}, {'dest': 13, 'n': 1}, {'dest': 9, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['C', 'C', 'B']), ('control 26', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [9], 'load': 8, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [11, 14, 4], 'load': 8, 'cap': 13}], 'requests': [{'dest': 13, 'n': 1}, {'dest': 5, 'n': 1}, {'dest': 12, 'n': 1}, {'dest': 9, 'n': 1}, {'dest': 7, 'n': 3}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'A', 'A', 'A', 'B']), ('control 29', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [], 'load': 0, 'cap': 13}, {'id': 'B', 'ready_s': 10, 'stops': [2, 5, 7], 'load': 8, 'cap': 13}, {'id': 'C', 'ready_s': 20, 'stops': [2], 'load': 4, 'cap': 12}], 'requests': [{'dest': 6, 'n': 1}, {'dest': 3, 'n': 5}], 'stop_penalty_s': 15, 'per_stop_s': 5}, ['A', 'A'])], [('sampled regression 9', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [3, 9], 'load': 4, 'cap': 13}, {'id': 'B', 'ready_s': 20, 'stops': [8, 6, 12], 'load': 11, 'cap': 13}], 'requests': [{'dest': 10, 'n': 3}, {'dest': 3, 'n': 3}, {'dest': 13, 'n': 1}, {'dest': 2, 'n': 1}, {'dest': 5, 'n': 5}], 'stop_penalty_s': 10, 'per_stop_s': 3}, ['A', 'A', 'A', 'B', None]), ('sampled regression 15', {'cars': [{'id': 'A', 'ready_s': 5, 'stops': [3], 'load': 0, 'cap': 13}, {'id': 'B', 'ready_s': 5, 'stops': [7, 2], 'load': 0, 'cap': 13}, {'id': 'C', 'ready_s': 5, 'stops': [12], 'load': 0, 'cap': 12}], 'requests': [{'dest': 2, 'n': 3}, {'dest': 13, 'n': 5}, {'dest': 11, 'n': 1}, {'dest': 2, 'n': 1}, {'dest': 12, 'n': 3}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['B', 'A', 'C', 'B', 'C']), ('sampled regression 6', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [14, 11, 6], 'load': 11, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [13], 'load': 0, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [11], 'load': 4, 'cap': 13}], 'requests': [{'dest': 8, 'n': 5}, {'dest': 9, 'n': 3}, {'dest': 3, 'n': 1}, {'dest': 2, 'n': 2}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['B', 'C', 'B', 'C']), ('control 60', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [13, 4, 8], 'load': 0, 'cap': 13}, {'id': 'B', 'ready_s': 10, 'stops': [7, 6], 'load': 4, 'cap': 13}, {'id': 'C', 'ready_s': 10, 'stops': [], 'load': 4, 'cap': 12}], 'requests': [{'dest': 4, 'n': 3}, {'dest': 12, 'n': 5}, {'dest': 7, 'n': 5}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['A', 'A', 'B']), ('boundary: no eligible car', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 11, 'cap': 12}], 'requests': [{'dest': 5, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, [None]), ('sampled regression 34', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [8], 'load': 8, 'cap': 13}, {'id': 'B', 'ready_s': 10, 'stops': [2], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 1}, {'dest': 11, 'n': 3}, {'dest': 5, 'n': 1}, {'dest': 9, 'n': 1}, {'dest': 10, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['B', 'B', 'A', 'B', 'A']), ('sampled regression 37', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [], 'load': 8, 'cap': 12}, {'id': 'B', 'ready_s': 5, 'stops': [9, 14, 8], 'load': 8, 'cap': 12}], 'requests': [{'dest': 5, 'n': 1}, {'dest': 8, 'n': 1}, {'dest': 2, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['A', 'B', 'A']), ('control 40', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 4, 'cap': 13}, {'id': 'B', 'ready_s': 0, 'stops': [10, 5, 7], 'load': 0, 'cap': 12}], 'requests': [{'dest': 5, 'n': 5}, {'dest': 5, 'n': 5}, {'dest': 7, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['A', 'B', 'A'])], [('sampled regression 10', {'cars': [{'id': 'A', 'ready_s': 10, 'stops': [], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 5, 'stops': [5], 'load': 0, 'cap': 12}], 'requests': [{'dest': 12, 'n': 1}, {'dest': 8, 'n': 3}], 'stop_penalty_s': 15, 'per_stop_s': 5}, ['A', 'B']), ('sampled regression 23', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [2], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [9, 8], 'load': 4, 'cap': 13}, {'id': 'C', 'ready_s': 10, 'stops': [], 'load': 0, 'cap': 13}], 'requests': [{'dest': 8, 'n': 3}, {'dest': 13, 'n': 1}, {'dest': 9, 'n': 2}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['C', 'C', 'B']), ('sampled regression 27', {'cars': [{'id': 'A', 'ready_s': 20, 'stops': [12, 6, 13], 'load': 0, 'cap': 13}, {'id': 'B', 'ready_s': 10, 'stops': [6, 14, 5], 'load': 8, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [], 'load': 4, 'cap': 12}], 'requests': [{'dest': 12, 'n': 3}, {'dest': 2, 'n': 2}, {'dest': 8, 'n': 5}, {'dest': 11, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['C', 'B', 'C', 'B']), ('sampled regression 8', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [12], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [], 'load': 8, 'cap': 13}], 'requests': [{'dest': 6, 'n': 3}, {'dest': 4, 'n': 1}, {'dest': 7, 'n': 1}, {'dest': 6, 'n': 2}, {'dest': 14, 'n': 2}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['A', 'A', 'B', 'A', 'A']), ('boundary: coincident destination beats an idle car', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [], 'load': 0, 'cap': 12}, {'id': 'B', 'ready_s': 0, 'stops': [7], 'load': 0, 'cap': 12}], 'requests': [{'dest': 7, 'n': 1}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['B']), ('sampled regression 45', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [5], 'load': 4, 'cap': 12}, {'id': 'B', 'ready_s': 0, 'stops': [], 'load': 0, 'cap': 12}], 'requests': [{'dest': 6, 'n': 5}, {'dest': 9, 'n': 5}, {'dest': 13, 'n': 1}, {'dest': 9, 'n': 2}, {'dest': 8, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 3}, ['B', 'A', 'B', 'A', 'A']), ('control 48', {'cars': [{'id': 'A', 'ready_s': 0, 'stops': [7], 'load': 11, 'cap': 12}, {'id': 'B', 'ready_s': 20, 'stops': [2, 13], 'load': 11, 'cap': 13}, {'id': 'C', 'ready_s': 20, 'stops': [10, 12], 'load': 11, 'cap': 12}], 'requests': [{'dest': 6, 'n': 2}, {'dest': 14, 'n': 5}], 'stop_penalty_s': 10, 'per_stop_s': 5}, ['B', None]), ('control 51', {'cars': [{'id': 'A', 'ready_s': 5, 'stops': [3], 'load': 8, 'cap': 12}, {'id': 'B', 'ready_s': 10, 'stops': [12, 8], 'load': 0, 'cap': 12}, {'id': 'C', 'ready_s': 20, 'stops': [10], 'load': 0, 'cap': 13}], 'requests': [{'dest': 14, 'n': 1}, {'dest': 13, 'n': 2}, {'dest': 5, 'n': 1}], 'stop_penalty_s': 8, 'per_stop_s': 5}, ['A', 'A', 'A'])]]
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:
Later passengers for the same floor are not recognised as coincident.

Requests (destination, group size) are allocated one by one. A car is eligible if load + group size <= capacity. Cost = ready time + per_stop_s * existing stops + stop_penalty_s if the destination is not already a stop. The lowest cost wins, ties to the lowest car id. The chosen car adds the destination to its stops and the group to its load. None if no car is eligible.

split: open-access


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

N = 1
observations = []
def solve(x):
    base = 40 if x['call_type'] == 'hall' else 25
    if x['accessible']:
        base = base * 3 // 2
    pax = x['boarding'] + x['alighting']
    dwell = base + 10 * max(pax - 1, 0)
    dwell = min(dwell, 150)
    nudge = x['reopen_count'] >= 3
    if nudge:
        dwell = 20
    return {'dwell_ds': dwell, 'nudge': nudge}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: stop with hall and car calls', {'call_type': 'both', 'boarding': 1, 'alighting': 1, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 50, 'nudge': False}), ('sampled regression 19', {'call_type': 'both', 'boarding': 1, 'alighting': 3, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 90, 'nudge': False}), ('sampled regression 3', {'call_type': 'both', 'boarding': 4, 'alighting': 4, 'reopen_count': 2, 'accessible': True}, {'dwell_ds': 130, 'nudge': False}), ('boundary: accessible car call stop', {'call_type': 'car', 'boarding': 1, 'alighting': 0, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 37, 'nudge': False}), ('boundary: accessible busy hall stop', {'call_type': 'hall', 'boarding': 5, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 130, 'nudge': False}), ('control 1', {'call_type': 'both', 'boarding': 6, 'alighting': 3, 'reopen_count': 4, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 4', {'call_type': 'hall', 'boarding': 5, 'alighting': 0, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 100, 'nudge': False}), ('control 7', {'call_type': 'both', 'boarding': 5, 'alighting': 1, 'reopen_count': 4, 'accessible': True}, {'dwell_ds': 20, 'nudge': True})], [('regression: stop with hall and car calls', {'call_type': 'both', 'boarding': 1, 'alighting': 1, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 50, 'nudge': False}), ('sampled regression 67', {'call_type': 'both', 'boarding': 6, 'alighting': 1, 'reopen_count': 1, 'accessible': False}, {'dwell_ds': 100, 'nudge': False}), ('sampled regression 38', {'call_type': 'both', 'boarding': 5, 'alighting': 3, 'reopen_count': 1, 'accessible': False}, {'dwell_ds': 110, 'nudge': False}), ('boundary: accessible busy hall stop', {'call_type': 'hall', 'boarding': 5, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 130, 'nudge': False}), ('boundary: nobody boards or alights', {'call_type': 'car', 'boarding': 0, 'alighting': 0, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 25, 'nudge': False}), ('control 12', {'call_type': 'car', 'boarding': 0, 'alighting': 4, 'reopen_count': 3, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 15', {'call_type': 'hall', 'boarding': 2, 'alighting': 5, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 100, 'nudge': False}), ('control 18', {'call_type': 'car', 'boarding': 8, 'alighting': 7, 'reopen_count': 2, 'accessible': False}, {'dwell_ds': 150, 'nudge': False})], [('regression: stop with hall and car calls', {'call_type': 'both', 'boarding': 1, 'alighting': 1, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 50, 'nudge': False}), ('sampled regression 19', {'call_type': 'both', 'boarding': 1, 'alighting': 3, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 90, 'nudge': False}), ('sampled regression 77', {'call_type': 'both', 'boarding': 3, 'alighting': 3, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 110, 'nudge': False}), ('boundary: crowd exceeds the cap', {'call_type': 'hall', 'boarding': 8, 'alighting': 8, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 150, 'nudge': False}), ('boundary: third reopen', {'call_type': 'hall', 'boarding': 2, 'alighting': 0, 'reopen_count': 3, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 23', {'call_type': 'hall', 'boarding': 7, 'alighting': 3, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 130, 'nudge': False}), ('sampled regression 26', {'call_type': 'both', 'boarding': 3, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 110, 'nudge': False}), ('control 29', {'call_type': 'both', 'boarding': 1, 'alighting': 0, 'reopen_count': 3, 'accessible': False}, {'dwell_ds': 20, 'nudge': True})], [('regression: stop with hall and car calls', {'call_type': 'both', 'boarding': 1, 'alighting': 1, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 50, 'nudge': False}), ('sampled regression 67', {'call_type': 'both', 'boarding': 6, 'alighting': 1, 'reopen_count': 1, 'accessible': False}, {'dwell_ds': 100, 'nudge': False}), ('sampled regression 19', {'call_type': 'both', 'boarding': 1, 'alighting': 3, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 90, 'nudge': False}), ('boundary: third reopen with nobody moving', {'call_type': 'car', 'boarding': 0, 'alighting': 0, 'reopen_count': 3, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('boundary: single passenger', {'call_type': 'hall', 'boarding': 1, 'alighting': 0, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 40, 'nudge': False}), ('control 34', {'call_type': 'hall', 'boarding': 3, 'alighting': 5, 'reopen_count': 1, 'accessible': False}, {'dwell_ds': 110, 'nudge': False}), ('control 37', {'call_type': 'hall', 'boarding': 4, 'alighting': 0, 'reopen_count': 4, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 40', {'call_type': 'car', 'boarding': 1, 'alighting': 8, 'reopen_count': 4, 'accessible': False}, {'dwell_ds': 20, 'nudge': True})], [('regression: stop with hall and car calls', {'call_type': 'both', 'boarding': 1, 'alighting': 1, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 50, 'nudge': False}), ('sampled regression 19', {'call_type': 'both', 'boarding': 1, 'alighting': 3, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 90, 'nudge': False}), ('sampled regression 65', {'call_type': 'both', 'boarding': 2, 'alighting': 6, 'reopen_count': 2, 'accessible': False}, {'dwell_ds': 110, 'nudge': False}), ('boundary: accessible car call stop', {'call_type': 'car', 'boarding': 1, 'alighting': 0, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 37, 'nudge': False}), ('boundary: accessible busy hall stop', {'call_type': 'hall', 'boarding': 5, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 130, 'nudge': False}), ('control 45', {'call_type': 'both', 'boarding': 6, 'alighting': 0, 'reopen_count': 4, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 48', {'call_type': 'hall', 'boarding': 3, 'alighting': 8, 'reopen_count': 2, 'accessible': False}, {'dwell_ds': 140, 'nudge': False}), ('control 51', {'call_type': 'hall', 'boarding': 2, 'alighting': 4, 'reopen_count': 1, 'accessible': False}, {'dwell_ds': 90, 'nudge': False})]]
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):
    base = 40 if x['call_type'] == 'hall' else 25 if x['call_type'] == 'car' else 32
    if x['accessible']:
        base = base * 3 // 2
    pax = x['boarding'] + x['alighting']
    dwell = base + 10 * max(pax - 1, 0)
    dwell = min(dwell, 150)
    nudge = x['reopen_count'] >= 3
    if nudge:
        dwell = 20
    return {'dwell_ds': dwell, 'nudge': nudge}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: stop with hall and car calls', {'call_type': 'both', 'boarding': 1, 'alighting': 1, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 50, 'nudge': False}), ('sampled regression 19', {'call_type': 'both', 'boarding': 1, 'alighting': 3, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 90, 'nudge': False}), ('sampled regression 3', {'call_type': 'both', 'boarding': 4, 'alighting': 4, 'reopen_count': 2, 'accessible': True}, {'dwell_ds': 130, 'nudge': False}), ('boundary: accessible car call stop', {'call_type': 'car', 'boarding': 1, 'alighting': 0, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 37, 'nudge': False}), ('boundary: accessible busy hall stop', {'call_type': 'hall', 'boarding': 5, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 130, 'nudge': False}), ('control 1', {'call_type': 'both', 'boarding': 6, 'alighting': 3, 'reopen_count': 4, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 4', {'call_type': 'hall', 'boarding': 5, 'alighting': 0, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 100, 'nudge': False}), ('control 7', {'call_type': 'both', 'boarding': 5, 'alighting': 1, 'reopen_count': 4, 'accessible': True}, {'dwell_ds': 20, 'nudge': True})], [('regression: stop with hall and car calls', {'call_type': 'both', 'boarding': 1, 'alighting': 1, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 50, 'nudge': False}), ('sampled regression 67', {'call_type': 'both', 'boarding': 6, 'alighting': 1, 'reopen_count': 1, 'accessible': False}, {'dwell_ds': 100, 'nudge': False}), ('sampled regression 38', {'call_type': 'both', 'boarding': 5, 'alighting': 3, 'reopen_count': 1, 'accessible': False}, {'dwell_ds': 110, 'nudge': False}), ('boundary: accessible busy hall stop', {'call_type': 'hall', 'boarding': 5, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 130, 'nudge': False}), ('boundary: nobody boards or alights', {'call_type': 'car', 'boarding': 0, 'alighting': 0, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 25, 'nudge': False}), ('control 12', {'call_type': 'car', 'boarding': 0, 'alighting': 4, 'reopen_count': 3, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 15', {'call_type': 'hall', 'boarding': 2, 'alighting': 5, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 100, 'nudge': False}), ('control 18', {'call_type': 'car', 'boarding': 8, 'alighting': 7, 'reopen_count': 2, 'accessible': False}, {'dwell_ds': 150, 'nudge': False})], [('regression: stop with hall and car calls', {'call_type': 'both', 'boarding': 1, 'alighting': 1, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 50, 'nudge': False}), ('sampled regression 19', {'call_type': 'both', 'boarding': 1, 'alighting': 3, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 90, 'nudge': False}), ('sampled regression 77', {'call_type': 'both', 'boarding': 3, 'alighting': 3, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 110, 'nudge': False}), ('boundary: crowd exceeds the cap', {'call_type': 'hall', 'boarding': 8, 'alighting': 8, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 150, 'nudge': False}), ('boundary: third reopen', {'call_type': 'hall', 'boarding': 2, 'alighting': 0, 'reopen_count': 3, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 23', {'call_type': 'hall', 'boarding': 7, 'alighting': 3, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 130, 'nudge': False}), ('sampled regression 26', {'call_type': 'both', 'boarding': 3, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 110, 'nudge': False}), ('control 29', {'call_type': 'both', 'boarding': 1, 'alighting': 0, 'reopen_count': 3, 'accessible': False}, {'dwell_ds': 20, 'nudge': True})], [('regression: stop with hall and car calls', {'call_type': 'both', 'boarding': 1, 'alighting': 1, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 50, 'nudge': False}), ('sampled regression 67', {'call_type': 'both', 'boarding': 6, 'alighting': 1, 'reopen_count': 1, 'accessible': False}, {'dwell_ds': 100, 'nudge': False}), ('sampled regression 19', {'call_type': 'both', 'boarding': 1, 'alighting': 3, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 90, 'nudge': False}), ('boundary: third reopen with nobody moving', {'call_type': 'car', 'boarding': 0, 'alighting': 0, 'reopen_count': 3, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('boundary: single passenger', {'call_type': 'hall', 'boarding': 1, 'alighting': 0, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 40, 'nudge': False}), ('control 34', {'call_type': 'hall', 'boarding': 3, 'alighting': 5, 'reopen_count': 1, 'accessible': False}, {'dwell_ds': 110, 'nudge': False}), ('control 37', {'call_type': 'hall', 'boarding': 4, 'alighting': 0, 'reopen_count': 4, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 40', {'call_type': 'car', 'boarding': 1, 'alighting': 8, 'reopen_count': 4, 'accessible': False}, {'dwell_ds': 20, 'nudge': True})], [('regression: stop with hall and car calls', {'call_type': 'both', 'boarding': 1, 'alighting': 1, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 50, 'nudge': False}), ('sampled regression 19', {'call_type': 'both', 'boarding': 1, 'alighting': 3, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 90, 'nudge': False}), ('sampled regression 65', {'call_type': 'both', 'boarding': 2, 'alighting': 6, 'reopen_count': 2, 'accessible': False}, {'dwell_ds': 110, 'nudge': False}), ('boundary: accessible car call stop', {'call_type': 'car', 'boarding': 1, 'alighting': 0, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 37, 'nudge': False}), ('boundary: accessible busy hall stop', {'call_type': 'hall', 'boarding': 5, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 130, 'nudge': False}), ('control 45', {'call_type': 'both', 'boarding': 6, 'alighting': 0, 'reopen_count': 4, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 48', {'call_type': 'hall', 'boarding': 3, 'alighting': 8, 'reopen_count': 2, 'accessible': False}, {'dwell_ds': 140, 'nudge': False}), ('control 51', {'call_type': 'hall', 'boarding': 2, 'alighting': 4, 'reopen_count': 1, 'accessible': False}, {'dwell_ds': 90, 'nudge': False})]]
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 stop serving both hall and car calls closes its doors too quickly.

Dwell time in deciseconds: base 40 for a hall call stop (or a stop with both hall and car calls), 25 for a car-call-only stop. Accessible mode extends the base by half (integer). Every passenger beyond the first adds 10. The result is capped at 150. From the third reopen onward the door nudges with a fixed dwell of 20.

split: open-access


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

N = 1
observations = []
def solve(x):
    base = 40 if x['call_type'] in ('hall', 'both') else 25
    if x['accessible']:
        dwell_ext = base * 3 // 2
    pax = x['boarding'] + x['alighting']
    dwell = base + 10 * max(pax - 1, 0)
    dwell = min(dwell, 150)
    nudge = x['reopen_count'] >= 3
    if nudge:
        dwell = 20
    return {'dwell_ds': dwell, 'nudge': nudge}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: accessible car call stop', {'call_type': 'car', 'boarding': 1, 'alighting': 0, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 37, 'nudge': False}), ('sampled regression 4', {'call_type': 'hall', 'boarding': 5, 'alighting': 0, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 100, 'nudge': False}), ('sampled regression 47', {'call_type': 'car', 'boarding': 1, 'alighting': 5, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 87, 'nudge': False}), ('boundary: stop with hall and car calls', {'call_type': 'both', 'boarding': 1, 'alighting': 1, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 50, 'nudge': False}), ('regression: accessible busy hall stop', {'call_type': 'hall', 'boarding': 5, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 130, 'nudge': False}), ('control 1', {'call_type': 'both', 'boarding': 6, 'alighting': 3, 'reopen_count': 4, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 7', {'call_type': 'both', 'boarding': 5, 'alighting': 1, 'reopen_count': 4, 'accessible': True}, {'dwell_ds': 20, 'nudge': True}), ('control 10', {'call_type': 'car', 'boarding': 6, 'alighting': 5, 'reopen_count': 3, 'accessible': True}, {'dwell_ds': 20, 'nudge': True})], [('regression: accessible busy hall stop', {'call_type': 'hall', 'boarding': 5, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 130, 'nudge': False}), ('regression: accessible car call stop', {'call_type': 'car', 'boarding': 1, 'alighting': 0, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 37, 'nudge': False}), ('sampled regression 69', {'call_type': 'car', 'boarding': 0, 'alighting': 0, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 37, 'nudge': False}), ('sampled regression 47', {'call_type': 'car', 'boarding': 1, 'alighting': 5, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 87, 'nudge': False}), ('boundary: nobody boards or alights', {'call_type': 'car', 'boarding': 0, 'alighting': 0, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 25, 'nudge': False}), ('control 12', {'call_type': 'car', 'boarding': 0, 'alighting': 4, 'reopen_count': 3, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 15', {'call_type': 'hall', 'boarding': 2, 'alighting': 5, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 100, 'nudge': False}), ('control 18', {'call_type': 'car', 'boarding': 8, 'alighting': 7, 'reopen_count': 2, 'accessible': False}, {'dwell_ds': 150, 'nudge': False})], [('regression: accessible car call stop', {'call_type': 'car', 'boarding': 1, 'alighting': 0, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 37, 'nudge': False}), ('sampled regression 19', {'call_type': 'both', 'boarding': 1, 'alighting': 3, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 90, 'nudge': False}), ('sampled regression 47', {'call_type': 'car', 'boarding': 1, 'alighting': 5, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 87, 'nudge': False}), ('boundary: crowd exceeds the cap', {'call_type': 'hall', 'boarding': 8, 'alighting': 8, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 150, 'nudge': False}), ('boundary: third reopen', {'call_type': 'hall', 'boarding': 2, 'alighting': 0, 'reopen_count': 3, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 23', {'call_type': 'hall', 'boarding': 7, 'alighting': 3, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 130, 'nudge': False}), ('sampled regression 26', {'call_type': 'both', 'boarding': 3, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 110, 'nudge': False}), ('control 29', {'call_type': 'both', 'boarding': 1, 'alighting': 0, 'reopen_count': 3, 'accessible': False}, {'dwell_ds': 20, 'nudge': True})], [('regression: accessible busy hall stop', {'call_type': 'hall', 'boarding': 5, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 130, 'nudge': False}), ('regression: accessible car call stop', {'call_type': 'car', 'boarding': 1, 'alighting': 0, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 37, 'nudge': False}), ('sampled regression 77', {'call_type': 'both', 'boarding': 3, 'alighting': 3, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 110, 'nudge': False}), ('sampled regression 47', {'call_type': 'car', 'boarding': 1, 'alighting': 5, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 87, 'nudge': False}), ('boundary: third reopen with nobody moving', {'call_type': 'car', 'boarding': 0, 'alighting': 0, 'reopen_count': 3, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 34', {'call_type': 'hall', 'boarding': 3, 'alighting': 5, 'reopen_count': 1, 'accessible': False}, {'dwell_ds': 110, 'nudge': False}), ('control 37', {'call_type': 'hall', 'boarding': 4, 'alighting': 0, 'reopen_count': 4, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 40', {'call_type': 'car', 'boarding': 1, 'alighting': 8, 'reopen_count': 4, 'accessible': False}, {'dwell_ds': 20, 'nudge': True})], [('regression: accessible car call stop', {'call_type': 'car', 'boarding': 1, 'alighting': 0, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 37, 'nudge': False}), ('sampled regression 26', {'call_type': 'both', 'boarding': 3, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 110, 'nudge': False}), ('sampled regression 47', {'call_type': 'car', 'boarding': 1, 'alighting': 5, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 87, 'nudge': False}), ('boundary: stop with hall and car calls', {'call_type': 'both', 'boarding': 1, 'alighting': 1, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 50, 'nudge': False}), ('regression: accessible busy hall stop', {'call_type': 'hall', 'boarding': 5, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 130, 'nudge': False}), ('control 45', {'call_type': 'both', 'boarding': 6, 'alighting': 0, 'reopen_count': 4, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 48', {'call_type': 'hall', 'boarding': 3, 'alighting': 8, 'reopen_count': 2, 'accessible': False}, {'dwell_ds': 140, 'nudge': False}), ('control 51', {'call_type': 'hall', 'boarding': 2, 'alighting': 4, 'reopen_count': 1, 'accessible': False}, {'dwell_ds': 90, 'nudge': False})]]
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):
    base = 40 if x['call_type'] in ('hall', 'both') else 25
    if x['accessible']:
        base = base * 3 / 2
    pax = x['boarding'] + x['alighting']
    dwell = base + 10 * max(pax - 1, 0)
    dwell = min(dwell, 150)
    nudge = x['reopen_count'] >= 3
    if nudge:
        dwell = 20
    return {'dwell_ds': dwell, 'nudge': nudge}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: accessible car call stop', {'call_type': 'car', 'boarding': 1, 'alighting': 0, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 37, 'nudge': False}), ('sampled regression 4', {'call_type': 'hall', 'boarding': 5, 'alighting': 0, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 100, 'nudge': False}), ('sampled regression 47', {'call_type': 'car', 'boarding': 1, 'alighting': 5, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 87, 'nudge': False}), ('boundary: stop with hall and car calls', {'call_type': 'both', 'boarding': 1, 'alighting': 1, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 50, 'nudge': False}), ('regression: accessible busy hall stop', {'call_type': 'hall', 'boarding': 5, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 130, 'nudge': False}), ('control 1', {'call_type': 'both', 'boarding': 6, 'alighting': 3, 'reopen_count': 4, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 7', {'call_type': 'both', 'boarding': 5, 'alighting': 1, 'reopen_count': 4, 'accessible': True}, {'dwell_ds': 20, 'nudge': True}), ('control 10', {'call_type': 'car', 'boarding': 6, 'alighting': 5, 'reopen_count': 3, 'accessible': True}, {'dwell_ds': 20, 'nudge': True})], [('regression: accessible busy hall stop', {'call_type': 'hall', 'boarding': 5, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 130, 'nudge': False}), ('regression: accessible car call stop', {'call_type': 'car', 'boarding': 1, 'alighting': 0, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 37, 'nudge': False}), ('sampled regression 69', {'call_type': 'car', 'boarding': 0, 'alighting': 0, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 37, 'nudge': False}), ('sampled regression 47', {'call_type': 'car', 'boarding': 1, 'alighting': 5, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 87, 'nudge': False}), ('boundary: nobody boards or alights', {'call_type': 'car', 'boarding': 0, 'alighting': 0, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 25, 'nudge': False}), ('control 12', {'call_type': 'car', 'boarding': 0, 'alighting': 4, 'reopen_count': 3, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 15', {'call_type': 'hall', 'boarding': 2, 'alighting': 5, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 100, 'nudge': False}), ('control 18', {'call_type': 'car', 'boarding': 8, 'alighting': 7, 'reopen_count': 2, 'accessible': False}, {'dwell_ds': 150, 'nudge': False})], [('regression: accessible car call stop', {'call_type': 'car', 'boarding': 1, 'alighting': 0, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 37, 'nudge': False}), ('sampled regression 19', {'call_type': 'both', 'boarding': 1, 'alighting': 3, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 90, 'nudge': False}), ('sampled regression 47', {'call_type': 'car', 'boarding': 1, 'alighting': 5, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 87, 'nudge': False}), ('boundary: crowd exceeds the cap', {'call_type': 'hall', 'boarding': 8, 'alighting': 8, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 150, 'nudge': False}), ('boundary: third reopen', {'call_type': 'hall', 'boarding': 2, 'alighting': 0, 'reopen_count': 3, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 23', {'call_type': 'hall', 'boarding': 7, 'alighting': 3, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 130, 'nudge': False}), ('sampled regression 26', {'call_type': 'both', 'boarding': 3, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 110, 'nudge': False}), ('control 29', {'call_type': 'both', 'boarding': 1, 'alighting': 0, 'reopen_count': 3, 'accessible': False}, {'dwell_ds': 20, 'nudge': True})], [('regression: accessible busy hall stop', {'call_type': 'hall', 'boarding': 5, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 130, 'nudge': False}), ('regression: accessible car call stop', {'call_type': 'car', 'boarding': 1, 'alighting': 0, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 37, 'nudge': False}), ('sampled regression 77', {'call_type': 'both', 'boarding': 3, 'alighting': 3, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 110, 'nudge': False}), ('sampled regression 47', {'call_type': 'car', 'boarding': 1, 'alighting': 5, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 87, 'nudge': False}), ('boundary: third reopen with nobody moving', {'call_type': 'car', 'boarding': 0, 'alighting': 0, 'reopen_count': 3, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 34', {'call_type': 'hall', 'boarding': 3, 'alighting': 5, 'reopen_count': 1, 'accessible': False}, {'dwell_ds': 110, 'nudge': False}), ('control 37', {'call_type': 'hall', 'boarding': 4, 'alighting': 0, 'reopen_count': 4, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 40', {'call_type': 'car', 'boarding': 1, 'alighting': 8, 'reopen_count': 4, 'accessible': False}, {'dwell_ds': 20, 'nudge': True})], [('regression: accessible car call stop', {'call_type': 'car', 'boarding': 1, 'alighting': 0, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 37, 'nudge': False}), ('sampled regression 26', {'call_type': 'both', 'boarding': 3, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 110, 'nudge': False}), ('sampled regression 47', {'call_type': 'car', 'boarding': 1, 'alighting': 5, 'reopen_count': 1, 'accessible': True}, {'dwell_ds': 87, 'nudge': False}), ('boundary: stop with hall and car calls', {'call_type': 'both', 'boarding': 1, 'alighting': 1, 'reopen_count': 0, 'accessible': False}, {'dwell_ds': 50, 'nudge': False}), ('regression: accessible busy hall stop', {'call_type': 'hall', 'boarding': 5, 'alighting': 3, 'reopen_count': 0, 'accessible': True}, {'dwell_ds': 130, 'nudge': False}), ('control 45', {'call_type': 'both', 'boarding': 6, 'alighting': 0, 'reopen_count': 4, 'accessible': False}, {'dwell_ds': 20, 'nudge': True}), ('control 48', {'call_type': 'hall', 'boarding': 3, 'alighting': 8, 'reopen_count': 2, 'accessible': False}, {'dwell_ds': 140, 'nudge': False}), ('control 51', {'call_type': 'hall', 'boarding': 2, 'alighting': 4, 'reopen_count': 1, 'accessible': False}, {'dwell_ds': 90, 'nudge': False})]]
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:
Accessible mode has no effect or yields fractional deciseconds.

Dwell time in deciseconds: base 40 for a hall call stop (or a stop with both hall and car calls), 25 for a car-call-only stop. Accessible mode extends the base by half (integer). Every passenger beyond the first adds 10. The result is capped at 150. From the third reopen onward the door nudges with a fixed dwell of 20.

split: open-access