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

N = 1
observations = []
def solve(min_on, min_off, startup_delay, calls):
    running = False
    on_at = None
    off_at = None
    out = []
    for minute, (demand, safety_ok) in enumerate(calls):
        if running:
            if not safety_ok:
                running = False
                off_at = minute
            elif not demand and minute - on_at > min_on:
                running = False
                off_at = minute
        elif demand and safety_ok and minute >= startup_delay:
            if off_at is None or minute - off_at >= min_off:
                running = True
                on_at = minute
        out.append(running)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['control: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['control: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['control: scenario 1',
   [3,
    3,
    4,
    [[False, False],
     [False, True],
     [False, True],
     [False, False],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True]]],
   [False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False]],
  ['control: scenario 2',
   [5,
    3,
    0,
    [[True, True],
     [True, True],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True]]],
   [True, True, True, False, False, False, True, True, False, False, False, False, False, True]],
  ['control: scenario 3',
   [3,
    4,
    0,
    [[True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [True, True, True, True, False, False, False, False, True, False, False]],
  ['control: scenario 4',
   [5,
    5,
    4,
    [[True, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True]]],
   [False, False, False, False, False, False, False, False, False, False, False, False, False]]],
 [['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['regression: scenario 2',
   [2,
    5,
    4,
    [[False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [True, True],
     [False, False],
     [False, True],
     [False, True]]],
   [False, False, False, False, False, True, True, True, False, False, False, False, False, False]],
  ['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['control: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['control: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['control: scenario 1',
   [5,
    3,
    0,
    [[False, True],
     [False, True],
     [False, True],
     [False, False],
     [False, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True]]],
   [False, False, False, False, False, True, True, True, True, True, True, True]],
  ['regression: scenario 3',
   [3,
    4,
    0,
    [[True, True],
     [True, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, False],
     [True, True],
     [False, True],
     [False, True]]],
   [True,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True]],
  ['control: scenario 4',
   [2,
    4,
    2,
    [[True, True],
     [True, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [True, False],
     [True, False]]],
   [False, False, True, True, True, True, True, False, False, False, False, False, False, False, False]]],
 [['regression: scenario 1',
   [2,
    5,
    2,
    [[True, False],
     [True, True],
     [True, False],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, False],
     [True, True],
     [True, False],
     [True, True]]],
   [False,
    False,
    False,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    False,
    False]],
  ['regression: scenario 8',
   [3,
    4,
    4,
    [[False, True],
     [True, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True]]],
   [False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True]],
  ['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['control: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['control: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['regression: scenario 2',
   [2,
    4,
    0,
    [[False, True],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True]]],
   [False,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False]],
  ['control: scenario 3',
   [2,
    5,
    0,
    [[False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, False],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True]]],
   [False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True]]],
 [['regression: scenario 11',
   [5,
    5,
    0,
    [[True, False],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, False],
     [True, True],
     [True, True],
     [True, True]]],
   [False,
    True,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True]],
  ['regression: scenario 5',
   [3,
    5,
    2,
    [[False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True]]],
   [False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False]],
  ['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['control: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['control: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['control: scenario 1',
   [5,
    4,
    2,
    [[False, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, False],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True]]],
   [False,
    False,
    False,
    False,
    False,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    False]],
  ['control: scenario 2',
   [2,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True],
     [False, False]]],
   [False,
    False,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False]]],
 [['regression: scenario 5',
   [5,
    3,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True],
     [True, False],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [False, False],
     [False, True]]],
   [False,
    False,
    True,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    False,
    False,
    False]],
  ['regression: scenario 9',
   [3,
    4,
    0,
    [[False, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [False, False],
     [False, False],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True]]],
   [False,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    False]],
  ['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['control: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['control: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['regression: scenario 1',
   [3,
    4,
    0,
    [[False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [False, False],
     [False, False],
     [False, True]]],
   [False, False, False, False, True, True, True, False, False, False, False]],
  ['control: scenario 2',
   [2,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True]]],
   [False,
    False,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    False]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(min_on, min_off, startup_delay, calls):
    running = False
    on_at = None
    off_at = None
    out = []
    for minute, (demand, safety_ok) in enumerate(calls):
        if running:
            if not safety_ok:
                running = False
                off_at = minute
            elif not demand and minute - on_at >= min_on - 1:
                running = False
                off_at = minute
        elif demand and safety_ok and minute >= startup_delay:
            if off_at is None or minute - off_at >= min_off:
                running = True
                on_at = minute
        out.append(running)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['control: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['control: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['control: scenario 1',
   [3,
    3,
    4,
    [[False, False],
     [False, True],
     [False, True],
     [False, False],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True]]],
   [False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False]],
  ['control: scenario 2',
   [5,
    3,
    0,
    [[True, True],
     [True, True],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True]]],
   [True, True, True, False, False, False, True, True, False, False, False, False, False, True]],
  ['control: scenario 3',
   [3,
    4,
    0,
    [[True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [True, True, True, True, False, False, False, False, True, False, False]],
  ['control: scenario 4',
   [5,
    5,
    4,
    [[True, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True]]],
   [False, False, False, False, False, False, False, False, False, False, False, False, False]]],
 [['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['regression: scenario 2',
   [2,
    5,
    4,
    [[False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [True, True],
     [False, False],
     [False, True],
     [False, True]]],
   [False, False, False, False, False, True, True, True, False, False, False, False, False, False]],
  ['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['control: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['control: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['control: scenario 1',
   [5,
    3,
    0,
    [[False, True],
     [False, True],
     [False, True],
     [False, False],
     [False, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True]]],
   [False, False, False, False, False, True, True, True, True, True, True, True]],
  ['regression: scenario 3',
   [3,
    4,
    0,
    [[True, True],
     [True, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, False],
     [True, True],
     [False, True],
     [False, True]]],
   [True,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True]],
  ['control: scenario 4',
   [2,
    4,
    2,
    [[True, True],
     [True, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [True, False],
     [True, False]]],
   [False, False, True, True, True, True, True, False, False, False, False, False, False, False, False]]],
 [['regression: scenario 1',
   [2,
    5,
    2,
    [[True, False],
     [True, True],
     [True, False],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, False],
     [True, True],
     [True, False],
     [True, True]]],
   [False,
    False,
    False,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    False,
    False]],
  ['regression: scenario 8',
   [3,
    4,
    4,
    [[False, True],
     [True, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True]]],
   [False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True]],
  ['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['control: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['control: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['regression: scenario 2',
   [2,
    4,
    0,
    [[False, True],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True]]],
   [False,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False]],
  ['control: scenario 3',
   [2,
    5,
    0,
    [[False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, False],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True]]],
   [False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True]]],
 [['regression: scenario 11',
   [5,
    5,
    0,
    [[True, False],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, False],
     [True, True],
     [True, True],
     [True, True]]],
   [False,
    True,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True]],
  ['regression: scenario 5',
   [3,
    5,
    2,
    [[False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True]]],
   [False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False]],
  ['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['control: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['control: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['control: scenario 1',
   [5,
    4,
    2,
    [[False, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, False],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True]]],
   [False,
    False,
    False,
    False,
    False,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    False]],
  ['control: scenario 2',
   [2,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True],
     [False, False]]],
   [False,
    False,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False]]],
 [['regression: scenario 5',
   [5,
    3,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True],
     [True, False],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [False, False],
     [False, True]]],
   [False,
    False,
    True,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    False,
    False,
    False]],
  ['regression: scenario 9',
   [3,
    4,
    0,
    [[False, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [False, False],
     [False, False],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True]]],
   [False,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    False]],
  ['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['control: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['control: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['regression: scenario 1',
   [3,
    4,
    0,
    [[False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [False, False],
     [False, False],
     [False, True]]],
   [False, False, False, False, True, True, True, False, False, False, False]],
  ['control: scenario 2',
   [2,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True]]],
   [False,
    False,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    False]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Every short call runs one minute longer than the configured minimum.

Compressor protection sampled per minute; calls is a list of [demand, safety_ok]. After power-up the compressor may not start before minute startup_delay. Once started it runs at least min_on minutes even if demand ends; after stopping it stays off at least min_off minutes. A safety fault stops it immediately regardless of minimum on time, and that stop also starts the minimum off time; it cannot start while the safety is faulted. Return the compressor state per minute.

split: open-access


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

N = 1
observations = []
def solve(min_on, min_off, startup_delay, calls):
    running = False
    on_at = None
    off_at = None
    out = []
    for minute, (demand, safety_ok) in enumerate(calls):
        if running:
            if not safety_ok:
                running = False
                off_at = minute
            elif not demand and minute - on_at >= min_on:
                running = False
                off_at = minute
        elif demand and safety_ok and minute >= startup_delay:
            if off_at is None or minute - on_at >= min_off:
                running = True
                on_at = minute
        out.append(running)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['regression: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['regression: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['control: scenario 1',
   [3,
    3,
    4,
    [[False, False],
     [False, True],
     [False, True],
     [False, False],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True]]],
   [False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False]],
  ['regression: scenario 2',
   [5,
    3,
    0,
    [[True, True],
     [True, True],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True]]],
   [True, True, True, False, False, False, True, True, False, False, False, False, False, True]],
  ['regression: scenario 3',
   [3,
    4,
    0,
    [[True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [True, True, True, True, False, False, False, False, True, False, False]],
  ['control: scenario 4',
   [5,
    5,
    4,
    [[True, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True]]],
   [False, False, False, False, False, False, False, False, False, False, False, False, False]]],
 [['regression: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['regression: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['control: scenario 1',
   [5,
    3,
    0,
    [[False, True],
     [False, True],
     [False, True],
     [False, False],
     [False, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True]]],
   [False, False, False, False, False, True, True, True, True, True, True, True]],
  ['regression: scenario 2',
   [2,
    5,
    4,
    [[False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [True, True],
     [False, False],
     [False, True],
     [False, True]]],
   [False, False, False, False, False, True, True, True, False, False, False, False, False, False]],
  ['regression: scenario 3',
   [3,
    4,
    0,
    [[True, True],
     [True, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, False],
     [True, True],
     [False, True],
     [False, True]]],
   [True,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True]],
  ['regression: scenario 4',
   [2,
    4,
    2,
    [[True, True],
     [True, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [True, False],
     [True, False]]],
   [False, False, True, True, True, True, True, False, False, False, False, False, False, False, False]]],
 [['regression: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['regression: scenario 3',
   [2,
    5,
    0,
    [[False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, False],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True]]],
   [False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True]],
  ['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['regression: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['regression: scenario 1',
   [2,
    5,
    2,
    [[True, False],
     [True, True],
     [True, False],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, False],
     [True, True],
     [True, False],
     [True, True]]],
   [False,
    False,
    False,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    False,
    False]],
  ['regression: scenario 2',
   [2,
    4,
    0,
    [[False, True],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True]]],
   [False,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False]],
  ['control: scenario 4',
   [5,
    5,
    4,
    [[True, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, False],
     [True, True],
     [True, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True]]],
   [False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    False]]],
 [['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['regression: scenario 3',
   [2,
    3,
    0,
    [[False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, False],
     [False, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True]]],
   [False,
    False,
    True,
    True,
    True,
    False,
    False,
    False,
    True,
    True,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True]],
  ['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['regression: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['regression: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['regression: scenario 1',
   [5,
    4,
    2,
    [[False, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, False],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True]]],
   [False,
    False,
    False,
    False,
    False,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    False]],
  ['regression: scenario 2',
   [2,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True],
     [False, False]]],
   [False,
    False,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False]],
  ['regression: scenario 4',
   [2,
    5,
    4,
    [[False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True]]],
   [False, False, False, False, True, True, True, False, False, False, False, False, False, False]]],
 [['regression: scenario 2',
   [2,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True]]],
   [False,
    False,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    False]],
  ['regression: scenario 14',
   [5,
    5,
    4,
    [[False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True]]],
   [False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True]],
  ['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['regression: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['regression: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['control: scenario 1',
   [3,
    4,
    0,
    [[False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [False, False],
     [False, False],
     [False, True]]],
   [False, False, False, False, True, True, True, False, False, False, False]],
  ['regression: scenario 3',
   [2,
    5,
    0,
    [[True, True],
     [True, True],
     [True, False],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True]]],
   [True, True, False, False, False, False, False, False, True, True, False, False]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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(min_on, min_off, startup_delay, calls):
    running = False
    on_at = None
    off_at = None
    out = []
    for minute, (demand, safety_ok) in enumerate(calls):
        if running:
            if not safety_ok:
                running = False
                off_at = minute
            elif not demand and minute - on_at >= min_on:
                running = False
                off_at = minute
        elif demand and safety_ok and minute >= startup_delay:
            if off_at is None or minute - off_at > min_off:
                running = True
                on_at = minute
        out.append(running)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['regression: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['regression: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['control: scenario 1',
   [3,
    3,
    4,
    [[False, False],
     [False, True],
     [False, True],
     [False, False],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True]]],
   [False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False]],
  ['regression: scenario 2',
   [5,
    3,
    0,
    [[True, True],
     [True, True],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True]]],
   [True, True, True, False, False, False, True, True, False, False, False, False, False, True]],
  ['regression: scenario 3',
   [3,
    4,
    0,
    [[True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [True, True, True, True, False, False, False, False, True, False, False]],
  ['control: scenario 4',
   [5,
    5,
    4,
    [[True, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True]]],
   [False, False, False, False, False, False, False, False, False, False, False, False, False]]],
 [['regression: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['regression: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['control: scenario 1',
   [5,
    3,
    0,
    [[False, True],
     [False, True],
     [False, True],
     [False, False],
     [False, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True]]],
   [False, False, False, False, False, True, True, True, True, True, True, True]],
  ['regression: scenario 2',
   [2,
    5,
    4,
    [[False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [True, True],
     [False, False],
     [False, True],
     [False, True]]],
   [False, False, False, False, False, True, True, True, False, False, False, False, False, False]],
  ['regression: scenario 3',
   [3,
    4,
    0,
    [[True, True],
     [True, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, False],
     [True, True],
     [False, True],
     [False, True]]],
   [True,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True]],
  ['regression: scenario 4',
   [2,
    4,
    2,
    [[True, True],
     [True, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [True, False],
     [True, False]]],
   [False, False, True, True, True, True, True, False, False, False, False, False, False, False, False]]],
 [['regression: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['regression: scenario 3',
   [2,
    5,
    0,
    [[False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, False],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True]]],
   [False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True]],
  ['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['regression: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['regression: scenario 1',
   [2,
    5,
    2,
    [[True, False],
     [True, True],
     [True, False],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, False],
     [True, True],
     [True, False],
     [True, True]]],
   [False,
    False,
    False,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    False,
    False]],
  ['regression: scenario 2',
   [2,
    4,
    0,
    [[False, True],
     [True, True],
     [True, False],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True]]],
   [False,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    False]],
  ['control: scenario 4',
   [5,
    5,
    4,
    [[True, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, False],
     [True, True],
     [True, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True]]],
   [False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    False]]],
 [['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['regression: scenario 3',
   [2,
    3,
    0,
    [[False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, False],
     [False, False],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True]]],
   [False,
    False,
    True,
    True,
    True,
    False,
    False,
    False,
    True,
    True,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True]],
  ['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['regression: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['regression: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['regression: scenario 1',
   [5,
    4,
    2,
    [[False, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, False],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True]]],
   [False,
    False,
    False,
    False,
    False,
    True,
    False,
    False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    False]],
  ['regression: scenario 2',
   [2,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, False],
     [False, True],
     [False, True],
     [False, True],
     [False, False]]],
   [False,
    False,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False]],
  ['regression: scenario 4',
   [2,
    5,
    4,
    [[False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True]]],
   [False, False, False, False, True, True, True, False, False, False, False, False, False, False]]],
 [['regression: scenario 2',
   [2,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True]]],
   [False,
    False,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    False]],
  ['regression: scenario 14',
   [5,
    5,
    4,
    [[False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True]]],
   [False,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True,
    True,
    True,
    True,
    True,
    False,
    False,
    False,
    False,
    False,
    True,
    True,
    True]],
  ['regression: min on and off',
   [3,
    4,
    2,
    [[True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, False],
     [True, True]]],
   [False, False, True, True, True, False, False, False, False, False, True]],
  ['regression: safety during min on',
   [5,
    3,
    0,
    [[True, True], [False, True], [False, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, True, True]],
  ['regression: safety then quick recall',
   [2,
    4,
    0,
    [[True, True], [True, True], [True, False], [True, True], [True, True], [True, True], [True, True]]],
   [True, True, False, False, False, False, True]],
  ['regression: exact min on',
   [2,
    3,
    0,
    [[True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [True, True],
     [True, True]]],
   [True, True, False, False, False, True, True, False, False, False, True, True]],
  ['control: scenario 1',
   [3,
    4,
    0,
    [[False, True],
     [False, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [True, True],
     [False, True],
     [False, False],
     [False, False],
     [False, True]]],
   [False, False, False, False, True, True, True, False, False, False, False]],
  ['regression: scenario 3',
   [2,
    5,
    0,
    [[True, True],
     [True, True],
     [True, False],
     [False, True],
     [True, True],
     [True, True],
     [False, True],
     [False, True],
     [True, True],
     [False, True],
     [False, True],
     [False, True]]],
   [True, True, False, False, False, False, False, False, True, True, False, False]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A compressor that ran longer than the off delay restarts immediately after stopping.

Compressor protection sampled per minute; calls is a list of [demand, safety_ok]. After power-up the compressor may not start before minute startup_delay. Once started it runs at least min_on minutes even if demand ends; after stopping it stays off at least min_off minutes. A safety fault stops it immediately regardless of minimum on time, and that stop also starts the minimum off time; it cannot start while the safety is faulted. Return the compressor state per minute.

split: open-access