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

N = 1
observations = []
def solve(scans):
    motor = False
    tripped = False
    need_release = False
    out = []
    for s in scans:
        if not s.get('power', True):
            motor = False
            need_release = True
            out.append([False, tripped])
            continue
        start = s.get('start', False)
        if not start:
            need_release = False
        if not s.get('ol_nc', True):
            tripped = True
        elif s.get('reset', False):
            tripped = False
        run_cmd = start and not need_release
        motor = run_cmd and s.get('stop_nc', True) and not tripped
        out.append([motor, tripped])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['regression: reset while running',
   [[{'start': True}, {}, {'reset': True}, {}]],
   [[True, False], [True, False], [True, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['control: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['control: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['control: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['control: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]],
  ['control: start after overload recovers',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]]],
 [['regression: reset while running',
   [[{'start': True}, {}, {'reset': True}, {}]],
   [[True, False], [True, False], [True, False], [True, False]]],
  ['regression: scenario 29',
   [[{},
     {'stop_nc': True},
     {'start': True, 'ol_nc': True, 'power': False},
     {'start': True},
     {'start': False},
     {'start': True, 'ol_nc': False},
     {},
     {'start': False, 'ol_nc': True},
     {'start': True},
     {'stop_nc': True},
     {'stop_nc': False},
     {'stop_nc': False, 'ol_nc': True},
     {'start': True, 'reset': True},
     {'stop_nc': True, 'ol_nc': True, 'reset': True}]],
   [[False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False],
    [True, False]]],
  ['regression: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['control: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['control: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['control: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['control: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]]],
 [['regression: scenario 1',
   [[{'stop_nc': True},
     {'start': True},
     {'stop_nc': True},
     {'reset': True},
     {'start': True, 'stop_nc': True, 'ol_nc': False, 'power': False},
     {'stop_nc': False},
     {'start': True},
     {'start': True, 'stop_nc': False},
     {'start': True, 'stop_nc': True, 'reset': True}]],
   [[False, False],
    [True, False],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [True, False],
    [False, False],
    [True, False]]],
  ['regression: scenario 9',
   [[{'start': True, 'ol_nc': True, 'reset': True},
     {'power': False},
     {},
     {'start': True, 'stop_nc': True, 'ol_nc': True, 'reset': True},
     {'ol_nc': True},
     {},
     {'reset': True}]],
   [[True, False],
    [False, False],
    [False, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False]]],
  ['regression: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['control: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['control: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['control: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['control: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]]],
 [['regression: scenario 3',
   [[{'stop_nc': True},
     {'stop_nc': False},
     {'stop_nc': False},
     {'start': True},
     {'start': True},
     {'start': False},
     {'stop_nc': False, 'reset': True},
     {'start': False},
     {'ol_nc': True, 'reset': True},
     {},
     {'start': False}]],
   [[False, False],
    [False, False],
    [False, False],
    [True, False],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False]]],
  ['regression: scenario 14',
   [[{'start': False, 'ol_nc': True},
     {'stop_nc': False},
     {},
     {'start': True},
     {'stop_nc': True},
     {'start': True},
     {},
     {'ol_nc': True, 'reset': True},
     {'ol_nc': False},
     {'stop_nc': False, 'ol_nc': False, 'reset': True},
     {'power': False}]],
   [[False, False],
    [False, False],
    [False, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [False, True],
    [False, True],
    [False, True]]],
  ['regression: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['control: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['control: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['control: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['control: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]]],
 [['regression: scenario 4',
   [[{'start': True, 'stop_nc': True, 'reset': True},
     {'start': True, 'stop_nc': True},
     {'power': False},
     {},
     {'start': False, 'stop_nc': True, 'ol_nc': True},
     {'reset': True},
     {'ol_nc': True},
     {'start': True, 'stop_nc': False, 'ol_nc': True},
     {'start': True},
     {'ol_nc': True},
     {'start': True},
     {'start': True, 'stop_nc': False},
     {'stop_nc': False}]],
   [[True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [True, False],
    [True, False],
    [True, False],
    [False, False],
    [False, False]]],
  ['regression: scenario 14',
   [[{'start': True, 'stop_nc': True},
     {'start': True},
     {'reset': True},
     {},
     {'start': True},
     {'stop_nc': True},
     {'stop_nc': False, 'ol_nc': False, 'reset': True},
     {'stop_nc': False},
     {'reset': True, 'power': False},
     {'start': False},
     {'start': False, 'stop_nc': True, 'reset': True}]],
   [[True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, False]]],
  ['regression: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['control: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['control: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['control: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['control: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [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(scans):
    motor = False
    tripped = False
    need_release = False
    out = []
    for s in scans:
        if not s.get('power', True):
            motor = False
            need_release = True
            out.append([False, tripped])
            continue
        start = s.get('start', False)
        if not start:
            need_release = False
        if not s.get('ol_nc', True):
            tripped = True
        elif s.get('reset', False):
            tripped = False
        run_cmd = (start and not need_release) or (motor and not s.get('reset', False))
        motor = run_cmd and s.get('stop_nc', True) and not tripped
        out.append([motor, tripped])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['regression: reset while running',
   [[{'start': True}, {}, {'reset': True}, {}]],
   [[True, False], [True, False], [True, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['control: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['control: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['control: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['control: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]],
  ['control: start after overload recovers',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]]],
 [['regression: reset while running',
   [[{'start': True}, {}, {'reset': True}, {}]],
   [[True, False], [True, False], [True, False], [True, False]]],
  ['regression: scenario 29',
   [[{},
     {'stop_nc': True},
     {'start': True, 'ol_nc': True, 'power': False},
     {'start': True},
     {'start': False},
     {'start': True, 'ol_nc': False},
     {},
     {'start': False, 'ol_nc': True},
     {'start': True},
     {'stop_nc': True},
     {'stop_nc': False},
     {'stop_nc': False, 'ol_nc': True},
     {'start': True, 'reset': True},
     {'stop_nc': True, 'ol_nc': True, 'reset': True}]],
   [[False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [True, False],
    [True, False]]],
  ['regression: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['control: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['control: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['control: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['control: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]]],
 [['regression: scenario 1',
   [[{'stop_nc': True},
     {'start': True},
     {'stop_nc': True},
     {'reset': True},
     {'start': True, 'stop_nc': True, 'ol_nc': False, 'power': False},
     {'stop_nc': False},
     {'start': True},
     {'start': True, 'stop_nc': False},
     {'start': True, 'stop_nc': True, 'reset': True}]],
   [[False, False],
    [True, False],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [True, False],
    [False, False],
    [True, False]]],
  ['regression: scenario 9',
   [[{'start': True, 'ol_nc': True, 'reset': True},
     {'power': False},
     {},
     {'start': True, 'stop_nc': True, 'ol_nc': True, 'reset': True},
     {'ol_nc': True},
     {},
     {'reset': True}]],
   [[True, False],
    [False, False],
    [False, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False]]],
  ['regression: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['control: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['control: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['control: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['control: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]]],
 [['regression: scenario 3',
   [[{'stop_nc': True},
     {'stop_nc': False},
     {'stop_nc': False},
     {'start': True},
     {'start': True},
     {'start': False},
     {'stop_nc': False, 'reset': True},
     {'start': False},
     {'ol_nc': True, 'reset': True},
     {},
     {'start': False}]],
   [[False, False],
    [False, False],
    [False, False],
    [True, False],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False]]],
  ['regression: scenario 14',
   [[{'start': False, 'ol_nc': True},
     {'stop_nc': False},
     {},
     {'start': True},
     {'stop_nc': True},
     {'start': True},
     {},
     {'ol_nc': True, 'reset': True},
     {'ol_nc': False},
     {'stop_nc': False, 'ol_nc': False, 'reset': True},
     {'power': False}]],
   [[False, False],
    [False, False],
    [False, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [False, True],
    [False, True],
    [False, True]]],
  ['regression: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['control: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['control: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['control: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['control: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]]],
 [['regression: scenario 4',
   [[{'start': True, 'stop_nc': True, 'reset': True},
     {'start': True, 'stop_nc': True},
     {'power': False},
     {},
     {'start': False, 'stop_nc': True, 'ol_nc': True},
     {'reset': True},
     {'ol_nc': True},
     {'start': True, 'stop_nc': False, 'ol_nc': True},
     {'start': True},
     {'ol_nc': True},
     {'start': True},
     {'start': True, 'stop_nc': False},
     {'stop_nc': False}]],
   [[True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [True, False],
    [True, False],
    [True, False],
    [False, False],
    [False, False]]],
  ['regression: scenario 14',
   [[{'start': True, 'stop_nc': True},
     {'start': True},
     {'reset': True},
     {},
     {'start': True},
     {'stop_nc': True},
     {'stop_nc': False, 'ol_nc': False, 'reset': True},
     {'stop_nc': False},
     {'reset': True, 'power': False},
     {'start': False},
     {'start': False, 'stop_nc': True, 'reset': True}]],
   [[True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, False]]],
  ['regression: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['control: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['control: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['control: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['control: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [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:
The motor only runs while start is held, like a jog circuit.

Three-wire motor starter rung evaluated per scan. Each scan is a dict with optional keys start (pushbutton, default false), stop_nc (normally-closed stop contact: true means not pressed, default true), ol_nc (normally-closed overload contact, default true), reset (default false) and power (default true). An open overload contact latches a trip (retentive); reset clears it only on a scan where the overload contact is closed. The motor runs on start or its own seal-in, and only while stop_nc is closed and no trip is latched; stop and trip dominate start. A power-loss scan drops the motor and requires the start button to be seen released before it can start again. Return [motor, tripped] per scan.

split: open-access


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

N = 1
observations = []
def solve(scans):
    motor = False
    tripped = False
    need_release = False
    out = []
    for s in scans:
        if not s.get('power', True):
            motor = False
            need_release = True
            out.append([False, tripped])
            continue
        start = s.get('start', False)
        if not start:
            need_release = False
        if not s.get('ol_nc', True):
            tripped = True
        elif s.get('reset', False):
            tripped = False
        motor = (start and not need_release) or (motor and s.get('stop_nc', True) and not tripped)
        out.append([motor, tripped])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['regression: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['control: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['regression: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['regression: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]],
  ['regression: start after overload recovers',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]],
  ['control: reset while running',
   [[{'start': True}, {}, {'reset': True}, {}]],
   [[True, False], [True, False], [True, False], [True, False]]]],
 [['regression: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['regression: scenario 1',
   [[{'start': False, 'ol_nc': False},
     {'start': False, 'ol_nc': True},
     {'stop_nc': False},
     {'start': True, 'stop_nc': True},
     {'stop_nc': True, 'ol_nc': False},
     {'start': True, 'stop_nc': False},
     {'ol_nc': True},
     {'reset': True},
     {'start': True, 'stop_nc': True, 'reset': True},
     {'start': True, 'stop_nc': True},
     {'start': True, 'stop_nc': False, 'reset': True},
     {'ol_nc': True},
     {'power': False},
     {'start': False, 'stop_nc': True}]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, False],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False]]],
  ['control: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['regression: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['regression: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['regression: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]],
  ['regression: start after overload recovers',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]]],
 [['regression: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['regression: scenario 8',
   [[{'start': True, 'stop_nc': False},
     {},
     {},
     {'ol_nc': False},
     {'start': False, 'ol_nc': True},
     {'start': False, 'reset': True},
     {'stop_nc': False, 'reset': True},
     {'stop_nc': False},
     {'ol_nc': True},
     {'stop_nc': True, 'ol_nc': True},
     {'start': True, 'ol_nc': False},
     {}]],
   [[False, False],
    [False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, True],
    [False, True]]],
  ['control: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['regression: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['regression: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['regression: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]],
  ['regression: start after overload recovers',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]]],
 [['regression: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]],
  ['regression: scenario 13',
   [[{'stop_nc': True},
     {'stop_nc': True, 'ol_nc': True},
     {'stop_nc': True, 'ol_nc': True, 'reset': True},
     {'start': True},
     {'start': True, 'stop_nc': False},
     {'reset': True},
     {'start': False, 'ol_nc': True},
     {'start': True},
     {'start': True, 'stop_nc': True}]],
   [[False, False],
    [False, False],
    [False, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [True, False],
    [True, False]]],
  ['control: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['regression: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['regression: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['regression: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['regression: start after overload recovers',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]]],
 [['regression: start after overload recovers',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]],
  ['regression: scenario 18',
   [[{'start': True, 'reset': True},
     {'start': True, 'stop_nc': False, 'reset': True},
     {'start': True},
     {},
     {'stop_nc': True, 'ol_nc': False},
     {'stop_nc': True},
     {},
     {'reset': True},
     {}]],
   [[True, False],
    [False, False],
    [True, False],
    [True, False],
    [False, True],
    [False, True],
    [False, True],
    [False, False],
    [False, False]]],
  ['control: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['regression: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['regression: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['regression: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['regression: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [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(scans):
    motor = False
    tripped = False
    need_release = False
    out = []
    for s in scans:
        if not s.get('power', True):
            motor = False
            need_release = True
            out.append([False, tripped])
            continue
        start = s.get('start', False)
        if not start:
            need_release = False
        if not s.get('ol_nc', True):
            tripped = True
        elif s.get('reset', False):
            tripped = False
        motor = (start and not need_release and not tripped) or (motor and s.get('stop_nc', True) and not tripped)
        out.append([motor, tripped])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['regression: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['control: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['regression: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['regression: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]],
  ['regression: start after overload recovers',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]],
  ['control: reset while running',
   [[{'start': True}, {}, {'reset': True}, {}]],
   [[True, False], [True, False], [True, False], [True, False]]]],
 [['regression: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['regression: scenario 1',
   [[{'start': False, 'ol_nc': False},
     {'start': False, 'ol_nc': True},
     {'stop_nc': False},
     {'start': True, 'stop_nc': True},
     {'stop_nc': True, 'ol_nc': False},
     {'start': True, 'stop_nc': False},
     {'ol_nc': True},
     {'reset': True},
     {'start': True, 'stop_nc': True, 'reset': True},
     {'start': True, 'stop_nc': True},
     {'start': True, 'stop_nc': False, 'reset': True},
     {'ol_nc': True},
     {'power': False},
     {'start': False, 'stop_nc': True}]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, False],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False]]],
  ['control: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['regression: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['regression: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['regression: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]],
  ['regression: start after overload recovers',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]]],
 [['regression: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['regression: scenario 8',
   [[{'start': True, 'stop_nc': False},
     {},
     {},
     {'ol_nc': False},
     {'start': False, 'ol_nc': True},
     {'start': False, 'reset': True},
     {'stop_nc': False, 'reset': True},
     {'stop_nc': False},
     {'ol_nc': True},
     {'stop_nc': True, 'ol_nc': True},
     {'start': True, 'ol_nc': False},
     {}]],
   [[False, False],
    [False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, True],
    [False, True]]],
  ['control: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['regression: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['regression: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['regression: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]],
  ['regression: start after overload recovers',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]]],
 [['regression: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]],
  ['regression: scenario 13',
   [[{'stop_nc': True},
     {'stop_nc': True, 'ol_nc': True},
     {'stop_nc': True, 'ol_nc': True, 'reset': True},
     {'start': True},
     {'start': True, 'stop_nc': False},
     {'reset': True},
     {'start': False, 'ol_nc': True},
     {'start': True},
     {'start': True, 'stop_nc': True}]],
   [[False, False],
    [False, False],
    [False, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [True, False],
    [True, False]]],
  ['control: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['regression: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['regression: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['regression: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['regression: start after overload recovers',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]]],
 [['regression: start after overload recovers',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]],
  ['regression: scenario 18',
   [[{'start': True, 'reset': True},
     {'start': True, 'stop_nc': False, 'reset': True},
     {'start': True},
     {},
     {'stop_nc': True, 'ol_nc': False},
     {'stop_nc': True},
     {},
     {'reset': True},
     {}]],
   [[True, False],
    [False, False],
    [True, False],
    [True, False],
    [False, True],
    [False, True],
    [False, True],
    [False, False],
    [False, False]]],
  ['control: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['control: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['regression: overload trip and reset',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True], [False, True], [False, False], [True, False]]],
  ['regression: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['regression: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['regression: trip across power loss',
   [[{'start': True}, {'ol_nc': False}, {'power': False}, {}, {'start': True}]],
   [[True, False], [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:
Holding start while pressing stop keeps the motor running.

Three-wire motor starter rung evaluated per scan. Each scan is a dict with optional keys start (pushbutton, default false), stop_nc (normally-closed stop contact: true means not pressed, default true), ol_nc (normally-closed overload contact, default true), reset (default false) and power (default true). An open overload contact latches a trip (retentive); reset clears it only on a scan where the overload contact is closed. The motor runs on start or its own seal-in, and only while stop_nc is closed and no trip is latched; stop and trip dominate start. A power-loss scan drops the motor and requires the start button to be seen released before it can start again. Return [motor, tripped] per scan.

split: open-access


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

N = 1
observations = []
def solve(rungs, scans):
    bits = {}
    first = True
    out = []
    for scan in scans:
        if scan.get('power_cycle'):
            for instr, bit, cond in rungs:
                bits[bit] = False
            first = True
            out.append(sorted(b for b, v in bits.items() if v))
            continue
        for instr, bit, cond in rungs:
            rung = first if cond == 'S:FS' else bool(scan.get(cond, False))
            if instr == 'OTE':
                bits[bit] = rung
            elif rung and instr == 'OTL':
                bits[bit] = True
            elif rung and instr == 'OTU':
                bits[bit] = False
        first = False
        out.append(sorted(b for b, v in bits.items() if v))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['regression: scenario 6',
   [[['OTU', 'B:2', 'I:0'],
     ['OTU', 'B:0', 'I:1'],
     ['OTL', 'B:2', 'I:2'],
     ['OTL', 'B:0', 'I:0'],
     ['OTL', 'B:2', 'I:1'],
     ['OTL', 'B:2', 'I:2']],
    [{'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [[], ['B:2'], ['B:2'], ['B:2'], ['B:0', 'B:2'], ['B:0', 'B:2']]],
  ['control: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['control: scenario 1',
   [[['OTL', 'B:3', 'I:2'],
     ['OTL', 'B:0', 'I:0'],
     ['OTE', 'B:0', 'S:FS'],
     ['OTL', 'B:1', 'S:FS'],
     ['OTU', 'B:1', 'S:FS'],
     ['OTE', 'B:2', 'I:1']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True}]],
   [['B:0'], [], ['B:2', 'B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:2', 'B:3'], ['B:2', 'B:3'], ['B:3']]],
  ['regression: scenario 2',
   [[['OTU', 'B:2', 'I:1'], ['OTL', 'B:1', 'I:1'], ['OTL', 'B:1', 'I:2'], ['OTL', 'B:0', 'I:0']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True}]],
   [['B:0'],
    ['B:0'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1']]],
  ['regression: scenario 3',
   [[['OTE', 'B:3', 'I:2'],
     ['OTE', 'B:1', 'I:1'],
     ['OTL', 'B:2', 'I:0'],
     ['OTL', 'B:2', 'I:2'],
     ['OTL', 'B:2', 'I:0']],
    [{'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True}]],
   [['B:1', 'B:2', 'B:3'], ['B:2', 'B:3'], ['B:1', 'B:2'], ['B:2'], ['B:2']]]],
 [['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: scenario 37',
   [[['OTU', 'B:0', 'S:FS'], ['OTL', 'B:3', 'I:0'], ['OTL', 'B:1', 'I:0'], ['OTL', 'B:0', 'I:1']],
    [{'I:0': False, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'power_cycle': True}]],
   [[], [], [], [], ['B:1', 'B:3'], ['B:0', 'B:1', 'B:3'], ['B:0', 'B:1', 'B:3']]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['control: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['control: scenario 1',
   [[['OTE', 'B:3', 'S:FS'], ['OTL', 'B:0', 'S:FS'], ['OTL', 'B:0', 'I:0'], ['OTE', 'B:0', 'S:FS']],
    [{'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [['B:0', 'B:3'], [], [], [], [], []]],
  ['regression: scenario 2',
   [[['OTL', 'B:2', 'I:1'], ['OTL', 'B:3', 'I:2'], ['OTU', 'B:0', 'I:0'], ['OTL', 'B:0', 'S:FS']],
    [{'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False}]],
   [['B:0', 'B:3'],
    ['B:2', 'B:3'],
    ['B:2', 'B:3'],
    ['B:2', 'B:3'],
    ['B:2', 'B:3'],
    ['B:0', 'B:2', 'B:3'],
    ['B:0', 'B:2', 'B:3']]],
  ['control: scenario 3',
   [[['OTL', 'B:2', 'I:0'],
     ['OTL', 'B:3', 'S:FS'],
     ['OTL', 'B:2', 'I:2'],
     ['OTL', 'B:1', 'S:FS'],
     ['OTL', 'B:3', 'I:2']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False}]],
   [[],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3']]]],
 [['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: scenario 7',
   [[['OTU', 'B:3', 'I:2'],
     ['OTU', 'B:0', 'I:1'],
     ['OTL', 'B:0', 'I:2'],
     ['OTU', 'B:2', 'I:0'],
     ['OTL', 'B:0', 'S:FS'],
     ['OTL', 'B:1', 'S:FS']],
    [{'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'power_cycle': True}]],
   [['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1']]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['control: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: scenario 1',
   [[['OTL', 'B:3', 'I:2'], ['OTE', 'B:1', 'I:0'], ['OTL', 'B:1', 'I:0']],
    [{'power_cycle': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True}]],
   [[], [], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:3'], ['B:3']]],
  ['regression: scenario 2',
   [[['OTL', 'B:0', 'I:2'], ['OTL', 'B:2', 'S:FS'], ['OTU', 'B:0', 'I:2'], ['OTU', 'B:3', 'I:2']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'power_cycle': True},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True}]],
   [['B:2'], ['B:2'], ['B:2'], ['B:2'], ['B:2']]],
  ['regression: scenario 3',
   [[['OTU', 'B:0', 'I:0'], ['OTL', 'B:0', 'I:0'], ['OTE', 'B:3', 'I:0']],
    [{'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True}]],
   [[], [], [], [], ['B:0', 'B:3'], ['B:0']]]],
 [['regression: scenario 1',
   [[['OTL', 'B:3', 'I:1'],
     ['OTL', 'B:1', 'S:FS'],
     ['OTU', 'B:1', 'S:FS'],
     ['OTL', 'B:0', 'S:FS'],
     ['OTE', 'B:2', 'I:0']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'power_cycle': True}]],
   [['B:0', 'B:2'], ['B:0', 'B:3'], ['B:0', 'B:2', 'B:3'], ['B:0', 'B:3'], ['B:0', 'B:3']]],
  ['regression: scenario 17',
   [[['OTU', 'B:2', 'I:2'],
     ['OTL', 'B:2', 'I:1'],
     ['OTU', 'B:1', 'I:0'],
     ['OTU', 'B:2', 'I:2'],
     ['OTL', 'B:1', 'I:2']],
    [{'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True}]],
   [['B:2'], ['B:2'], ['B:2'], ['B:2'], ['B:2'], ['B:1'], ['B:2'], ['B:1']]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['control: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['control: scenario 2',
   [[['OTE', 'B:1', 'I:1'],
     ['OTU', 'B:3', 'I:2'],
     ['OTL', 'B:1', 'I:0'],
     ['OTL', 'B:1', 'I:0'],
     ['OTL', 'B:3', 'I:2'],
     ['OTL', 'B:3', 'I:1']],
    [{'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': False}]],
   [['B:1', 'B:3'], ['B:3'], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:1', 'B:3']]],
  ['regression: scenario 3',
   [[['OTU', 'B:3', 'I:0'],
     ['OTL', 'B:1', 'I:0'],
     ['OTE', 'B:1', 'S:FS'],
     ['OTU', 'B:2', 'S:FS'],
     ['OTL', 'B:2', 'I:1'],
     ['OTU', 'B:1', 'S:FS']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [[], [], ['B:2'], ['B:2'], ['B:2'], ['B:2'], [], []]]],
 [['regression: scenario 3',
   [[['OTU', 'B:0', 'S:FS'],
     ['OTU', 'B:1', 'S:FS'],
     ['OTU', 'B:3', 'I:0'],
     ['OTL', 'B:2', 'I:1'],
     ['OTL', 'B:1', 'I:2'],
     ['OTU', 'B:0', 'S:FS']],
    [{'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True}]],
   [[],
    ['B:2'],
    ['B:2'],
    ['B:2'],
    ['B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2']]],
  ['regression: scenario 25',
   [[['OTE', 'B:0', 'S:FS'],
     ['OTL', 'B:3', 'I:2'],
     ['OTU', 'B:1', 'I:0'],
     ['OTU', 'B:3', 'S:FS'],
     ['OTL', 'B:0', 'S:FS']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True}]],
   [[], ['B:0'], ['B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:3']]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['control: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['control: scenario 1',
   [[['OTL', 'B:3', 'S:FS'],
     ['OTL', 'B:1', 'I:1'],
     ['OTL', 'B:2', 'S:FS'],
     ['OTL', 'B:1', 'I:0'],
     ['OTL', 'B:1', 'I:1']],
    [{'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [[],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3']]],
  ['regression: scenario 2',
   [[['OTU', 'B:0', 'I:2'], ['OTE', 'B:2', 'I:0'], ['OTL', 'B:1', 'I:2']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': False}]],
   [[], [], ['B:2'], ['B:2'], ['B:2'], ['B:1', 'B:2'], ['B:1', 'B:2'], ['B:1'], ['B:1']]]]]
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(rungs, scans):
    bits = {}
    first = True
    out = []
    for scan in scans:
        if scan.get('power_cycle'):
            for instr, bit, cond in rungs:
                if instr != 'OTL':
                    bits[bit] = False
            first = True
            out.append(sorted(b for b, v in bits.items() if v))
            continue
        for instr, bit, cond in rungs:
            rung = first if cond == 'S:FS' else bool(scan.get(cond, False))
            if instr == 'OTE':
                bits[bit] = rung
            elif rung and instr == 'OTL':
                bits[bit] = True
            elif rung and instr == 'OTU':
                bits[bit] = False
        first = False
        out.append(sorted(b for b, v in bits.items() if v))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['regression: scenario 6',
   [[['OTU', 'B:2', 'I:0'],
     ['OTU', 'B:0', 'I:1'],
     ['OTL', 'B:2', 'I:2'],
     ['OTL', 'B:0', 'I:0'],
     ['OTL', 'B:2', 'I:1'],
     ['OTL', 'B:2', 'I:2']],
    [{'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [[], ['B:2'], ['B:2'], ['B:2'], ['B:0', 'B:2'], ['B:0', 'B:2']]],
  ['control: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['control: scenario 1',
   [[['OTL', 'B:3', 'I:2'],
     ['OTL', 'B:0', 'I:0'],
     ['OTE', 'B:0', 'S:FS'],
     ['OTL', 'B:1', 'S:FS'],
     ['OTU', 'B:1', 'S:FS'],
     ['OTE', 'B:2', 'I:1']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True}]],
   [['B:0'], [], ['B:2', 'B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:2', 'B:3'], ['B:2', 'B:3'], ['B:3']]],
  ['regression: scenario 2',
   [[['OTU', 'B:2', 'I:1'], ['OTL', 'B:1', 'I:1'], ['OTL', 'B:1', 'I:2'], ['OTL', 'B:0', 'I:0']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True}]],
   [['B:0'],
    ['B:0'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1']]],
  ['regression: scenario 3',
   [[['OTE', 'B:3', 'I:2'],
     ['OTE', 'B:1', 'I:1'],
     ['OTL', 'B:2', 'I:0'],
     ['OTL', 'B:2', 'I:2'],
     ['OTL', 'B:2', 'I:0']],
    [{'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True}]],
   [['B:1', 'B:2', 'B:3'], ['B:2', 'B:3'], ['B:1', 'B:2'], ['B:2'], ['B:2']]]],
 [['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: scenario 37',
   [[['OTU', 'B:0', 'S:FS'], ['OTL', 'B:3', 'I:0'], ['OTL', 'B:1', 'I:0'], ['OTL', 'B:0', 'I:1']],
    [{'I:0': False, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'power_cycle': True}]],
   [[], [], [], [], ['B:1', 'B:3'], ['B:0', 'B:1', 'B:3'], ['B:0', 'B:1', 'B:3']]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['control: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['control: scenario 1',
   [[['OTE', 'B:3', 'S:FS'], ['OTL', 'B:0', 'S:FS'], ['OTL', 'B:0', 'I:0'], ['OTE', 'B:0', 'S:FS']],
    [{'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [['B:0', 'B:3'], [], [], [], [], []]],
  ['regression: scenario 2',
   [[['OTL', 'B:2', 'I:1'], ['OTL', 'B:3', 'I:2'], ['OTU', 'B:0', 'I:0'], ['OTL', 'B:0', 'S:FS']],
    [{'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False}]],
   [['B:0', 'B:3'],
    ['B:2', 'B:3'],
    ['B:2', 'B:3'],
    ['B:2', 'B:3'],
    ['B:2', 'B:3'],
    ['B:0', 'B:2', 'B:3'],
    ['B:0', 'B:2', 'B:3']]],
  ['control: scenario 3',
   [[['OTL', 'B:2', 'I:0'],
     ['OTL', 'B:3', 'S:FS'],
     ['OTL', 'B:2', 'I:2'],
     ['OTL', 'B:1', 'S:FS'],
     ['OTL', 'B:3', 'I:2']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False}]],
   [[],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3']]]],
 [['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: scenario 7',
   [[['OTU', 'B:3', 'I:2'],
     ['OTU', 'B:0', 'I:1'],
     ['OTL', 'B:0', 'I:2'],
     ['OTU', 'B:2', 'I:0'],
     ['OTL', 'B:0', 'S:FS'],
     ['OTL', 'B:1', 'S:FS']],
    [{'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'power_cycle': True}]],
   [['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1']]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['control: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: scenario 1',
   [[['OTL', 'B:3', 'I:2'], ['OTE', 'B:1', 'I:0'], ['OTL', 'B:1', 'I:0']],
    [{'power_cycle': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True}]],
   [[], [], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:3'], ['B:3']]],
  ['regression: scenario 2',
   [[['OTL', 'B:0', 'I:2'], ['OTL', 'B:2', 'S:FS'], ['OTU', 'B:0', 'I:2'], ['OTU', 'B:3', 'I:2']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'power_cycle': True},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True}]],
   [['B:2'], ['B:2'], ['B:2'], ['B:2'], ['B:2']]],
  ['regression: scenario 3',
   [[['OTU', 'B:0', 'I:0'], ['OTL', 'B:0', 'I:0'], ['OTE', 'B:3', 'I:0']],
    [{'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True}]],
   [[], [], [], [], ['B:0', 'B:3'], ['B:0']]]],
 [['regression: scenario 1',
   [[['OTL', 'B:3', 'I:1'],
     ['OTL', 'B:1', 'S:FS'],
     ['OTU', 'B:1', 'S:FS'],
     ['OTL', 'B:0', 'S:FS'],
     ['OTE', 'B:2', 'I:0']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'power_cycle': True}]],
   [['B:0', 'B:2'], ['B:0', 'B:3'], ['B:0', 'B:2', 'B:3'], ['B:0', 'B:3'], ['B:0', 'B:3']]],
  ['regression: scenario 17',
   [[['OTU', 'B:2', 'I:2'],
     ['OTL', 'B:2', 'I:1'],
     ['OTU', 'B:1', 'I:0'],
     ['OTU', 'B:2', 'I:2'],
     ['OTL', 'B:1', 'I:2']],
    [{'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True}]],
   [['B:2'], ['B:2'], ['B:2'], ['B:2'], ['B:2'], ['B:1'], ['B:2'], ['B:1']]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['control: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['control: scenario 2',
   [[['OTE', 'B:1', 'I:1'],
     ['OTU', 'B:3', 'I:2'],
     ['OTL', 'B:1', 'I:0'],
     ['OTL', 'B:1', 'I:0'],
     ['OTL', 'B:3', 'I:2'],
     ['OTL', 'B:3', 'I:1']],
    [{'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': False}]],
   [['B:1', 'B:3'], ['B:3'], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:1', 'B:3']]],
  ['regression: scenario 3',
   [[['OTU', 'B:3', 'I:0'],
     ['OTL', 'B:1', 'I:0'],
     ['OTE', 'B:1', 'S:FS'],
     ['OTU', 'B:2', 'S:FS'],
     ['OTL', 'B:2', 'I:1'],
     ['OTU', 'B:1', 'S:FS']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [[], [], ['B:2'], ['B:2'], ['B:2'], ['B:2'], [], []]]],
 [['regression: scenario 3',
   [[['OTU', 'B:0', 'S:FS'],
     ['OTU', 'B:1', 'S:FS'],
     ['OTU', 'B:3', 'I:0'],
     ['OTL', 'B:2', 'I:1'],
     ['OTL', 'B:1', 'I:2'],
     ['OTU', 'B:0', 'S:FS']],
    [{'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True}]],
   [[],
    ['B:2'],
    ['B:2'],
    ['B:2'],
    ['B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2']]],
  ['regression: scenario 25',
   [[['OTE', 'B:0', 'S:FS'],
     ['OTL', 'B:3', 'I:2'],
     ['OTU', 'B:1', 'I:0'],
     ['OTU', 'B:3', 'S:FS'],
     ['OTL', 'B:0', 'S:FS']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True}]],
   [[], ['B:0'], ['B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:3']]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['control: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['control: scenario 1',
   [[['OTL', 'B:3', 'S:FS'],
     ['OTL', 'B:1', 'I:1'],
     ['OTL', 'B:2', 'S:FS'],
     ['OTL', 'B:1', 'I:0'],
     ['OTL', 'B:1', 'I:1']],
    [{'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [[],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3']]],
  ['regression: scenario 2',
   [[['OTU', 'B:0', 'I:2'], ['OTE', 'B:2', 'I:0'], ['OTL', 'B:1', 'I:2']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': False}]],
   [[], [], ['B:2'], ['B:2'], ['B:2'], ['B:1', 'B:2'], ['B:1', 'B:2'], ['B:1'], ['B:1']]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A latched mode or fault memory is lost after a controller power cycle.

Latch (OTL), unlatch (OTU) and non-retentive output (OTE) rungs executed in program order each scan. rungs is a list of [instr, bit, condition_tag]; the rung is true when the condition input is true, or, for condition S:FS, on the first scan after power-up. A scan item {"power_cycle": true} models a power cycle: prescan clears only OTE destination bits, OTL/OTU bits are retentive, and the next scan is a first scan; it also reports the post-prescan state. OTL sets and OTU clears its bit only when its rung is true; the later rung wins. Return the sorted true bits after each item.

split: open-access