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 < 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: double press of the only call', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 3]}, {'calls': [3], 'log': ['registered', 'kept']}), ('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 5', {'floors': 11, 'floor': 1, 'doors_open': True, 'load_kg': 15, 'presses': [10, 10, 8]}, {'calls': [8, 10], 'log': ['registered', 'kept', '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']}), ('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: double press of the only call', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 3]}, {'calls': [3], 'log': ['registered', 'kept']}), ('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 67', {'floors': 11, 'floor': 4, 'doors_open': False, 'load_kg': 80, 'presses': [4, 4, 0, 0, 9, 6, 2, 3, 9]}, {'calls': [2, 3, 4, 6], 'log': ['registered', 'kept', 'registered', 'cancelled', 'registered', 'registered', 'registered', 'registered', 'cancelled']}), ('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']}), ('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']}), ('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']}), ('control 21', {'floors': 15, 'floor': 0, 'doors_open': True, 'load_kg': 19, 'presses': [7, 14, 5, 9]}, {'calls': [5, 7, 9, 14], 'log': ['registered', 'registered', 'registered', 'registered']})], [('regression: double press of the only call', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 3]}, {'calls': [3], 'log': ['registered', 'kept']}), ('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 24', {'floors': 10, 'floor': 8, 'doors_open': False, 'load_kg': 15, 'presses': [10, 5, 5, 2]}, {'calls': [2, 5], 'log': ['invalid', 'registered', 'kept', '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']}), ('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 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: double press of the only call', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 3]}, {'calls': [3], 'log': ['registered', 'kept']}), ('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 71', {'floors': 13, 'floor': 9, 'doors_open': True, 'load_kg': 300, 'presses': [12, 12, 1, 5]}, {'calls': [1, 5, 12], 'log': ['registered', 'kept', 'registered', '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: child presses every button', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 3, 4, 5, 6, 7]}, {'calls': [1, 2, 3, 4, 5], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'nuisance', 'nuisance']}), ('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']}), ('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: double press of the only call', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 3]}, {'calls': [3], 'log': ['registered', 'kept']}), ('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 27', {'floors': 8, 'floor': 4, 'doors_open': False, 'load_kg': 300, 'presses': [0, 0, 4, -1, 6, 8]}, {'calls': [0, 4, 6], 'log': ['registered', 'kept', 'registered', 'invalid', 'registered', 'invalid']}), ('control 66', {'floors': 9, 'floor': 2, 'doors_open': True, 'load_kg': 300, 'presses': [8, 2, 6, 8]}, {'calls': [6], 'log': ['registered', 'reopen', 'registered', 'cancelled']}), ('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 and calls[-1] == f:
                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: double press of the only call', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 3]}, {'calls': [3], 'log': ['registered', 'kept']}), ('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 5', {'floors': 11, 'floor': 1, 'doors_open': True, 'load_kg': 15, 'presses': [10, 10, 8]}, {'calls': [8, 10], 'log': ['registered', 'kept', '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']}), ('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: double press of the only call', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 3]}, {'calls': [3], 'log': ['registered', 'kept']}), ('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 67', {'floors': 11, 'floor': 4, 'doors_open': False, 'load_kg': 80, 'presses': [4, 4, 0, 0, 9, 6, 2, 3, 9]}, {'calls': [2, 3, 4, 6], 'log': ['registered', 'kept', 'registered', 'cancelled', 'registered', 'registered', 'registered', 'registered', 'cancelled']}), ('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']}), ('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']}), ('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']}), ('control 21', {'floors': 15, 'floor': 0, 'doors_open': True, 'load_kg': 19, 'presses': [7, 14, 5, 9]}, {'calls': [5, 7, 9, 14], 'log': ['registered', 'registered', 'registered', 'registered']})], [('regression: double press of the only call', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 3]}, {'calls': [3], 'log': ['registered', 'kept']}), ('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 24', {'floors': 10, 'floor': 8, 'doors_open': False, 'load_kg': 15, 'presses': [10, 5, 5, 2]}, {'calls': [2, 5], 'log': ['invalid', 'registered', 'kept', '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']}), ('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 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: double press of the only call', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 3]}, {'calls': [3], 'log': ['registered', 'kept']}), ('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 71', {'floors': 13, 'floor': 9, 'doors_open': True, 'load_kg': 300, 'presses': [12, 12, 1, 5]}, {'calls': [1, 5, 12], 'log': ['registered', 'kept', 'registered', '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: child presses every button', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 3, 4, 5, 6, 7]}, {'calls': [1, 2, 3, 4, 5], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'nuisance', 'nuisance']}), ('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']}), ('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: double press of the only call', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [3, 3]}, {'calls': [3], 'log': ['registered', 'kept']}), ('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 27', {'floors': 8, 'floor': 4, 'doors_open': False, 'load_kg': 300, 'presses': [0, 0, 4, -1, 6, 8]}, {'calls': [0, 4, 6], 'log': ['registered', 'kept', 'registered', 'invalid', 'registered', 'invalid']}), ('control 66', {'floors': 9, 'floor': 2, 'doors_open': True, 'load_kg': 300, 'presses': [8, 2, 6, 8]}, {'calls': [6], 'log': ['registered', 'reopen', 'registered', 'cancelled']}), ('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:
The last remaining call is cancelled by a double press, or earlier calls cannot be cancelled.

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 < 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: child presses every button', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 3, 4, 5, 6, 7]}, {'calls': [1, 2, 3, 4, 5], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'nuisance', 'nuisance']}), ('boundary: cancelled presses do not count', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 2, 3, 3, 4, 5, 6]}, {'calls': [1, 4, 5, 6], 'log': ['registered', 'registered', 'cancelled', 'registered', 'cancelled', 'registered', 'registered', 'registered']}), ('sampled regression 69', {'floors': 15, 'floor': 10, 'doors_open': False, 'load_kg': 15, 'presses': [3, 6, 0, -1, 12, 7, 10, 14, 6]}, {'calls': [0, 3, 7, 12], 'log': ['registered', 'registered', 'registered', 'invalid', 'registered', 'registered', 'nuisance', 'nuisance', 'cancelled']}), ('control 2', {'floors': 8, 'floor': 7, 'doors_open': False, 'load_kg': 19, 'presses': [4, 7, 0, 5, 6, -1, 4, 1]}, {'calls': [0, 1, 5, 6, 7], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'invalid', 'cancelled', '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']}), ('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']}), ('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: child presses every button', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 3, 4, 5, 6, 7]}, {'calls': [1, 2, 3, 4, 5], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'nuisance', 'nuisance']}), ('boundary: cancelled presses do not count', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 2, 3, 3, 4, 5, 6]}, {'calls': [1, 4, 5, 6], 'log': ['registered', 'registered', 'cancelled', 'registered', 'cancelled', 'registered', 'registered', 'registered']}), ('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']}), ('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']}), ('boundary: button one above the top', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [10, 9]}, {'calls': [9], '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']}), ('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']}), ('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: child presses every button', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 3, 4, 5, 6, 7]}, {'calls': [1, 2, 3, 4, 5], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'nuisance', 'nuisance']}), ('boundary: cancelled presses do not count', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 2, 3, 3, 4, 5, 6]}, {'calls': [1, 4, 5, 6], 'log': ['registered', 'registered', 'cancelled', 'registered', 'cancelled', 'registered', 'registered', 'registered']}), ('sampled regression 64', {'floors': 12, 'floor': 6, 'doors_open': False, 'load_kg': 15, 'presses': [0, 7, 1, 9, 6, 2]}, {'calls': [0, 1, 6, 7, 9], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'nuisance']}), ('control 56', {'floors': 11, 'floor': 6, 'doors_open': True, 'load_kg': 0, 'presses': [0, 6, 4, 11, 11, 6, 2, -1, 8]}, {'calls': [0, 2, 4, 8], 'log': ['registered', 'reopen', 'registered', 'invalid', 'invalid', 'reopen', 'registered', 'invalid', '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 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']}), ('sampled regression 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: child presses every button', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 3, 4, 5, 6, 7]}, {'calls': [1, 2, 3, 4, 5], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'nuisance', 'nuisance']}), ('boundary: cancelled presses do not count', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 2, 3, 3, 4, 5, 6]}, {'calls': [1, 4, 5, 6], 'log': ['registered', 'registered', 'cancelled', 'registered', 'cancelled', 'registered', 'registered', 'registered']}), ('sampled regression 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: 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']}), ('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 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: child presses every button', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 3, 4, 5, 6, 7]}, {'calls': [1, 2, 3, 4, 5], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'nuisance', 'nuisance']}), ('boundary: cancelled presses do not count', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 2, 3, 3, 4, 5, 6]}, {'calls': [1, 4, 5, 6], 'log': ['registered', 'registered', 'cancelled', 'registered', 'cancelled', 'registered', 'registered', 'registered']}), ('sampled regression 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 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: 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)

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):
    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(log) >= 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: child presses every button', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 3, 4, 5, 6, 7]}, {'calls': [1, 2, 3, 4, 5], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'nuisance', 'nuisance']}), ('boundary: cancelled presses do not count', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 2, 3, 3, 4, 5, 6]}, {'calls': [1, 4, 5, 6], 'log': ['registered', 'registered', 'cancelled', 'registered', 'cancelled', 'registered', 'registered', 'registered']}), ('sampled regression 69', {'floors': 15, 'floor': 10, 'doors_open': False, 'load_kg': 15, 'presses': [3, 6, 0, -1, 12, 7, 10, 14, 6]}, {'calls': [0, 3, 7, 12], 'log': ['registered', 'registered', 'registered', 'invalid', 'registered', 'registered', 'nuisance', 'nuisance', 'cancelled']}), ('control 2', {'floors': 8, 'floor': 7, 'doors_open': False, 'load_kg': 19, 'presses': [4, 7, 0, 5, 6, -1, 4, 1]}, {'calls': [0, 1, 5, 6, 7], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'invalid', 'cancelled', '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']}), ('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']}), ('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: child presses every button', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 3, 4, 5, 6, 7]}, {'calls': [1, 2, 3, 4, 5], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'nuisance', 'nuisance']}), ('boundary: cancelled presses do not count', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 2, 3, 3, 4, 5, 6]}, {'calls': [1, 4, 5, 6], 'log': ['registered', 'registered', 'cancelled', 'registered', 'cancelled', 'registered', 'registered', 'registered']}), ('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']}), ('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']}), ('boundary: button one above the top', {'floors': 10, 'floor': 0, 'doors_open': False, 'load_kg': 80, 'presses': [10, 9]}, {'calls': [9], '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']}), ('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']}), ('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: child presses every button', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 3, 4, 5, 6, 7]}, {'calls': [1, 2, 3, 4, 5], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'nuisance', 'nuisance']}), ('boundary: cancelled presses do not count', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 2, 3, 3, 4, 5, 6]}, {'calls': [1, 4, 5, 6], 'log': ['registered', 'registered', 'cancelled', 'registered', 'cancelled', 'registered', 'registered', 'registered']}), ('sampled regression 64', {'floors': 12, 'floor': 6, 'doors_open': False, 'load_kg': 15, 'presses': [0, 7, 1, 9, 6, 2]}, {'calls': [0, 1, 6, 7, 9], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'nuisance']}), ('control 56', {'floors': 11, 'floor': 6, 'doors_open': True, 'load_kg': 0, 'presses': [0, 6, 4, 11, 11, 6, 2, -1, 8]}, {'calls': [0, 2, 4, 8], 'log': ['registered', 'reopen', 'registered', 'invalid', 'invalid', 'reopen', 'registered', 'invalid', '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 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']}), ('sampled regression 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: child presses every button', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 3, 4, 5, 6, 7]}, {'calls': [1, 2, 3, 4, 5], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'nuisance', 'nuisance']}), ('boundary: cancelled presses do not count', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 2, 3, 3, 4, 5, 6]}, {'calls': [1, 4, 5, 6], 'log': ['registered', 'registered', 'cancelled', 'registered', 'cancelled', 'registered', 'registered', 'registered']}), ('sampled regression 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: 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']}), ('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 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: child presses every button', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 3, 4, 5, 6, 7]}, {'calls': [1, 2, 3, 4, 5], 'log': ['registered', 'registered', 'registered', 'registered', 'registered', 'nuisance', 'nuisance']}), ('boundary: cancelled presses do not count', {'floors': 12, 'floor': 0, 'doors_open': False, 'load_kg': 15, 'presses': [1, 2, 2, 3, 3, 4, 5, 6]}, {'calls': [1, 4, 5, 6], 'log': ['registered', 'registered', 'cancelled', 'registered', 'cancelled', 'registered', 'registered', 'registered']}), ('sampled regression 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 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: 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:
An empty car accepts a sixth call from a prankster, or legitimate calls are refused.

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):
    waits = []
    for reg, ans in x['calls']:
        if ans is None:
            continue
        else:
            waits.append(max(0, ans - reg))
    if not waits:
        return {'avg': 0, 'long_permille': 0, 'max': 0, 'count': 0}
    longs = sum(1 for w in waits if w > 60)
    return {'avg': sum(waits) // len(waits), 'long_permille': longs * 1000 // len(waits), 'max': max(waits), 'count': len(waits)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: unanswered call at the end', {'end_s': 600, 'calls': [[500, None], [10, 30]]}, {'avg': 60, 'long_permille': 500, 'max': 100, 'count': 2}), ('sampled regression 4', {'end_s': 600, 'calls': [[15, None], [80, 100], [304, 324], [560, 557], [73, 78], [574, None]]}, {'avg': 109, 'long_permille': 166, 'max': 585, 'count': 6}), ('regression: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('boundary: answer logged before registration', {'end_s': 600, 'calls': [[100, 98], [200, 230]]}, {'avg': 15, 'long_permille': 0, 'max': 30, 'count': 2}), ('boundary: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('sampled regression 1', {'end_s': 600, 'calls': [[93, 138], [499, 519], [546, None], [485, None], [376, 526], [329, 419], [42, None], [303, None]]}, {'avg': 166, 'long_permille': 625, 'max': 558, 'count': 8}), ('sampled regression 7', {'end_s': 600, 'calls': [[196, 216], [228, 248], [100, None], [381, 471], [370, 415], [56, 76]]}, {'avg': 115, 'long_permille': 333, 'max': 500, 'count': 6}), ('control 10', {'end_s': 600, 'calls': [[274, 279]]}, {'avg': 5, 'long_permille': 0, 'max': 5, 'count': 1})], [('regression: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('sampled regression 12', {'end_s': 600, 'calls': [[549, None], [34, 94], [153, 243]]}, {'avg': 67, 'long_permille': 333, 'max': 90, 'count': 3}), ('sampled regression 7', {'end_s': 600, 'calls': [[196, 216], [228, 248], [100, None], [381, 471], [370, 415], [56, 76]]}, {'avg': 115, 'long_permille': 333, 'max': 500, 'count': 6}), ('boundary: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('boundary: mean with a remainder', {'end_s': 600, 'calls': [[0, 10], [0, 11], [0, 11]]}, {'avg': 10, 'long_permille': 0, 'max': 11, 'count': 3}), ('sampled regression 15', {'end_s': 600, 'calls': [[427, 472], [290, 440], [125, None], [18, 79], [88, 178], [156, 306], [7, None], [120, None]]}, {'avg': 255, 'long_permille': 875, 'max': 593, 'count': 8}), ('control 18', {'end_s': 600, 'calls': [[508, 528]]}, {'avg': 20, 'long_permille': 0, 'max': 20, 'count': 1}), ('sampled regression 21', {'end_s': 600, 'calls': [[423, 513], [105, 150], [229, None], [580, None], [55, 115], [215, None], [514, 575], [425, 423]]}, {'avg': 129, 'long_permille': 500, 'max': 385, 'count': 8})], [('regression: unanswered call at the end', {'end_s': 600, 'calls': [[500, None], [10, 30]]}, {'avg': 60, 'long_permille': 500, 'max': 100, 'count': 2}), ('sampled regression 20', {'end_s': 600, 'calls': [[520, None], [447, 467], [161, 221], [506, 511], [146, 296], [576, None], [73, 223], [194, 214]]}, {'avg': 63, 'long_permille': 375, 'max': 150, 'count': 8}), ('sampled regression 13', {'end_s': 600, 'calls': [[451, 511], [494, 539], [553, None], [26, None], [306, 367], [164, 314], [548, None], [406, 556]]}, {'avg': 142, 'long_permille': 500, 'max': 574, 'count': 8}), ('boundary: mean with a remainder', {'end_s': 600, 'calls': [[0, 10], [0, 11], [0, 11]]}, {'avg': 10, 'long_permille': 0, 'max': 11, 'count': 3}), ('boundary: no calls', {'end_s': 600, 'calls': []}, {'avg': 0, 'long_permille': 0, 'max': 0, 'count': 0}), ('sampled regression 23', {'end_s': 600, 'calls': [[121, 141], [388, None], [577, None]]}, {'avg': 85, 'long_permille': 333, 'max': 212, 'count': 3}), ('control 26', {'end_s': 600, 'calls': [[205, 225], [336, 381]]}, {'avg': 32, 'long_permille': 0, 'max': 45, 'count': 2}), ('sampled regression 29', {'end_s': 600, 'calls': [[26, 31], [282, 287], [487, 577], [127, 187], [568, None], [130, 280], [335, 395], [184, 274]]}, {'avg': 61, 'long_permille': 375, 'max': 150, 'count': 8})], [('regression: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('sampled regression 30', {'end_s': 600, 'calls': [[430, None]]}, {'avg': 170, 'long_permille': 1000, 'max': 170, 'count': 1}), ('sampled regression 19', {'end_s': 600, 'calls': [[490, 551], [203, None], [559, None], [20, 65]]}, {'avg': 136, 'long_permille': 500, 'max': 397, 'count': 4}), ('regression: unanswered call at the end', {'end_s': 600, 'calls': [[500, None], [10, 30]]}, {'avg': 60, 'long_permille': 500, 'max': 100, 'count': 2}), ('boundary: answer logged before registration', {'end_s': 600, 'calls': [[100, 98], [200, 230]]}, {'avg': 15, 'long_permille': 0, 'max': 30, 'count': 2}), ('sampled regression 34', {'end_s': 600, 'calls': [[526, 531], [100, 160], [338, None], [152, 242], [413, 433], [56, 117]]}, {'avg': 83, 'long_permille': 500, 'max': 262, 'count': 6}), ('sampled regression 37', {'end_s': 600, 'calls': [[542, 547], [483, None], [421, 418], [216, None]]}, {'avg': 126, 'long_permille': 500, 'max': 384, 'count': 4}), ('sampled regression 40', {'end_s': 600, 'calls': [[286, 346], [342, None], [309, 308], [91, 96], [519, 524], [518, None], [12, 73]]}, {'avg': 67, 'long_permille': 428, 'max': 258, 'count': 7})], [('regression: unanswered call at the end', {'end_s': 600, 'calls': [[500, None], [10, 30]]}, {'avg': 60, 'long_permille': 500, 'max': 100, 'count': 2}), ('sampled regression 39', {'end_s': 600, 'calls': [[181, None], [11, 31], [517, 537], [294, 339], [11, 56], [451, 471]]}, {'avg': 94, 'long_permille': 166, 'max': 419, 'count': 6}), ('sampled regression 27', {'end_s': 600, 'calls': [[441, None], [579, None], [47, 137], [447, None]]}, {'avg': 105, 'long_permille': 750, 'max': 159, 'count': 4}), ('boundary: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('regression: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('sampled regression 45', {'end_s': 600, 'calls': [[54, 204], [360, None], [102, None], [487, None], [396, None]]}, {'avg': 241, 'long_permille': 1000, 'max': 498, 'count': 5}), ('control 48', {'end_s': 600, 'calls': [[235, 234], [112, 202], [453, 498], [10, 30], [166, 186], [359, 358], [466, 471]]}, {'avg': 25, 'long_permille': 142, 'max': 90, 'count': 7}), ('sampled regression 51', {'end_s': 600, 'calls': [[553, None], [377, 422], [370, None], [180, 241]]}, {'avg': 95, 'long_permille': 500, 'max': 230, 'count': 4})]]
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):
    waits = []
    for reg, ans in x['calls']:
        if ans is None:
            waits.append(x['end_s'])
        else:
            waits.append(max(0, ans - reg))
    if not waits:
        return {'avg': 0, 'long_permille': 0, 'max': 0, 'count': 0}
    longs = sum(1 for w in waits if w > 60)
    return {'avg': sum(waits) // len(waits), 'long_permille': longs * 1000 // len(waits), 'max': max(waits), 'count': len(waits)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: unanswered call at the end', {'end_s': 600, 'calls': [[500, None], [10, 30]]}, {'avg': 60, 'long_permille': 500, 'max': 100, 'count': 2}), ('sampled regression 4', {'end_s': 600, 'calls': [[15, None], [80, 100], [304, 324], [560, 557], [73, 78], [574, None]]}, {'avg': 109, 'long_permille': 166, 'max': 585, 'count': 6}), ('regression: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('boundary: answer logged before registration', {'end_s': 600, 'calls': [[100, 98], [200, 230]]}, {'avg': 15, 'long_permille': 0, 'max': 30, 'count': 2}), ('boundary: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('sampled regression 1', {'end_s': 600, 'calls': [[93, 138], [499, 519], [546, None], [485, None], [376, 526], [329, 419], [42, None], [303, None]]}, {'avg': 166, 'long_permille': 625, 'max': 558, 'count': 8}), ('sampled regression 7', {'end_s': 600, 'calls': [[196, 216], [228, 248], [100, None], [381, 471], [370, 415], [56, 76]]}, {'avg': 115, 'long_permille': 333, 'max': 500, 'count': 6}), ('control 10', {'end_s': 600, 'calls': [[274, 279]]}, {'avg': 5, 'long_permille': 0, 'max': 5, 'count': 1})], [('regression: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('sampled regression 12', {'end_s': 600, 'calls': [[549, None], [34, 94], [153, 243]]}, {'avg': 67, 'long_permille': 333, 'max': 90, 'count': 3}), ('sampled regression 7', {'end_s': 600, 'calls': [[196, 216], [228, 248], [100, None], [381, 471], [370, 415], [56, 76]]}, {'avg': 115, 'long_permille': 333, 'max': 500, 'count': 6}), ('boundary: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('boundary: mean with a remainder', {'end_s': 600, 'calls': [[0, 10], [0, 11], [0, 11]]}, {'avg': 10, 'long_permille': 0, 'max': 11, 'count': 3}), ('sampled regression 15', {'end_s': 600, 'calls': [[427, 472], [290, 440], [125, None], [18, 79], [88, 178], [156, 306], [7, None], [120, None]]}, {'avg': 255, 'long_permille': 875, 'max': 593, 'count': 8}), ('control 18', {'end_s': 600, 'calls': [[508, 528]]}, {'avg': 20, 'long_permille': 0, 'max': 20, 'count': 1}), ('sampled regression 21', {'end_s': 600, 'calls': [[423, 513], [105, 150], [229, None], [580, None], [55, 115], [215, None], [514, 575], [425, 423]]}, {'avg': 129, 'long_permille': 500, 'max': 385, 'count': 8})], [('regression: unanswered call at the end', {'end_s': 600, 'calls': [[500, None], [10, 30]]}, {'avg': 60, 'long_permille': 500, 'max': 100, 'count': 2}), ('sampled regression 20', {'end_s': 600, 'calls': [[520, None], [447, 467], [161, 221], [506, 511], [146, 296], [576, None], [73, 223], [194, 214]]}, {'avg': 63, 'long_permille': 375, 'max': 150, 'count': 8}), ('sampled regression 13', {'end_s': 600, 'calls': [[451, 511], [494, 539], [553, None], [26, None], [306, 367], [164, 314], [548, None], [406, 556]]}, {'avg': 142, 'long_permille': 500, 'max': 574, 'count': 8}), ('boundary: mean with a remainder', {'end_s': 600, 'calls': [[0, 10], [0, 11], [0, 11]]}, {'avg': 10, 'long_permille': 0, 'max': 11, 'count': 3}), ('boundary: no calls', {'end_s': 600, 'calls': []}, {'avg': 0, 'long_permille': 0, 'max': 0, 'count': 0}), ('sampled regression 23', {'end_s': 600, 'calls': [[121, 141], [388, None], [577, None]]}, {'avg': 85, 'long_permille': 333, 'max': 212, 'count': 3}), ('control 26', {'end_s': 600, 'calls': [[205, 225], [336, 381]]}, {'avg': 32, 'long_permille': 0, 'max': 45, 'count': 2}), ('sampled regression 29', {'end_s': 600, 'calls': [[26, 31], [282, 287], [487, 577], [127, 187], [568, None], [130, 280], [335, 395], [184, 274]]}, {'avg': 61, 'long_permille': 375, 'max': 150, 'count': 8})], [('regression: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('sampled regression 30', {'end_s': 600, 'calls': [[430, None]]}, {'avg': 170, 'long_permille': 1000, 'max': 170, 'count': 1}), ('sampled regression 19', {'end_s': 600, 'calls': [[490, 551], [203, None], [559, None], [20, 65]]}, {'avg': 136, 'long_permille': 500, 'max': 397, 'count': 4}), ('regression: unanswered call at the end', {'end_s': 600, 'calls': [[500, None], [10, 30]]}, {'avg': 60, 'long_permille': 500, 'max': 100, 'count': 2}), ('boundary: answer logged before registration', {'end_s': 600, 'calls': [[100, 98], [200, 230]]}, {'avg': 15, 'long_permille': 0, 'max': 30, 'count': 2}), ('sampled regression 34', {'end_s': 600, 'calls': [[526, 531], [100, 160], [338, None], [152, 242], [413, 433], [56, 117]]}, {'avg': 83, 'long_permille': 500, 'max': 262, 'count': 6}), ('sampled regression 37', {'end_s': 600, 'calls': [[542, 547], [483, None], [421, 418], [216, None]]}, {'avg': 126, 'long_permille': 500, 'max': 384, 'count': 4}), ('sampled regression 40', {'end_s': 600, 'calls': [[286, 346], [342, None], [309, 308], [91, 96], [519, 524], [518, None], [12, 73]]}, {'avg': 67, 'long_permille': 428, 'max': 258, 'count': 7})], [('regression: unanswered call at the end', {'end_s': 600, 'calls': [[500, None], [10, 30]]}, {'avg': 60, 'long_permille': 500, 'max': 100, 'count': 2}), ('sampled regression 39', {'end_s': 600, 'calls': [[181, None], [11, 31], [517, 537], [294, 339], [11, 56], [451, 471]]}, {'avg': 94, 'long_permille': 166, 'max': 419, 'count': 6}), ('sampled regression 27', {'end_s': 600, 'calls': [[441, None], [579, None], [47, 137], [447, None]]}, {'avg': 105, 'long_permille': 750, 'max': 159, 'count': 4}), ('boundary: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('regression: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('sampled regression 45', {'end_s': 600, 'calls': [[54, 204], [360, None], [102, None], [487, None], [396, None]]}, {'avg': 241, 'long_permille': 1000, 'max': 498, 'count': 5}), ('control 48', {'end_s': 600, 'calls': [[235, 234], [112, 202], [453, 498], [10, 30], [166, 186], [359, 358], [466, 471]]}, {'avg': 25, 'long_permille': 142, 'max': 90, 'count': 7}), ('sampled regression 51', {'end_s': 600, 'calls': [[553, None], [377, 422], [370, None], [180, 241]]}, {'avg': 95, 'long_permille': 500, 'max': 230, 'count': 4})]]
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:
Long-waiting unanswered calls vanish from the statistics.

Each hall call has a registration time and an answer time (None if still unanswered at end_s). Waits are answer - registration clamped at zero (clock skew); unanswered calls count with the censored wait end_s - registration. Report the integer mean (floor), per-mille of waits over 60 s (floor), the maximum and the count; all zeros when there are no calls.

split: open-access


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

N = 1
observations = []
def solve(x):
    waits = []
    for reg, ans in x['calls']:
        if ans is None:
            waits.append(x['end_s'] - reg)
        else:
            waits.append(ans - reg)
    if not waits:
        return {'avg': 0, 'long_permille': 0, 'max': 0, 'count': 0}
    longs = sum(1 for w in waits if w > 60)
    return {'avg': sum(waits) // len(waits), 'long_permille': longs * 1000 // len(waits), 'max': max(waits), 'count': len(waits)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: answer logged before registration', {'end_s': 600, 'calls': [[100, 98], [200, 230]]}, {'avg': 15, 'long_permille': 0, 'max': 30, 'count': 2}), ('sampled regression 17', {'end_s': 600, 'calls': [[26, None], [377, 374], [447, 492], [321, 411], [154, 151], [571, None], [283, 344]]}, {'avg': 114, 'long_permille': 428, 'max': 574, 'count': 7}), ('sampled regression 16', {'end_s': 600, 'calls': [[293, None], [565, None], [526, 586], [205, 202]]}, {'avg': 100, 'long_permille': 250, 'max': 307, 'count': 4}), ('boundary: unanswered call at the end', {'end_s': 600, 'calls': [[500, None], [10, 30]]}, {'avg': 60, 'long_permille': 500, 'max': 100, 'count': 2}), ('boundary: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('control 1', {'end_s': 600, 'calls': [[93, 138], [499, 519], [546, None], [485, None], [376, 526], [329, 419], [42, None], [303, None]]}, {'avg': 166, 'long_permille': 625, 'max': 558, 'count': 8}), ('sampled regression 4', {'end_s': 600, 'calls': [[15, None], [80, 100], [304, 324], [560, 557], [73, 78], [574, None]]}, {'avg': 109, 'long_permille': 166, 'max': 585, 'count': 6}), ('control 7', {'end_s': 600, 'calls': [[196, 216], [228, 248], [100, None], [381, 471], [370, 415], [56, 76]]}, {'avg': 115, 'long_permille': 333, 'max': 500, 'count': 6})], [('regression: answer logged before registration', {'end_s': 600, 'calls': [[100, 98], [200, 230]]}, {'avg': 15, 'long_permille': 0, 'max': 30, 'count': 2}), ('sampled regression 57', {'end_s': 600, 'calls': [[218, 216], [34, 184]]}, {'avg': 75, 'long_permille': 500, 'max': 150, 'count': 2}), ('control 48', {'end_s': 600, 'calls': [[235, 234], [112, 202], [453, 498], [10, 30], [166, 186], [359, 358], [466, 471]]}, {'avg': 25, 'long_permille': 142, 'max': 90, 'count': 7}), ('boundary: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('boundary: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('control 12', {'end_s': 600, 'calls': [[549, None], [34, 94], [153, 243]]}, {'avg': 67, 'long_permille': 333, 'max': 90, 'count': 3}), ('control 15', {'end_s': 600, 'calls': [[427, 472], [290, 440], [125, None], [18, 79], [88, 178], [156, 306], [7, None], [120, None]]}, {'avg': 255, 'long_permille': 875, 'max': 593, 'count': 8}), ('control 18', {'end_s': 600, 'calls': [[508, 528]]}, {'avg': 20, 'long_permille': 0, 'max': 20, 'count': 1})], [('regression: answer logged before registration', {'end_s': 600, 'calls': [[100, 98], [200, 230]]}, {'avg': 15, 'long_permille': 0, 'max': 30, 'count': 2}), ('sampled regression 4', {'end_s': 600, 'calls': [[15, None], [80, 100], [304, 324], [560, 557], [73, 78], [574, None]]}, {'avg': 109, 'long_permille': 166, 'max': 585, 'count': 6}), ('boundary: mean with a remainder', {'end_s': 600, 'calls': [[0, 10], [0, 11], [0, 11]]}, {'avg': 10, 'long_permille': 0, 'max': 11, 'count': 3}), ('boundary: no calls', {'end_s': 600, 'calls': []}, {'avg': 0, 'long_permille': 0, 'max': 0, 'count': 0}), ('boundary: unanswered call at the end', {'end_s': 600, 'calls': [[500, None], [10, 30]]}, {'avg': 60, 'long_permille': 500, 'max': 100, 'count': 2}), ('control 23', {'end_s': 600, 'calls': [[121, 141], [388, None], [577, None]]}, {'avg': 85, 'long_permille': 333, 'max': 212, 'count': 3}), ('control 26', {'end_s': 600, 'calls': [[205, 225], [336, 381]]}, {'avg': 32, 'long_permille': 0, 'max': 45, 'count': 2}), ('control 29', {'end_s': 600, 'calls': [[26, 31], [282, 287], [487, 577], [127, 187], [568, None], [130, 280], [335, 395], [184, 274]]}, {'avg': 61, 'long_permille': 375, 'max': 150, 'count': 8})], [('regression: answer logged before registration', {'end_s': 600, 'calls': [[100, 98], [200, 230]]}, {'avg': 15, 'long_permille': 0, 'max': 30, 'count': 2}), ('sampled regression 44', {'end_s': 600, 'calls': [[294, 299], [351, 396], [215, 276], [154, 244], [532, 577], [340, 337], [420, 481], [449, 510]]}, {'avg': 46, 'long_permille': 500, 'max': 90, 'count': 8}), ('sampled regression 38', {'end_s': 600, 'calls': [[292, 382], [521, 518]]}, {'avg': 45, 'long_permille': 500, 'max': 90, 'count': 2}), ('boundary: unanswered call at the end', {'end_s': 600, 'calls': [[500, None], [10, 30]]}, {'avg': 60, 'long_permille': 500, 'max': 100, 'count': 2}), ('boundary: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('control 34', {'end_s': 600, 'calls': [[526, 531], [100, 160], [338, None], [152, 242], [413, 433], [56, 117]]}, {'avg': 83, 'long_permille': 500, 'max': 262, 'count': 6}), ('sampled regression 37', {'end_s': 600, 'calls': [[542, 547], [483, None], [421, 418], [216, None]]}, {'avg': 126, 'long_permille': 500, 'max': 384, 'count': 4}), ('control 40', {'end_s': 600, 'calls': [[286, 346], [342, None], [309, 308], [91, 96], [519, 524], [518, None], [12, 73]]}, {'avg': 67, 'long_permille': 428, 'max': 258, 'count': 7})], [('regression: answer logged before registration', {'end_s': 600, 'calls': [[100, 98], [200, 230]]}, {'avg': 15, 'long_permille': 0, 'max': 30, 'count': 2}), ('sampled regression 77', {'end_s': 600, 'calls': [[391, 388]]}, {'avg': 0, 'long_permille': 0, 'max': 0, 'count': 1}), ('boundary: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('boundary: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('boundary: mean with a remainder', {'end_s': 600, 'calls': [[0, 10], [0, 11], [0, 11]]}, {'avg': 10, 'long_permille': 0, 'max': 11, 'count': 3}), ('control 45', {'end_s': 600, 'calls': [[54, 204], [360, None], [102, None], [487, None], [396, None]]}, {'avg': 241, 'long_permille': 1000, 'max': 498, 'count': 5}), ('control 48', {'end_s': 600, 'calls': [[235, 234], [112, 202], [453, 498], [10, 30], [166, 186], [359, 358], [466, 471]]}, {'avg': 25, 'long_permille': 142, 'max': 90, 'count': 7}), ('control 51', {'end_s': 600, 'calls': [[553, None], [377, 422], [370, None], [180, 241]]}, {'avg': 95, 'long_permille': 500, 'max': 230, 'count': 4})]]
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):
    waits = []
    for reg, ans in x['calls']:
        if ans is None:
            waits.append(x['end_s'] - reg)
        else:
            waits.append(abs(ans - reg))
    if not waits:
        return {'avg': 0, 'long_permille': 0, 'max': 0, 'count': 0}
    longs = sum(1 for w in waits if w > 60)
    return {'avg': sum(waits) // len(waits), 'long_permille': longs * 1000 // len(waits), 'max': max(waits), 'count': len(waits)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: answer logged before registration', {'end_s': 600, 'calls': [[100, 98], [200, 230]]}, {'avg': 15, 'long_permille': 0, 'max': 30, 'count': 2}), ('sampled regression 17', {'end_s': 600, 'calls': [[26, None], [377, 374], [447, 492], [321, 411], [154, 151], [571, None], [283, 344]]}, {'avg': 114, 'long_permille': 428, 'max': 574, 'count': 7}), ('sampled regression 16', {'end_s': 600, 'calls': [[293, None], [565, None], [526, 586], [205, 202]]}, {'avg': 100, 'long_permille': 250, 'max': 307, 'count': 4}), ('boundary: unanswered call at the end', {'end_s': 600, 'calls': [[500, None], [10, 30]]}, {'avg': 60, 'long_permille': 500, 'max': 100, 'count': 2}), ('boundary: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('control 1', {'end_s': 600, 'calls': [[93, 138], [499, 519], [546, None], [485, None], [376, 526], [329, 419], [42, None], [303, None]]}, {'avg': 166, 'long_permille': 625, 'max': 558, 'count': 8}), ('sampled regression 4', {'end_s': 600, 'calls': [[15, None], [80, 100], [304, 324], [560, 557], [73, 78], [574, None]]}, {'avg': 109, 'long_permille': 166, 'max': 585, 'count': 6}), ('control 7', {'end_s': 600, 'calls': [[196, 216], [228, 248], [100, None], [381, 471], [370, 415], [56, 76]]}, {'avg': 115, 'long_permille': 333, 'max': 500, 'count': 6})], [('regression: answer logged before registration', {'end_s': 600, 'calls': [[100, 98], [200, 230]]}, {'avg': 15, 'long_permille': 0, 'max': 30, 'count': 2}), ('sampled regression 57', {'end_s': 600, 'calls': [[218, 216], [34, 184]]}, {'avg': 75, 'long_permille': 500, 'max': 150, 'count': 2}), ('control 48', {'end_s': 600, 'calls': [[235, 234], [112, 202], [453, 498], [10, 30], [166, 186], [359, 358], [466, 471]]}, {'avg': 25, 'long_permille': 142, 'max': 90, 'count': 7}), ('boundary: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('boundary: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('control 12', {'end_s': 600, 'calls': [[549, None], [34, 94], [153, 243]]}, {'avg': 67, 'long_permille': 333, 'max': 90, 'count': 3}), ('control 15', {'end_s': 600, 'calls': [[427, 472], [290, 440], [125, None], [18, 79], [88, 178], [156, 306], [7, None], [120, None]]}, {'avg': 255, 'long_permille': 875, 'max': 593, 'count': 8}), ('control 18', {'end_s': 600, 'calls': [[508, 528]]}, {'avg': 20, 'long_permille': 0, 'max': 20, 'count': 1})], [('regression: answer logged before registration', {'end_s': 600, 'calls': [[100, 98], [200, 230]]}, {'avg': 15, 'long_permille': 0, 'max': 30, 'count': 2}), ('sampled regression 4', {'end_s': 600, 'calls': [[15, None], [80, 100], [304, 324], [560, 557], [73, 78], [574, None]]}, {'avg': 109, 'long_permille': 166, 'max': 585, 'count': 6}), ('boundary: mean with a remainder', {'end_s': 600, 'calls': [[0, 10], [0, 11], [0, 11]]}, {'avg': 10, 'long_permille': 0, 'max': 11, 'count': 3}), ('boundary: no calls', {'end_s': 600, 'calls': []}, {'avg': 0, 'long_permille': 0, 'max': 0, 'count': 0}), ('boundary: unanswered call at the end', {'end_s': 600, 'calls': [[500, None], [10, 30]]}, {'avg': 60, 'long_permille': 500, 'max': 100, 'count': 2}), ('control 23', {'end_s': 600, 'calls': [[121, 141], [388, None], [577, None]]}, {'avg': 85, 'long_permille': 333, 'max': 212, 'count': 3}), ('control 26', {'end_s': 600, 'calls': [[205, 225], [336, 381]]}, {'avg': 32, 'long_permille': 0, 'max': 45, 'count': 2}), ('control 29', {'end_s': 600, 'calls': [[26, 31], [282, 287], [487, 577], [127, 187], [568, None], [130, 280], [335, 395], [184, 274]]}, {'avg': 61, 'long_permille': 375, 'max': 150, 'count': 8})], [('regression: answer logged before registration', {'end_s': 600, 'calls': [[100, 98], [200, 230]]}, {'avg': 15, 'long_permille': 0, 'max': 30, 'count': 2}), ('sampled regression 44', {'end_s': 600, 'calls': [[294, 299], [351, 396], [215, 276], [154, 244], [532, 577], [340, 337], [420, 481], [449, 510]]}, {'avg': 46, 'long_permille': 500, 'max': 90, 'count': 8}), ('sampled regression 38', {'end_s': 600, 'calls': [[292, 382], [521, 518]]}, {'avg': 45, 'long_permille': 500, 'max': 90, 'count': 2}), ('boundary: unanswered call at the end', {'end_s': 600, 'calls': [[500, None], [10, 30]]}, {'avg': 60, 'long_permille': 500, 'max': 100, 'count': 2}), ('boundary: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('control 34', {'end_s': 600, 'calls': [[526, 531], [100, 160], [338, None], [152, 242], [413, 433], [56, 117]]}, {'avg': 83, 'long_permille': 500, 'max': 262, 'count': 6}), ('sampled regression 37', {'end_s': 600, 'calls': [[542, 547], [483, None], [421, 418], [216, None]]}, {'avg': 126, 'long_permille': 500, 'max': 384, 'count': 4}), ('control 40', {'end_s': 600, 'calls': [[286, 346], [342, None], [309, 308], [91, 96], [519, 524], [518, None], [12, 73]]}, {'avg': 67, 'long_permille': 428, 'max': 258, 'count': 7})], [('regression: answer logged before registration', {'end_s': 600, 'calls': [[100, 98], [200, 230]]}, {'avg': 15, 'long_permille': 0, 'max': 30, 'count': 2}), ('sampled regression 77', {'end_s': 600, 'calls': [[391, 388]]}, {'avg': 0, 'long_permille': 0, 'max': 0, 'count': 1}), ('boundary: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('boundary: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('boundary: mean with a remainder', {'end_s': 600, 'calls': [[0, 10], [0, 11], [0, 11]]}, {'avg': 10, 'long_permille': 0, 'max': 11, 'count': 3}), ('control 45', {'end_s': 600, 'calls': [[54, 204], [360, None], [102, None], [487, None], [396, None]]}, {'avg': 241, 'long_permille': 1000, 'max': 498, 'count': 5}), ('control 48', {'end_s': 600, 'calls': [[235, 234], [112, 202], [453, 498], [10, 30], [166, 186], [359, 358], [466, 471]]}, {'avg': 25, 'long_permille': 142, 'max': 90, 'count': 7}), ('control 51', {'end_s': 600, 'calls': [[553, None], [377, 422], [370, None], [180, 241]]}, {'avg': 95, 'long_permille': 500, 'max': 230, 'count': 4})]]
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:
Negative waits pull the average down.

Each hall call has a registration time and an answer time (None if still unanswered at end_s). Waits are answer - registration clamped at zero (clock skew); unanswered calls count with the censored wait end_s - registration. Report the integer mean (floor), per-mille of waits over 60 s (floor), the maximum and the count; all zeros when there are no calls.

split: open-access


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

N = 1
observations = []
def solve(x):
    waits = []
    for reg, ans in x['calls']:
        if ans is None:
            waits.append(x['end_s'] - reg)
        else:
            waits.append(max(0, ans - reg))
    if not waits:
        return {'avg': 0, 'long_permille': 0, 'max': 0, 'count': 0}
    longs = sum(1 for w in waits if w >= 60)
    return {'avg': sum(waits) // len(waits), 'long_permille': longs * 1000 // len(waits), 'max': max(waits), 'count': len(waits)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('boundary: unanswered call at the end', {'end_s': 600, 'calls': [[500, None], [10, 30]]}, {'avg': 60, 'long_permille': 500, 'max': 100, 'count': 2}), ('sampled regression 13', {'end_s': 600, 'calls': [[451, 511], [494, 539], [553, None], [26, None], [306, 367], [164, 314], [548, None], [406, 556]]}, {'avg': 142, 'long_permille': 500, 'max': 574, 'count': 8}), ('boundary: answer logged before registration', {'end_s': 600, 'calls': [[100, 98], [200, 230]]}, {'avg': 15, 'long_permille': 0, 'max': 30, 'count': 2}), ('boundary: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('control 1', {'end_s': 600, 'calls': [[93, 138], [499, 519], [546, None], [485, None], [376, 526], [329, 419], [42, None], [303, None]]}, {'avg': 166, 'long_permille': 625, 'max': 558, 'count': 8}), ('control 4', {'end_s': 600, 'calls': [[15, None], [80, 100], [304, 324], [560, 557], [73, 78], [574, None]]}, {'avg': 109, 'long_permille': 166, 'max': 585, 'count': 6}), ('control 7', {'end_s': 600, 'calls': [[196, 216], [228, 248], [100, None], [381, 471], [370, 415], [56, 76]]}, {'avg': 115, 'long_permille': 333, 'max': 500, 'count': 6})], [('regression: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('sampled regression 40', {'end_s': 600, 'calls': [[286, 346], [342, None], [309, 308], [91, 96], [519, 524], [518, None], [12, 73]]}, {'avg': 67, 'long_permille': 428, 'max': 258, 'count': 7}), ('control 5', {'end_s': 600, 'calls': [[33, 123], [260, None], [120, 125], [150, 240], [547, 567], [556, 554], [207, 252], [567, 587]]}, {'avg': 76, 'long_permille': 375, 'max': 340, 'count': 8}), ('boundary: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('boundary: mean with a remainder', {'end_s': 600, 'calls': [[0, 10], [0, 11], [0, 11]]}, {'avg': 10, 'long_permille': 0, 'max': 11, 'count': 3}), ('sampled regression 12', {'end_s': 600, 'calls': [[549, None], [34, 94], [153, 243]]}, {'avg': 67, 'long_permille': 333, 'max': 90, 'count': 3}), ('control 15', {'end_s': 600, 'calls': [[427, 472], [290, 440], [125, None], [18, 79], [88, 178], [156, 306], [7, None], [120, None]]}, {'avg': 255, 'long_permille': 875, 'max': 593, 'count': 8}), ('control 18', {'end_s': 600, 'calls': [[508, 528]]}, {'avg': 20, 'long_permille': 0, 'max': 20, 'count': 1})], [('regression: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('boundary: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('sampled regression 61', {'end_s': 600, 'calls': [[410, 415], [504, 564], [213, 258], [291, None], [359, None], [364, 369], [125, None]]}, {'avg': 162, 'long_permille': 428, 'max': 475, 'count': 7}), ('control 11', {'end_s': 600, 'calls': [[132, 152], [202, 247], [472, None], [462, 507], [80, 85], [378, None]]}, {'avg': 77, 'long_permille': 333, 'max': 222, 'count': 6}), ('boundary: mean with a remainder', {'end_s': 600, 'calls': [[0, 10], [0, 11], [0, 11]]}, {'avg': 10, 'long_permille': 0, 'max': 11, 'count': 3}), ('control 23', {'end_s': 600, 'calls': [[121, 141], [388, None], [577, None]]}, {'avg': 85, 'long_permille': 333, 'max': 212, 'count': 3}), ('control 26', {'end_s': 600, 'calls': [[205, 225], [336, 381]]}, {'avg': 32, 'long_permille': 0, 'max': 45, 'count': 2}), ('sampled regression 29', {'end_s': 600, 'calls': [[26, 31], [282, 287], [487, 577], [127, 187], [568, None], [130, 280], [335, 395], [184, 274]]}, {'avg': 61, 'long_permille': 375, 'max': 150, 'count': 8})], [('regression: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('boundary: unanswered call at the end', {'end_s': 600, 'calls': [[500, None], [10, 30]]}, {'avg': 60, 'long_permille': 500, 'max': 100, 'count': 2}), ('sampled regression 80', {'end_s': 600, 'calls': [[219, 280], [536, 541], [424, 484], [130, None], [104, 164], [442, 441], [286, 436]]}, {'avg': 115, 'long_permille': 428, 'max': 470, 'count': 7}), ('sampled regression 16', {'end_s': 600, 'calls': [[293, None], [565, None], [526, 586], [205, 202]]}, {'avg': 100, 'long_permille': 250, 'max': 307, 'count': 4}), ('boundary: answer logged before registration', {'end_s': 600, 'calls': [[100, 98], [200, 230]]}, {'avg': 15, 'long_permille': 0, 'max': 30, 'count': 2}), ('sampled regression 34', {'end_s': 600, 'calls': [[526, 531], [100, 160], [338, None], [152, 242], [413, 433], [56, 117]]}, {'avg': 83, 'long_permille': 500, 'max': 262, 'count': 6}), ('control 37', {'end_s': 600, 'calls': [[542, 547], [483, None], [421, 418], [216, None]]}, {'avg': 126, 'long_permille': 500, 'max': 384, 'count': 4}), ('sampled regression 40', {'end_s': 600, 'calls': [[286, 346], [342, None], [309, 308], [91, 96], [519, 524], [518, None], [12, 73]]}, {'avg': 67, 'long_permille': 428, 'max': 258, 'count': 7})], [('regression: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('sampled regression 20', {'end_s': 600, 'calls': [[520, None], [447, 467], [161, 221], [506, 511], [146, 296], [576, None], [73, 223], [194, 214]]}, {'avg': 63, 'long_permille': 375, 'max': 150, 'count': 8}), ('control 22', {'end_s': 600, 'calls': [[271, 421], [385, 446]]}, {'avg': 105, 'long_permille': 1000, 'max': 150, 'count': 2}), ('boundary: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('boundary: mean with a remainder', {'end_s': 600, 'calls': [[0, 10], [0, 11], [0, 11]]}, {'avg': 10, 'long_permille': 0, 'max': 11, 'count': 3}), ('control 45', {'end_s': 600, 'calls': [[54, 204], [360, None], [102, None], [487, None], [396, None]]}, {'avg': 241, 'long_permille': 1000, 'max': 498, 'count': 5}), ('control 48', {'end_s': 600, 'calls': [[235, 234], [112, 202], [453, 498], [10, 30], [166, 186], [359, 358], [466, 471]]}, {'avg': 25, 'long_permille': 142, 'max': 90, 'count': 7}), ('control 51', {'end_s': 600, 'calls': [[553, None], [377, 422], [370, None], [180, 241]]}, {'avg': 95, 'long_permille': 500, 'max': 230, 'count': 4})]]
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):
    waits = []
    for reg, ans in x['calls']:
        if ans is None:
            waits.append(x['end_s'] - reg)
        else:
            waits.append(max(0, ans - reg))
    if not waits:
        return {'avg': 0, 'long_permille': 0, 'max': 0, 'count': 0}
    longs = sum(1 for w in waits if w > 60 * 1000)
    return {'avg': sum(waits) // len(waits), 'long_permille': longs * 1000 // len(waits), 'max': max(waits), 'count': len(waits)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('boundary: unanswered call at the end', {'end_s': 600, 'calls': [[500, None], [10, 30]]}, {'avg': 60, 'long_permille': 500, 'max': 100, 'count': 2}), ('sampled regression 13', {'end_s': 600, 'calls': [[451, 511], [494, 539], [553, None], [26, None], [306, 367], [164, 314], [548, None], [406, 556]]}, {'avg': 142, 'long_permille': 500, 'max': 574, 'count': 8}), ('boundary: answer logged before registration', {'end_s': 600, 'calls': [[100, 98], [200, 230]]}, {'avg': 15, 'long_permille': 0, 'max': 30, 'count': 2}), ('boundary: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('control 1', {'end_s': 600, 'calls': [[93, 138], [499, 519], [546, None], [485, None], [376, 526], [329, 419], [42, None], [303, None]]}, {'avg': 166, 'long_permille': 625, 'max': 558, 'count': 8}), ('control 4', {'end_s': 600, 'calls': [[15, None], [80, 100], [304, 324], [560, 557], [73, 78], [574, None]]}, {'avg': 109, 'long_permille': 166, 'max': 585, 'count': 6}), ('control 7', {'end_s': 600, 'calls': [[196, 216], [228, 248], [100, None], [381, 471], [370, 415], [56, 76]]}, {'avg': 115, 'long_permille': 333, 'max': 500, 'count': 6})], [('regression: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('sampled regression 40', {'end_s': 600, 'calls': [[286, 346], [342, None], [309, 308], [91, 96], [519, 524], [518, None], [12, 73]]}, {'avg': 67, 'long_permille': 428, 'max': 258, 'count': 7}), ('control 5', {'end_s': 600, 'calls': [[33, 123], [260, None], [120, 125], [150, 240], [547, 567], [556, 554], [207, 252], [567, 587]]}, {'avg': 76, 'long_permille': 375, 'max': 340, 'count': 8}), ('boundary: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('boundary: mean with a remainder', {'end_s': 600, 'calls': [[0, 10], [0, 11], [0, 11]]}, {'avg': 10, 'long_permille': 0, 'max': 11, 'count': 3}), ('sampled regression 12', {'end_s': 600, 'calls': [[549, None], [34, 94], [153, 243]]}, {'avg': 67, 'long_permille': 333, 'max': 90, 'count': 3}), ('control 15', {'end_s': 600, 'calls': [[427, 472], [290, 440], [125, None], [18, 79], [88, 178], [156, 306], [7, None], [120, None]]}, {'avg': 255, 'long_permille': 875, 'max': 593, 'count': 8}), ('control 18', {'end_s': 600, 'calls': [[508, 528]]}, {'avg': 20, 'long_permille': 0, 'max': 20, 'count': 1})], [('regression: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('boundary: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('sampled regression 61', {'end_s': 600, 'calls': [[410, 415], [504, 564], [213, 258], [291, None], [359, None], [364, 369], [125, None]]}, {'avg': 162, 'long_permille': 428, 'max': 475, 'count': 7}), ('control 11', {'end_s': 600, 'calls': [[132, 152], [202, 247], [472, None], [462, 507], [80, 85], [378, None]]}, {'avg': 77, 'long_permille': 333, 'max': 222, 'count': 6}), ('boundary: mean with a remainder', {'end_s': 600, 'calls': [[0, 10], [0, 11], [0, 11]]}, {'avg': 10, 'long_permille': 0, 'max': 11, 'count': 3}), ('control 23', {'end_s': 600, 'calls': [[121, 141], [388, None], [577, None]]}, {'avg': 85, 'long_permille': 333, 'max': 212, 'count': 3}), ('control 26', {'end_s': 600, 'calls': [[205, 225], [336, 381]]}, {'avg': 32, 'long_permille': 0, 'max': 45, 'count': 2}), ('sampled regression 29', {'end_s': 600, 'calls': [[26, 31], [282, 287], [487, 577], [127, 187], [568, None], [130, 280], [335, 395], [184, 274]]}, {'avg': 61, 'long_permille': 375, 'max': 150, 'count': 8})], [('regression: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('boundary: unanswered call at the end', {'end_s': 600, 'calls': [[500, None], [10, 30]]}, {'avg': 60, 'long_permille': 500, 'max': 100, 'count': 2}), ('sampled regression 80', {'end_s': 600, 'calls': [[219, 280], [536, 541], [424, 484], [130, None], [104, 164], [442, 441], [286, 436]]}, {'avg': 115, 'long_permille': 428, 'max': 470, 'count': 7}), ('sampled regression 16', {'end_s': 600, 'calls': [[293, None], [565, None], [526, 586], [205, 202]]}, {'avg': 100, 'long_permille': 250, 'max': 307, 'count': 4}), ('boundary: answer logged before registration', {'end_s': 600, 'calls': [[100, 98], [200, 230]]}, {'avg': 15, 'long_permille': 0, 'max': 30, 'count': 2}), ('sampled regression 34', {'end_s': 600, 'calls': [[526, 531], [100, 160], [338, None], [152, 242], [413, 433], [56, 117]]}, {'avg': 83, 'long_permille': 500, 'max': 262, 'count': 6}), ('control 37', {'end_s': 600, 'calls': [[542, 547], [483, None], [421, 418], [216, None]]}, {'avg': 126, 'long_permille': 500, 'max': 384, 'count': 4}), ('sampled regression 40', {'end_s': 600, 'calls': [[286, 346], [342, None], [309, 308], [91, 96], [519, 524], [518, None], [12, 73]]}, {'avg': 67, 'long_permille': 428, 'max': 258, 'count': 7})], [('regression: wait of exactly sixty seconds', {'end_s': 600, 'calls': [[0, 60], [100, 161]]}, {'avg': 60, 'long_permille': 500, 'max': 61, 'count': 2}), ('sampled regression 20', {'end_s': 600, 'calls': [[520, None], [447, 467], [161, 221], [506, 511], [146, 296], [576, None], [73, 223], [194, 214]]}, {'avg': 63, 'long_permille': 375, 'max': 150, 'count': 8}), ('control 22', {'end_s': 600, 'calls': [[271, 421], [385, 446]]}, {'avg': 105, 'long_permille': 1000, 'max': 150, 'count': 2}), ('boundary: long unanswered call', {'end_s': 600, 'calls': [[400, None], [0, 10], [5, 15]]}, {'avg': 73, 'long_permille': 333, 'max': 200, 'count': 3}), ('boundary: mean with a remainder', {'end_s': 600, 'calls': [[0, 10], [0, 11], [0, 11]]}, {'avg': 10, 'long_permille': 0, 'max': 11, 'count': 3}), ('control 45', {'end_s': 600, 'calls': [[54, 204], [360, None], [102, None], [487, None], [396, None]]}, {'avg': 241, 'long_permille': 1000, 'max': 498, 'count': 5}), ('control 48', {'end_s': 600, 'calls': [[235, 234], [112, 202], [453, 498], [10, 30], [166, 186], [359, 358], [466, 471]]}, {'avg': 25, 'long_permille': 142, 'max': 90, 'count': 7}), ('control 51', {'end_s': 600, 'calls': [[553, None], [377, 422], [370, None], [180, 241]]}, {'avg': 95, 'long_permille': 500, 'max': 230, 'count': 4})]]
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:
Calls answered in exactly sixty seconds count as long waits, or none ever do.

Each hall call has a registration time and an answer time (None if still unanswered at end_s). Waits are answer - registration clamped at zero (clock skew); unanswered calls count with the censored wait end_s - registration. Report the integer mean (floor), per-mille of waits over 60 s (floor), the maximum and the count; all zeros when there are no calls.

split: open-access