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

N = 1
observations = []
def solve(x):
    mode = 'interfloor'
    out = []
    for w in x['windows']:
        tot = w['lobby_up'] + w['other_up'] + w['down']
        up_pct = w['lobby_up'] * 100 // tot if tot else 0
        dn_pct = w['to_lobby'] * 100 // tot if tot else 0
        if mode == 'up-peak':
            if up_pct < 60 or tot < 10:
                mode = 'interfloor'
        elif mode == 'down-peak':
            if dn_pct < 40 or tot < 10:
                mode = 'interfloor'
        if mode == 'interfloor' and tot >= 10:
            if up_pct >= 60:
                mode = 'up-peak'
            elif dn_pct >= 60:
                mode = 'down-peak'
        out.append(mode)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('sampled regression 22', {'windows': [{'lobby_up': 0, 'other_up': 0, 'down': 15, 'to_lobby': 7}, {'lobby_up': 7, 'other_up': 4, 'down': 18, 'to_lobby': 0}, {'lobby_up': 10, 'other_up': 0, 'down': 4, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 7, 'down': 4, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 2, 'down': 20, 'to_lobby': 14}, {'lobby_up': 6, 'other_up': 5, 'down': 11, 'to_lobby': 11}, {'lobby_up': 0, 'other_up': 6, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'interfloor', 'interfloor']), ('sampled regression 16', {'windows': [{'lobby_up': 1, 'other_up': 0, 'down': 6, 'to_lobby': 5}, {'lobby_up': 18, 'other_up': 8, 'down': 13, 'to_lobby': 0}, {'lobby_up': 18, 'other_up': 6, 'down': 2, 'to_lobby': 2}, {'lobby_up': 8, 'other_up': 6, 'down': 12, 'to_lobby': 6}, {'lobby_up': 17, 'other_up': 7, 'down': 7, 'to_lobby': 4}, {'lobby_up': 4, 'other_up': 8, 'down': 8, 'to_lobby': 6}, {'lobby_up': 18, 'other_up': 4, 'down': 0, 'to_lobby': 0}, {'lobby_up': 14, 'other_up': 4, 'down': 10, 'to_lobby': 10}]}, ['interfloor', 'interfloor', 'up-peak', 'interfloor', 'interfloor', 'interfloor', 'up-peak', 'up-peak']), ('sampled regression 67', {'windows': [{'lobby_up': 7, 'other_up': 0, 'down': 15, 'to_lobby': 4}, {'lobby_up': 8, 'other_up': 7, 'down': 9, 'to_lobby': 2}, {'lobby_up': 17, 'other_up': 1, 'down': 9, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 0, 'down': 15, 'to_lobby': 10}, {'lobby_up': 12, 'other_up': 1, 'down': 17, 'to_lobby': 1}, {'lobby_up': 19, 'other_up': 3, 'down': 15, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 7, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'up-peak', 'up-peak']), ('boundary: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('control 1', {'windows': [{'lobby_up': 0, 'other_up': 2, 'down': 3, 'to_lobby': 3}, {'lobby_up': 10, 'other_up': 4, 'down': 12, 'to_lobby': 11}, {'lobby_up': 0, 'other_up': 6, 'down': 8, 'to_lobby': 2}, {'lobby_up': 17, 'other_up': 3, 'down': 17, 'to_lobby': 15}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('control 4', {'windows': [{'lobby_up': 18, 'other_up': 3, 'down': 8, 'to_lobby': 4}, {'lobby_up': 2, 'other_up': 3, 'down': 15, 'to_lobby': 5}, {'lobby_up': 20, 'other_up': 6, 'down': 15, 'to_lobby': 15}, {'lobby_up': 16, 'other_up': 5, 'down': 19, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 6, 'down': 16, 'to_lobby': 6}, {'lobby_up': 1, 'other_up': 8, 'down': 0, 'to_lobby': 0}, {'lobby_up': 1, 'other_up': 2, 'down': 8, 'to_lobby': 8}, {'lobby_up': 6, 'other_up': 6, 'down': 0, 'to_lobby': 0}]}, ['up-peak', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'down-peak', 'interfloor']), ('sampled regression 7', {'windows': [{'lobby_up': 17, 'other_up': 7, 'down': 6, 'to_lobby': 6}, {'lobby_up': 7, 'other_up': 3, 'down': 4, 'to_lobby': 3}, {'lobby_up': 20, 'other_up': 8, 'down': 2, 'to_lobby': 1}, {'lobby_up': 17, 'other_up': 7, 'down': 7, 'to_lobby': 6}, {'lobby_up': 2, 'other_up': 3, 'down': 8, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 3, 'down': 16, 'to_lobby': 7}, {'lobby_up': 5, 'other_up': 5, 'down': 1, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'interfloor', 'interfloor', 'interfloor'])], [('regression: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('sampled regression 67', {'windows': [{'lobby_up': 7, 'other_up': 0, 'down': 15, 'to_lobby': 4}, {'lobby_up': 8, 'other_up': 7, 'down': 9, 'to_lobby': 2}, {'lobby_up': 17, 'other_up': 1, 'down': 9, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 0, 'down': 15, 'to_lobby': 10}, {'lobby_up': 12, 'other_up': 1, 'down': 17, 'to_lobby': 1}, {'lobby_up': 19, 'other_up': 3, 'down': 15, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 7, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'up-peak', 'up-peak']), ('sampled regression 50', {'windows': [{'lobby_up': 13, 'other_up': 3, 'down': 2, 'to_lobby': 2}, {'lobby_up': 9, 'other_up': 8, 'down': 8, 'to_lobby': 8}, {'lobby_up': 18, 'other_up': 2, 'down': 6, 'to_lobby': 2}, {'lobby_up': 13, 'other_up': 7, 'down': 10, 'to_lobby': 10}, {'lobby_up': 12, 'other_up': 5, 'down': 17, 'to_lobby': 13}]}, ['up-peak', 'interfloor', 'up-peak', 'up-peak', 'interfloor']), ('sampled regression 22', {'windows': [{'lobby_up': 0, 'other_up': 0, 'down': 15, 'to_lobby': 7}, {'lobby_up': 7, 'other_up': 4, 'down': 18, 'to_lobby': 0}, {'lobby_up': 10, 'other_up': 0, 'down': 4, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 7, 'down': 4, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 2, 'down': 20, 'to_lobby': 14}, {'lobby_up': 6, 'other_up': 5, 'down': 11, 'to_lobby': 11}, {'lobby_up': 0, 'other_up': 6, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'interfloor', 'interfloor']), ('boundary: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('control 12', {'windows': [{'lobby_up': 16, 'other_up': 6, 'down': 0, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 4, 'down': 13, 'to_lobby': 8}, {'lobby_up': 6, 'other_up': 1, 'down': 17, 'to_lobby': 7}, {'lobby_up': 20, 'other_up': 8, 'down': 13, 'to_lobby': 11}, {'lobby_up': 19, 'other_up': 5, 'down': 0, 'to_lobby': 0}, {'lobby_up': 2, 'other_up': 6, 'down': 20, 'to_lobby': 10}, {'lobby_up': 17, 'other_up': 1, 'down': 5, 'to_lobby': 4}]}, ['up-peak', 'interfloor', 'interfloor', 'interfloor', 'up-peak', 'interfloor', 'up-peak']), ('control 15', {'windows': [{'lobby_up': 8, 'other_up': 2, 'down': 2, 'to_lobby': 2}, {'lobby_up': 2, 'other_up': 0, 'down': 19, 'to_lobby': 13}, {'lobby_up': 11, 'other_up': 7, 'down': 20, 'to_lobby': 2}, {'lobby_up': 13, 'other_up': 7, 'down': 5, 'to_lobby': 5}, {'lobby_up': 1, 'other_up': 6, 'down': 7, 'to_lobby': 2}, {'lobby_up': 3, 'other_up': 1, 'down': 20, 'to_lobby': 20}]}, ['up-peak', 'down-peak', 'interfloor', 'interfloor', 'interfloor', 'down-peak']), ('control 18', {'windows': [{'lobby_up': 9, 'other_up': 7, 'down': 0, 'to_lobby': 0}, {'lobby_up': 18, 'other_up': 8, 'down': 11, 'to_lobby': 5}, {'lobby_up': 2, 'other_up': 6, 'down': 8, 'to_lobby': 3}, {'lobby_up': 10, 'other_up': 4, 'down': 20, 'to_lobby': 1}, {'lobby_up': 13, 'other_up': 5, 'down': 19, 'to_lobby': 12}, {'lobby_up': 1, 'other_up': 5, 'down': 16, 'to_lobby': 4}, {'lobby_up': 12, 'other_up': 6, 'down': 11, 'to_lobby': 2}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor'])], [('regression: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('sampled regression 22', {'windows': [{'lobby_up': 0, 'other_up': 0, 'down': 15, 'to_lobby': 7}, {'lobby_up': 7, 'other_up': 4, 'down': 18, 'to_lobby': 0}, {'lobby_up': 10, 'other_up': 0, 'down': 4, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 7, 'down': 4, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 2, 'down': 20, 'to_lobby': 14}, {'lobby_up': 6, 'other_up': 5, 'down': 11, 'to_lobby': 11}, {'lobby_up': 0, 'other_up': 6, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'interfloor', 'interfloor']), ('sampled regression 75', {'windows': [{'lobby_up': 4, 'other_up': 5, 'down': 11, 'to_lobby': 10}, {'lobby_up': 7, 'other_up': 6, 'down': 4, 'to_lobby': 4}, {'lobby_up': 19, 'other_up': 7, 'down': 2, 'to_lobby': 1}, {'lobby_up': 6, 'other_up': 8, 'down': 14, 'to_lobby': 4}, {'lobby_up': 18, 'other_up': 0, 'down': 17, 'to_lobby': 12}, {'lobby_up': 6, 'other_up': 3, 'down': 0, 'to_lobby': 0}, {'lobby_up': 17, 'other_up': 6, 'down': 4, 'to_lobby': 1}, {'lobby_up': 20, 'other_up': 2, 'down': 19, 'to_lobby': 14}]}, ['interfloor', 'interfloor', 'up-peak', 'interfloor', 'interfloor', 'interfloor', 'up-peak', 'up-peak']), ('sampled regression 67', {'windows': [{'lobby_up': 7, 'other_up': 0, 'down': 15, 'to_lobby': 4}, {'lobby_up': 8, 'other_up': 7, 'down': 9, 'to_lobby': 2}, {'lobby_up': 17, 'other_up': 1, 'down': 9, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 0, 'down': 15, 'to_lobby': 10}, {'lobby_up': 12, 'other_up': 1, 'down': 17, 'to_lobby': 1}, {'lobby_up': 19, 'other_up': 3, 'down': 15, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 7, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'up-peak', 'up-peak']), ('boundary: fraction just under sixty', {'windows': [{'lobby_up': 119, 'other_up': 41, 'down': 40, 'to_lobby': 0}]}, ['interfloor']), ('control 23', {'windows': [{'lobby_up': 6, 'other_up': 6, 'down': 20, 'to_lobby': 19}, {'lobby_up': 4, 'other_up': 7, 'down': 17, 'to_lobby': 9}, {'lobby_up': 3, 'other_up': 8, 'down': 7, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 8, 'down': 3, 'to_lobby': 2}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('control 26', {'windows': [{'lobby_up': 6, 'other_up': 0, 'down': 20, 'to_lobby': 17}, {'lobby_up': 17, 'other_up': 3, 'down': 18, 'to_lobby': 1}, {'lobby_up': 6, 'other_up': 5, 'down': 7, 'to_lobby': 0}, {'lobby_up': 17, 'other_up': 8, 'down': 20, 'to_lobby': 8}, {'lobby_up': 3, 'other_up': 5, 'down': 5, 'to_lobby': 0}, {'lobby_up': 12, 'other_up': 3, 'down': 20, 'to_lobby': 19}, {'lobby_up': 17, 'other_up': 2, 'down': 1, 'to_lobby': 1}, {'lobby_up': 7, 'other_up': 5, 'down': 9, 'to_lobby': 6}]}, ['down-peak', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'up-peak', 'interfloor']), ('control 29', {'windows': [{'lobby_up': 19, 'other_up': 4, 'down': 20, 'to_lobby': 10}, {'lobby_up': 6, 'other_up': 5, 'down': 9, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 0, 'down': 17, 'to_lobby': 0}, {'lobby_up': 19, 'other_up': 4, 'down': 8, 'to_lobby': 1}]}, ['interfloor', 'interfloor', 'interfloor', 'up-peak'])], [('regression: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('sampled regression 67', {'windows': [{'lobby_up': 7, 'other_up': 0, 'down': 15, 'to_lobby': 4}, {'lobby_up': 8, 'other_up': 7, 'down': 9, 'to_lobby': 2}, {'lobby_up': 17, 'other_up': 1, 'down': 9, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 0, 'down': 15, 'to_lobby': 10}, {'lobby_up': 12, 'other_up': 1, 'down': 17, 'to_lobby': 1}, {'lobby_up': 19, 'other_up': 3, 'down': 15, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 7, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'up-peak', 'up-peak']), ('sampled regression 22', {'windows': [{'lobby_up': 0, 'other_up': 0, 'down': 15, 'to_lobby': 7}, {'lobby_up': 7, 'other_up': 4, 'down': 18, 'to_lobby': 0}, {'lobby_up': 10, 'other_up': 0, 'down': 4, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 7, 'down': 4, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 2, 'down': 20, 'to_lobby': 14}, {'lobby_up': 6, 'other_up': 5, 'down': 11, 'to_lobby': 11}, {'lobby_up': 0, 'other_up': 6, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'interfloor', 'interfloor']), ('boundary: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('boundary: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('control 34', {'windows': [{'lobby_up': 14, 'other_up': 3, 'down': 13, 'to_lobby': 8}, {'lobby_up': 8, 'other_up': 4, 'down': 1, 'to_lobby': 1}, {'lobby_up': 20, 'other_up': 0, 'down': 3, 'to_lobby': 3}, {'lobby_up': 4, 'other_up': 5, 'down': 8, 'to_lobby': 7}, {'lobby_up': 6, 'other_up': 6, 'down': 19, 'to_lobby': 5}, {'lobby_up': 6, 'other_up': 5, 'down': 7, 'to_lobby': 5}]}, ['interfloor', 'up-peak', 'up-peak', 'interfloor', 'interfloor', 'interfloor']), ('control 37', {'windows': [{'lobby_up': 16, 'other_up': 8, 'down': 17, 'to_lobby': 12}, {'lobby_up': 16, 'other_up': 3, 'down': 11, 'to_lobby': 0}, {'lobby_up': 4, 'other_up': 8, 'down': 1, 'to_lobby': 0}, {'lobby_up': 10, 'other_up': 5, 'down': 8, 'to_lobby': 5}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('sampled regression 40', {'windows': [{'lobby_up': 7, 'other_up': 6, 'down': 2, 'to_lobby': 1}, {'lobby_up': 11, 'other_up': 2, 'down': 1, 'to_lobby': 0}, {'lobby_up': 18, 'other_up': 7, 'down': 16, 'to_lobby': 4}, {'lobby_up': 0, 'other_up': 8, 'down': 18, 'to_lobby': 1}, {'lobby_up': 1, 'other_up': 2, 'down': 12, 'to_lobby': 9}, {'lobby_up': 7, 'other_up': 3, 'down': 0, 'to_lobby': 0}]}, ['interfloor', 'up-peak', 'up-peak', 'interfloor', 'down-peak', 'up-peak'])], [('regression: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('sampled regression 22', {'windows': [{'lobby_up': 0, 'other_up': 0, 'down': 15, 'to_lobby': 7}, {'lobby_up': 7, 'other_up': 4, 'down': 18, 'to_lobby': 0}, {'lobby_up': 10, 'other_up': 0, 'down': 4, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 7, 'down': 4, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 2, 'down': 20, 'to_lobby': 14}, {'lobby_up': 6, 'other_up': 5, 'down': 11, 'to_lobby': 11}, {'lobby_up': 0, 'other_up': 6, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'interfloor', 'interfloor']), ('sampled regression 53', {'windows': [{'lobby_up': 16, 'other_up': 7, 'down': 15, 'to_lobby': 3}, {'lobby_up': 20, 'other_up': 7, 'down': 6, 'to_lobby': 1}, {'lobby_up': 15, 'other_up': 2, 'down': 9, 'to_lobby': 3}]}, ['interfloor', 'up-peak', 'up-peak']), ('sampled regression 67', {'windows': [{'lobby_up': 7, 'other_up': 0, 'down': 15, 'to_lobby': 4}, {'lobby_up': 8, 'other_up': 7, 'down': 9, 'to_lobby': 2}, {'lobby_up': 17, 'other_up': 1, 'down': 9, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 0, 'down': 15, 'to_lobby': 10}, {'lobby_up': 12, 'other_up': 1, 'down': 17, 'to_lobby': 1}, {'lobby_up': 19, 'other_up': 3, 'down': 15, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 7, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'up-peak', 'up-peak']), ('boundary: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('control 45', {'windows': [{'lobby_up': 15, 'other_up': 5, 'down': 7, 'to_lobby': 2}, {'lobby_up': 5, 'other_up': 7, 'down': 14, 'to_lobby': 0}, {'lobby_up': 17, 'other_up': 2, 'down': 13, 'to_lobby': 4}, {'lobby_up': 3, 'other_up': 3, 'down': 10, 'to_lobby': 7}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('control 48', {'windows': [{'lobby_up': 0, 'other_up': 3, 'down': 12, 'to_lobby': 1}, {'lobby_up': 19, 'other_up': 1, 'down': 12, 'to_lobby': 11}, {'lobby_up': 8, 'other_up': 2, 'down': 4, 'to_lobby': 3}, {'lobby_up': 18, 'other_up': 8, 'down': 1, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 7, 'down': 18, 'to_lobby': 17}, {'lobby_up': 11, 'other_up': 1, 'down': 18, 'to_lobby': 7}, {'lobby_up': 10, 'other_up': 2, 'down': 15, 'to_lobby': 2}]}, ['interfloor', 'interfloor', 'interfloor', 'up-peak', 'interfloor', 'interfloor', 'interfloor']), ('control 51', {'windows': [{'lobby_up': 4, 'other_up': 0, 'down': 1, 'to_lobby': 0}, {'lobby_up': 16, 'other_up': 6, 'down': 19, 'to_lobby': 15}, {'lobby_up': 13, 'other_up': 6, 'down': 3, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 0, 'down': 16, 'to_lobby': 2}, {'lobby_up': 20, 'other_up': 8, 'down': 11, 'to_lobby': 7}, {'lobby_up': 10, 'other_up': 5, 'down': 6, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 6, 'down': 19, 'to_lobby': 0}, {'lobby_up': 20, 'other_up': 2, 'down': 1, 'to_lobby': 1}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'up-peak'])]]
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):
    mode = 'interfloor'
    out = []
    for w in x['windows']:
        tot = w['lobby_up'] + w['other_up'] + w['down']
        up_pct = w['lobby_up'] * 100 // tot if tot else 0
        dn_pct = w['to_lobby'] * 100 // tot if tot else 0
        if mode == 'up-peak':
            if up_pct <= 40 or tot < 10:
                mode = 'interfloor'
        elif mode == 'down-peak':
            if dn_pct < 40 or tot < 10:
                mode = 'interfloor'
        if mode == 'interfloor' and tot >= 10:
            if up_pct >= 60:
                mode = 'up-peak'
            elif dn_pct >= 60:
                mode = 'down-peak'
        out.append(mode)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('sampled regression 22', {'windows': [{'lobby_up': 0, 'other_up': 0, 'down': 15, 'to_lobby': 7}, {'lobby_up': 7, 'other_up': 4, 'down': 18, 'to_lobby': 0}, {'lobby_up': 10, 'other_up': 0, 'down': 4, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 7, 'down': 4, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 2, 'down': 20, 'to_lobby': 14}, {'lobby_up': 6, 'other_up': 5, 'down': 11, 'to_lobby': 11}, {'lobby_up': 0, 'other_up': 6, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'interfloor', 'interfloor']), ('sampled regression 16', {'windows': [{'lobby_up': 1, 'other_up': 0, 'down': 6, 'to_lobby': 5}, {'lobby_up': 18, 'other_up': 8, 'down': 13, 'to_lobby': 0}, {'lobby_up': 18, 'other_up': 6, 'down': 2, 'to_lobby': 2}, {'lobby_up': 8, 'other_up': 6, 'down': 12, 'to_lobby': 6}, {'lobby_up': 17, 'other_up': 7, 'down': 7, 'to_lobby': 4}, {'lobby_up': 4, 'other_up': 8, 'down': 8, 'to_lobby': 6}, {'lobby_up': 18, 'other_up': 4, 'down': 0, 'to_lobby': 0}, {'lobby_up': 14, 'other_up': 4, 'down': 10, 'to_lobby': 10}]}, ['interfloor', 'interfloor', 'up-peak', 'interfloor', 'interfloor', 'interfloor', 'up-peak', 'up-peak']), ('sampled regression 67', {'windows': [{'lobby_up': 7, 'other_up': 0, 'down': 15, 'to_lobby': 4}, {'lobby_up': 8, 'other_up': 7, 'down': 9, 'to_lobby': 2}, {'lobby_up': 17, 'other_up': 1, 'down': 9, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 0, 'down': 15, 'to_lobby': 10}, {'lobby_up': 12, 'other_up': 1, 'down': 17, 'to_lobby': 1}, {'lobby_up': 19, 'other_up': 3, 'down': 15, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 7, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'up-peak', 'up-peak']), ('boundary: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('control 1', {'windows': [{'lobby_up': 0, 'other_up': 2, 'down': 3, 'to_lobby': 3}, {'lobby_up': 10, 'other_up': 4, 'down': 12, 'to_lobby': 11}, {'lobby_up': 0, 'other_up': 6, 'down': 8, 'to_lobby': 2}, {'lobby_up': 17, 'other_up': 3, 'down': 17, 'to_lobby': 15}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('control 4', {'windows': [{'lobby_up': 18, 'other_up': 3, 'down': 8, 'to_lobby': 4}, {'lobby_up': 2, 'other_up': 3, 'down': 15, 'to_lobby': 5}, {'lobby_up': 20, 'other_up': 6, 'down': 15, 'to_lobby': 15}, {'lobby_up': 16, 'other_up': 5, 'down': 19, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 6, 'down': 16, 'to_lobby': 6}, {'lobby_up': 1, 'other_up': 8, 'down': 0, 'to_lobby': 0}, {'lobby_up': 1, 'other_up': 2, 'down': 8, 'to_lobby': 8}, {'lobby_up': 6, 'other_up': 6, 'down': 0, 'to_lobby': 0}]}, ['up-peak', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'down-peak', 'interfloor']), ('sampled regression 7', {'windows': [{'lobby_up': 17, 'other_up': 7, 'down': 6, 'to_lobby': 6}, {'lobby_up': 7, 'other_up': 3, 'down': 4, 'to_lobby': 3}, {'lobby_up': 20, 'other_up': 8, 'down': 2, 'to_lobby': 1}, {'lobby_up': 17, 'other_up': 7, 'down': 7, 'to_lobby': 6}, {'lobby_up': 2, 'other_up': 3, 'down': 8, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 3, 'down': 16, 'to_lobby': 7}, {'lobby_up': 5, 'other_up': 5, 'down': 1, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'interfloor', 'interfloor', 'interfloor'])], [('regression: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('sampled regression 67', {'windows': [{'lobby_up': 7, 'other_up': 0, 'down': 15, 'to_lobby': 4}, {'lobby_up': 8, 'other_up': 7, 'down': 9, 'to_lobby': 2}, {'lobby_up': 17, 'other_up': 1, 'down': 9, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 0, 'down': 15, 'to_lobby': 10}, {'lobby_up': 12, 'other_up': 1, 'down': 17, 'to_lobby': 1}, {'lobby_up': 19, 'other_up': 3, 'down': 15, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 7, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'up-peak', 'up-peak']), ('sampled regression 50', {'windows': [{'lobby_up': 13, 'other_up': 3, 'down': 2, 'to_lobby': 2}, {'lobby_up': 9, 'other_up': 8, 'down': 8, 'to_lobby': 8}, {'lobby_up': 18, 'other_up': 2, 'down': 6, 'to_lobby': 2}, {'lobby_up': 13, 'other_up': 7, 'down': 10, 'to_lobby': 10}, {'lobby_up': 12, 'other_up': 5, 'down': 17, 'to_lobby': 13}]}, ['up-peak', 'interfloor', 'up-peak', 'up-peak', 'interfloor']), ('sampled regression 22', {'windows': [{'lobby_up': 0, 'other_up': 0, 'down': 15, 'to_lobby': 7}, {'lobby_up': 7, 'other_up': 4, 'down': 18, 'to_lobby': 0}, {'lobby_up': 10, 'other_up': 0, 'down': 4, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 7, 'down': 4, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 2, 'down': 20, 'to_lobby': 14}, {'lobby_up': 6, 'other_up': 5, 'down': 11, 'to_lobby': 11}, {'lobby_up': 0, 'other_up': 6, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'interfloor', 'interfloor']), ('boundary: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('control 12', {'windows': [{'lobby_up': 16, 'other_up': 6, 'down': 0, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 4, 'down': 13, 'to_lobby': 8}, {'lobby_up': 6, 'other_up': 1, 'down': 17, 'to_lobby': 7}, {'lobby_up': 20, 'other_up': 8, 'down': 13, 'to_lobby': 11}, {'lobby_up': 19, 'other_up': 5, 'down': 0, 'to_lobby': 0}, {'lobby_up': 2, 'other_up': 6, 'down': 20, 'to_lobby': 10}, {'lobby_up': 17, 'other_up': 1, 'down': 5, 'to_lobby': 4}]}, ['up-peak', 'interfloor', 'interfloor', 'interfloor', 'up-peak', 'interfloor', 'up-peak']), ('control 15', {'windows': [{'lobby_up': 8, 'other_up': 2, 'down': 2, 'to_lobby': 2}, {'lobby_up': 2, 'other_up': 0, 'down': 19, 'to_lobby': 13}, {'lobby_up': 11, 'other_up': 7, 'down': 20, 'to_lobby': 2}, {'lobby_up': 13, 'other_up': 7, 'down': 5, 'to_lobby': 5}, {'lobby_up': 1, 'other_up': 6, 'down': 7, 'to_lobby': 2}, {'lobby_up': 3, 'other_up': 1, 'down': 20, 'to_lobby': 20}]}, ['up-peak', 'down-peak', 'interfloor', 'interfloor', 'interfloor', 'down-peak']), ('control 18', {'windows': [{'lobby_up': 9, 'other_up': 7, 'down': 0, 'to_lobby': 0}, {'lobby_up': 18, 'other_up': 8, 'down': 11, 'to_lobby': 5}, {'lobby_up': 2, 'other_up': 6, 'down': 8, 'to_lobby': 3}, {'lobby_up': 10, 'other_up': 4, 'down': 20, 'to_lobby': 1}, {'lobby_up': 13, 'other_up': 5, 'down': 19, 'to_lobby': 12}, {'lobby_up': 1, 'other_up': 5, 'down': 16, 'to_lobby': 4}, {'lobby_up': 12, 'other_up': 6, 'down': 11, 'to_lobby': 2}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor'])], [('regression: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('sampled regression 22', {'windows': [{'lobby_up': 0, 'other_up': 0, 'down': 15, 'to_lobby': 7}, {'lobby_up': 7, 'other_up': 4, 'down': 18, 'to_lobby': 0}, {'lobby_up': 10, 'other_up': 0, 'down': 4, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 7, 'down': 4, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 2, 'down': 20, 'to_lobby': 14}, {'lobby_up': 6, 'other_up': 5, 'down': 11, 'to_lobby': 11}, {'lobby_up': 0, 'other_up': 6, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'interfloor', 'interfloor']), ('sampled regression 75', {'windows': [{'lobby_up': 4, 'other_up': 5, 'down': 11, 'to_lobby': 10}, {'lobby_up': 7, 'other_up': 6, 'down': 4, 'to_lobby': 4}, {'lobby_up': 19, 'other_up': 7, 'down': 2, 'to_lobby': 1}, {'lobby_up': 6, 'other_up': 8, 'down': 14, 'to_lobby': 4}, {'lobby_up': 18, 'other_up': 0, 'down': 17, 'to_lobby': 12}, {'lobby_up': 6, 'other_up': 3, 'down': 0, 'to_lobby': 0}, {'lobby_up': 17, 'other_up': 6, 'down': 4, 'to_lobby': 1}, {'lobby_up': 20, 'other_up': 2, 'down': 19, 'to_lobby': 14}]}, ['interfloor', 'interfloor', 'up-peak', 'interfloor', 'interfloor', 'interfloor', 'up-peak', 'up-peak']), ('sampled regression 67', {'windows': [{'lobby_up': 7, 'other_up': 0, 'down': 15, 'to_lobby': 4}, {'lobby_up': 8, 'other_up': 7, 'down': 9, 'to_lobby': 2}, {'lobby_up': 17, 'other_up': 1, 'down': 9, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 0, 'down': 15, 'to_lobby': 10}, {'lobby_up': 12, 'other_up': 1, 'down': 17, 'to_lobby': 1}, {'lobby_up': 19, 'other_up': 3, 'down': 15, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 7, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'up-peak', 'up-peak']), ('boundary: fraction just under sixty', {'windows': [{'lobby_up': 119, 'other_up': 41, 'down': 40, 'to_lobby': 0}]}, ['interfloor']), ('control 23', {'windows': [{'lobby_up': 6, 'other_up': 6, 'down': 20, 'to_lobby': 19}, {'lobby_up': 4, 'other_up': 7, 'down': 17, 'to_lobby': 9}, {'lobby_up': 3, 'other_up': 8, 'down': 7, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 8, 'down': 3, 'to_lobby': 2}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('control 26', {'windows': [{'lobby_up': 6, 'other_up': 0, 'down': 20, 'to_lobby': 17}, {'lobby_up': 17, 'other_up': 3, 'down': 18, 'to_lobby': 1}, {'lobby_up': 6, 'other_up': 5, 'down': 7, 'to_lobby': 0}, {'lobby_up': 17, 'other_up': 8, 'down': 20, 'to_lobby': 8}, {'lobby_up': 3, 'other_up': 5, 'down': 5, 'to_lobby': 0}, {'lobby_up': 12, 'other_up': 3, 'down': 20, 'to_lobby': 19}, {'lobby_up': 17, 'other_up': 2, 'down': 1, 'to_lobby': 1}, {'lobby_up': 7, 'other_up': 5, 'down': 9, 'to_lobby': 6}]}, ['down-peak', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'up-peak', 'interfloor']), ('control 29', {'windows': [{'lobby_up': 19, 'other_up': 4, 'down': 20, 'to_lobby': 10}, {'lobby_up': 6, 'other_up': 5, 'down': 9, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 0, 'down': 17, 'to_lobby': 0}, {'lobby_up': 19, 'other_up': 4, 'down': 8, 'to_lobby': 1}]}, ['interfloor', 'interfloor', 'interfloor', 'up-peak'])], [('regression: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('sampled regression 67', {'windows': [{'lobby_up': 7, 'other_up': 0, 'down': 15, 'to_lobby': 4}, {'lobby_up': 8, 'other_up': 7, 'down': 9, 'to_lobby': 2}, {'lobby_up': 17, 'other_up': 1, 'down': 9, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 0, 'down': 15, 'to_lobby': 10}, {'lobby_up': 12, 'other_up': 1, 'down': 17, 'to_lobby': 1}, {'lobby_up': 19, 'other_up': 3, 'down': 15, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 7, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'up-peak', 'up-peak']), ('sampled regression 22', {'windows': [{'lobby_up': 0, 'other_up': 0, 'down': 15, 'to_lobby': 7}, {'lobby_up': 7, 'other_up': 4, 'down': 18, 'to_lobby': 0}, {'lobby_up': 10, 'other_up': 0, 'down': 4, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 7, 'down': 4, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 2, 'down': 20, 'to_lobby': 14}, {'lobby_up': 6, 'other_up': 5, 'down': 11, 'to_lobby': 11}, {'lobby_up': 0, 'other_up': 6, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'interfloor', 'interfloor']), ('boundary: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('boundary: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('control 34', {'windows': [{'lobby_up': 14, 'other_up': 3, 'down': 13, 'to_lobby': 8}, {'lobby_up': 8, 'other_up': 4, 'down': 1, 'to_lobby': 1}, {'lobby_up': 20, 'other_up': 0, 'down': 3, 'to_lobby': 3}, {'lobby_up': 4, 'other_up': 5, 'down': 8, 'to_lobby': 7}, {'lobby_up': 6, 'other_up': 6, 'down': 19, 'to_lobby': 5}, {'lobby_up': 6, 'other_up': 5, 'down': 7, 'to_lobby': 5}]}, ['interfloor', 'up-peak', 'up-peak', 'interfloor', 'interfloor', 'interfloor']), ('control 37', {'windows': [{'lobby_up': 16, 'other_up': 8, 'down': 17, 'to_lobby': 12}, {'lobby_up': 16, 'other_up': 3, 'down': 11, 'to_lobby': 0}, {'lobby_up': 4, 'other_up': 8, 'down': 1, 'to_lobby': 0}, {'lobby_up': 10, 'other_up': 5, 'down': 8, 'to_lobby': 5}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('sampled regression 40', {'windows': [{'lobby_up': 7, 'other_up': 6, 'down': 2, 'to_lobby': 1}, {'lobby_up': 11, 'other_up': 2, 'down': 1, 'to_lobby': 0}, {'lobby_up': 18, 'other_up': 7, 'down': 16, 'to_lobby': 4}, {'lobby_up': 0, 'other_up': 8, 'down': 18, 'to_lobby': 1}, {'lobby_up': 1, 'other_up': 2, 'down': 12, 'to_lobby': 9}, {'lobby_up': 7, 'other_up': 3, 'down': 0, 'to_lobby': 0}]}, ['interfloor', 'up-peak', 'up-peak', 'interfloor', 'down-peak', 'up-peak'])], [('regression: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('sampled regression 22', {'windows': [{'lobby_up': 0, 'other_up': 0, 'down': 15, 'to_lobby': 7}, {'lobby_up': 7, 'other_up': 4, 'down': 18, 'to_lobby': 0}, {'lobby_up': 10, 'other_up': 0, 'down': 4, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 7, 'down': 4, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 2, 'down': 20, 'to_lobby': 14}, {'lobby_up': 6, 'other_up': 5, 'down': 11, 'to_lobby': 11}, {'lobby_up': 0, 'other_up': 6, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'interfloor', 'interfloor']), ('sampled regression 53', {'windows': [{'lobby_up': 16, 'other_up': 7, 'down': 15, 'to_lobby': 3}, {'lobby_up': 20, 'other_up': 7, 'down': 6, 'to_lobby': 1}, {'lobby_up': 15, 'other_up': 2, 'down': 9, 'to_lobby': 3}]}, ['interfloor', 'up-peak', 'up-peak']), ('sampled regression 67', {'windows': [{'lobby_up': 7, 'other_up': 0, 'down': 15, 'to_lobby': 4}, {'lobby_up': 8, 'other_up': 7, 'down': 9, 'to_lobby': 2}, {'lobby_up': 17, 'other_up': 1, 'down': 9, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 0, 'down': 15, 'to_lobby': 10}, {'lobby_up': 12, 'other_up': 1, 'down': 17, 'to_lobby': 1}, {'lobby_up': 19, 'other_up': 3, 'down': 15, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 7, 'down': 5, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'up-peak', 'up-peak']), ('boundary: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('control 45', {'windows': [{'lobby_up': 15, 'other_up': 5, 'down': 7, 'to_lobby': 2}, {'lobby_up': 5, 'other_up': 7, 'down': 14, 'to_lobby': 0}, {'lobby_up': 17, 'other_up': 2, 'down': 13, 'to_lobby': 4}, {'lobby_up': 3, 'other_up': 3, 'down': 10, 'to_lobby': 7}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('control 48', {'windows': [{'lobby_up': 0, 'other_up': 3, 'down': 12, 'to_lobby': 1}, {'lobby_up': 19, 'other_up': 1, 'down': 12, 'to_lobby': 11}, {'lobby_up': 8, 'other_up': 2, 'down': 4, 'to_lobby': 3}, {'lobby_up': 18, 'other_up': 8, 'down': 1, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 7, 'down': 18, 'to_lobby': 17}, {'lobby_up': 11, 'other_up': 1, 'down': 18, 'to_lobby': 7}, {'lobby_up': 10, 'other_up': 2, 'down': 15, 'to_lobby': 2}]}, ['interfloor', 'interfloor', 'interfloor', 'up-peak', 'interfloor', 'interfloor', 'interfloor']), ('control 51', {'windows': [{'lobby_up': 4, 'other_up': 0, 'down': 1, 'to_lobby': 0}, {'lobby_up': 16, 'other_up': 6, 'down': 19, 'to_lobby': 15}, {'lobby_up': 13, 'other_up': 6, 'down': 3, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 0, 'down': 16, 'to_lobby': 2}, {'lobby_up': 20, 'other_up': 8, 'down': 11, 'to_lobby': 7}, {'lobby_up': 10, 'other_up': 5, 'down': 6, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 6, 'down': 19, 'to_lobby': 0}, {'lobby_up': 20, 'other_up': 2, 'down': 1, 'to_lobby': 1}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'up-peak'])]]
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:
Up-peak flickers off as soon as the lobby share dips below the entry level.

Per 5-minute window, total = lobby_up + other_up + down. up% = lobby_up*100//total and down% = to_lobby*100//total (0 if total is 0). An active peak ends when its percentage falls below 40 or total < 10. From interfloor (including just after a peak ended) a window with total >= 10 enters up-peak at up% >= 60, else down-peak at down% >= 60. Output the mode per window.

split: open-access


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

N = 1
observations = []
def solve(x):
    mode = 'interfloor'
    out = []
    for w in x['windows']:
        tot = w['lobby_up'] + w['other_up'] + w['down']
        up_pct = w['lobby_up'] * 100 // tot if tot else 0
        dn_pct = w['to_lobby'] * 100 // tot if tot else 0
        if mode == 'up-peak':
            if up_pct < 40 or tot < 10:
                mode = 'interfloor'
        elif mode == 'down-peak':
            if dn_pct < 40 or tot < 10:
                mode = 'interfloor'
        if mode == 'interfloor':
            if up_pct >= 60:
                mode = 'up-peak'
            elif dn_pct >= 60:
                mode = 'down-peak'
        out.append(mode)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('boundary: exactly sixty percent', {'windows': [{'lobby_up': 6, 'other_up': 2, 'down': 2, 'to_lobby': 0}]}, ['up-peak']), ('sampled regression 5', {'windows': [{'lobby_up': 1, 'other_up': 0, 'down': 2, 'to_lobby': 2}, {'lobby_up': 6, 'other_up': 7, 'down': 13, 'to_lobby': 2}, {'lobby_up': 0, 'other_up': 8, 'down': 11, 'to_lobby': 10}, {'lobby_up': 7, 'other_up': 3, 'down': 2, 'to_lobby': 2}, {'lobby_up': 9, 'other_up': 0, 'down': 11, 'to_lobby': 0}, {'lobby_up': 1, 'other_up': 6, 'down': 13, 'to_lobby': 6}, {'lobby_up': 7, 'other_up': 8, 'down': 20, 'to_lobby': 15}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor']), ('control 21', {'windows': [{'lobby_up': 8, 'other_up': 5, 'down': 6, 'to_lobby': 1}, {'lobby_up': 20, 'other_up': 1, 'down': 15, 'to_lobby': 8}, {'lobby_up': 10, 'other_up': 0, 'down': 0, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak']), ('boundary: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('sampled regression 1', {'windows': [{'lobby_up': 0, 'other_up': 2, 'down': 3, 'to_lobby': 3}, {'lobby_up': 10, 'other_up': 4, 'down': 12, 'to_lobby': 11}, {'lobby_up': 0, 'other_up': 6, 'down': 8, 'to_lobby': 2}, {'lobby_up': 17, 'other_up': 3, 'down': 17, 'to_lobby': 15}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('control 4', {'windows': [{'lobby_up': 18, 'other_up': 3, 'down': 8, 'to_lobby': 4}, {'lobby_up': 2, 'other_up': 3, 'down': 15, 'to_lobby': 5}, {'lobby_up': 20, 'other_up': 6, 'down': 15, 'to_lobby': 15}, {'lobby_up': 16, 'other_up': 5, 'down': 19, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 6, 'down': 16, 'to_lobby': 6}, {'lobby_up': 1, 'other_up': 8, 'down': 0, 'to_lobby': 0}, {'lobby_up': 1, 'other_up': 2, 'down': 8, 'to_lobby': 8}, {'lobby_up': 6, 'other_up': 6, 'down': 0, 'to_lobby': 0}]}, ['up-peak', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'down-peak', 'interfloor']), ('control 7', {'windows': [{'lobby_up': 17, 'other_up': 7, 'down': 6, 'to_lobby': 6}, {'lobby_up': 7, 'other_up': 3, 'down': 4, 'to_lobby': 3}, {'lobby_up': 20, 'other_up': 8, 'down': 2, 'to_lobby': 1}, {'lobby_up': 17, 'other_up': 7, 'down': 7, 'to_lobby': 6}, {'lobby_up': 2, 'other_up': 3, 'down': 8, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 3, 'down': 16, 'to_lobby': 7}, {'lobby_up': 5, 'other_up': 5, 'down': 1, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'interfloor', 'interfloor', 'interfloor'])], [('regression: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('boundary: exactly sixty percent', {'windows': [{'lobby_up': 6, 'other_up': 2, 'down': 2, 'to_lobby': 0}]}, ['up-peak']), ('sampled regression 77', {'windows': [{'lobby_up': 14, 'other_up': 0, 'down': 2, 'to_lobby': 2}, {'lobby_up': 16, 'other_up': 4, 'down': 14, 'to_lobby': 10}, {'lobby_up': 0, 'other_up': 0, 'down': 8, 'to_lobby': 8}, {'lobby_up': 20, 'other_up': 7, 'down': 15, 'to_lobby': 1}, {'lobby_up': 17, 'other_up': 2, 'down': 8, 'to_lobby': 6}]}, ['up-peak', 'up-peak', 'interfloor', 'interfloor', 'up-peak']), ('control 40', {'windows': [{'lobby_up': 7, 'other_up': 6, 'down': 2, 'to_lobby': 1}, {'lobby_up': 11, 'other_up': 2, 'down': 1, 'to_lobby': 0}, {'lobby_up': 18, 'other_up': 7, 'down': 16, 'to_lobby': 4}, {'lobby_up': 0, 'other_up': 8, 'down': 18, 'to_lobby': 1}, {'lobby_up': 1, 'other_up': 2, 'down': 12, 'to_lobby': 9}, {'lobby_up': 7, 'other_up': 3, 'down': 0, 'to_lobby': 0}]}, ['interfloor', 'up-peak', 'up-peak', 'interfloor', 'down-peak', 'up-peak']), ('boundary: fraction just under sixty', {'windows': [{'lobby_up': 119, 'other_up': 41, 'down': 40, 'to_lobby': 0}]}, ['interfloor']), ('control 12', {'windows': [{'lobby_up': 16, 'other_up': 6, 'down': 0, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 4, 'down': 13, 'to_lobby': 8}, {'lobby_up': 6, 'other_up': 1, 'down': 17, 'to_lobby': 7}, {'lobby_up': 20, 'other_up': 8, 'down': 13, 'to_lobby': 11}, {'lobby_up': 19, 'other_up': 5, 'down': 0, 'to_lobby': 0}, {'lobby_up': 2, 'other_up': 6, 'down': 20, 'to_lobby': 10}, {'lobby_up': 17, 'other_up': 1, 'down': 5, 'to_lobby': 4}]}, ['up-peak', 'interfloor', 'interfloor', 'interfloor', 'up-peak', 'interfloor', 'up-peak']), ('control 15', {'windows': [{'lobby_up': 8, 'other_up': 2, 'down': 2, 'to_lobby': 2}, {'lobby_up': 2, 'other_up': 0, 'down': 19, 'to_lobby': 13}, {'lobby_up': 11, 'other_up': 7, 'down': 20, 'to_lobby': 2}, {'lobby_up': 13, 'other_up': 7, 'down': 5, 'to_lobby': 5}, {'lobby_up': 1, 'other_up': 6, 'down': 7, 'to_lobby': 2}, {'lobby_up': 3, 'other_up': 1, 'down': 20, 'to_lobby': 20}]}, ['up-peak', 'down-peak', 'interfloor', 'interfloor', 'interfloor', 'down-peak']), ('control 18', {'windows': [{'lobby_up': 9, 'other_up': 7, 'down': 0, 'to_lobby': 0}, {'lobby_up': 18, 'other_up': 8, 'down': 11, 'to_lobby': 5}, {'lobby_up': 2, 'other_up': 6, 'down': 8, 'to_lobby': 3}, {'lobby_up': 10, 'other_up': 4, 'down': 20, 'to_lobby': 1}, {'lobby_up': 13, 'other_up': 5, 'down': 19, 'to_lobby': 12}, {'lobby_up': 1, 'other_up': 5, 'down': 16, 'to_lobby': 4}, {'lobby_up': 12, 'other_up': 6, 'down': 11, 'to_lobby': 2}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor'])], [('regression: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('boundary: exactly sixty percent', {'windows': [{'lobby_up': 6, 'other_up': 2, 'down': 2, 'to_lobby': 0}]}, ['up-peak']), ('sampled regression 47', {'windows': [{'lobby_up': 2, 'other_up': 7, 'down': 18, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 5, 'down': 2, 'to_lobby': 2}, {'lobby_up': 0, 'other_up': 1, 'down': 6, 'to_lobby': 6}, {'lobby_up': 15, 'other_up': 6, 'down': 3, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 0, 'down': 16, 'to_lobby': 6}, {'lobby_up': 2, 'other_up': 1, 'down': 5, 'to_lobby': 3}, {'lobby_up': 12, 'other_up': 4, 'down': 8, 'to_lobby': 8}]}, ['interfloor', 'up-peak', 'interfloor', 'up-peak', 'up-peak', 'interfloor', 'interfloor']), ('control 71', {'windows': [{'lobby_up': 8, 'other_up': 1, 'down': 1, 'to_lobby': 1}, {'lobby_up': 3, 'other_up': 5, 'down': 12, 'to_lobby': 12}, {'lobby_up': 15, 'other_up': 5, 'down': 7, 'to_lobby': 4}, {'lobby_up': 4, 'other_up': 4, 'down': 7, 'to_lobby': 2}, {'lobby_up': 15, 'other_up': 5, 'down': 11, 'to_lobby': 4}, {'lobby_up': 6, 'other_up': 6, 'down': 17, 'to_lobby': 11}, {'lobby_up': 2, 'other_up': 4, 'down': 12, 'to_lobby': 9}]}, ['up-peak', 'down-peak', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor']), ('boundary: fraction just under sixty', {'windows': [{'lobby_up': 119, 'other_up': 41, 'down': 40, 'to_lobby': 0}]}, ['interfloor']), ('control 23', {'windows': [{'lobby_up': 6, 'other_up': 6, 'down': 20, 'to_lobby': 19}, {'lobby_up': 4, 'other_up': 7, 'down': 17, 'to_lobby': 9}, {'lobby_up': 3, 'other_up': 8, 'down': 7, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 8, 'down': 3, 'to_lobby': 2}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('control 26', {'windows': [{'lobby_up': 6, 'other_up': 0, 'down': 20, 'to_lobby': 17}, {'lobby_up': 17, 'other_up': 3, 'down': 18, 'to_lobby': 1}, {'lobby_up': 6, 'other_up': 5, 'down': 7, 'to_lobby': 0}, {'lobby_up': 17, 'other_up': 8, 'down': 20, 'to_lobby': 8}, {'lobby_up': 3, 'other_up': 5, 'down': 5, 'to_lobby': 0}, {'lobby_up': 12, 'other_up': 3, 'down': 20, 'to_lobby': 19}, {'lobby_up': 17, 'other_up': 2, 'down': 1, 'to_lobby': 1}, {'lobby_up': 7, 'other_up': 5, 'down': 9, 'to_lobby': 6}]}, ['down-peak', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'up-peak', 'interfloor']), ('control 29', {'windows': [{'lobby_up': 19, 'other_up': 4, 'down': 20, 'to_lobby': 10}, {'lobby_up': 6, 'other_up': 5, 'down': 9, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 0, 'down': 17, 'to_lobby': 0}, {'lobby_up': 19, 'other_up': 4, 'down': 8, 'to_lobby': 1}]}, ['interfloor', 'interfloor', 'interfloor', 'up-peak'])], [('regression: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('boundary: exactly sixty percent', {'windows': [{'lobby_up': 6, 'other_up': 2, 'down': 2, 'to_lobby': 0}]}, ['up-peak']), ('sampled regression 1', {'windows': [{'lobby_up': 0, 'other_up': 2, 'down': 3, 'to_lobby': 3}, {'lobby_up': 10, 'other_up': 4, 'down': 12, 'to_lobby': 11}, {'lobby_up': 0, 'other_up': 6, 'down': 8, 'to_lobby': 2}, {'lobby_up': 17, 'other_up': 3, 'down': 17, 'to_lobby': 15}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('boundary: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('regression: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('control 34', {'windows': [{'lobby_up': 14, 'other_up': 3, 'down': 13, 'to_lobby': 8}, {'lobby_up': 8, 'other_up': 4, 'down': 1, 'to_lobby': 1}, {'lobby_up': 20, 'other_up': 0, 'down': 3, 'to_lobby': 3}, {'lobby_up': 4, 'other_up': 5, 'down': 8, 'to_lobby': 7}, {'lobby_up': 6, 'other_up': 6, 'down': 19, 'to_lobby': 5}, {'lobby_up': 6, 'other_up': 5, 'down': 7, 'to_lobby': 5}]}, ['interfloor', 'up-peak', 'up-peak', 'interfloor', 'interfloor', 'interfloor']), ('control 37', {'windows': [{'lobby_up': 16, 'other_up': 8, 'down': 17, 'to_lobby': 12}, {'lobby_up': 16, 'other_up': 3, 'down': 11, 'to_lobby': 0}, {'lobby_up': 4, 'other_up': 8, 'down': 1, 'to_lobby': 0}, {'lobby_up': 10, 'other_up': 5, 'down': 8, 'to_lobby': 5}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('control 40', {'windows': [{'lobby_up': 7, 'other_up': 6, 'down': 2, 'to_lobby': 1}, {'lobby_up': 11, 'other_up': 2, 'down': 1, 'to_lobby': 0}, {'lobby_up': 18, 'other_up': 7, 'down': 16, 'to_lobby': 4}, {'lobby_up': 0, 'other_up': 8, 'down': 18, 'to_lobby': 1}, {'lobby_up': 1, 'other_up': 2, 'down': 12, 'to_lobby': 9}, {'lobby_up': 7, 'other_up': 3, 'down': 0, 'to_lobby': 0}]}, ['interfloor', 'up-peak', 'up-peak', 'interfloor', 'down-peak', 'up-peak'])], [('regression: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('boundary: exactly sixty percent', {'windows': [{'lobby_up': 6, 'other_up': 2, 'down': 2, 'to_lobby': 0}]}, ['up-peak']), ('sampled regression 75', {'windows': [{'lobby_up': 4, 'other_up': 5, 'down': 11, 'to_lobby': 10}, {'lobby_up': 7, 'other_up': 6, 'down': 4, 'to_lobby': 4}, {'lobby_up': 19, 'other_up': 7, 'down': 2, 'to_lobby': 1}, {'lobby_up': 6, 'other_up': 8, 'down': 14, 'to_lobby': 4}, {'lobby_up': 18, 'other_up': 0, 'down': 17, 'to_lobby': 12}, {'lobby_up': 6, 'other_up': 3, 'down': 0, 'to_lobby': 0}, {'lobby_up': 17, 'other_up': 6, 'down': 4, 'to_lobby': 1}, {'lobby_up': 20, 'other_up': 2, 'down': 19, 'to_lobby': 14}]}, ['interfloor', 'interfloor', 'up-peak', 'interfloor', 'interfloor', 'interfloor', 'up-peak', 'up-peak']), ('control 21', {'windows': [{'lobby_up': 8, 'other_up': 5, 'down': 6, 'to_lobby': 1}, {'lobby_up': 20, 'other_up': 1, 'down': 15, 'to_lobby': 8}, {'lobby_up': 10, 'other_up': 0, 'down': 0, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak']), ('regression: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('control 45', {'windows': [{'lobby_up': 15, 'other_up': 5, 'down': 7, 'to_lobby': 2}, {'lobby_up': 5, 'other_up': 7, 'down': 14, 'to_lobby': 0}, {'lobby_up': 17, 'other_up': 2, 'down': 13, 'to_lobby': 4}, {'lobby_up': 3, 'other_up': 3, 'down': 10, 'to_lobby': 7}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('control 48', {'windows': [{'lobby_up': 0, 'other_up': 3, 'down': 12, 'to_lobby': 1}, {'lobby_up': 19, 'other_up': 1, 'down': 12, 'to_lobby': 11}, {'lobby_up': 8, 'other_up': 2, 'down': 4, 'to_lobby': 3}, {'lobby_up': 18, 'other_up': 8, 'down': 1, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 7, 'down': 18, 'to_lobby': 17}, {'lobby_up': 11, 'other_up': 1, 'down': 18, 'to_lobby': 7}, {'lobby_up': 10, 'other_up': 2, 'down': 15, 'to_lobby': 2}]}, ['interfloor', 'interfloor', 'interfloor', 'up-peak', 'interfloor', 'interfloor', 'interfloor']), ('sampled regression 51', {'windows': [{'lobby_up': 4, 'other_up': 0, 'down': 1, 'to_lobby': 0}, {'lobby_up': 16, 'other_up': 6, 'down': 19, 'to_lobby': 15}, {'lobby_up': 13, 'other_up': 6, 'down': 3, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 0, 'down': 16, 'to_lobby': 2}, {'lobby_up': 20, 'other_up': 8, 'down': 11, 'to_lobby': 7}, {'lobby_up': 10, 'other_up': 5, 'down': 6, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 6, 'down': 19, 'to_lobby': 0}, {'lobby_up': 20, 'other_up': 2, 'down': 1, 'to_lobby': 1}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'up-peak'])]]
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):
    mode = 'interfloor'
    out = []
    for w in x['windows']:
        tot = w['lobby_up'] + w['other_up'] + w['down']
        up_pct = w['lobby_up'] * 100 // tot if tot else 0
        dn_pct = w['to_lobby'] * 100 // tot if tot else 0
        if mode == 'up-peak':
            if up_pct < 40 or tot < 10:
                mode = 'interfloor'
        elif mode == 'down-peak':
            if dn_pct < 40 or tot < 10:
                mode = 'interfloor'
        if mode == 'interfloor' and tot > 10:
            if up_pct >= 60:
                mode = 'up-peak'
            elif dn_pct >= 60:
                mode = 'down-peak'
        out.append(mode)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('boundary: exactly sixty percent', {'windows': [{'lobby_up': 6, 'other_up': 2, 'down': 2, 'to_lobby': 0}]}, ['up-peak']), ('sampled regression 5', {'windows': [{'lobby_up': 1, 'other_up': 0, 'down': 2, 'to_lobby': 2}, {'lobby_up': 6, 'other_up': 7, 'down': 13, 'to_lobby': 2}, {'lobby_up': 0, 'other_up': 8, 'down': 11, 'to_lobby': 10}, {'lobby_up': 7, 'other_up': 3, 'down': 2, 'to_lobby': 2}, {'lobby_up': 9, 'other_up': 0, 'down': 11, 'to_lobby': 0}, {'lobby_up': 1, 'other_up': 6, 'down': 13, 'to_lobby': 6}, {'lobby_up': 7, 'other_up': 8, 'down': 20, 'to_lobby': 15}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor']), ('control 21', {'windows': [{'lobby_up': 8, 'other_up': 5, 'down': 6, 'to_lobby': 1}, {'lobby_up': 20, 'other_up': 1, 'down': 15, 'to_lobby': 8}, {'lobby_up': 10, 'other_up': 0, 'down': 0, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak']), ('boundary: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('sampled regression 1', {'windows': [{'lobby_up': 0, 'other_up': 2, 'down': 3, 'to_lobby': 3}, {'lobby_up': 10, 'other_up': 4, 'down': 12, 'to_lobby': 11}, {'lobby_up': 0, 'other_up': 6, 'down': 8, 'to_lobby': 2}, {'lobby_up': 17, 'other_up': 3, 'down': 17, 'to_lobby': 15}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('control 4', {'windows': [{'lobby_up': 18, 'other_up': 3, 'down': 8, 'to_lobby': 4}, {'lobby_up': 2, 'other_up': 3, 'down': 15, 'to_lobby': 5}, {'lobby_up': 20, 'other_up': 6, 'down': 15, 'to_lobby': 15}, {'lobby_up': 16, 'other_up': 5, 'down': 19, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 6, 'down': 16, 'to_lobby': 6}, {'lobby_up': 1, 'other_up': 8, 'down': 0, 'to_lobby': 0}, {'lobby_up': 1, 'other_up': 2, 'down': 8, 'to_lobby': 8}, {'lobby_up': 6, 'other_up': 6, 'down': 0, 'to_lobby': 0}]}, ['up-peak', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'down-peak', 'interfloor']), ('control 7', {'windows': [{'lobby_up': 17, 'other_up': 7, 'down': 6, 'to_lobby': 6}, {'lobby_up': 7, 'other_up': 3, 'down': 4, 'to_lobby': 3}, {'lobby_up': 20, 'other_up': 8, 'down': 2, 'to_lobby': 1}, {'lobby_up': 17, 'other_up': 7, 'down': 7, 'to_lobby': 6}, {'lobby_up': 2, 'other_up': 3, 'down': 8, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 3, 'down': 16, 'to_lobby': 7}, {'lobby_up': 5, 'other_up': 5, 'down': 1, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'interfloor', 'interfloor', 'interfloor'])], [('regression: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('boundary: exactly sixty percent', {'windows': [{'lobby_up': 6, 'other_up': 2, 'down': 2, 'to_lobby': 0}]}, ['up-peak']), ('sampled regression 77', {'windows': [{'lobby_up': 14, 'other_up': 0, 'down': 2, 'to_lobby': 2}, {'lobby_up': 16, 'other_up': 4, 'down': 14, 'to_lobby': 10}, {'lobby_up': 0, 'other_up': 0, 'down': 8, 'to_lobby': 8}, {'lobby_up': 20, 'other_up': 7, 'down': 15, 'to_lobby': 1}, {'lobby_up': 17, 'other_up': 2, 'down': 8, 'to_lobby': 6}]}, ['up-peak', 'up-peak', 'interfloor', 'interfloor', 'up-peak']), ('control 40', {'windows': [{'lobby_up': 7, 'other_up': 6, 'down': 2, 'to_lobby': 1}, {'lobby_up': 11, 'other_up': 2, 'down': 1, 'to_lobby': 0}, {'lobby_up': 18, 'other_up': 7, 'down': 16, 'to_lobby': 4}, {'lobby_up': 0, 'other_up': 8, 'down': 18, 'to_lobby': 1}, {'lobby_up': 1, 'other_up': 2, 'down': 12, 'to_lobby': 9}, {'lobby_up': 7, 'other_up': 3, 'down': 0, 'to_lobby': 0}]}, ['interfloor', 'up-peak', 'up-peak', 'interfloor', 'down-peak', 'up-peak']), ('boundary: fraction just under sixty', {'windows': [{'lobby_up': 119, 'other_up': 41, 'down': 40, 'to_lobby': 0}]}, ['interfloor']), ('control 12', {'windows': [{'lobby_up': 16, 'other_up': 6, 'down': 0, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 4, 'down': 13, 'to_lobby': 8}, {'lobby_up': 6, 'other_up': 1, 'down': 17, 'to_lobby': 7}, {'lobby_up': 20, 'other_up': 8, 'down': 13, 'to_lobby': 11}, {'lobby_up': 19, 'other_up': 5, 'down': 0, 'to_lobby': 0}, {'lobby_up': 2, 'other_up': 6, 'down': 20, 'to_lobby': 10}, {'lobby_up': 17, 'other_up': 1, 'down': 5, 'to_lobby': 4}]}, ['up-peak', 'interfloor', 'interfloor', 'interfloor', 'up-peak', 'interfloor', 'up-peak']), ('control 15', {'windows': [{'lobby_up': 8, 'other_up': 2, 'down': 2, 'to_lobby': 2}, {'lobby_up': 2, 'other_up': 0, 'down': 19, 'to_lobby': 13}, {'lobby_up': 11, 'other_up': 7, 'down': 20, 'to_lobby': 2}, {'lobby_up': 13, 'other_up': 7, 'down': 5, 'to_lobby': 5}, {'lobby_up': 1, 'other_up': 6, 'down': 7, 'to_lobby': 2}, {'lobby_up': 3, 'other_up': 1, 'down': 20, 'to_lobby': 20}]}, ['up-peak', 'down-peak', 'interfloor', 'interfloor', 'interfloor', 'down-peak']), ('control 18', {'windows': [{'lobby_up': 9, 'other_up': 7, 'down': 0, 'to_lobby': 0}, {'lobby_up': 18, 'other_up': 8, 'down': 11, 'to_lobby': 5}, {'lobby_up': 2, 'other_up': 6, 'down': 8, 'to_lobby': 3}, {'lobby_up': 10, 'other_up': 4, 'down': 20, 'to_lobby': 1}, {'lobby_up': 13, 'other_up': 5, 'down': 19, 'to_lobby': 12}, {'lobby_up': 1, 'other_up': 5, 'down': 16, 'to_lobby': 4}, {'lobby_up': 12, 'other_up': 6, 'down': 11, 'to_lobby': 2}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor'])], [('regression: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('boundary: exactly sixty percent', {'windows': [{'lobby_up': 6, 'other_up': 2, 'down': 2, 'to_lobby': 0}]}, ['up-peak']), ('sampled regression 47', {'windows': [{'lobby_up': 2, 'other_up': 7, 'down': 18, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 5, 'down': 2, 'to_lobby': 2}, {'lobby_up': 0, 'other_up': 1, 'down': 6, 'to_lobby': 6}, {'lobby_up': 15, 'other_up': 6, 'down': 3, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 0, 'down': 16, 'to_lobby': 6}, {'lobby_up': 2, 'other_up': 1, 'down': 5, 'to_lobby': 3}, {'lobby_up': 12, 'other_up': 4, 'down': 8, 'to_lobby': 8}]}, ['interfloor', 'up-peak', 'interfloor', 'up-peak', 'up-peak', 'interfloor', 'interfloor']), ('control 71', {'windows': [{'lobby_up': 8, 'other_up': 1, 'down': 1, 'to_lobby': 1}, {'lobby_up': 3, 'other_up': 5, 'down': 12, 'to_lobby': 12}, {'lobby_up': 15, 'other_up': 5, 'down': 7, 'to_lobby': 4}, {'lobby_up': 4, 'other_up': 4, 'down': 7, 'to_lobby': 2}, {'lobby_up': 15, 'other_up': 5, 'down': 11, 'to_lobby': 4}, {'lobby_up': 6, 'other_up': 6, 'down': 17, 'to_lobby': 11}, {'lobby_up': 2, 'other_up': 4, 'down': 12, 'to_lobby': 9}]}, ['up-peak', 'down-peak', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor']), ('boundary: fraction just under sixty', {'windows': [{'lobby_up': 119, 'other_up': 41, 'down': 40, 'to_lobby': 0}]}, ['interfloor']), ('control 23', {'windows': [{'lobby_up': 6, 'other_up': 6, 'down': 20, 'to_lobby': 19}, {'lobby_up': 4, 'other_up': 7, 'down': 17, 'to_lobby': 9}, {'lobby_up': 3, 'other_up': 8, 'down': 7, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 8, 'down': 3, 'to_lobby': 2}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('control 26', {'windows': [{'lobby_up': 6, 'other_up': 0, 'down': 20, 'to_lobby': 17}, {'lobby_up': 17, 'other_up': 3, 'down': 18, 'to_lobby': 1}, {'lobby_up': 6, 'other_up': 5, 'down': 7, 'to_lobby': 0}, {'lobby_up': 17, 'other_up': 8, 'down': 20, 'to_lobby': 8}, {'lobby_up': 3, 'other_up': 5, 'down': 5, 'to_lobby': 0}, {'lobby_up': 12, 'other_up': 3, 'down': 20, 'to_lobby': 19}, {'lobby_up': 17, 'other_up': 2, 'down': 1, 'to_lobby': 1}, {'lobby_up': 7, 'other_up': 5, 'down': 9, 'to_lobby': 6}]}, ['down-peak', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'up-peak', 'interfloor']), ('control 29', {'windows': [{'lobby_up': 19, 'other_up': 4, 'down': 20, 'to_lobby': 10}, {'lobby_up': 6, 'other_up': 5, 'down': 9, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 0, 'down': 17, 'to_lobby': 0}, {'lobby_up': 19, 'other_up': 4, 'down': 8, 'to_lobby': 1}]}, ['interfloor', 'interfloor', 'interfloor', 'up-peak'])], [('regression: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('boundary: exactly sixty percent', {'windows': [{'lobby_up': 6, 'other_up': 2, 'down': 2, 'to_lobby': 0}]}, ['up-peak']), ('sampled regression 1', {'windows': [{'lobby_up': 0, 'other_up': 2, 'down': 3, 'to_lobby': 3}, {'lobby_up': 10, 'other_up': 4, 'down': 12, 'to_lobby': 11}, {'lobby_up': 0, 'other_up': 6, 'down': 8, 'to_lobby': 2}, {'lobby_up': 17, 'other_up': 3, 'down': 17, 'to_lobby': 15}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('boundary: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('regression: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('control 34', {'windows': [{'lobby_up': 14, 'other_up': 3, 'down': 13, 'to_lobby': 8}, {'lobby_up': 8, 'other_up': 4, 'down': 1, 'to_lobby': 1}, {'lobby_up': 20, 'other_up': 0, 'down': 3, 'to_lobby': 3}, {'lobby_up': 4, 'other_up': 5, 'down': 8, 'to_lobby': 7}, {'lobby_up': 6, 'other_up': 6, 'down': 19, 'to_lobby': 5}, {'lobby_up': 6, 'other_up': 5, 'down': 7, 'to_lobby': 5}]}, ['interfloor', 'up-peak', 'up-peak', 'interfloor', 'interfloor', 'interfloor']), ('control 37', {'windows': [{'lobby_up': 16, 'other_up': 8, 'down': 17, 'to_lobby': 12}, {'lobby_up': 16, 'other_up': 3, 'down': 11, 'to_lobby': 0}, {'lobby_up': 4, 'other_up': 8, 'down': 1, 'to_lobby': 0}, {'lobby_up': 10, 'other_up': 5, 'down': 8, 'to_lobby': 5}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('control 40', {'windows': [{'lobby_up': 7, 'other_up': 6, 'down': 2, 'to_lobby': 1}, {'lobby_up': 11, 'other_up': 2, 'down': 1, 'to_lobby': 0}, {'lobby_up': 18, 'other_up': 7, 'down': 16, 'to_lobby': 4}, {'lobby_up': 0, 'other_up': 8, 'down': 18, 'to_lobby': 1}, {'lobby_up': 1, 'other_up': 2, 'down': 12, 'to_lobby': 9}, {'lobby_up': 7, 'other_up': 3, 'down': 0, 'to_lobby': 0}]}, ['interfloor', 'up-peak', 'up-peak', 'interfloor', 'down-peak', 'up-peak'])], [('regression: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('boundary: exactly sixty percent', {'windows': [{'lobby_up': 6, 'other_up': 2, 'down': 2, 'to_lobby': 0}]}, ['up-peak']), ('sampled regression 75', {'windows': [{'lobby_up': 4, 'other_up': 5, 'down': 11, 'to_lobby': 10}, {'lobby_up': 7, 'other_up': 6, 'down': 4, 'to_lobby': 4}, {'lobby_up': 19, 'other_up': 7, 'down': 2, 'to_lobby': 1}, {'lobby_up': 6, 'other_up': 8, 'down': 14, 'to_lobby': 4}, {'lobby_up': 18, 'other_up': 0, 'down': 17, 'to_lobby': 12}, {'lobby_up': 6, 'other_up': 3, 'down': 0, 'to_lobby': 0}, {'lobby_up': 17, 'other_up': 6, 'down': 4, 'to_lobby': 1}, {'lobby_up': 20, 'other_up': 2, 'down': 19, 'to_lobby': 14}]}, ['interfloor', 'interfloor', 'up-peak', 'interfloor', 'interfloor', 'interfloor', 'up-peak', 'up-peak']), ('control 21', {'windows': [{'lobby_up': 8, 'other_up': 5, 'down': 6, 'to_lobby': 1}, {'lobby_up': 20, 'other_up': 1, 'down': 15, 'to_lobby': 8}, {'lobby_up': 10, 'other_up': 0, 'down': 0, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak']), ('regression: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('control 45', {'windows': [{'lobby_up': 15, 'other_up': 5, 'down': 7, 'to_lobby': 2}, {'lobby_up': 5, 'other_up': 7, 'down': 14, 'to_lobby': 0}, {'lobby_up': 17, 'other_up': 2, 'down': 13, 'to_lobby': 4}, {'lobby_up': 3, 'other_up': 3, 'down': 10, 'to_lobby': 7}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('control 48', {'windows': [{'lobby_up': 0, 'other_up': 3, 'down': 12, 'to_lobby': 1}, {'lobby_up': 19, 'other_up': 1, 'down': 12, 'to_lobby': 11}, {'lobby_up': 8, 'other_up': 2, 'down': 4, 'to_lobby': 3}, {'lobby_up': 18, 'other_up': 8, 'down': 1, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 7, 'down': 18, 'to_lobby': 17}, {'lobby_up': 11, 'other_up': 1, 'down': 18, 'to_lobby': 7}, {'lobby_up': 10, 'other_up': 2, 'down': 15, 'to_lobby': 2}]}, ['interfloor', 'interfloor', 'interfloor', 'up-peak', 'interfloor', 'interfloor', 'interfloor']), ('sampled regression 51', {'windows': [{'lobby_up': 4, 'other_up': 0, 'down': 1, 'to_lobby': 0}, {'lobby_up': 16, 'other_up': 6, 'down': 19, 'to_lobby': 15}, {'lobby_up': 13, 'other_up': 6, 'down': 3, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 0, 'down': 16, 'to_lobby': 2}, {'lobby_up': 20, 'other_up': 8, 'down': 11, 'to_lobby': 7}, {'lobby_up': 10, 'other_up': 5, 'down': 6, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 6, 'down': 19, 'to_lobby': 0}, {'lobby_up': 20, 'other_up': 2, 'down': 1, 'to_lobby': 1}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'up-peak'])]]
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 handful of calls switches the group into a peak mode.

Per 5-minute window, total = lobby_up + other_up + down. up% = lobby_up*100//total and down% = to_lobby*100//total (0 if total is 0). An active peak ends when its percentage falls below 40 or total < 10. From interfloor (including just after a peak ended) a window with total >= 10 enters up-peak at up% >= 60, else down-peak at down% >= 60. Output the mode per window.

split: open-access


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

N = 1
observations = []
def solve(x):
    mode = 'interfloor'
    out = []
    for w in x['windows']:
        tot = w['lobby_up'] + w['other_up'] + w['down']
        up_pct = w['lobby_up'] // tot * 100 if tot else 0
        dn_pct = w['to_lobby'] * 100 // tot if tot else 0
        if mode == 'up-peak':
            if up_pct < 40 or tot < 10:
                mode = 'interfloor'
        elif mode == 'down-peak':
            if dn_pct < 40 or tot < 10:
                mode = 'interfloor'
        if mode == 'interfloor' and tot >= 10:
            if up_pct >= 60:
                mode = 'up-peak'
            elif dn_pct >= 60:
                mode = 'down-peak'
        out.append(mode)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('boundary: fraction just under sixty', {'windows': [{'lobby_up': 119, 'other_up': 41, 'down': 40, 'to_lobby': 0}]}, ['interfloor']), ('sampled regression 3', {'windows': [{'lobby_up': 15, 'other_up': 6, 'down': 15, 'to_lobby': 7}, {'lobby_up': 17, 'other_up': 1, 'down': 12, 'to_lobby': 11}, {'lobby_up': 9, 'other_up': 7, 'down': 10, 'to_lobby': 3}, {'lobby_up': 9, 'other_up': 2, 'down': 12, 'to_lobby': 5}, {'lobby_up': 17, 'other_up': 4, 'down': 10, 'to_lobby': 8}, {'lobby_up': 4, 'other_up': 4, 'down': 7, 'to_lobby': 7}, {'lobby_up': 6, 'other_up': 1, 'down': 19, 'to_lobby': 9}, {'lobby_up': 13, 'other_up': 1, 'down': 3, 'to_lobby': 3}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'up-peak']), ('regression: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('boundary: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('control 1', {'windows': [{'lobby_up': 0, 'other_up': 2, 'down': 3, 'to_lobby': 3}, {'lobby_up': 10, 'other_up': 4, 'down': 12, 'to_lobby': 11}, {'lobby_up': 0, 'other_up': 6, 'down': 8, 'to_lobby': 2}, {'lobby_up': 17, 'other_up': 3, 'down': 17, 'to_lobby': 15}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('sampled regression 4', {'windows': [{'lobby_up': 18, 'other_up': 3, 'down': 8, 'to_lobby': 4}, {'lobby_up': 2, 'other_up': 3, 'down': 15, 'to_lobby': 5}, {'lobby_up': 20, 'other_up': 6, 'down': 15, 'to_lobby': 15}, {'lobby_up': 16, 'other_up': 5, 'down': 19, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 6, 'down': 16, 'to_lobby': 6}, {'lobby_up': 1, 'other_up': 8, 'down': 0, 'to_lobby': 0}, {'lobby_up': 1, 'other_up': 2, 'down': 8, 'to_lobby': 8}, {'lobby_up': 6, 'other_up': 6, 'down': 0, 'to_lobby': 0}]}, ['up-peak', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'down-peak', 'interfloor']), ('sampled regression 7', {'windows': [{'lobby_up': 17, 'other_up': 7, 'down': 6, 'to_lobby': 6}, {'lobby_up': 7, 'other_up': 3, 'down': 4, 'to_lobby': 3}, {'lobby_up': 20, 'other_up': 8, 'down': 2, 'to_lobby': 1}, {'lobby_up': 17, 'other_up': 7, 'down': 7, 'to_lobby': 6}, {'lobby_up': 2, 'other_up': 3, 'down': 8, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 3, 'down': 16, 'to_lobby': 7}, {'lobby_up': 5, 'other_up': 5, 'down': 1, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'interfloor', 'interfloor', 'interfloor'])], [('regression: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('boundary: fraction just under sixty', {'windows': [{'lobby_up': 119, 'other_up': 41, 'down': 40, 'to_lobby': 0}]}, ['interfloor']), ('sampled regression 12', {'windows': [{'lobby_up': 16, 'other_up': 6, 'down': 0, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 4, 'down': 13, 'to_lobby': 8}, {'lobby_up': 6, 'other_up': 1, 'down': 17, 'to_lobby': 7}, {'lobby_up': 20, 'other_up': 8, 'down': 13, 'to_lobby': 11}, {'lobby_up': 19, 'other_up': 5, 'down': 0, 'to_lobby': 0}, {'lobby_up': 2, 'other_up': 6, 'down': 20, 'to_lobby': 10}, {'lobby_up': 17, 'other_up': 1, 'down': 5, 'to_lobby': 4}]}, ['up-peak', 'interfloor', 'interfloor', 'interfloor', 'up-peak', 'interfloor', 'up-peak']), ('boundary: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('regression: exactly sixty percent', {'windows': [{'lobby_up': 6, 'other_up': 2, 'down': 2, 'to_lobby': 0}]}, ['up-peak']), ('sampled regression 15', {'windows': [{'lobby_up': 8, 'other_up': 2, 'down': 2, 'to_lobby': 2}, {'lobby_up': 2, 'other_up': 0, 'down': 19, 'to_lobby': 13}, {'lobby_up': 11, 'other_up': 7, 'down': 20, 'to_lobby': 2}, {'lobby_up': 13, 'other_up': 7, 'down': 5, 'to_lobby': 5}, {'lobby_up': 1, 'other_up': 6, 'down': 7, 'to_lobby': 2}, {'lobby_up': 3, 'other_up': 1, 'down': 20, 'to_lobby': 20}]}, ['up-peak', 'down-peak', 'interfloor', 'interfloor', 'interfloor', 'down-peak']), ('control 18', {'windows': [{'lobby_up': 9, 'other_up': 7, 'down': 0, 'to_lobby': 0}, {'lobby_up': 18, 'other_up': 8, 'down': 11, 'to_lobby': 5}, {'lobby_up': 2, 'other_up': 6, 'down': 8, 'to_lobby': 3}, {'lobby_up': 10, 'other_up': 4, 'down': 20, 'to_lobby': 1}, {'lobby_up': 13, 'other_up': 5, 'down': 19, 'to_lobby': 12}, {'lobby_up': 1, 'other_up': 5, 'down': 16, 'to_lobby': 4}, {'lobby_up': 12, 'other_up': 6, 'down': 11, 'to_lobby': 2}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor']), ('control 21', {'windows': [{'lobby_up': 8, 'other_up': 5, 'down': 6, 'to_lobby': 1}, {'lobby_up': 20, 'other_up': 1, 'down': 15, 'to_lobby': 8}, {'lobby_up': 10, 'other_up': 0, 'down': 0, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak'])], [('regression: exactly sixty percent', {'windows': [{'lobby_up': 6, 'other_up': 2, 'down': 2, 'to_lobby': 0}]}, ['up-peak']), ('boundary: fraction just under sixty', {'windows': [{'lobby_up': 119, 'other_up': 41, 'down': 40, 'to_lobby': 0}]}, ['interfloor']), ('sampled regression 20', {'windows': [{'lobby_up': 17, 'other_up': 3, 'down': 20, 'to_lobby': 3}, {'lobby_up': 13, 'other_up': 1, 'down': 12, 'to_lobby': 11}, {'lobby_up': 12, 'other_up': 4, 'down': 10, 'to_lobby': 7}, {'lobby_up': 14, 'other_up': 3, 'down': 2, 'to_lobby': 0}, {'lobby_up': 12, 'other_up': 4, 'down': 2, 'to_lobby': 0}, {'lobby_up': 17, 'other_up': 2, 'down': 9, 'to_lobby': 3}, {'lobby_up': 19, 'other_up': 0, 'down': 11, 'to_lobby': 1}]}, ['interfloor', 'interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'up-peak']), ('boundary: down peak', {'windows': [{'lobby_up': 1, 'other_up': 1, 'down': 18, 'to_lobby': 15}, {'lobby_up': 2, 'other_up': 2, 'down': 16, 'to_lobby': 7}]}, ['down-peak', 'interfloor']), ('regression: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('control 23', {'windows': [{'lobby_up': 6, 'other_up': 6, 'down': 20, 'to_lobby': 19}, {'lobby_up': 4, 'other_up': 7, 'down': 17, 'to_lobby': 9}, {'lobby_up': 3, 'other_up': 8, 'down': 7, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 8, 'down': 3, 'to_lobby': 2}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('sampled regression 26', {'windows': [{'lobby_up': 6, 'other_up': 0, 'down': 20, 'to_lobby': 17}, {'lobby_up': 17, 'other_up': 3, 'down': 18, 'to_lobby': 1}, {'lobby_up': 6, 'other_up': 5, 'down': 7, 'to_lobby': 0}, {'lobby_up': 17, 'other_up': 8, 'down': 20, 'to_lobby': 8}, {'lobby_up': 3, 'other_up': 5, 'down': 5, 'to_lobby': 0}, {'lobby_up': 12, 'other_up': 3, 'down': 20, 'to_lobby': 19}, {'lobby_up': 17, 'other_up': 2, 'down': 1, 'to_lobby': 1}, {'lobby_up': 7, 'other_up': 5, 'down': 9, 'to_lobby': 6}]}, ['down-peak', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'up-peak', 'interfloor']), ('sampled regression 29', {'windows': [{'lobby_up': 19, 'other_up': 4, 'down': 20, 'to_lobby': 10}, {'lobby_up': 6, 'other_up': 5, 'down': 9, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 0, 'down': 17, 'to_lobby': 0}, {'lobby_up': 19, 'other_up': 4, 'down': 8, 'to_lobby': 1}]}, ['interfloor', 'interfloor', 'interfloor', 'up-peak'])], [('regression: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('boundary: fraction just under sixty', {'windows': [{'lobby_up': 119, 'other_up': 41, 'down': 40, 'to_lobby': 0}]}, ['interfloor']), ('sampled regression 32', {'windows': [{'lobby_up': 6, 'other_up': 6, 'down': 1, 'to_lobby': 0}, {'lobby_up': 10, 'other_up': 0, 'down': 19, 'to_lobby': 12}, {'lobby_up': 17, 'other_up': 4, 'down': 2, 'to_lobby': 1}]}, ['interfloor', 'interfloor', 'up-peak']), ('regression: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('boundary: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('sampled regression 34', {'windows': [{'lobby_up': 14, 'other_up': 3, 'down': 13, 'to_lobby': 8}, {'lobby_up': 8, 'other_up': 4, 'down': 1, 'to_lobby': 1}, {'lobby_up': 20, 'other_up': 0, 'down': 3, 'to_lobby': 3}, {'lobby_up': 4, 'other_up': 5, 'down': 8, 'to_lobby': 7}, {'lobby_up': 6, 'other_up': 6, 'down': 19, 'to_lobby': 5}, {'lobby_up': 6, 'other_up': 5, 'down': 7, 'to_lobby': 5}]}, ['interfloor', 'up-peak', 'up-peak', 'interfloor', 'interfloor', 'interfloor']), ('control 37', {'windows': [{'lobby_up': 16, 'other_up': 8, 'down': 17, 'to_lobby': 12}, {'lobby_up': 16, 'other_up': 3, 'down': 11, 'to_lobby': 0}, {'lobby_up': 4, 'other_up': 8, 'down': 1, 'to_lobby': 0}, {'lobby_up': 10, 'other_up': 5, 'down': 8, 'to_lobby': 5}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('sampled regression 40', {'windows': [{'lobby_up': 7, 'other_up': 6, 'down': 2, 'to_lobby': 1}, {'lobby_up': 11, 'other_up': 2, 'down': 1, 'to_lobby': 0}, {'lobby_up': 18, 'other_up': 7, 'down': 16, 'to_lobby': 4}, {'lobby_up': 0, 'other_up': 8, 'down': 18, 'to_lobby': 1}, {'lobby_up': 1, 'other_up': 2, 'down': 12, 'to_lobby': 9}, {'lobby_up': 7, 'other_up': 3, 'down': 0, 'to_lobby': 0}]}, ['interfloor', 'up-peak', 'up-peak', 'interfloor', 'down-peak', 'up-peak'])], [('regression: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('boundary: fraction just under sixty', {'windows': [{'lobby_up': 119, 'other_up': 41, 'down': 40, 'to_lobby': 0}]}, ['interfloor']), ('sampled regression 47', {'windows': [{'lobby_up': 2, 'other_up': 7, 'down': 18, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 5, 'down': 2, 'to_lobby': 2}, {'lobby_up': 0, 'other_up': 1, 'down': 6, 'to_lobby': 6}, {'lobby_up': 15, 'other_up': 6, 'down': 3, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 0, 'down': 16, 'to_lobby': 6}, {'lobby_up': 2, 'other_up': 1, 'down': 5, 'to_lobby': 3}, {'lobby_up': 12, 'other_up': 4, 'down': 8, 'to_lobby': 8}]}, ['interfloor', 'up-peak', 'interfloor', 'up-peak', 'up-peak', 'interfloor', 'interfloor']), ('boundary: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('regression: exactly sixty percent', {'windows': [{'lobby_up': 6, 'other_up': 2, 'down': 2, 'to_lobby': 0}]}, ['up-peak']), ('control 45', {'windows': [{'lobby_up': 15, 'other_up': 5, 'down': 7, 'to_lobby': 2}, {'lobby_up': 5, 'other_up': 7, 'down': 14, 'to_lobby': 0}, {'lobby_up': 17, 'other_up': 2, 'down': 13, 'to_lobby': 4}, {'lobby_up': 3, 'other_up': 3, 'down': 10, 'to_lobby': 7}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('sampled regression 48', {'windows': [{'lobby_up': 0, 'other_up': 3, 'down': 12, 'to_lobby': 1}, {'lobby_up': 19, 'other_up': 1, 'down': 12, 'to_lobby': 11}, {'lobby_up': 8, 'other_up': 2, 'down': 4, 'to_lobby': 3}, {'lobby_up': 18, 'other_up': 8, 'down': 1, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 7, 'down': 18, 'to_lobby': 17}, {'lobby_up': 11, 'other_up': 1, 'down': 18, 'to_lobby': 7}, {'lobby_up': 10, 'other_up': 2, 'down': 15, 'to_lobby': 2}]}, ['interfloor', 'interfloor', 'interfloor', 'up-peak', 'interfloor', 'interfloor', 'interfloor']), ('sampled regression 51', {'windows': [{'lobby_up': 4, 'other_up': 0, 'down': 1, 'to_lobby': 0}, {'lobby_up': 16, 'other_up': 6, 'down': 19, 'to_lobby': 15}, {'lobby_up': 13, 'other_up': 6, 'down': 3, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 0, 'down': 16, 'to_lobby': 2}, {'lobby_up': 20, 'other_up': 8, 'down': 11, 'to_lobby': 7}, {'lobby_up': 10, 'other_up': 5, 'down': 6, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 6, 'down': 19, 'to_lobby': 0}, {'lobby_up': 20, 'other_up': 2, 'down': 1, 'to_lobby': 1}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'up-peak'])]]
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):
    mode = 'interfloor'
    out = []
    for w in x['windows']:
        tot = w['lobby_up'] + w['other_up'] + w['down']
        up_pct = round(w['lobby_up'] * 100 / tot) if tot else 0
        dn_pct = w['to_lobby'] * 100 // tot if tot else 0
        if mode == 'up-peak':
            if up_pct < 40 or tot < 10:
                mode = 'interfloor'
        elif mode == 'down-peak':
            if dn_pct < 40 or tot < 10:
                mode = 'interfloor'
        if mode == 'interfloor' and tot >= 10:
            if up_pct >= 60:
                mode = 'up-peak'
            elif dn_pct >= 60:
                mode = 'down-peak'
        out.append(mode)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('boundary: fraction just under sixty', {'windows': [{'lobby_up': 119, 'other_up': 41, 'down': 40, 'to_lobby': 0}]}, ['interfloor']), ('sampled regression 3', {'windows': [{'lobby_up': 15, 'other_up': 6, 'down': 15, 'to_lobby': 7}, {'lobby_up': 17, 'other_up': 1, 'down': 12, 'to_lobby': 11}, {'lobby_up': 9, 'other_up': 7, 'down': 10, 'to_lobby': 3}, {'lobby_up': 9, 'other_up': 2, 'down': 12, 'to_lobby': 5}, {'lobby_up': 17, 'other_up': 4, 'down': 10, 'to_lobby': 8}, {'lobby_up': 4, 'other_up': 4, 'down': 7, 'to_lobby': 7}, {'lobby_up': 6, 'other_up': 1, 'down': 19, 'to_lobby': 9}, {'lobby_up': 13, 'other_up': 1, 'down': 3, 'to_lobby': 3}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'up-peak']), ('regression: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('boundary: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('control 1', {'windows': [{'lobby_up': 0, 'other_up': 2, 'down': 3, 'to_lobby': 3}, {'lobby_up': 10, 'other_up': 4, 'down': 12, 'to_lobby': 11}, {'lobby_up': 0, 'other_up': 6, 'down': 8, 'to_lobby': 2}, {'lobby_up': 17, 'other_up': 3, 'down': 17, 'to_lobby': 15}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('sampled regression 4', {'windows': [{'lobby_up': 18, 'other_up': 3, 'down': 8, 'to_lobby': 4}, {'lobby_up': 2, 'other_up': 3, 'down': 15, 'to_lobby': 5}, {'lobby_up': 20, 'other_up': 6, 'down': 15, 'to_lobby': 15}, {'lobby_up': 16, 'other_up': 5, 'down': 19, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 6, 'down': 16, 'to_lobby': 6}, {'lobby_up': 1, 'other_up': 8, 'down': 0, 'to_lobby': 0}, {'lobby_up': 1, 'other_up': 2, 'down': 8, 'to_lobby': 8}, {'lobby_up': 6, 'other_up': 6, 'down': 0, 'to_lobby': 0}]}, ['up-peak', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'down-peak', 'interfloor']), ('sampled regression 7', {'windows': [{'lobby_up': 17, 'other_up': 7, 'down': 6, 'to_lobby': 6}, {'lobby_up': 7, 'other_up': 3, 'down': 4, 'to_lobby': 3}, {'lobby_up': 20, 'other_up': 8, 'down': 2, 'to_lobby': 1}, {'lobby_up': 17, 'other_up': 7, 'down': 7, 'to_lobby': 6}, {'lobby_up': 2, 'other_up': 3, 'down': 8, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 3, 'down': 16, 'to_lobby': 7}, {'lobby_up': 5, 'other_up': 5, 'down': 1, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak', 'up-peak', 'interfloor', 'interfloor', 'interfloor'])], [('regression: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('boundary: fraction just under sixty', {'windows': [{'lobby_up': 119, 'other_up': 41, 'down': 40, 'to_lobby': 0}]}, ['interfloor']), ('sampled regression 12', {'windows': [{'lobby_up': 16, 'other_up': 6, 'down': 0, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 4, 'down': 13, 'to_lobby': 8}, {'lobby_up': 6, 'other_up': 1, 'down': 17, 'to_lobby': 7}, {'lobby_up': 20, 'other_up': 8, 'down': 13, 'to_lobby': 11}, {'lobby_up': 19, 'other_up': 5, 'down': 0, 'to_lobby': 0}, {'lobby_up': 2, 'other_up': 6, 'down': 20, 'to_lobby': 10}, {'lobby_up': 17, 'other_up': 1, 'down': 5, 'to_lobby': 4}]}, ['up-peak', 'interfloor', 'interfloor', 'interfloor', 'up-peak', 'interfloor', 'up-peak']), ('boundary: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('regression: exactly sixty percent', {'windows': [{'lobby_up': 6, 'other_up': 2, 'down': 2, 'to_lobby': 0}]}, ['up-peak']), ('sampled regression 15', {'windows': [{'lobby_up': 8, 'other_up': 2, 'down': 2, 'to_lobby': 2}, {'lobby_up': 2, 'other_up': 0, 'down': 19, 'to_lobby': 13}, {'lobby_up': 11, 'other_up': 7, 'down': 20, 'to_lobby': 2}, {'lobby_up': 13, 'other_up': 7, 'down': 5, 'to_lobby': 5}, {'lobby_up': 1, 'other_up': 6, 'down': 7, 'to_lobby': 2}, {'lobby_up': 3, 'other_up': 1, 'down': 20, 'to_lobby': 20}]}, ['up-peak', 'down-peak', 'interfloor', 'interfloor', 'interfloor', 'down-peak']), ('control 18', {'windows': [{'lobby_up': 9, 'other_up': 7, 'down': 0, 'to_lobby': 0}, {'lobby_up': 18, 'other_up': 8, 'down': 11, 'to_lobby': 5}, {'lobby_up': 2, 'other_up': 6, 'down': 8, 'to_lobby': 3}, {'lobby_up': 10, 'other_up': 4, 'down': 20, 'to_lobby': 1}, {'lobby_up': 13, 'other_up': 5, 'down': 19, 'to_lobby': 12}, {'lobby_up': 1, 'other_up': 5, 'down': 16, 'to_lobby': 4}, {'lobby_up': 12, 'other_up': 6, 'down': 11, 'to_lobby': 2}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor']), ('control 21', {'windows': [{'lobby_up': 8, 'other_up': 5, 'down': 6, 'to_lobby': 1}, {'lobby_up': 20, 'other_up': 1, 'down': 15, 'to_lobby': 8}, {'lobby_up': 10, 'other_up': 0, 'down': 0, 'to_lobby': 0}]}, ['interfloor', 'interfloor', 'up-peak'])], [('regression: exactly sixty percent', {'windows': [{'lobby_up': 6, 'other_up': 2, 'down': 2, 'to_lobby': 0}]}, ['up-peak']), ('boundary: fraction just under sixty', {'windows': [{'lobby_up': 119, 'other_up': 41, 'down': 40, 'to_lobby': 0}]}, ['interfloor']), ('sampled regression 20', {'windows': [{'lobby_up': 17, 'other_up': 3, 'down': 20, 'to_lobby': 3}, {'lobby_up': 13, 'other_up': 1, 'down': 12, 'to_lobby': 11}, {'lobby_up': 12, 'other_up': 4, 'down': 10, 'to_lobby': 7}, {'lobby_up': 14, 'other_up': 3, 'down': 2, 'to_lobby': 0}, {'lobby_up': 12, 'other_up': 4, 'down': 2, 'to_lobby': 0}, {'lobby_up': 17, 'other_up': 2, 'down': 9, 'to_lobby': 3}, {'lobby_up': 19, 'other_up': 0, 'down': 11, 'to_lobby': 1}]}, ['interfloor', 'interfloor', 'interfloor', 'up-peak', 'up-peak', 'up-peak', 'up-peak']), ('boundary: down peak', {'windows': [{'lobby_up': 1, 'other_up': 1, 'down': 18, 'to_lobby': 15}, {'lobby_up': 2, 'other_up': 2, 'down': 16, 'to_lobby': 7}]}, ['down-peak', 'interfloor']), ('regression: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('control 23', {'windows': [{'lobby_up': 6, 'other_up': 6, 'down': 20, 'to_lobby': 19}, {'lobby_up': 4, 'other_up': 7, 'down': 17, 'to_lobby': 9}, {'lobby_up': 3, 'other_up': 8, 'down': 7, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 8, 'down': 3, 'to_lobby': 2}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('sampled regression 26', {'windows': [{'lobby_up': 6, 'other_up': 0, 'down': 20, 'to_lobby': 17}, {'lobby_up': 17, 'other_up': 3, 'down': 18, 'to_lobby': 1}, {'lobby_up': 6, 'other_up': 5, 'down': 7, 'to_lobby': 0}, {'lobby_up': 17, 'other_up': 8, 'down': 20, 'to_lobby': 8}, {'lobby_up': 3, 'other_up': 5, 'down': 5, 'to_lobby': 0}, {'lobby_up': 12, 'other_up': 3, 'down': 20, 'to_lobby': 19}, {'lobby_up': 17, 'other_up': 2, 'down': 1, 'to_lobby': 1}, {'lobby_up': 7, 'other_up': 5, 'down': 9, 'to_lobby': 6}]}, ['down-peak', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'up-peak', 'interfloor']), ('sampled regression 29', {'windows': [{'lobby_up': 19, 'other_up': 4, 'down': 20, 'to_lobby': 10}, {'lobby_up': 6, 'other_up': 5, 'down': 9, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 0, 'down': 17, 'to_lobby': 0}, {'lobby_up': 19, 'other_up': 4, 'down': 8, 'to_lobby': 1}]}, ['interfloor', 'interfloor', 'interfloor', 'up-peak'])], [('regression: hysteresis keeps up-peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 5, 'down': 6, 'to_lobby': 1}]}, ['up-peak', 'up-peak']), ('boundary: fraction just under sixty', {'windows': [{'lobby_up': 119, 'other_up': 41, 'down': 40, 'to_lobby': 0}]}, ['interfloor']), ('sampled regression 32', {'windows': [{'lobby_up': 6, 'other_up': 6, 'down': 1, 'to_lobby': 0}, {'lobby_up': 10, 'other_up': 0, 'down': 19, 'to_lobby': 12}, {'lobby_up': 17, 'other_up': 4, 'down': 2, 'to_lobby': 1}]}, ['interfloor', 'interfloor', 'up-peak']), ('regression: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('boundary: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('sampled regression 34', {'windows': [{'lobby_up': 14, 'other_up': 3, 'down': 13, 'to_lobby': 8}, {'lobby_up': 8, 'other_up': 4, 'down': 1, 'to_lobby': 1}, {'lobby_up': 20, 'other_up': 0, 'down': 3, 'to_lobby': 3}, {'lobby_up': 4, 'other_up': 5, 'down': 8, 'to_lobby': 7}, {'lobby_up': 6, 'other_up': 6, 'down': 19, 'to_lobby': 5}, {'lobby_up': 6, 'other_up': 5, 'down': 7, 'to_lobby': 5}]}, ['interfloor', 'up-peak', 'up-peak', 'interfloor', 'interfloor', 'interfloor']), ('control 37', {'windows': [{'lobby_up': 16, 'other_up': 8, 'down': 17, 'to_lobby': 12}, {'lobby_up': 16, 'other_up': 3, 'down': 11, 'to_lobby': 0}, {'lobby_up': 4, 'other_up': 8, 'down': 1, 'to_lobby': 0}, {'lobby_up': 10, 'other_up': 5, 'down': 8, 'to_lobby': 5}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('sampled regression 40', {'windows': [{'lobby_up': 7, 'other_up': 6, 'down': 2, 'to_lobby': 1}, {'lobby_up': 11, 'other_up': 2, 'down': 1, 'to_lobby': 0}, {'lobby_up': 18, 'other_up': 7, 'down': 16, 'to_lobby': 4}, {'lobby_up': 0, 'other_up': 8, 'down': 18, 'to_lobby': 1}, {'lobby_up': 1, 'other_up': 2, 'down': 12, 'to_lobby': 9}, {'lobby_up': 7, 'other_up': 3, 'down': 0, 'to_lobby': 0}]}, ['interfloor', 'up-peak', 'up-peak', 'interfloor', 'down-peak', 'up-peak'])], [('regression: quiet window ends a peak', {'windows': [{'lobby_up': 12, 'other_up': 2, 'down': 6, 'to_lobby': 0}, {'lobby_up': 6, 'other_up': 0, 'down': 2, 'to_lobby': 0}]}, ['up-peak', 'interfloor']), ('boundary: fraction just under sixty', {'windows': [{'lobby_up': 119, 'other_up': 41, 'down': 40, 'to_lobby': 0}]}, ['interfloor']), ('sampled regression 47', {'windows': [{'lobby_up': 2, 'other_up': 7, 'down': 18, 'to_lobby': 2}, {'lobby_up': 19, 'other_up': 5, 'down': 2, 'to_lobby': 2}, {'lobby_up': 0, 'other_up': 1, 'down': 6, 'to_lobby': 6}, {'lobby_up': 15, 'other_up': 6, 'down': 3, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 0, 'down': 16, 'to_lobby': 6}, {'lobby_up': 2, 'other_up': 1, 'down': 5, 'to_lobby': 3}, {'lobby_up': 12, 'other_up': 4, 'down': 8, 'to_lobby': 8}]}, ['interfloor', 'up-peak', 'interfloor', 'up-peak', 'up-peak', 'interfloor', 'interfloor']), ('boundary: quiet window cannot start a peak', {'windows': [{'lobby_up': 8, 'other_up': 0, 'down': 1, 'to_lobby': 0}]}, ['interfloor']), ('regression: exactly sixty percent', {'windows': [{'lobby_up': 6, 'other_up': 2, 'down': 2, 'to_lobby': 0}]}, ['up-peak']), ('control 45', {'windows': [{'lobby_up': 15, 'other_up': 5, 'down': 7, 'to_lobby': 2}, {'lobby_up': 5, 'other_up': 7, 'down': 14, 'to_lobby': 0}, {'lobby_up': 17, 'other_up': 2, 'down': 13, 'to_lobby': 4}, {'lobby_up': 3, 'other_up': 3, 'down': 10, 'to_lobby': 7}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor']), ('sampled regression 48', {'windows': [{'lobby_up': 0, 'other_up': 3, 'down': 12, 'to_lobby': 1}, {'lobby_up': 19, 'other_up': 1, 'down': 12, 'to_lobby': 11}, {'lobby_up': 8, 'other_up': 2, 'down': 4, 'to_lobby': 3}, {'lobby_up': 18, 'other_up': 8, 'down': 1, 'to_lobby': 0}, {'lobby_up': 9, 'other_up': 7, 'down': 18, 'to_lobby': 17}, {'lobby_up': 11, 'other_up': 1, 'down': 18, 'to_lobby': 7}, {'lobby_up': 10, 'other_up': 2, 'down': 15, 'to_lobby': 2}]}, ['interfloor', 'interfloor', 'interfloor', 'up-peak', 'interfloor', 'interfloor', 'interfloor']), ('sampled regression 51', {'windows': [{'lobby_up': 4, 'other_up': 0, 'down': 1, 'to_lobby': 0}, {'lobby_up': 16, 'other_up': 6, 'down': 19, 'to_lobby': 15}, {'lobby_up': 13, 'other_up': 6, 'down': 3, 'to_lobby': 3}, {'lobby_up': 15, 'other_up': 0, 'down': 16, 'to_lobby': 2}, {'lobby_up': 20, 'other_up': 8, 'down': 11, 'to_lobby': 7}, {'lobby_up': 10, 'other_up': 5, 'down': 6, 'to_lobby': 1}, {'lobby_up': 12, 'other_up': 6, 'down': 19, 'to_lobby': 0}, {'lobby_up': 20, 'other_up': 2, 'down': 1, 'to_lobby': 1}]}, ['interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'interfloor', 'up-peak'])]]
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 up-peak share is always 0 or 100 percent, or rounds up across the threshold.

Per 5-minute window, total = lobby_up + other_up + down. up% = lobby_up*100//total and down% = to_lobby*100//total (0 if total is 0). An active peak ends when its percentage falls below 40 or total < 10. From interfloor (including just after a peak ended) a window with total >= 10 enters up-peak at up% >= 60, else down-peak at down% >= 60. Output the mode per window.

split: open-access