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

N = 1
observations = []
def solve(min_scans, latched, scans):
    in_alarm = False
    acked = True
    count = 0
    out = []
    for cond, ack, reset in scans:
        count = count + 1 if cond else 0
        if count > min_scans and cond and not in_alarm:
            in_alarm = True
            acked = False
        elif in_alarm and not cond and (not latched or reset):
            in_alarm = False
        if ack and not acked:
            acked = True
        out.append([in_alarm, acked])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 1',
   [1,
    False,
    [[True, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False]]],
   [[True, False],
    [False, False],
    [True, False],
    [False, False],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [True, False]]],
  ['regression: scenario 2',
   [1,
    True,
    [[False, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, True],
     [False, False, False],
     [False, True, False],
     [True, False, False],
     [False, False, False]]],
   [[False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, True],
    [True, False],
    [True, False]]],
  ['regression: scenario 3',
   [3,
    False,
    [[True, False, False],
     [True, False, True],
     [False, False, False],
     [False, False, False],
     [False, False, True],
     [True, False, False],
     [True, True, False],
     [False, True, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False]]]],
 [['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: scenario 2',
   [3,
    False,
    [[False, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [False, False, True],
     [False, True, False],
     [True, False, False],
     [False, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 1',
   [1,
    False,
    [[False, False, False],
     [False, False, True],
     [False, False, False],
     [True, True, False],
     [False, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [True, True],
    [False, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [True, False]]],
  ['regression: scenario 3',
   [2,
    False,
    [[True, False, False],
     [True, False, True],
     [False, True, True],
     [False, False, False],
     [False, False, True],
     [True, False, False],
     [True, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, True],
     [False, False, False],
     [False, False, False]]],
   [[False, True],
    [True, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True]]]],
 [['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: scenario 1',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, True],
     [False, False, True]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [True, False],
    [False, False],
    [False, False]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 2',
   [2,
    True,
    [[False, True, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, True],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, True, True]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]],
  ['regression: scenario 3',
   [3,
    True,
    [[True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, True],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [False, True, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]]],
 [['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: scenario 2',
   [2,
    False,
    [[False, True, False],
     [True, False, False],
     [True, True, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [True, True, False],
     [True, False, True],
     [False, False, False],
     [True, False, True],
     [True, True, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [True, True],
    [True, True]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 1',
   [2,
    True,
    [[False, True, False],
     [True, False, False],
     [False, False, False],
     [False, False, True],
     [False, False, True],
     [True, False, True],
     [True, True, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, True, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]],
  ['regression: scenario 3',
   [1,
    True,
    [[False, False, False],
     [False, False, False],
     [False, False, True],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, True],
     [True, False, False],
     [True, True, False],
     [True, False, True],
     [True, False, True],
     [True, True, True]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]]],
 [['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 4',
   [3,
    False,
    [[True, False, False],
     [True, False, True],
     [True, False, True],
     [True, False, True],
     [False, False, False],
     [True, False, True],
     [False, False, False],
     [False, False, False],
     [False, False, False],
     [False, False, True]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: scenario 1',
   [2,
    False,
    [[False, False, False],
     [True, True, False],
     [True, True, False],
     [False, False, True],
     [False, False, True],
     [True, True, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, True]]],
   [[False, True],
    [False, True],
    [True, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False],
    [False, False],
    [False, False],
    [True, False]]],
  ['regression: scenario 2',
   [2,
    False,
    [[False, True, False],
     [True, True, True],
     [False, False, False],
     [False, True, True],
     [True, False, False],
     [False, False, False],
     [True, False, True],
     [False, False, False],
     [True, False, False],
     [False, True, False],
     [False, True, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True]]]]]
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_scans, latched, scans):
    in_alarm = False
    acked = True
    count = 0
    out = []
    for cond, ack, reset in scans:
        count = count + 1 if cond else 0
        if count >= min_scans - 1 and cond and not in_alarm:
            in_alarm = True
            acked = False
        elif in_alarm and not cond and (not latched or reset):
            in_alarm = False
        if ack and not acked:
            acked = True
        out.append([in_alarm, acked])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 1',
   [1,
    False,
    [[True, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False]]],
   [[True, False],
    [False, False],
    [True, False],
    [False, False],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [True, False]]],
  ['regression: scenario 2',
   [1,
    True,
    [[False, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, True],
     [False, False, False],
     [False, True, False],
     [True, False, False],
     [False, False, False]]],
   [[False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, True],
    [True, False],
    [True, False]]],
  ['regression: scenario 3',
   [3,
    False,
    [[True, False, False],
     [True, False, True],
     [False, False, False],
     [False, False, False],
     [False, False, True],
     [True, False, False],
     [True, True, False],
     [False, True, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False]]]],
 [['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: scenario 2',
   [3,
    False,
    [[False, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [False, False, True],
     [False, True, False],
     [True, False, False],
     [False, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 1',
   [1,
    False,
    [[False, False, False],
     [False, False, True],
     [False, False, False],
     [True, True, False],
     [False, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [True, True],
    [False, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [True, False]]],
  ['regression: scenario 3',
   [2,
    False,
    [[True, False, False],
     [True, False, True],
     [False, True, True],
     [False, False, False],
     [False, False, True],
     [True, False, False],
     [True, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, True],
     [False, False, False],
     [False, False, False]]],
   [[False, True],
    [True, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True]]]],
 [['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: scenario 1',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, True],
     [False, False, True]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [True, False],
    [False, False],
    [False, False]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 2',
   [2,
    True,
    [[False, True, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, True],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, True, True]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]],
  ['regression: scenario 3',
   [3,
    True,
    [[True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, True],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [False, True, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]]],
 [['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: scenario 2',
   [2,
    False,
    [[False, True, False],
     [True, False, False],
     [True, True, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [True, True, False],
     [True, False, True],
     [False, False, False],
     [True, False, True],
     [True, True, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [True, True],
    [True, True]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 1',
   [2,
    True,
    [[False, True, False],
     [True, False, False],
     [False, False, False],
     [False, False, True],
     [False, False, True],
     [True, False, True],
     [True, True, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, True, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]],
  ['regression: scenario 3',
   [1,
    True,
    [[False, False, False],
     [False, False, False],
     [False, False, True],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, True],
     [True, False, False],
     [True, True, False],
     [True, False, True],
     [True, False, True],
     [True, True, True]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]]],
 [['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 4',
   [3,
    False,
    [[True, False, False],
     [True, False, True],
     [True, False, True],
     [True, False, True],
     [False, False, False],
     [True, False, True],
     [False, False, False],
     [False, False, False],
     [False, False, False],
     [False, False, True]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: scenario 1',
   [2,
    False,
    [[False, False, False],
     [True, True, False],
     [True, True, False],
     [False, False, True],
     [False, False, True],
     [True, True, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, True]]],
   [[False, True],
    [False, True],
    [True, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False],
    [False, False],
    [False, False],
    [True, False]]],
  ['regression: scenario 2',
   [2,
    False,
    [[False, True, False],
     [True, True, True],
     [False, False, False],
     [False, True, True],
     [True, False, False],
     [False, False, False],
     [True, False, True],
     [False, False, False],
     [True, False, False],
     [False, True, False],
     [False, True, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True]]]]]
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 alarm is announced one scan late.

Digital alarm instruction evaluated per scan; scans is a list of [condition, ack, reset], min_scans >= 1. The alarm activates when the condition has been true for min_scans consecutive scans; activation clears the acknowledged flag. A non-latched alarm clears when the condition goes false; a latched alarm clears only on a reset while the condition is false. ack sets acknowledged. Return [in_alarm, acknowledged] per scan.

split: open-access


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

N = 1
observations = []
def solve(min_scans, latched, scans):
    in_alarm = False
    acked = True
    count = 0
    out = []
    for cond, ack, reset in scans:
        count = count + 1 if cond else 0
        if count >= min_scans and cond and not in_alarm:
            in_alarm = True
        elif in_alarm and not cond and (not latched or reset):
            in_alarm = False
        if ack and not acked:
            acked = True
        out.append([in_alarm, acked])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 1',
   [1,
    False,
    [[True, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False]]],
   [[True, False],
    [False, False],
    [True, False],
    [False, False],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [True, False]]],
  ['regression: scenario 2',
   [1,
    True,
    [[False, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, True],
     [False, False, False],
     [False, True, False],
     [True, False, False],
     [False, False, False]]],
   [[False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, True],
    [True, False],
    [True, False]]],
  ['regression: scenario 3',
   [3,
    False,
    [[True, False, False],
     [True, False, True],
     [False, False, False],
     [False, False, False],
     [False, False, True],
     [True, False, False],
     [True, True, False],
     [False, True, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False]]]],
 [['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 1',
   [1,
    False,
    [[False, False, False],
     [False, False, True],
     [False, False, False],
     [True, True, False],
     [False, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [True, True],
    [False, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [True, False]]],
  ['regression: scenario 2',
   [3,
    False,
    [[False, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [False, False, True],
     [False, True, False],
     [True, False, False],
     [False, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False]]],
  ['regression: scenario 3',
   [2,
    False,
    [[True, False, False],
     [True, False, True],
     [False, True, True],
     [False, False, False],
     [False, False, True],
     [True, False, False],
     [True, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, True],
     [False, False, False],
     [False, False, False]]],
   [[False, True],
    [True, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True]]]],
 [['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: scenario 1',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, True],
     [False, False, True]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [True, False],
    [False, False],
    [False, False]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 2',
   [2,
    True,
    [[False, True, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, True],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, True, True]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]],
  ['regression: scenario 3',
   [3,
    True,
    [[True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, True],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [False, True, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]]],
 [['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: scenario 9',
   [2,
    False,
    [[True, True, False],
     [False, False, False],
     [True, False, False],
     [False, True, True],
     [True, False, False],
     [True, True, False],
     [False, False, False],
     [True, True, False],
     [False, False, False],
     [False, True, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, True]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False],
    [True, False],
    [False, False]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['control: scenario 1',
   [2,
    True,
    [[False, True, False],
     [True, False, False],
     [False, False, False],
     [False, False, True],
     [False, False, True],
     [True, False, True],
     [True, True, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, True, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]],
  ['control: scenario 2',
   [2,
    False,
    [[False, True, False],
     [True, False, False],
     [True, True, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [True, True, False],
     [True, False, True],
     [False, False, False],
     [True, False, True],
     [True, True, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [True, True],
    [True, True]]]],
 [['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 4',
   [3,
    False,
    [[True, False, False],
     [True, False, True],
     [True, False, True],
     [True, False, True],
     [False, False, False],
     [True, False, True],
     [False, False, False],
     [False, False, False],
     [False, False, False],
     [False, False, True]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: scenario 1',
   [2,
    False,
    [[False, False, False],
     [True, True, False],
     [True, True, False],
     [False, False, True],
     [False, False, True],
     [True, True, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, True]]],
   [[False, True],
    [False, True],
    [True, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False],
    [False, False],
    [False, False],
    [True, False]]],
  ['control: scenario 2',
   [2,
    False,
    [[False, True, False],
     [True, True, True],
     [False, False, False],
     [False, True, True],
     [True, False, False],
     [False, False, False],
     [True, False, True],
     [False, False, False],
     [True, False, False],
     [False, True, False],
     [False, True, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True]]]]]
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_scans, latched, scans):
    in_alarm = False
    acked = True
    count = 0
    out = []
    for cond, ack, reset in scans:
        count = count + 1 if cond else 0
        if count >= min_scans and cond and not in_alarm:
            in_alarm = True
            acked = acked and not latched
        elif in_alarm and not cond and (not latched or reset):
            in_alarm = False
        if ack and not acked:
            acked = True
        out.append([in_alarm, acked])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 1',
   [1,
    False,
    [[True, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False]]],
   [[True, False],
    [False, False],
    [True, False],
    [False, False],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [True, False]]],
  ['regression: scenario 2',
   [1,
    True,
    [[False, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, True],
     [False, False, False],
     [False, True, False],
     [True, False, False],
     [False, False, False]]],
   [[False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, True],
    [True, False],
    [True, False]]],
  ['regression: scenario 3',
   [3,
    False,
    [[True, False, False],
     [True, False, True],
     [False, False, False],
     [False, False, False],
     [False, False, True],
     [True, False, False],
     [True, True, False],
     [False, True, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False]]]],
 [['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 1',
   [1,
    False,
    [[False, False, False],
     [False, False, True],
     [False, False, False],
     [True, True, False],
     [False, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [True, True],
    [False, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [True, False]]],
  ['regression: scenario 2',
   [3,
    False,
    [[False, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [False, False, True],
     [False, True, False],
     [True, False, False],
     [False, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False]]],
  ['regression: scenario 3',
   [2,
    False,
    [[True, False, False],
     [True, False, True],
     [False, True, True],
     [False, False, False],
     [False, False, True],
     [True, False, False],
     [True, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, True],
     [False, False, False],
     [False, False, False]]],
   [[False, True],
    [True, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True]]]],
 [['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: scenario 1',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, True],
     [False, False, True]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [True, False],
    [False, False],
    [False, False]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 2',
   [2,
    True,
    [[False, True, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, True],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, True, True]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]],
  ['regression: scenario 3',
   [3,
    True,
    [[True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, True],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [False, True, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]]],
 [['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: scenario 9',
   [2,
    False,
    [[True, True, False],
     [False, False, False],
     [True, False, False],
     [False, True, True],
     [True, False, False],
     [True, True, False],
     [False, False, False],
     [True, True, False],
     [False, False, False],
     [False, True, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, True]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False],
    [True, False],
    [False, False]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['control: scenario 1',
   [2,
    True,
    [[False, True, False],
     [True, False, False],
     [False, False, False],
     [False, False, True],
     [False, False, True],
     [True, False, True],
     [True, True, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, True, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]],
  ['control: scenario 2',
   [2,
    False,
    [[False, True, False],
     [True, False, False],
     [True, True, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [True, True, False],
     [True, False, True],
     [False, False, False],
     [True, False, True],
     [True, True, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [True, True],
    [True, True]]]],
 [['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 4',
   [3,
    False,
    [[True, False, False],
     [True, False, True],
     [True, False, True],
     [True, False, True],
     [False, False, False],
     [True, False, True],
     [False, False, False],
     [False, False, False],
     [False, False, False],
     [False, False, True]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['regression: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['regression: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: scenario 1',
   [2,
    False,
    [[False, False, False],
     [True, True, False],
     [True, True, False],
     [False, False, True],
     [False, False, True],
     [True, True, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, True]]],
   [[False, True],
    [False, True],
    [True, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False],
    [False, False],
    [False, False],
    [True, False]]],
  ['control: scenario 2',
   [2,
    False,
    [[False, True, False],
     [True, True, True],
     [False, False, False],
     [False, True, True],
     [True, False, False],
     [False, False, False],
     [True, False, True],
     [False, False, False],
     [True, False, False],
     [False, True, False],
     [False, True, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True]]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
An alarm that returns after being acknowledged is shown as already acknowledged.

Digital alarm instruction evaluated per scan; scans is a list of [condition, ack, reset], min_scans >= 1. The alarm activates when the condition has been true for min_scans consecutive scans; activation clears the acknowledged flag. A non-latched alarm clears when the condition goes false; a latched alarm clears only on a reset while the condition is false. ack sets acknowledged. Return [in_alarm, acknowledged] per scan.

split: open-access


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

N = 1
observations = []
def solve(min_scans, latched, scans):
    in_alarm = False
    acked = True
    count = 0
    out = []
    for cond, ack, reset in scans:
        count = count + 1 if cond else 0
        if count >= min_scans and cond and not in_alarm:
            in_alarm = True
            acked = False
        elif in_alarm and not cond and (not latched or ack):
            in_alarm = False
        if ack and not acked:
            acked = True
        out.append([in_alarm, acked])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['control: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['control: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['control: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['control: scenario 1',
   [1,
    False,
    [[True, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False]]],
   [[True, False],
    [False, False],
    [True, False],
    [False, False],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [True, False]]],
  ['regression: scenario 2',
   [1,
    True,
    [[False, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, True],
     [False, False, False],
     [False, True, False],
     [True, False, False],
     [False, False, False]]],
   [[False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, True],
    [True, False],
    [True, False]]],
  ['control: scenario 3',
   [3,
    False,
    [[True, False, False],
     [True, False, True],
     [False, False, False],
     [False, False, False],
     [False, False, True],
     [True, False, False],
     [True, True, False],
     [False, True, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False]]]],
 [['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 6',
   [2,
    True,
    [[False, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, True],
     [False, False, False],
     [False, False, True],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [True, True, False],
     [False, False, False],
     [True, True, False],
     [False, False, False],
     [False, True, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['control: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['control: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['control: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['control: scenario 1',
   [1,
    False,
    [[False, False, False],
     [False, False, True],
     [False, False, False],
     [True, True, False],
     [False, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [True, True],
    [False, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [True, False]]],
  ['control: scenario 2',
   [3,
    False,
    [[False, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [False, False, True],
     [False, True, False],
     [True, False, False],
     [False, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False]]]],
 [['regression: scenario 2',
   [2,
    True,
    [[False, True, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, True],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, True, True]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]],
  ['regression: scenario 3',
   [3,
    True,
    [[True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, True],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [False, True, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['control: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['control: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['control: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['control: scenario 1',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, True],
     [False, False, True]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [True, False],
    [False, False],
    [False, False]]]],
 [['regression: scenario 11',
   [1,
    True,
    [[False, False, False],
     [True, False, False],
     [True, False, False],
     [False, True, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [False, False, False],
     [False, False, False],
     [True, True, False],
     [True, True, False],
     [False, False, True]]],
   [[False, True],
    [True, False],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [False, True]]],
  ['regression: scenario 34',
   [1,
    True,
    [[False, False, False],
     [True, False, False],
     [False, True, False],
     [False, True, False],
     [False, False, False],
     [False, False, True],
     [False, False, False],
     [False, True, False],
     [False, False, False]]],
   [[False, True],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['control: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['control: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['control: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['control: scenario 1',
   [2,
    True,
    [[False, True, False],
     [True, False, False],
     [False, False, False],
     [False, False, True],
     [False, False, True],
     [True, False, True],
     [True, True, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, True, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]]],
 [['regression: scenario 10',
   [1,
    True,
    [[True, False, False],
     [True, False, False],
     [False, True, False],
     [False, False, False],
     [False, False, False],
     [False, False, True],
     [False, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False]]],
   [[True, False],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False]]],
  ['regression: scenario 11',
   [2,
    True,
    [[True, False, True],
     [True, True, False],
     [True, False, False],
     [False, True, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [False, True, True],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, True],
     [True, True, False]]],
   [[False, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, True]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['control: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['control: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['control: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['control: scenario 1',
   [2,
    False,
    [[False, False, False],
     [True, True, False],
     [True, True, False],
     [False, False, True],
     [False, False, True],
     [True, True, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, True]]],
   [[False, True],
    [False, True],
    [True, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False],
    [False, False],
    [False, False],
    [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_scans, latched, scans):
    in_alarm = False
    acked = True
    count = 0
    out = []
    for cond, ack, reset in scans:
        count = count + 1 if cond else 0
        if count >= min_scans and cond and not in_alarm:
            in_alarm = True
            acked = False
        elif in_alarm and not cond and (not latched or reset or ack):
            in_alarm = False
        if ack and not acked:
            acked = True
        out.append([in_alarm, acked])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['control: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['control: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['control: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['control: scenario 1',
   [1,
    False,
    [[True, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False]]],
   [[True, False],
    [False, False],
    [True, False],
    [False, False],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [True, False]]],
  ['regression: scenario 2',
   [1,
    True,
    [[False, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, True],
     [False, False, False],
     [False, True, False],
     [True, False, False],
     [False, False, False]]],
   [[False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, True],
    [True, False],
    [True, False]]],
  ['control: scenario 3',
   [3,
    False,
    [[True, False, False],
     [True, False, True],
     [False, False, False],
     [False, False, False],
     [False, False, True],
     [True, False, False],
     [True, True, False],
     [False, True, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False]]]],
 [['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['regression: scenario 6',
   [2,
    True,
    [[False, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, True],
     [False, False, False],
     [False, False, True],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [True, True, False],
     [False, False, False],
     [True, True, False],
     [False, False, False],
     [False, True, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['control: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['control: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['control: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['control: scenario 1',
   [1,
    False,
    [[False, False, False],
     [False, False, True],
     [False, False, False],
     [True, True, False],
     [False, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [True, True],
    [False, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [True, False]]],
  ['control: scenario 2',
   [3,
    False,
    [[False, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [False, False, True],
     [False, True, False],
     [True, False, False],
     [False, False, False],
     [True, True, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False]]]],
 [['regression: scenario 2',
   [2,
    True,
    [[False, True, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, True],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, True, True]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]],
  ['regression: scenario 3',
   [3,
    True,
    [[True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, True],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [False, True, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['control: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['control: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['control: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['control: scenario 1',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [False, False, True],
     [False, False, True]]],
   [[False, True],
    [False, True],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [True, False],
    [False, False],
    [False, False]]]],
 [['regression: scenario 11',
   [1,
    True,
    [[False, False, False],
     [True, False, False],
     [True, False, False],
     [False, True, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [False, False, False],
     [False, False, False],
     [False, False, False],
     [True, True, False],
     [True, True, False],
     [False, False, True]]],
   [[False, True],
    [True, False],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [False, True]]],
  ['regression: scenario 34',
   [1,
    True,
    [[False, False, False],
     [True, False, False],
     [False, True, False],
     [False, True, False],
     [False, False, False],
     [False, False, True],
     [False, False, False],
     [False, True, False],
     [False, False, False]]],
   [[False, True],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['control: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['control: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['control: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['control: scenario 1',
   [2,
    True,
    [[False, True, False],
     [True, False, False],
     [False, False, False],
     [False, False, True],
     [False, False, True],
     [True, False, True],
     [True, True, False],
     [True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, True, False],
     [True, False, False]]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True]]]],
 [['regression: scenario 10',
   [1,
    True,
    [[True, False, False],
     [True, False, False],
     [False, True, False],
     [False, False, False],
     [False, False, False],
     [False, False, True],
     [False, False, False],
     [False, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [False, False, False]]],
   [[True, False],
    [True, False],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, False]]],
  ['regression: scenario 11',
   [2,
    True,
    [[True, False, True],
     [True, True, False],
     [True, False, False],
     [False, True, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [False, True, True],
     [True, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, True],
     [True, True, False]]],
   [[False, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [True, True],
    [False, True],
    [False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, True]]],
  ['regression: latched with ack and reset',
   [2,
    True,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [False, True, False],
     [False, False, True],
     [True, False, False]]],
   [[False, True], [True, False], [True, False], [True, True], [False, True], [False, True]]],
  ['control: chattering condition',
   [3,
    False,
    [[True, False, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, False],
     [True, False, False]]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [True, False]]],
  ['control: realarm after ack',
   [1, False, [[True, False, False], [True, True, False], [False, False, False], [True, False, False]]],
   [[True, False], [True, True], [False, True], [True, False]]],
  ['control: reset while condition true',
   [1, False, [[True, False, False], [True, False, True], [True, False, False]]],
   [[True, False], [True, False], [True, False]]],
  ['regression: ack on latched alarm',
   [1, True, [[True, False, False], [False, True, False], [False, False, False], [False, False, True]]],
   [[True, False], [True, True], [True, True], [False, True]]],
  ['control: scenario 1',
   [2,
    False,
    [[False, False, False],
     [True, True, False],
     [True, True, False],
     [False, False, True],
     [False, False, True],
     [True, True, False],
     [True, False, False],
     [False, False, False],
     [True, False, False],
     [True, False, True]]],
   [[False, True],
    [False, True],
    [True, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False],
    [False, False],
    [False, False],
    [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:
Operators clear latched alarms with the acknowledge button, bypassing the reset.

Digital alarm instruction evaluated per scan; scans is a list of [condition, ack, reset], min_scans >= 1. The alarm activates when the condition has been true for min_scans consecutive scans; activation clears the acknowledged flag. A non-latched alarm clears when the condition goes false; a latched alarm clears only on a reset while the condition is false. ack sets acknowledged. Return [in_alarm, acknowledged] per scan.

split: open-access