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

N = 1
observations = []
def solve(x):
    cards = x['cards']
    restricted = set(x['restricted'])
    lo, hi = x['secure_hours']
    card = None
    card_t = None
    out = []
    for t, kind, v in x['events']:
        if kind == 'card':
            card = v
            card_t = t
            out.append('read')
            continue
        hour = t // 3600
        in_window = (lo <= hour < hi) if lo <= hi else (hour >= lo or hour < hi)
        if v not in restricted or not in_window:
            out.append('accepted')
        elif card is not None and t - card_t <= 10 and v in cards.get(card, []):
            out.append('accepted')
            card = None
        else:
            out.append('denied')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('sampled regression 5', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[85805, 'call', 12], [89405, 'call', 2], [89406, 'card', 'K1'], [89407, 'call', 5], [89418, 'card', 'K9'], [89427, 'call', 5]]}, ['accepted', 'accepted', 'read', 'accepted', 'read', 'denied']), ('boundary: end of the secured window', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [8, 18], 'events': [[64800, 'call', 5], [64799, 'call', 5]]}, ['accepted', 'denied']), ('sampled regression 44', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[85809, 'card', 'K2'], [89409, 'call', 7], [89419, 'call', 12], [89429, 'card', 'K9'], [93029, 'card', 'K9'], [93034, 'call', 5]]}, ['read', 'denied', 'accepted', 'read', 'read', 'denied']), ('boundary: overnight window', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[82800, 'call', 9], [10800, 'call', 9], [43200, 'call', 9]]}, ['denied', 'denied', 'accepted']), ('boundary: call ten seconds after the read', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[100, 'card', 'K1'], [110, 'call', 5]]}, ['read', 'accepted']), ('control 1', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[9, 'card', 'K1'], [14, 'card', 'K1'], [23, 'call', 2]]}, ['read', 'read', 'accepted']), ('control 4', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[10, 'call', 7], [3610, 'call', 2], [3615, 'card', 'K9'], [3625, 'call', 2]]}, ['denied', 'accepted', 'read', 'accepted']), ('control 7', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [8, 18], 'events': [[85810, 'card', 'K1'], [85811, 'call', 7], [85812, 'card', 'K1'], [85821, 'call', 5], [85831, 'card', 'K2']]}, ['read', 'accepted', 'read', 'accepted', 'read'])], [('sampled regression 15', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[89400, 'call', 9], [93000, 'call', 7]]}, ['denied', 'denied']), ('boundary: overnight window', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[82800, 'call', 9], [10800, 'call', 9], [43200, 'call', 9]]}, ['denied', 'denied', 'accepted']), ('sampled regression 42', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[85801, 'call', 7], [89401, 'call', 9], [89461, 'card', 'K1'], [89472, 'call', 12], [89532, 'call', 5], [89541, 'card', 'K9'], [89550, 'card', 'K2']]}, ['denied', 'denied', 'read', 'accepted', 'denied', 'read', 'read']), ('control 18', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [8, 18], 'events': [[85810, 'card', 'K1'], [85870, 'call', 2], [85880, 'call', 5], [85889, 'call', 12], [85900, 'card', 'K2']]}, ['read', 'accepted', 'accepted', 'accepted', 'read']), ('boundary: credential used twice', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[100, 'card', 'K1'], [102, 'call', 5], [104, 'call', 7]]}, ['read', 'accepted', 'denied']), ('control 12', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[5, 'card', 'K1'], [3605, 'call', 12], [3615, 'call', 9], [3616, 'call', 7]]}, ['read', 'accepted', 'denied', 'denied']), ('control 21', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[25209, 'card', 'K1'], [28809, 'call', 12], [28818, 'card', 'K1'], [28878, 'call', 7], [28879, 'call', 12]]}, ['read', 'accepted', 'read', 'denied', 'accepted']), ('control 24', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[9, 'call', 9], [14, 'card', 'K1'], [15, 'card', 'K9'], [25, 'card', 'K9']]}, ['denied', 'read', 'read', 'read'])], [('sampled regression 42', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[85801, 'call', 7], [89401, 'call', 9], [89461, 'card', 'K1'], [89472, 'call', 12], [89532, 'call', 5], [89541, 'card', 'K9'], [89550, 'card', 'K2']]}, ['denied', 'denied', 'read', 'accepted', 'denied', 'read', 'read']), ('boundary: end of the secured window', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [8, 18], 'events': [[64800, 'call', 5], [64799, 'call', 5]]}, ['accepted', 'denied']), ('sampled regression 15', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[89400, 'call', 9], [93000, 'call', 7]]}, ['denied', 'denied']), ('control 47', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [8, 18], 'events': [[25260, 'call', 5], [28860, 'card', 'K1'], [28920, 'call', 12], [28931, 'card', 'K1'], [28936, 'card', 'K1']]}, ['accepted', 'read', 'accepted', 'read', 'read']), ('boundary: overnight window', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[82800, 'call', 9], [10800, 'call', 9], [43200, 'call', 9]]}, ['denied', 'denied', 'accepted']), ('control 23', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[72010, 'call', 9], [75610, 'card', 'K1'], [75615, 'call', 12], [75675, 'call', 5], [75686, 'call', 9], [75696, 'call', 5], [75705, 'call', 9]]}, ['denied', 'read', 'accepted', 'denied', 'denied', 'denied', 'denied']), ('control 26', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[85810, 'call', 2], [85819, 'card', 'K1'], [85820, 'card', 'K9'], [85825, 'call', 2]]}, ['accepted', 'read', 'read', 'accepted']), ('control 29', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [8, 18], 'events': [[85801, 'card', 'K2'], [85812, 'call', 12], [85823, 'call', 9], [85832, 'call', 12], [85892, 'card', 'K2']]}, ['read', 'accepted', 'accepted', 'accepted', 'read'])], [('sampled regression 44', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[85809, 'card', 'K2'], [89409, 'call', 7], [89419, 'call', 12], [89429, 'card', 'K9'], [93029, 'card', 'K9'], [93034, 'call', 5]]}, ['read', 'denied', 'accepted', 'read', 'read', 'denied']), ('boundary: overnight window', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[82800, 'call', 9], [10800, 'call', 9], [43200, 'call', 9]]}, ['denied', 'denied', 'accepted']), ('sampled regression 5', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[85805, 'call', 12], [89405, 'call', 2], [89406, 'card', 'K1'], [89407, 'call', 5], [89418, 'card', 'K9'], [89427, 'call', 5]]}, ['accepted', 'accepted', 'read', 'accepted', 'read', 'denied']), ('control 59', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[85809, 'call', 5], [85818, 'call', 2], [85823, 'card', 'K9'], [85834, 'call', 12], [85894, 'card', 'K1'], [85954, 'call', 7], [85965, 'call', 9]]}, ['denied', 'accepted', 'read', 'accepted', 'read', 'denied', 'denied']), ('boundary: card without the floor', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[100, 'card', 'K2'], [101, 'call', 5]]}, ['read', 'denied']), ('control 34', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[3600, 'call', 2], [3611, 'card', 'K2']]}, ['accepted', 'read']), ('control 37', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[3600, 'card', 'K9'], [3609, 'card', 'K1'], [3619, 'card', 'K1'], [7219, 'card', 'K1'], [7224, 'card', 'K1']]}, ['read', 'read', 'read', 'read', 'read']), ('control 40', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[72011, 'call', 12], [72022, 'call', 9]]}, ['accepted', 'denied'])], [('sampled regression 5', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[85805, 'call', 12], [89405, 'call', 2], [89406, 'card', 'K1'], [89407, 'call', 5], [89418, 'card', 'K9'], [89427, 'call', 5]]}, ['accepted', 'accepted', 'read', 'accepted', 'read', 'denied']), ('boundary: end of the secured window', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [8, 18], 'events': [[64800, 'call', 5], [64799, 'call', 5]]}, ['accepted', 'denied']), ('sampled regression 44', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[85809, 'card', 'K2'], [89409, 'call', 7], [89419, 'call', 12], [89429, 'card', 'K9'], [93029, 'card', 'K9'], [93034, 'call', 5]]}, ['read', 'denied', 'accepted', 'read', 'read', 'denied']), ('boundary: overnight window', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[82800, 'call', 9], [10800, 'call', 9], [43200, 'call', 9]]}, ['denied', 'denied', 'accepted']), ('boundary: call eleven seconds after the read', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[100, 'card', 'K1'], [111, 'call', 5]]}, ['read', 'denied']), ('control 45', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [8, 18], 'events': [[72011, 'call', 2], [72020, 'card', 'K9'], [72021, 'call', 2]]}, ['accepted', 'read', 'accepted']), ('control 48', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[25260, 'call', 5], [25265, 'card', 'K2']]}, ['accepted', 'read']), ('control 51', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [8, 18], 'events': [[72011, 'card', 'K9'], [75611, 'call', 5], [75620, 'call', 12], [75629, 'card', 'K1']]}, ['read', 'accepted', 'accepted', 'read'])]]
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):
    cards = x['cards']
    restricted = set(x['restricted'])
    lo, hi = x['secure_hours']
    card = None
    card_t = None
    out = []
    for t, kind, v in x['events']:
        if kind == 'card':
            card = v
            card_t = t
            out.append('read')
            continue
        hour = (t // 60) % 24
        in_window = (lo <= hour < hi) if lo <= hi else (hour >= lo or hour < hi)
        if v not in restricted or not in_window:
            out.append('accepted')
        elif card is not None and t - card_t <= 10 and v in cards.get(card, []):
            out.append('accepted')
            card = None
        else:
            out.append('denied')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('sampled regression 5', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[85805, 'call', 12], [89405, 'call', 2], [89406, 'card', 'K1'], [89407, 'call', 5], [89418, 'card', 'K9'], [89427, 'call', 5]]}, ['accepted', 'accepted', 'read', 'accepted', 'read', 'denied']), ('boundary: end of the secured window', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [8, 18], 'events': [[64800, 'call', 5], [64799, 'call', 5]]}, ['accepted', 'denied']), ('sampled regression 44', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[85809, 'card', 'K2'], [89409, 'call', 7], [89419, 'call', 12], [89429, 'card', 'K9'], [93029, 'card', 'K9'], [93034, 'call', 5]]}, ['read', 'denied', 'accepted', 'read', 'read', 'denied']), ('boundary: overnight window', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[82800, 'call', 9], [10800, 'call', 9], [43200, 'call', 9]]}, ['denied', 'denied', 'accepted']), ('boundary: call ten seconds after the read', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[100, 'card', 'K1'], [110, 'call', 5]]}, ['read', 'accepted']), ('control 1', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[9, 'card', 'K1'], [14, 'card', 'K1'], [23, 'call', 2]]}, ['read', 'read', 'accepted']), ('control 4', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[10, 'call', 7], [3610, 'call', 2], [3615, 'card', 'K9'], [3625, 'call', 2]]}, ['denied', 'accepted', 'read', 'accepted']), ('control 7', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [8, 18], 'events': [[85810, 'card', 'K1'], [85811, 'call', 7], [85812, 'card', 'K1'], [85821, 'call', 5], [85831, 'card', 'K2']]}, ['read', 'accepted', 'read', 'accepted', 'read'])], [('sampled regression 15', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[89400, 'call', 9], [93000, 'call', 7]]}, ['denied', 'denied']), ('boundary: overnight window', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[82800, 'call', 9], [10800, 'call', 9], [43200, 'call', 9]]}, ['denied', 'denied', 'accepted']), ('sampled regression 42', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[85801, 'call', 7], [89401, 'call', 9], [89461, 'card', 'K1'], [89472, 'call', 12], [89532, 'call', 5], [89541, 'card', 'K9'], [89550, 'card', 'K2']]}, ['denied', 'denied', 'read', 'accepted', 'denied', 'read', 'read']), ('control 18', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [8, 18], 'events': [[85810, 'card', 'K1'], [85870, 'call', 2], [85880, 'call', 5], [85889, 'call', 12], [85900, 'card', 'K2']]}, ['read', 'accepted', 'accepted', 'accepted', 'read']), ('boundary: credential used twice', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[100, 'card', 'K1'], [102, 'call', 5], [104, 'call', 7]]}, ['read', 'accepted', 'denied']), ('control 12', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[5, 'card', 'K1'], [3605, 'call', 12], [3615, 'call', 9], [3616, 'call', 7]]}, ['read', 'accepted', 'denied', 'denied']), ('control 21', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[25209, 'card', 'K1'], [28809, 'call', 12], [28818, 'card', 'K1'], [28878, 'call', 7], [28879, 'call', 12]]}, ['read', 'accepted', 'read', 'denied', 'accepted']), ('control 24', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[9, 'call', 9], [14, 'card', 'K1'], [15, 'card', 'K9'], [25, 'card', 'K9']]}, ['denied', 'read', 'read', 'read'])], [('sampled regression 42', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[85801, 'call', 7], [89401, 'call', 9], [89461, 'card', 'K1'], [89472, 'call', 12], [89532, 'call', 5], [89541, 'card', 'K9'], [89550, 'card', 'K2']]}, ['denied', 'denied', 'read', 'accepted', 'denied', 'read', 'read']), ('boundary: end of the secured window', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [8, 18], 'events': [[64800, 'call', 5], [64799, 'call', 5]]}, ['accepted', 'denied']), ('sampled regression 15', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[89400, 'call', 9], [93000, 'call', 7]]}, ['denied', 'denied']), ('control 47', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [8, 18], 'events': [[25260, 'call', 5], [28860, 'card', 'K1'], [28920, 'call', 12], [28931, 'card', 'K1'], [28936, 'card', 'K1']]}, ['accepted', 'read', 'accepted', 'read', 'read']), ('boundary: overnight window', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[82800, 'call', 9], [10800, 'call', 9], [43200, 'call', 9]]}, ['denied', 'denied', 'accepted']), ('control 23', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[72010, 'call', 9], [75610, 'card', 'K1'], [75615, 'call', 12], [75675, 'call', 5], [75686, 'call', 9], [75696, 'call', 5], [75705, 'call', 9]]}, ['denied', 'read', 'accepted', 'denied', 'denied', 'denied', 'denied']), ('control 26', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[85810, 'call', 2], [85819, 'card', 'K1'], [85820, 'card', 'K9'], [85825, 'call', 2]]}, ['accepted', 'read', 'read', 'accepted']), ('control 29', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [8, 18], 'events': [[85801, 'card', 'K2'], [85812, 'call', 12], [85823, 'call', 9], [85832, 'call', 12], [85892, 'card', 'K2']]}, ['read', 'accepted', 'accepted', 'accepted', 'read'])], [('sampled regression 44', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[85809, 'card', 'K2'], [89409, 'call', 7], [89419, 'call', 12], [89429, 'card', 'K9'], [93029, 'card', 'K9'], [93034, 'call', 5]]}, ['read', 'denied', 'accepted', 'read', 'read', 'denied']), ('boundary: overnight window', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[82800, 'call', 9], [10800, 'call', 9], [43200, 'call', 9]]}, ['denied', 'denied', 'accepted']), ('sampled regression 5', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[85805, 'call', 12], [89405, 'call', 2], [89406, 'card', 'K1'], [89407, 'call', 5], [89418, 'card', 'K9'], [89427, 'call', 5]]}, ['accepted', 'accepted', 'read', 'accepted', 'read', 'denied']), ('control 59', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[85809, 'call', 5], [85818, 'call', 2], [85823, 'card', 'K9'], [85834, 'call', 12], [85894, 'card', 'K1'], [85954, 'call', 7], [85965, 'call', 9]]}, ['denied', 'accepted', 'read', 'accepted', 'read', 'denied', 'denied']), ('boundary: card without the floor', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[100, 'card', 'K2'], [101, 'call', 5]]}, ['read', 'denied']), ('control 34', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[3600, 'call', 2], [3611, 'card', 'K2']]}, ['accepted', 'read']), ('control 37', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[3600, 'card', 'K9'], [3609, 'card', 'K1'], [3619, 'card', 'K1'], [7219, 'card', 'K1'], [7224, 'card', 'K1']]}, ['read', 'read', 'read', 'read', 'read']), ('control 40', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[72011, 'call', 12], [72022, 'call', 9]]}, ['accepted', 'denied'])], [('sampled regression 5', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[85805, 'call', 12], [89405, 'call', 2], [89406, 'card', 'K1'], [89407, 'call', 5], [89418, 'card', 'K9'], [89427, 'call', 5]]}, ['accepted', 'accepted', 'read', 'accepted', 'read', 'denied']), ('boundary: end of the secured window', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [8, 18], 'events': [[64800, 'call', 5], [64799, 'call', 5]]}, ['accepted', 'denied']), ('sampled regression 44', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[85809, 'card', 'K2'], [89409, 'call', 7], [89419, 'call', 12], [89429, 'card', 'K9'], [93029, 'card', 'K9'], [93034, 'call', 5]]}, ['read', 'denied', 'accepted', 'read', 'read', 'denied']), ('boundary: overnight window', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[82800, 'call', 9], [10800, 'call', 9], [43200, 'call', 9]]}, ['denied', 'denied', 'accepted']), ('boundary: call eleven seconds after the read', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [0, 24], 'events': [[100, 'card', 'K1'], [111, 'call', 5]]}, ['read', 'denied']), ('control 45', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [8, 18], 'events': [[72011, 'call', 2], [72020, 'card', 'K9'], [72021, 'call', 2]]}, ['accepted', 'read', 'accepted']), ('control 48', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [20, 6], 'events': [[25260, 'call', 5], [25265, 'card', 'K2']]}, ['accepted', 'read']), ('control 51', {'restricted': [5, 7, 9], 'cards': {'K1': [5, 7], 'K2': [9]}, 'secure_hours': [8, 18], 'events': [[72011, 'card', 'K9'], [75611, 'call', 5], [75620, 'call', 12], [75629, 'card', 'K1']]}, ['read', 'accepted', 'accepted', 'read'])]]
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:
Security windows stop applying after the first day or apply at random times.

Restricted floors are secured during [lo, hi) hours of day (hour = t//3600 mod 24; when lo > hi the window wraps midnight). A car call to a secured floor is accepted only within 10 s of a card read whose card allows that floor; the credential is consumed by the call it authorises. Unsecured calls are accepted without affecting the credential. Log read, accepted or denied.

split: open-access


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

N = 1
observations = []
def solve(x):
    stops = set()
    deck = {}
    rejected = []
    for d in x['dests']:
        lower = d % 2 == 1
        pos = d if lower else d - 1
        if pos < 1 or pos > x['top'] - 1:
            rejected.append(d)
            continue
        deck[str(d)] = 'lower' if lower else 'upper'
        stops.add(pos)
    return {'stops': sorted(stops), 'deck_of': deck, 'rejected': rejected}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: even-lower convention', {'top': 20, 'lower_odd': False, 'dests': [6, 7]}, {'stops': [6], 'deck_of': {'6': 'lower', '7': 'upper'}, 'rejected': []}), ('boundary: odd and even floors share a stop', {'top': 20, 'lower_odd': True, 'dests': [5, 6]}, {'stops': [5], 'deck_of': {'5': 'lower', '6': 'upper'}, 'rejected': []}), ('sampled regression 7', {'top': 21, 'lower_odd': False, 'dests': [9, 10, 3, 4, 7]}, {'stops': [2, 4, 6, 8, 10], 'deck_of': {'9': 'upper', '10': 'lower', '3': 'upper', '4': 'lower', '7': 'upper'}, 'rejected': []}), ('boundary: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('boundary: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('control 1', {'top': 30, 'lower_odd': True, 'dests': [0]}, {'stops': [], 'deck_of': {}, 'rejected': [0]}), ('sampled regression 4', {'top': 20, 'lower_odd': False, 'dests': [19, 3]}, {'stops': [2, 18], 'deck_of': {'19': 'upper', '3': 'upper'}, 'rejected': []}), ('sampled regression 10', {'top': 20, 'lower_odd': False, 'dests': [10, 11, 15, 13]}, {'stops': [10, 12, 14], 'deck_of': {'10': 'lower', '11': 'upper', '15': 'upper', '13': 'upper'}, 'rejected': []})], [('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('regression: even-lower convention', {'top': 20, 'lower_odd': False, 'dests': [6, 7]}, {'stops': [6], 'deck_of': {'6': 'lower', '7': 'upper'}, 'rejected': []}), ('sampled regression 19', {'top': 20, 'lower_odd': False, 'dests': [4, 9, 11]}, {'stops': [4, 8, 10], 'deck_of': {'4': 'lower', '9': 'upper', '11': 'upper'}, 'rejected': []}), ('control 2', {'top': 21, 'lower_odd': True, 'dests': [21, 20, 0, 16, 19, 7]}, {'stops': [7, 15, 19], 'deck_of': {'20': 'upper', '16': 'upper', '19': 'lower', '7': 'lower'}, 'rejected': [21, 0]}), ('boundary: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('control 12', {'top': 21, 'lower_odd': True, 'dests': [7, 16, 15, 14, 18, 5]}, {'stops': [5, 7, 13, 15, 17], 'deck_of': {'7': 'lower', '16': 'upper', '15': 'lower', '14': 'upper', '18': 'upper', '5': 'lower'}, 'rejected': []}), ('sampled regression 15', {'top': 21, 'lower_odd': False, 'dests': [2]}, {'stops': [2], 'deck_of': {'2': 'lower'}, 'rejected': []}), ('control 18', {'top': 30, 'lower_odd': True, 'dests': [1, 2, 16, 17, 9, 14]}, {'stops': [1, 9, 13, 15, 17], 'deck_of': {'1': 'lower', '2': 'upper', '16': 'upper', '17': 'lower', '9': 'lower', '14': 'upper'}, 'rejected': []})], [('regression: even-lower convention', {'top': 20, 'lower_odd': False, 'dests': [6, 7]}, {'stops': [6], 'deck_of': {'6': 'lower', '7': 'upper'}, 'rejected': []}), ('boundary: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('sampled regression 31', {'top': 21, 'lower_odd': False, 'dests': [10, 8, 21, 15, 13]}, {'stops': [8, 10, 12, 14, 20], 'deck_of': {'10': 'lower', '8': 'lower', '21': 'upper', '15': 'upper', '13': 'upper'}, 'rejected': []}), ('sampled regression 7', {'top': 21, 'lower_odd': False, 'dests': [9, 10, 3, 4, 7]}, {'stops': [2, 4, 6, 8, 10], 'deck_of': {'9': 'upper', '10': 'lower', '3': 'upper', '4': 'lower', '7': 'upper'}, 'rejected': []}), ('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('control 23', {'top': 20, 'lower_odd': True, 'dests': [11, 6, 9, 18, 10, 19]}, {'stops': [5, 9, 11, 17, 19], 'deck_of': {'11': 'lower', '6': 'upper', '9': 'lower', '18': 'upper', '10': 'upper', '19': 'lower'}, 'rejected': []}), ('control 26', {'top': 20, 'lower_odd': True, 'dests': [0, 7, 4, 8, 20]}, {'stops': [3, 7, 19], 'deck_of': {'7': 'lower', '4': 'upper', '8': 'upper', '20': 'upper'}, 'rejected': [0]}), ('sampled regression 29', {'top': 21, 'lower_odd': False, 'dests': [3, 12, 13, 19, 1]}, {'stops': [2, 12, 18], 'deck_of': {'3': 'upper', '12': 'lower', '13': 'upper', '19': 'upper'}, 'rejected': [1]})], [('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('boundary: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('sampled regression 41', {'top': 30, 'lower_odd': False, 'dests': [19, 10]}, {'stops': [10, 18], 'deck_of': {'19': 'upper', '10': 'lower'}, 'rejected': []}), ('control 12', {'top': 21, 'lower_odd': True, 'dests': [7, 16, 15, 14, 18, 5]}, {'stops': [5, 7, 13, 15, 17], 'deck_of': {'7': 'lower', '16': 'upper', '15': 'lower', '14': 'upper', '18': 'upper', '5': 'lower'}, 'rejected': []}), ('boundary: odd and even floors share a stop', {'top': 20, 'lower_odd': True, 'dests': [5, 6]}, {'stops': [5], 'deck_of': {'5': 'lower', '6': 'upper'}, 'rejected': []}), ('control 34', {'top': 20, 'lower_odd': True, 'dests': [5, 0]}, {'stops': [5], 'deck_of': {'5': 'lower'}, 'rejected': [0]}), ('sampled regression 37', {'top': 30, 'lower_odd': False, 'dests': [18, 28, 28]}, {'stops': [18, 28], 'deck_of': {'18': 'lower', '28': 'lower'}, 'rejected': []}), ('sampled regression 40', {'top': 20, 'lower_odd': False, 'dests': [11, 14, 12, 8, 0, 4]}, {'stops': [4, 8, 10, 12, 14], 'deck_of': {'11': 'upper', '14': 'lower', '12': 'lower', '8': 'lower', '4': 'lower'}, 'rejected': [0]})], [('regression: even-lower convention', {'top': 20, 'lower_odd': False, 'dests': [6, 7]}, {'stops': [6], 'deck_of': {'6': 'lower', '7': 'upper'}, 'rejected': []}), ('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('sampled regression 61', {'top': 30, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('control 17', {'top': 30, 'lower_odd': True, 'dests': [19, 5, 2, 23, 16]}, {'stops': [1, 5, 15, 19, 23], 'deck_of': {'19': 'lower', '5': 'lower', '2': 'upper', '23': 'lower', '16': 'upper'}, 'rejected': []}), ('boundary: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('sampled regression 45', {'top': 30, 'lower_odd': False, 'dests': [1, 11, 0, 7, 22]}, {'stops': [6, 10, 22], 'deck_of': {'11': 'upper', '7': 'upper', '22': 'lower'}, 'rejected': [1, 0]}), ('control 48', {'top': 20, 'lower_odd': True, 'dests': [7, 1, 12, 15, 14, 20]}, {'stops': [1, 7, 11, 13, 15, 19], 'deck_of': {'7': 'lower', '1': 'lower', '12': 'upper', '15': 'lower', '14': 'upper', '20': 'upper'}, 'rejected': []}), ('control 51', {'top': 21, 'lower_odd': True, 'dests': [22, 5, 13]}, {'stops': [5, 13], 'deck_of': {'5': 'lower', '13': 'lower'}, 'rejected': [22]})]]
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):
    stops = set()
    deck = {}
    rejected = []
    for d in x['dests']:
        lower = (d % 2 == 0) == x['lower_odd']
        pos = d if lower else d - 1
        if pos < 1 or pos > x['top'] - 1:
            rejected.append(d)
            continue
        deck[str(d)] = 'lower' if lower else 'upper'
        stops.add(pos)
    return {'stops': sorted(stops), 'deck_of': deck, 'rejected': rejected}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: even-lower convention', {'top': 20, 'lower_odd': False, 'dests': [6, 7]}, {'stops': [6], 'deck_of': {'6': 'lower', '7': 'upper'}, 'rejected': []}), ('boundary: odd and even floors share a stop', {'top': 20, 'lower_odd': True, 'dests': [5, 6]}, {'stops': [5], 'deck_of': {'5': 'lower', '6': 'upper'}, 'rejected': []}), ('sampled regression 7', {'top': 21, 'lower_odd': False, 'dests': [9, 10, 3, 4, 7]}, {'stops': [2, 4, 6, 8, 10], 'deck_of': {'9': 'upper', '10': 'lower', '3': 'upper', '4': 'lower', '7': 'upper'}, 'rejected': []}), ('boundary: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('boundary: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('control 1', {'top': 30, 'lower_odd': True, 'dests': [0]}, {'stops': [], 'deck_of': {}, 'rejected': [0]}), ('sampled regression 4', {'top': 20, 'lower_odd': False, 'dests': [19, 3]}, {'stops': [2, 18], 'deck_of': {'19': 'upper', '3': 'upper'}, 'rejected': []}), ('sampled regression 10', {'top': 20, 'lower_odd': False, 'dests': [10, 11, 15, 13]}, {'stops': [10, 12, 14], 'deck_of': {'10': 'lower', '11': 'upper', '15': 'upper', '13': 'upper'}, 'rejected': []})], [('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('regression: even-lower convention', {'top': 20, 'lower_odd': False, 'dests': [6, 7]}, {'stops': [6], 'deck_of': {'6': 'lower', '7': 'upper'}, 'rejected': []}), ('sampled regression 19', {'top': 20, 'lower_odd': False, 'dests': [4, 9, 11]}, {'stops': [4, 8, 10], 'deck_of': {'4': 'lower', '9': 'upper', '11': 'upper'}, 'rejected': []}), ('control 2', {'top': 21, 'lower_odd': True, 'dests': [21, 20, 0, 16, 19, 7]}, {'stops': [7, 15, 19], 'deck_of': {'20': 'upper', '16': 'upper', '19': 'lower', '7': 'lower'}, 'rejected': [21, 0]}), ('boundary: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('control 12', {'top': 21, 'lower_odd': True, 'dests': [7, 16, 15, 14, 18, 5]}, {'stops': [5, 7, 13, 15, 17], 'deck_of': {'7': 'lower', '16': 'upper', '15': 'lower', '14': 'upper', '18': 'upper', '5': 'lower'}, 'rejected': []}), ('sampled regression 15', {'top': 21, 'lower_odd': False, 'dests': [2]}, {'stops': [2], 'deck_of': {'2': 'lower'}, 'rejected': []}), ('control 18', {'top': 30, 'lower_odd': True, 'dests': [1, 2, 16, 17, 9, 14]}, {'stops': [1, 9, 13, 15, 17], 'deck_of': {'1': 'lower', '2': 'upper', '16': 'upper', '17': 'lower', '9': 'lower', '14': 'upper'}, 'rejected': []})], [('regression: even-lower convention', {'top': 20, 'lower_odd': False, 'dests': [6, 7]}, {'stops': [6], 'deck_of': {'6': 'lower', '7': 'upper'}, 'rejected': []}), ('boundary: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('sampled regression 31', {'top': 21, 'lower_odd': False, 'dests': [10, 8, 21, 15, 13]}, {'stops': [8, 10, 12, 14, 20], 'deck_of': {'10': 'lower', '8': 'lower', '21': 'upper', '15': 'upper', '13': 'upper'}, 'rejected': []}), ('sampled regression 7', {'top': 21, 'lower_odd': False, 'dests': [9, 10, 3, 4, 7]}, {'stops': [2, 4, 6, 8, 10], 'deck_of': {'9': 'upper', '10': 'lower', '3': 'upper', '4': 'lower', '7': 'upper'}, 'rejected': []}), ('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('control 23', {'top': 20, 'lower_odd': True, 'dests': [11, 6, 9, 18, 10, 19]}, {'stops': [5, 9, 11, 17, 19], 'deck_of': {'11': 'lower', '6': 'upper', '9': 'lower', '18': 'upper', '10': 'upper', '19': 'lower'}, 'rejected': []}), ('control 26', {'top': 20, 'lower_odd': True, 'dests': [0, 7, 4, 8, 20]}, {'stops': [3, 7, 19], 'deck_of': {'7': 'lower', '4': 'upper', '8': 'upper', '20': 'upper'}, 'rejected': [0]}), ('sampled regression 29', {'top': 21, 'lower_odd': False, 'dests': [3, 12, 13, 19, 1]}, {'stops': [2, 12, 18], 'deck_of': {'3': 'upper', '12': 'lower', '13': 'upper', '19': 'upper'}, 'rejected': [1]})], [('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('boundary: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('sampled regression 41', {'top': 30, 'lower_odd': False, 'dests': [19, 10]}, {'stops': [10, 18], 'deck_of': {'19': 'upper', '10': 'lower'}, 'rejected': []}), ('control 12', {'top': 21, 'lower_odd': True, 'dests': [7, 16, 15, 14, 18, 5]}, {'stops': [5, 7, 13, 15, 17], 'deck_of': {'7': 'lower', '16': 'upper', '15': 'lower', '14': 'upper', '18': 'upper', '5': 'lower'}, 'rejected': []}), ('boundary: odd and even floors share a stop', {'top': 20, 'lower_odd': True, 'dests': [5, 6]}, {'stops': [5], 'deck_of': {'5': 'lower', '6': 'upper'}, 'rejected': []}), ('control 34', {'top': 20, 'lower_odd': True, 'dests': [5, 0]}, {'stops': [5], 'deck_of': {'5': 'lower'}, 'rejected': [0]}), ('sampled regression 37', {'top': 30, 'lower_odd': False, 'dests': [18, 28, 28]}, {'stops': [18, 28], 'deck_of': {'18': 'lower', '28': 'lower'}, 'rejected': []}), ('sampled regression 40', {'top': 20, 'lower_odd': False, 'dests': [11, 14, 12, 8, 0, 4]}, {'stops': [4, 8, 10, 12, 14], 'deck_of': {'11': 'upper', '14': 'lower', '12': 'lower', '8': 'lower', '4': 'lower'}, 'rejected': [0]})], [('regression: even-lower convention', {'top': 20, 'lower_odd': False, 'dests': [6, 7]}, {'stops': [6], 'deck_of': {'6': 'lower', '7': 'upper'}, 'rejected': []}), ('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('sampled regression 61', {'top': 30, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('control 17', {'top': 30, 'lower_odd': True, 'dests': [19, 5, 2, 23, 16]}, {'stops': [1, 5, 15, 19, 23], 'deck_of': {'19': 'lower', '5': 'lower', '2': 'upper', '23': 'lower', '16': 'upper'}, 'rejected': []}), ('boundary: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('sampled regression 45', {'top': 30, 'lower_odd': False, 'dests': [1, 11, 0, 7, 22]}, {'stops': [6, 10, 22], 'deck_of': {'11': 'upper', '7': 'upper', '22': 'lower'}, 'rejected': [1, 0]}), ('control 48', {'top': 20, 'lower_odd': True, 'dests': [7, 1, 12, 15, 14, 20]}, {'stops': [1, 7, 11, 13, 15, 19], 'deck_of': {'7': 'lower', '1': 'lower', '12': 'upper', '15': 'lower', '14': 'upper', '20': 'upper'}, 'rejected': []}), ('control 51', {'top': 21, 'lower_odd': True, 'dests': [22, 5, 13]}, {'stops': [5, 13], 'deck_of': {'5': 'lower', '13': 'lower'}, 'rejected': [22]})]]
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:
Buildings with even-floor lower decks send passengers to the wrong deck.

A double-deck car has a lower deck and an upper deck one floor above it; the car position is the lower deck floor. With lower_odd the lower deck serves odd destinations and the upper deck even ones (reversed otherwise). A destination served by the upper deck needs car position dest-1. Positions must lie in 1..top-1 (the lower deck never reaches the top floor); unreachable destinations are rejected. Return sorted unique stop positions, deck per destination and rejected destinations in input order.

split: open-access


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

N = 1
observations = []
def solve(x):
    stops = set()
    deck = {}
    rejected = []
    for d in x['dests']:
        lower = (d % 2 == 1) == x['lower_odd']
        pos = d if lower else d + 1
        if pos < 1 or pos > x['top'] - 1:
            rejected.append(d)
            continue
        deck[str(d)] = 'lower' if lower else 'upper'
        stops.add(pos)
    return {'stops': sorted(stops), 'deck_of': deck, 'rejected': rejected}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: odd and even floors share a stop', {'top': 20, 'lower_odd': True, 'dests': [5, 6]}, {'stops': [5], 'deck_of': {'5': 'lower', '6': 'upper'}, 'rejected': []}), ('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('regression: even-lower convention', {'top': 20, 'lower_odd': False, 'dests': [6, 7]}, {'stops': [6], 'deck_of': {'6': 'lower', '7': 'upper'}, 'rejected': []}), ('regression: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('boundary: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('sampled regression 1', {'top': 30, 'lower_odd': True, 'dests': [0]}, {'stops': [], 'deck_of': {}, 'rejected': [0]}), ('sampled regression 4', {'top': 20, 'lower_odd': False, 'dests': [19, 3]}, {'stops': [2, 18], 'deck_of': {'19': 'upper', '3': 'upper'}, 'rejected': []}), ('sampled regression 7', {'top': 21, 'lower_odd': False, 'dests': [9, 10, 3, 4, 7]}, {'stops': [2, 4, 6, 8, 10], 'deck_of': {'9': 'upper', '10': 'lower', '3': 'upper', '4': 'lower', '7': 'upper'}, 'rejected': []})], [('regression: even-lower convention', {'top': 20, 'lower_odd': False, 'dests': [6, 7]}, {'stops': [6], 'deck_of': {'6': 'lower', '7': 'upper'}, 'rejected': []}), ('sampled regression 6', {'top': 20, 'lower_odd': True, 'dests': [21, 13, 16, 2]}, {'stops': [1, 13, 15], 'deck_of': {'13': 'lower', '16': 'upper', '2': 'upper'}, 'rejected': [21]}), ('sampled regression 3', {'top': 20, 'lower_odd': True, 'dests': [1, 17, 15, 8, 5, 7]}, {'stops': [1, 5, 7, 15, 17], 'deck_of': {'1': 'lower', '17': 'lower', '15': 'lower', '8': 'upper', '5': 'lower', '7': 'lower'}, 'rejected': []}), ('regression: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('boundary: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('sampled regression 12', {'top': 21, 'lower_odd': True, 'dests': [7, 16, 15, 14, 18, 5]}, {'stops': [5, 7, 13, 15, 17], 'deck_of': {'7': 'lower', '16': 'upper', '15': 'lower', '14': 'upper', '18': 'upper', '5': 'lower'}, 'rejected': []}), ('control 15', {'top': 21, 'lower_odd': False, 'dests': [2]}, {'stops': [2], 'deck_of': {'2': 'lower'}, 'rejected': []}), ('sampled regression 18', {'top': 30, 'lower_odd': True, 'dests': [1, 2, 16, 17, 9, 14]}, {'stops': [1, 9, 13, 15, 17], 'deck_of': {'1': 'lower', '2': 'upper', '16': 'upper', '17': 'lower', '9': 'lower', '14': 'upper'}, 'rejected': []})], [('regression: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('sampled regression 13', {'top': 30, 'lower_odd': False, 'dests': [25, 12, 4, 16]}, {'stops': [4, 12, 16, 24], 'deck_of': {'25': 'upper', '12': 'lower', '4': 'lower', '16': 'lower'}, 'rejected': []}), ('sampled regression 8', {'top': 30, 'lower_odd': True, 'dests': [26]}, {'stops': [25], 'deck_of': {'26': 'upper'}, 'rejected': []}), ('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('regression: repeated destinations', {'top': 20, 'lower_odd': True, 'dests': [9, 9, 10]}, {'stops': [9], 'deck_of': {'9': 'lower', '10': 'upper'}, 'rejected': []}), ('sampled regression 23', {'top': 20, 'lower_odd': True, 'dests': [11, 6, 9, 18, 10, 19]}, {'stops': [5, 9, 11, 17, 19], 'deck_of': {'11': 'lower', '6': 'upper', '9': 'lower', '18': 'upper', '10': 'upper', '19': 'lower'}, 'rejected': []}), ('sampled regression 26', {'top': 20, 'lower_odd': True, 'dests': [0, 7, 4, 8, 20]}, {'stops': [3, 7, 19], 'deck_of': {'7': 'lower', '4': 'upper', '8': 'upper', '20': 'upper'}, 'rejected': [0]}), ('sampled regression 29', {'top': 21, 'lower_odd': False, 'dests': [3, 12, 13, 19, 1]}, {'stops': [2, 12, 18], 'deck_of': {'3': 'upper', '12': 'lower', '13': 'upper', '19': 'upper'}, 'rejected': [1]})], [('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('sampled regression 21', {'top': 21, 'lower_odd': False, 'dests': [12, 5, 13, 0, 20]}, {'stops': [4, 12, 20], 'deck_of': {'12': 'lower', '5': 'upper', '13': 'upper', '20': 'lower'}, 'rejected': [0]}), ('sampled regression 13', {'top': 30, 'lower_odd': False, 'dests': [25, 12, 4, 16]}, {'stops': [4, 12, 16, 24], 'deck_of': {'25': 'upper', '12': 'lower', '4': 'lower', '16': 'lower'}, 'rejected': []}), ('regression: odd and even floors share a stop', {'top': 20, 'lower_odd': True, 'dests': [5, 6]}, {'stops': [5], 'deck_of': {'5': 'lower', '6': 'upper'}, 'rejected': []}), ('regression: even-lower convention', {'top': 20, 'lower_odd': False, 'dests': [6, 7]}, {'stops': [6], 'deck_of': {'6': 'lower', '7': 'upper'}, 'rejected': []}), ('sampled regression 34', {'top': 20, 'lower_odd': True, 'dests': [5, 0]}, {'stops': [5], 'deck_of': {'5': 'lower'}, 'rejected': [0]}), ('control 37', {'top': 30, 'lower_odd': False, 'dests': [18, 28, 28]}, {'stops': [18, 28], 'deck_of': {'18': 'lower', '28': 'lower'}, 'rejected': []}), ('sampled regression 40', {'top': 20, 'lower_odd': False, 'dests': [11, 14, 12, 8, 0, 4]}, {'stops': [4, 8, 10, 12, 14], 'deck_of': {'11': 'upper', '14': 'lower', '12': 'lower', '8': 'lower', '4': 'lower'}, 'rejected': [0]})], [('regression: repeated destinations', {'top': 20, 'lower_odd': True, 'dests': [9, 9, 10]}, {'stops': [9], 'deck_of': {'9': 'lower', '10': 'upper'}, 'rejected': []}), ('sampled regression 29', {'top': 21, 'lower_odd': False, 'dests': [3, 12, 13, 19, 1]}, {'stops': [2, 12, 18], 'deck_of': {'3': 'upper', '12': 'lower', '13': 'upper', '19': 'upper'}, 'rejected': [1]}), ('sampled regression 19', {'top': 20, 'lower_odd': False, 'dests': [4, 9, 11]}, {'stops': [4, 8, 10], 'deck_of': {'4': 'lower', '9': 'upper', '11': 'upper'}, 'rejected': []}), ('regression: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('boundary: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('sampled regression 45', {'top': 30, 'lower_odd': False, 'dests': [1, 11, 0, 7, 22]}, {'stops': [6, 10, 22], 'deck_of': {'11': 'upper', '7': 'upper', '22': 'lower'}, 'rejected': [1, 0]}), ('sampled regression 48', {'top': 20, 'lower_odd': True, 'dests': [7, 1, 12, 15, 14, 20]}, {'stops': [1, 7, 11, 13, 15, 19], 'deck_of': {'7': 'lower', '1': 'lower', '12': 'upper', '15': 'lower', '14': 'upper', '20': 'upper'}, 'rejected': []}), ('control 51', {'top': 21, 'lower_odd': True, 'dests': [22, 5, 13]}, {'stops': [5, 13], 'deck_of': {'5': 'lower', '13': 'lower'}, 'rejected': [22]})]]
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):
    stops = set()
    deck = {}
    rejected = []
    for d in x['dests']:
        lower = (d % 2 == 1) == x['lower_odd']
        pos = d
        if pos < 1 or pos > x['top'] - 1:
            rejected.append(d)
            continue
        deck[str(d)] = 'lower' if lower else 'upper'
        stops.add(pos)
    return {'stops': sorted(stops), 'deck_of': deck, 'rejected': rejected}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: odd and even floors share a stop', {'top': 20, 'lower_odd': True, 'dests': [5, 6]}, {'stops': [5], 'deck_of': {'5': 'lower', '6': 'upper'}, 'rejected': []}), ('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('regression: even-lower convention', {'top': 20, 'lower_odd': False, 'dests': [6, 7]}, {'stops': [6], 'deck_of': {'6': 'lower', '7': 'upper'}, 'rejected': []}), ('regression: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('boundary: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('sampled regression 1', {'top': 30, 'lower_odd': True, 'dests': [0]}, {'stops': [], 'deck_of': {}, 'rejected': [0]}), ('sampled regression 4', {'top': 20, 'lower_odd': False, 'dests': [19, 3]}, {'stops': [2, 18], 'deck_of': {'19': 'upper', '3': 'upper'}, 'rejected': []}), ('sampled regression 7', {'top': 21, 'lower_odd': False, 'dests': [9, 10, 3, 4, 7]}, {'stops': [2, 4, 6, 8, 10], 'deck_of': {'9': 'upper', '10': 'lower', '3': 'upper', '4': 'lower', '7': 'upper'}, 'rejected': []})], [('regression: even-lower convention', {'top': 20, 'lower_odd': False, 'dests': [6, 7]}, {'stops': [6], 'deck_of': {'6': 'lower', '7': 'upper'}, 'rejected': []}), ('sampled regression 6', {'top': 20, 'lower_odd': True, 'dests': [21, 13, 16, 2]}, {'stops': [1, 13, 15], 'deck_of': {'13': 'lower', '16': 'upper', '2': 'upper'}, 'rejected': [21]}), ('sampled regression 3', {'top': 20, 'lower_odd': True, 'dests': [1, 17, 15, 8, 5, 7]}, {'stops': [1, 5, 7, 15, 17], 'deck_of': {'1': 'lower', '17': 'lower', '15': 'lower', '8': 'upper', '5': 'lower', '7': 'lower'}, 'rejected': []}), ('regression: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('boundary: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('sampled regression 12', {'top': 21, 'lower_odd': True, 'dests': [7, 16, 15, 14, 18, 5]}, {'stops': [5, 7, 13, 15, 17], 'deck_of': {'7': 'lower', '16': 'upper', '15': 'lower', '14': 'upper', '18': 'upper', '5': 'lower'}, 'rejected': []}), ('control 15', {'top': 21, 'lower_odd': False, 'dests': [2]}, {'stops': [2], 'deck_of': {'2': 'lower'}, 'rejected': []}), ('sampled regression 18', {'top': 30, 'lower_odd': True, 'dests': [1, 2, 16, 17, 9, 14]}, {'stops': [1, 9, 13, 15, 17], 'deck_of': {'1': 'lower', '2': 'upper', '16': 'upper', '17': 'lower', '9': 'lower', '14': 'upper'}, 'rejected': []})], [('regression: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('sampled regression 13', {'top': 30, 'lower_odd': False, 'dests': [25, 12, 4, 16]}, {'stops': [4, 12, 16, 24], 'deck_of': {'25': 'upper', '12': 'lower', '4': 'lower', '16': 'lower'}, 'rejected': []}), ('sampled regression 8', {'top': 30, 'lower_odd': True, 'dests': [26]}, {'stops': [25], 'deck_of': {'26': 'upper'}, 'rejected': []}), ('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('regression: repeated destinations', {'top': 20, 'lower_odd': True, 'dests': [9, 9, 10]}, {'stops': [9], 'deck_of': {'9': 'lower', '10': 'upper'}, 'rejected': []}), ('sampled regression 23', {'top': 20, 'lower_odd': True, 'dests': [11, 6, 9, 18, 10, 19]}, {'stops': [5, 9, 11, 17, 19], 'deck_of': {'11': 'lower', '6': 'upper', '9': 'lower', '18': 'upper', '10': 'upper', '19': 'lower'}, 'rejected': []}), ('sampled regression 26', {'top': 20, 'lower_odd': True, 'dests': [0, 7, 4, 8, 20]}, {'stops': [3, 7, 19], 'deck_of': {'7': 'lower', '4': 'upper', '8': 'upper', '20': 'upper'}, 'rejected': [0]}), ('sampled regression 29', {'top': 21, 'lower_odd': False, 'dests': [3, 12, 13, 19, 1]}, {'stops': [2, 12, 18], 'deck_of': {'3': 'upper', '12': 'lower', '13': 'upper', '19': 'upper'}, 'rejected': [1]})], [('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('sampled regression 21', {'top': 21, 'lower_odd': False, 'dests': [12, 5, 13, 0, 20]}, {'stops': [4, 12, 20], 'deck_of': {'12': 'lower', '5': 'upper', '13': 'upper', '20': 'lower'}, 'rejected': [0]}), ('sampled regression 13', {'top': 30, 'lower_odd': False, 'dests': [25, 12, 4, 16]}, {'stops': [4, 12, 16, 24], 'deck_of': {'25': 'upper', '12': 'lower', '4': 'lower', '16': 'lower'}, 'rejected': []}), ('regression: odd and even floors share a stop', {'top': 20, 'lower_odd': True, 'dests': [5, 6]}, {'stops': [5], 'deck_of': {'5': 'lower', '6': 'upper'}, 'rejected': []}), ('regression: even-lower convention', {'top': 20, 'lower_odd': False, 'dests': [6, 7]}, {'stops': [6], 'deck_of': {'6': 'lower', '7': 'upper'}, 'rejected': []}), ('sampled regression 34', {'top': 20, 'lower_odd': True, 'dests': [5, 0]}, {'stops': [5], 'deck_of': {'5': 'lower'}, 'rejected': [0]}), ('control 37', {'top': 30, 'lower_odd': False, 'dests': [18, 28, 28]}, {'stops': [18, 28], 'deck_of': {'18': 'lower', '28': 'lower'}, 'rejected': []}), ('sampled regression 40', {'top': 20, 'lower_odd': False, 'dests': [11, 14, 12, 8, 0, 4]}, {'stops': [4, 8, 10, 12, 14], 'deck_of': {'11': 'upper', '14': 'lower', '12': 'lower', '8': 'lower', '4': 'lower'}, 'rejected': [0]})], [('regression: repeated destinations', {'top': 20, 'lower_odd': True, 'dests': [9, 9, 10]}, {'stops': [9], 'deck_of': {'9': 'lower', '10': 'upper'}, 'rejected': []}), ('sampled regression 29', {'top': 21, 'lower_odd': False, 'dests': [3, 12, 13, 19, 1]}, {'stops': [2, 12, 18], 'deck_of': {'3': 'upper', '12': 'lower', '13': 'upper', '19': 'upper'}, 'rejected': [1]}), ('sampled regression 19', {'top': 20, 'lower_odd': False, 'dests': [4, 9, 11]}, {'stops': [4, 8, 10], 'deck_of': {'4': 'lower', '9': 'upper', '11': 'upper'}, 'rejected': []}), ('regression: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('boundary: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('sampled regression 45', {'top': 30, 'lower_odd': False, 'dests': [1, 11, 0, 7, 22]}, {'stops': [6, 10, 22], 'deck_of': {'11': 'upper', '7': 'upper', '22': 'lower'}, 'rejected': [1, 0]}), ('sampled regression 48', {'top': 20, 'lower_odd': True, 'dests': [7, 1, 12, 15, 14, 20]}, {'stops': [1, 7, 11, 13, 15, 19], 'deck_of': {'7': 'lower', '1': 'lower', '12': 'upper', '15': 'lower', '14': 'upper', '20': 'upper'}, 'rejected': []}), ('control 51', {'top': 21, 'lower_odd': True, 'dests': [22, 5, 13]}, {'stops': [5, 13], 'deck_of': {'5': 'lower', '13': 'lower'}, 'rejected': [22]})]]
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 car stops a floor off for upper-deck passengers.

A double-deck car has a lower deck and an upper deck one floor above it; the car position is the lower deck floor. With lower_odd the lower deck serves odd destinations and the upper deck even ones (reversed otherwise). A destination served by the upper deck needs car position dest-1. Positions must lie in 1..top-1 (the lower deck never reaches the top floor); unreachable destinations are rejected. Return sorted unique stop positions, deck per destination and rejected destinations in input order.

split: open-access


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

N = 1
observations = []
def solve(x):
    stops = set()
    deck = {}
    rejected = []
    for d in x['dests']:
        lower = (d % 2 == 1) == x['lower_odd']
        pos = d if lower else d - 1
        if pos < 0 or pos > x['top']:
            rejected.append(d)
            continue
        deck[str(d)] = 'lower' if lower else 'upper'
        stops.add(pos)
    return {'stops': sorted(stops), 'deck_of': deck, 'rejected': rejected}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('sampled regression 5', {'top': 21, 'lower_odd': True, 'dests': [21, 7, 16]}, {'stops': [7, 15], 'deck_of': {'7': 'lower', '16': 'upper'}, 'rejected': [21]}), ('sampled regression 2', {'top': 21, 'lower_odd': True, 'dests': [21, 20, 0, 16, 19, 7]}, {'stops': [7, 15, 19], 'deck_of': {'20': 'upper', '16': 'upper', '19': 'lower', '7': 'lower'}, 'rejected': [21, 0]}), ('boundary: odd and even floors share a stop', {'top': 20, 'lower_odd': True, 'dests': [5, 6]}, {'stops': [5], 'deck_of': {'5': 'lower', '6': 'upper'}, 'rejected': []}), ('boundary: even-lower convention', {'top': 20, 'lower_odd': False, 'dests': [6, 7]}, {'stops': [6], 'deck_of': {'6': 'lower', '7': 'upper'}, 'rejected': []}), ('control 1', {'top': 30, 'lower_odd': True, 'dests': [0]}, {'stops': [], 'deck_of': {}, 'rejected': [0]}), ('control 4', {'top': 20, 'lower_odd': False, 'dests': [19, 3]}, {'stops': [2, 18], 'deck_of': {'19': 'upper', '3': 'upper'}, 'rejected': []}), ('control 7', {'top': 21, 'lower_odd': False, 'dests': [9, 10, 3, 4, 7]}, {'stops': [2, 4, 6, 8, 10], 'deck_of': {'9': 'upper', '10': 'lower', '3': 'upper', '4': 'lower', '7': 'upper'}, 'rejected': []})], [('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('regression: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('sampled regression 44', {'top': 21, 'lower_odd': False, 'dests': [1, 21, 20]}, {'stops': [20], 'deck_of': {'21': 'upper', '20': 'lower'}, 'rejected': [1]}), ('sampled regression 51', {'top': 21, 'lower_odd': True, 'dests': [22, 5, 13]}, {'stops': [5, 13], 'deck_of': {'5': 'lower', '13': 'lower'}, 'rejected': [22]}), ('boundary: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('control 12', {'top': 21, 'lower_odd': True, 'dests': [7, 16, 15, 14, 18, 5]}, {'stops': [5, 7, 13, 15, 17], 'deck_of': {'7': 'lower', '16': 'upper', '15': 'lower', '14': 'upper', '18': 'upper', '5': 'lower'}, 'rejected': []}), ('control 15', {'top': 21, 'lower_odd': False, 'dests': [2]}, {'stops': [2], 'deck_of': {'2': 'lower'}, 'rejected': []}), ('control 18', {'top': 30, 'lower_odd': True, 'dests': [1, 2, 16, 17, 9, 14]}, {'stops': [1, 9, 13, 15, 17], 'deck_of': {'1': 'lower', '2': 'upper', '16': 'upper', '17': 'lower', '9': 'lower', '14': 'upper'}, 'rejected': []})], [('regression: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('sampled regression 74', {'top': 20, 'lower_odd': False, 'dests': [4, 1, 8, 18, 18]}, {'stops': [4, 8, 18], 'deck_of': {'4': 'lower', '8': 'lower', '18': 'lower'}, 'rejected': [1]}), ('sampled regression 14', {'top': 20, 'lower_odd': False, 'dests': [5, 21, 17, 0, 13, 8]}, {'stops': [4, 8, 12, 16], 'deck_of': {'5': 'upper', '17': 'upper', '13': 'upper', '8': 'lower'}, 'rejected': [21, 0]}), ('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('boundary: repeated destinations', {'top': 20, 'lower_odd': True, 'dests': [9, 9, 10]}, {'stops': [9], 'deck_of': {'9': 'lower', '10': 'upper'}, 'rejected': []}), ('control 23', {'top': 20, 'lower_odd': True, 'dests': [11, 6, 9, 18, 10, 19]}, {'stops': [5, 9, 11, 17, 19], 'deck_of': {'11': 'lower', '6': 'upper', '9': 'lower', '18': 'upper', '10': 'upper', '19': 'lower'}, 'rejected': []}), ('control 26', {'top': 20, 'lower_odd': True, 'dests': [0, 7, 4, 8, 20]}, {'stops': [3, 7, 19], 'deck_of': {'7': 'lower', '4': 'upper', '8': 'upper', '20': 'upper'}, 'rejected': [0]}), ('sampled regression 29', {'top': 21, 'lower_odd': False, 'dests': [3, 12, 13, 19, 1]}, {'stops': [2, 12, 18], 'deck_of': {'3': 'upper', '12': 'lower', '13': 'upper', '19': 'upper'}, 'rejected': [1]})], [('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('regression: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('sampled regression 14', {'top': 20, 'lower_odd': False, 'dests': [5, 21, 17, 0, 13, 8]}, {'stops': [4, 8, 12, 16], 'deck_of': {'5': 'upper', '17': 'upper', '13': 'upper', '8': 'lower'}, 'rejected': [21, 0]}), ('sampled regression 5', {'top': 21, 'lower_odd': True, 'dests': [21, 7, 16]}, {'stops': [7, 15], 'deck_of': {'7': 'lower', '16': 'upper'}, 'rejected': [21]}), ('boundary: odd and even floors share a stop', {'top': 20, 'lower_odd': True, 'dests': [5, 6]}, {'stops': [5], 'deck_of': {'5': 'lower', '6': 'upper'}, 'rejected': []}), ('control 34', {'top': 20, 'lower_odd': True, 'dests': [5, 0]}, {'stops': [5], 'deck_of': {'5': 'lower'}, 'rejected': [0]}), ('control 37', {'top': 30, 'lower_odd': False, 'dests': [18, 28, 28]}, {'stops': [18, 28], 'deck_of': {'18': 'lower', '28': 'lower'}, 'rejected': []}), ('sampled regression 40', {'top': 20, 'lower_odd': False, 'dests': [11, 14, 12, 8, 0, 4]}, {'stops': [4, 8, 10, 12, 14], 'deck_of': {'11': 'upper', '14': 'lower', '12': 'lower', '8': 'lower', '4': 'lower'}, 'rejected': [0]})], [('regression: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('sampled regression 51', {'top': 21, 'lower_odd': True, 'dests': [22, 5, 13]}, {'stops': [5, 13], 'deck_of': {'5': 'lower', '13': 'lower'}, 'rejected': [22]}), ('boundary: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('boundary: repeated destinations', {'top': 20, 'lower_odd': True, 'dests': [9, 9, 10]}, {'stops': [9], 'deck_of': {'9': 'lower', '10': 'upper'}, 'rejected': []}), ('sampled regression 45', {'top': 30, 'lower_odd': False, 'dests': [1, 11, 0, 7, 22]}, {'stops': [6, 10, 22], 'deck_of': {'11': 'upper', '7': 'upper', '22': 'lower'}, 'rejected': [1, 0]}), ('control 48', {'top': 20, 'lower_odd': True, 'dests': [7, 1, 12, 15, 14, 20]}, {'stops': [1, 7, 11, 13, 15, 19], 'deck_of': {'7': 'lower', '1': 'lower', '12': 'upper', '15': 'lower', '14': 'upper', '20': 'upper'}, 'rejected': []}), ('control 54', {'top': 30, 'lower_odd': True, 'dests': [29]}, {'stops': [29], 'deck_of': {'29': 'lower'}, 'rejected': []})]]
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):
    stops = set()
    deck = {}
    rejected = []
    for d in x['dests']:
        lower = (d % 2 == 1) == x['lower_odd']
        pos = d if lower else d - 1
        if pos < 1 or pos > x['top']:
            rejected.append(d)
            continue
        deck[str(d)] = 'lower' if lower else 'upper'
        stops.add(pos)
    return {'stops': sorted(stops), 'deck_of': deck, 'rejected': rejected}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('sampled regression 5', {'top': 21, 'lower_odd': True, 'dests': [21, 7, 16]}, {'stops': [7, 15], 'deck_of': {'7': 'lower', '16': 'upper'}, 'rejected': [21]}), ('sampled regression 2', {'top': 21, 'lower_odd': True, 'dests': [21, 20, 0, 16, 19, 7]}, {'stops': [7, 15, 19], 'deck_of': {'20': 'upper', '16': 'upper', '19': 'lower', '7': 'lower'}, 'rejected': [21, 0]}), ('boundary: odd and even floors share a stop', {'top': 20, 'lower_odd': True, 'dests': [5, 6]}, {'stops': [5], 'deck_of': {'5': 'lower', '6': 'upper'}, 'rejected': []}), ('boundary: even-lower convention', {'top': 20, 'lower_odd': False, 'dests': [6, 7]}, {'stops': [6], 'deck_of': {'6': 'lower', '7': 'upper'}, 'rejected': []}), ('control 1', {'top': 30, 'lower_odd': True, 'dests': [0]}, {'stops': [], 'deck_of': {}, 'rejected': [0]}), ('control 4', {'top': 20, 'lower_odd': False, 'dests': [19, 3]}, {'stops': [2, 18], 'deck_of': {'19': 'upper', '3': 'upper'}, 'rejected': []}), ('control 7', {'top': 21, 'lower_odd': False, 'dests': [9, 10, 3, 4, 7]}, {'stops': [2, 4, 6, 8, 10], 'deck_of': {'9': 'upper', '10': 'lower', '3': 'upper', '4': 'lower', '7': 'upper'}, 'rejected': []})], [('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('regression: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('sampled regression 44', {'top': 21, 'lower_odd': False, 'dests': [1, 21, 20]}, {'stops': [20], 'deck_of': {'21': 'upper', '20': 'lower'}, 'rejected': [1]}), ('sampled regression 51', {'top': 21, 'lower_odd': True, 'dests': [22, 5, 13]}, {'stops': [5, 13], 'deck_of': {'5': 'lower', '13': 'lower'}, 'rejected': [22]}), ('boundary: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('control 12', {'top': 21, 'lower_odd': True, 'dests': [7, 16, 15, 14, 18, 5]}, {'stops': [5, 7, 13, 15, 17], 'deck_of': {'7': 'lower', '16': 'upper', '15': 'lower', '14': 'upper', '18': 'upper', '5': 'lower'}, 'rejected': []}), ('control 15', {'top': 21, 'lower_odd': False, 'dests': [2]}, {'stops': [2], 'deck_of': {'2': 'lower'}, 'rejected': []}), ('control 18', {'top': 30, 'lower_odd': True, 'dests': [1, 2, 16, 17, 9, 14]}, {'stops': [1, 9, 13, 15, 17], 'deck_of': {'1': 'lower', '2': 'upper', '16': 'upper', '17': 'lower', '9': 'lower', '14': 'upper'}, 'rejected': []})], [('regression: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('sampled regression 74', {'top': 20, 'lower_odd': False, 'dests': [4, 1, 8, 18, 18]}, {'stops': [4, 8, 18], 'deck_of': {'4': 'lower', '8': 'lower', '18': 'lower'}, 'rejected': [1]}), ('sampled regression 14', {'top': 20, 'lower_odd': False, 'dests': [5, 21, 17, 0, 13, 8]}, {'stops': [4, 8, 12, 16], 'deck_of': {'5': 'upper', '17': 'upper', '13': 'upper', '8': 'lower'}, 'rejected': [21, 0]}), ('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('boundary: repeated destinations', {'top': 20, 'lower_odd': True, 'dests': [9, 9, 10]}, {'stops': [9], 'deck_of': {'9': 'lower', '10': 'upper'}, 'rejected': []}), ('control 23', {'top': 20, 'lower_odd': True, 'dests': [11, 6, 9, 18, 10, 19]}, {'stops': [5, 9, 11, 17, 19], 'deck_of': {'11': 'lower', '6': 'upper', '9': 'lower', '18': 'upper', '10': 'upper', '19': 'lower'}, 'rejected': []}), ('control 26', {'top': 20, 'lower_odd': True, 'dests': [0, 7, 4, 8, 20]}, {'stops': [3, 7, 19], 'deck_of': {'7': 'lower', '4': 'upper', '8': 'upper', '20': 'upper'}, 'rejected': [0]}), ('sampled regression 29', {'top': 21, 'lower_odd': False, 'dests': [3, 12, 13, 19, 1]}, {'stops': [2, 12, 18], 'deck_of': {'3': 'upper', '12': 'lower', '13': 'upper', '19': 'upper'}, 'rejected': [1]})], [('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('regression: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('sampled regression 14', {'top': 20, 'lower_odd': False, 'dests': [5, 21, 17, 0, 13, 8]}, {'stops': [4, 8, 12, 16], 'deck_of': {'5': 'upper', '17': 'upper', '13': 'upper', '8': 'lower'}, 'rejected': [21, 0]}), ('sampled regression 5', {'top': 21, 'lower_odd': True, 'dests': [21, 7, 16]}, {'stops': [7, 15], 'deck_of': {'7': 'lower', '16': 'upper'}, 'rejected': [21]}), ('boundary: odd and even floors share a stop', {'top': 20, 'lower_odd': True, 'dests': [5, 6]}, {'stops': [5], 'deck_of': {'5': 'lower', '6': 'upper'}, 'rejected': []}), ('control 34', {'top': 20, 'lower_odd': True, 'dests': [5, 0]}, {'stops': [5], 'deck_of': {'5': 'lower'}, 'rejected': [0]}), ('control 37', {'top': 30, 'lower_odd': False, 'dests': [18, 28, 28]}, {'stops': [18, 28], 'deck_of': {'18': 'lower', '28': 'lower'}, 'rejected': []}), ('sampled regression 40', {'top': 20, 'lower_odd': False, 'dests': [11, 14, 12, 8, 0, 4]}, {'stops': [4, 8, 10, 12, 14], 'deck_of': {'11': 'upper', '14': 'lower', '12': 'lower', '8': 'lower', '4': 'lower'}, 'rejected': [0]})], [('regression: top floor by the lower deck', {'top': 21, 'lower_odd': True, 'dests': [21]}, {'stops': [], 'deck_of': {}, 'rejected': [21]}), ('sampled regression 51', {'top': 21, 'lower_odd': True, 'dests': [22, 5, 13]}, {'stops': [5, 13], 'deck_of': {'5': 'lower', '13': 'lower'}, 'rejected': [22]}), ('boundary: top floor by the upper deck', {'top': 20, 'lower_odd': True, 'dests': [20]}, {'stops': [19], 'deck_of': {'20': 'upper'}, 'rejected': []}), ('regression: floor one by the upper deck', {'top': 20, 'lower_odd': False, 'dests': [1]}, {'stops': [], 'deck_of': {}, 'rejected': [1]}), ('boundary: repeated destinations', {'top': 20, 'lower_odd': True, 'dests': [9, 9, 10]}, {'stops': [9], 'deck_of': {'9': 'lower', '10': 'upper'}, 'rejected': []}), ('sampled regression 45', {'top': 30, 'lower_odd': False, 'dests': [1, 11, 0, 7, 22]}, {'stops': [6, 10, 22], 'deck_of': {'11': 'upper', '7': 'upper', '22': 'lower'}, 'rejected': [1, 0]}), ('control 48', {'top': 20, 'lower_odd': True, 'dests': [7, 1, 12, 15, 14, 20]}, {'stops': [1, 7, 11, 13, 15, 19], 'deck_of': {'7': 'lower', '1': 'lower', '12': 'upper', '15': 'lower', '14': 'upper', '20': 'upper'}, 'rejected': []}), ('control 54', {'top': 30, 'lower_odd': True, 'dests': [29]}, {'stops': [29], 'deck_of': {'29': 'lower'}, 'rejected': []})]]
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:
Stops are planned where one of the decks would leave the shaft.

A double-deck car has a lower deck and an upper deck one floor above it; the car position is the lower deck floor. With lower_odd the lower deck serves odd destinations and the upper deck even ones (reversed otherwise). A destination served by the upper deck needs car position dest-1. Positions must lie in 1..top-1 (the lower deck never reaches the top floor); unreachable destinations are rejected. Return sorted unique stop positions, deck per destination and rejected destinations in input order.

split: open-access