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
        if s.get('reset', False):
            tripped = False
        run_cmd = (start and not need_release) or motor
        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: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['regression: scenario 3',
   [[{'start': True, 'ol_nc': False},
     {'stop_nc': False, 'ol_nc': True},
     {},
     {'stop_nc': True},
     {'start': True, 'stop_nc': True},
     {'stop_nc': False},
     {'start': True, 'reset': True}]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [False, True], [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]]],
  ['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: 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: scenario 4',
   [[{'start': False, 'stop_nc': False},
     {'stop_nc': True},
     {'ol_nc': False},
     {'stop_nc': True},
     {'stop_nc': False, 'ol_nc': False, 'reset': True},
     {'start': False, 'stop_nc': False, 'ol_nc': False},
     {'start': False, 'reset': True},
     {'start': True},
     {},
     {'ol_nc': False, 'reset': True},
     {'start': True},
     {'ol_nc': True}]],
   [[False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, False],
    [True, False],
    [True, False],
    [False, True],
    [False, True],
    [False, True]]],
  ['regression: scenario 6',
   [[{'start': True, 'stop_nc': False},
     {'start': True, 'reset': True},
     {'start': True, 'stop_nc': True},
     {'start': True},
     {'ol_nc': True, 'reset': True},
     {'stop_nc': True, 'ol_nc': False},
     {'start': False, 'stop_nc': False, 'ol_nc': False, 'reset': True},
     {},
     {'start': True, 'stop_nc': False, 'ol_nc': True},
     {'start': True},
     {'start': True},
     {'stop_nc': True},
     {}]],
   [[False, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [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]]],
  ['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]]],
  ['regression: 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 11',
   [[{'stop_nc': True},
     {'stop_nc': False},
     {'stop_nc': False},
     {'stop_nc': False},
     {'stop_nc': True, 'reset': True},
     {'stop_nc': True},
     {'start': True},
     {'start': False},
     {},
     {'stop_nc': False},
     {'stop_nc': False, 'power': False},
     {},
     {'stop_nc': True, 'ol_nc': False, 'reset': True}]],
   [[False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [True, False],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [False, True]]],
  ['regression: scenario 14',
   [[{'stop_nc': True, 'ol_nc': False, 'reset': True},
     {'start': True, 'stop_nc': True, 'ol_nc': True, 'reset': True},
     {'start': False, 'stop_nc': True},
     {},
     {'stop_nc': True},
     {'start': True, 'stop_nc': True, 'ol_nc': True, 'reset': True, 'power': False},
     {}]],
   [[False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, 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]]],
  ['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]]],
  ['regression: 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 15',
   [[{},
     {},
     {'ol_nc': False},
     {'start': True},
     {'reset': True},
     {'stop_nc': True},
     {'stop_nc': False, 'reset': True},
     {'start': True, 'ol_nc': False, 'reset': True},
     {'ol_nc': False},
     {},
     {'start': False, 'power': False},
     {},
     {'start': True, 'stop_nc': False},
     {'start': True}]],
   [[False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, False],
    [False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True]]],
  ['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]]],
  ['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]]],
  ['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]]],
  ['regression: 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 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: scenario 16',
   [[{'start': True},
     {'start': True, 'reset': True},
     {'start': True},
     {'start': True},
     {'start': True},
     {'start': True, 'ol_nc': False},
     {'start': True, 'stop_nc': True, 'reset': True},
     {'start': False},
     {'stop_nc': False, 'ol_nc': False},
     {'start': True, 'stop_nc': True, 'power': False}]],
   [[True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [False, True],
    [True, False],
    [True, 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]]],
  ['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]]],
  ['regression: 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
        if s.get('reset', False) and not start:
            tripped = False
        run_cmd = (start and not need_release) or motor
        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: reset while overload open',
   [[{'start': True}, {'ol_nc': False, 'reset': True}, {'start': True}]],
   [[True, False], [False, True], [False, True]]],
  ['regression: scenario 3',
   [[{'start': True, 'ol_nc': False},
     {'stop_nc': False, 'ol_nc': True},
     {},
     {'stop_nc': True},
     {'start': True, 'stop_nc': True},
     {'stop_nc': False},
     {'start': True, 'reset': True}]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [False, True], [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]]],
  ['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: 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: scenario 4',
   [[{'start': False, 'stop_nc': False},
     {'stop_nc': True},
     {'ol_nc': False},
     {'stop_nc': True},
     {'stop_nc': False, 'ol_nc': False, 'reset': True},
     {'start': False, 'stop_nc': False, 'ol_nc': False},
     {'start': False, 'reset': True},
     {'start': True},
     {},
     {'ol_nc': False, 'reset': True},
     {'start': True},
     {'ol_nc': True}]],
   [[False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, False],
    [True, False],
    [True, False],
    [False, True],
    [False, True],
    [False, True]]],
  ['regression: scenario 6',
   [[{'start': True, 'stop_nc': False},
     {'start': True, 'reset': True},
     {'start': True, 'stop_nc': True},
     {'start': True},
     {'ol_nc': True, 'reset': True},
     {'stop_nc': True, 'ol_nc': False},
     {'start': False, 'stop_nc': False, 'ol_nc': False, 'reset': True},
     {},
     {'start': True, 'stop_nc': False, 'ol_nc': True},
     {'start': True},
     {'start': True},
     {'stop_nc': True},
     {}]],
   [[False, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [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]]],
  ['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]]],
  ['regression: 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 11',
   [[{'stop_nc': True},
     {'stop_nc': False},
     {'stop_nc': False},
     {'stop_nc': False},
     {'stop_nc': True, 'reset': True},
     {'stop_nc': True},
     {'start': True},
     {'start': False},
     {},
     {'stop_nc': False},
     {'stop_nc': False, 'power': False},
     {},
     {'stop_nc': True, 'ol_nc': False, 'reset': True}]],
   [[False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [True, False],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [False, True]]],
  ['regression: scenario 14',
   [[{'stop_nc': True, 'ol_nc': False, 'reset': True},
     {'start': True, 'stop_nc': True, 'ol_nc': True, 'reset': True},
     {'start': False, 'stop_nc': True},
     {},
     {'stop_nc': True},
     {'start': True, 'stop_nc': True, 'ol_nc': True, 'reset': True, 'power': False},
     {}]],
   [[False, True],
    [True, False],
    [True, False],
    [True, False],
    [True, 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]]],
  ['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]]],
  ['regression: 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 15',
   [[{},
     {},
     {'ol_nc': False},
     {'start': True},
     {'reset': True},
     {'stop_nc': True},
     {'stop_nc': False, 'reset': True},
     {'start': True, 'ol_nc': False, 'reset': True},
     {'ol_nc': False},
     {},
     {'start': False, 'power': False},
     {},
     {'start': True, 'stop_nc': False},
     {'start': True}]],
   [[False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, False],
    [False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True]]],
  ['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]]],
  ['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]]],
  ['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]]],
  ['regression: 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 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: scenario 16',
   [[{'start': True},
     {'start': True, 'reset': True},
     {'start': True},
     {'start': True},
     {'start': True},
     {'start': True, 'ol_nc': False},
     {'start': True, 'stop_nc': True, 'reset': True},
     {'start': False},
     {'stop_nc': False, 'ol_nc': False},
     {'start': True, 'stop_nc': True, 'power': False}]],
   [[True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [False, True],
    [True, False],
    [True, 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]]],
  ['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]]],
  ['regression: 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:
Pressing reset with the heater element still tripped lets the motor restart on a live overload.

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
        tripped = not s.get('ol_nc', True)
        run_cmd = (start and not need_release) or motor
        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: 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]]],
  ['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]]],
  ['control: 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]]],
  ['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: 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 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]]],
  ['control: 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]]],
  ['control: reset while running',
   [[{'start': True}, {}, {'reset': True}, {}]],
   [[True, False], [True, False], [True, False], [True, 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]]],
  ['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]]],
  ['control: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['control: reset while running',
   [[{'start': True}, {}, {'reset': True}, {}]],
   [[True, False], [True, False], [True, False], [True, False]]]],
 [['regression: start after overload recovers',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]],
  ['regression: scenario 2',
   [[{'reset': True},
     {'start': False, 'stop_nc': True, 'reset': True},
     {'start': False, 'reset': True},
     {'ol_nc': False},
     {'reset': True},
     {},
     {'start': False, 'stop_nc': True, 'ol_nc': False, 'reset': True},
     {'start': True, 'ol_nc': True},
     {'stop_nc': True},
     {'reset': True}]],
   [[False, False],
    [False, False],
    [False, False],
    [False, True],
    [False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [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]]],
  ['control: 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: scenario 1',
   [[{'start': False, 'stop_nc': False, 'ol_nc': True},
     {'start': True},
     {'stop_nc': True, 'ol_nc': True},
     {'stop_nc': True},
     {'start': False},
     {},
     {},
     {},
     {'stop_nc': False, 'ol_nc': False},
     {'start': False, 'stop_nc': False},
     {'start': False}]],
   [[False, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [False, True],
    [False, True],
    [False, True]]],
  ['regression: scenario 7',
   [[{'start': True, 'ol_nc': False},
     {'stop_nc': False},
     {'start': True, 'stop_nc': True},
     {'start': False, 'stop_nc': True},
     {'ol_nc': False},
     {'start': True, 'stop_nc': True, 'reset': True},
     {'stop_nc': True}]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [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]]],
  ['control: 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
        tripped = not s.get('ol_nc', True) or (tripped and not s.get('reset', False) and not start)
        run_cmd = (start and not need_release) or motor
        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: 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]]],
  ['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]]],
  ['control: 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]]],
  ['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: 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 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]]],
  ['control: 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]]],
  ['control: reset while running',
   [[{'start': True}, {}, {'reset': True}, {}]],
   [[True, False], [True, False], [True, False], [True, 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]]],
  ['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]]],
  ['control: stop and start together',
   [[{'start': True, 'stop_nc': False}, {'start': True}, {'start': True, 'stop_nc': False}]],
   [[False, False], [True, False], [False, False]]],
  ['control: reset while running',
   [[{'start': True}, {}, {'reset': True}, {}]],
   [[True, False], [True, False], [True, False], [True, False]]]],
 [['regression: start after overload recovers',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]],
  ['regression: scenario 2',
   [[{'reset': True},
     {'start': False, 'stop_nc': True, 'reset': True},
     {'start': False, 'reset': True},
     {'ol_nc': False},
     {'reset': True},
     {},
     {'start': False, 'stop_nc': True, 'ol_nc': False, 'reset': True},
     {'start': True, 'ol_nc': True},
     {'stop_nc': True},
     {'reset': True}]],
   [[False, False],
    [False, False],
    [False, False],
    [False, True],
    [False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [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]]],
  ['control: 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: scenario 1',
   [[{'start': False, 'stop_nc': False, 'ol_nc': True},
     {'start': True},
     {'stop_nc': True, 'ol_nc': True},
     {'stop_nc': True},
     {'start': False},
     {},
     {},
     {},
     {'stop_nc': False, 'ol_nc': False},
     {'start': False, 'stop_nc': False},
     {'start': False}]],
   [[False, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [True, False],
    [False, True],
    [False, True],
    [False, True]]],
  ['regression: scenario 7',
   [[{'start': True, 'ol_nc': False},
     {'stop_nc': False},
     {'start': True, 'stop_nc': True},
     {'start': False, 'stop_nc': True},
     {'ol_nc': False},
     {'start': True, 'stop_nc': True, 'reset': True},
     {'stop_nc': True}]],
   [[False, True], [False, True], [False, True], [False, True], [False, True], [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]]],
  ['control: 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:
The motor restarts on the next start press after the overload cools, without an operator reset.

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
            tripped = False
            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
        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: 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 26',
   [[{'ol_nc': True},
     {'reset': True},
     {'ol_nc': False},
     {'stop_nc': True, 'power': False},
     {'stop_nc': True},
     {'start': True, 'ol_nc': True},
     {'start': False, 'ol_nc': True},
     {'stop_nc': True},
     {'start': False, 'stop_nc': False},
     {'start': False, 'ol_nc': False},
     {'start': True, 'stop_nc': False, 'ol_nc': True, 'reset': True},
     {},
     {'start': False, 'ol_nc': False},
     {'ol_nc': False}]],
   [[False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [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]]],
  ['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: start after overload recovers',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]]],
 [['regression: scenario 2',
   [[{'stop_nc': True},
     {'start': True, 'stop_nc': True},
     {'stop_nc': True},
     {'start': False, 'stop_nc': False},
     {'ol_nc': True},
     {'start': True},
     {'start': False, 'ol_nc': False},
     {},
     {'start': False, 'ol_nc': False},
     {'stop_nc': False, 'ol_nc': True, 'power': False},
     {'stop_nc': False, 'reset': True},
     {'start': True, 'stop_nc': True},
     {'start': False}]],
   [[False, False],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [True, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, False],
    [True, False],
    [True, False]]],
  ['regression: scenario 8',
   [[{'ol_nc': False},
     {'start': True},
     {'start': True, 'ol_nc': True},
     {},
     {'start': False},
     {'start': True},
     {'power': False},
     {},
     {},
     {'start': True, 'ol_nc': True, 'reset': True, 'power': False}]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [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]]],
  ['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]]],
  ['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',
   [[{'reset': True},
     {'ol_nc': False},
     {'power': False},
     {'start': True, 'stop_nc': False},
     {},
     {},
     {'stop_nc': False},
     {'start': True}]],
   [[False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True]]],
  ['regression: scenario 25',
   [[{'stop_nc': True, 'ol_nc': False},
     {'start': False, 'ol_nc': True},
     {'ol_nc': True},
     {},
     {'start': False, 'stop_nc': False},
     {},
     {'stop_nc': True, 'ol_nc': False, 'reset': True, 'power': False},
     {'stop_nc': True}]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [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]]],
  ['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]]],
  ['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 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: scenario 15',
   [[{},
     {},
     {'ol_nc': False},
     {'start': True},
     {'reset': True},
     {'stop_nc': True},
     {'stop_nc': False, 'reset': True},
     {'start': True, 'ol_nc': False, 'reset': True},
     {'ol_nc': False},
     {},
     {'start': False, 'power': False},
     {},
     {'start': True, 'stop_nc': False},
     {'start': True}]],
   [[False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, False],
    [False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [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]]],
  ['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]]],
  ['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 19',
   [[{'stop_nc': True, 'reset': True},
     {'start': True, 'stop_nc': False},
     {'ol_nc': True},
     {'start': True, 'ol_nc': False},
     {'stop_nc': True},
     {'start': True, 'stop_nc': False},
     {'start': False, 'stop_nc': True, 'reset': True, 'power': False},
     {'start': False},
     {'ol_nc': True},
     {'start': True, 'stop_nc': False},
     {'start': True, 'power': False}]],
   [[False, False],
    [False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True]]],
  ['regression: scenario 39',
   [[{'ol_nc': False},
     {'start': False, 'stop_nc': True},
     {'start': True},
     {'start': True},
     {'start': True, 'stop_nc': False, 'ol_nc': True},
     {'start': False, 'stop_nc': False},
     {'start': True, 'stop_nc': True, 'ol_nc': True, 'power': False},
     {'start': True, 'power': False},
     {},
     {'stop_nc': True, 'power': False},
     {'start': False, 'stop_nc': True, 'ol_nc': True},
     {'start': False, 'stop_nc': False},
     {'ol_nc': True}]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [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]]],
  ['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]]],
  ['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)

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)
        tripped = tripped and not need_release
        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
        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: 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 26',
   [[{'ol_nc': True},
     {'reset': True},
     {'ol_nc': False},
     {'stop_nc': True, 'power': False},
     {'stop_nc': True},
     {'start': True, 'ol_nc': True},
     {'start': False, 'ol_nc': True},
     {'stop_nc': True},
     {'start': False, 'stop_nc': False},
     {'start': False, 'ol_nc': False},
     {'start': True, 'stop_nc': False, 'ol_nc': True, 'reset': True},
     {},
     {'start': False, 'ol_nc': False},
     {'ol_nc': False}]],
   [[False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [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]]],
  ['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: start after overload recovers',
   [[{'start': True}, {'ol_nc': False}, {}, {'start': True}, {}]],
   [[True, False], [False, True], [False, True], [False, True], [False, True]]]],
 [['regression: scenario 2',
   [[{'stop_nc': True},
     {'start': True, 'stop_nc': True},
     {'stop_nc': True},
     {'start': False, 'stop_nc': False},
     {'ol_nc': True},
     {'start': True},
     {'start': False, 'ol_nc': False},
     {},
     {'start': False, 'ol_nc': False},
     {'stop_nc': False, 'ol_nc': True, 'power': False},
     {'stop_nc': False, 'reset': True},
     {'start': True, 'stop_nc': True},
     {'start': False}]],
   [[False, False],
    [True, False],
    [True, False],
    [False, False],
    [False, False],
    [True, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, False],
    [True, False],
    [True, False]]],
  ['regression: scenario 8',
   [[{'ol_nc': False},
     {'start': True},
     {'start': True, 'ol_nc': True},
     {},
     {'start': False},
     {'start': True},
     {'power': False},
     {},
     {},
     {'start': True, 'ol_nc': True, 'reset': True, 'power': False}]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [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]]],
  ['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]]],
  ['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',
   [[{'reset': True},
     {'ol_nc': False},
     {'power': False},
     {'start': True, 'stop_nc': False},
     {},
     {},
     {'stop_nc': False},
     {'start': True}]],
   [[False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True]]],
  ['regression: scenario 25',
   [[{'stop_nc': True, 'ol_nc': False},
     {'start': False, 'ol_nc': True},
     {'ol_nc': True},
     {},
     {'start': False, 'stop_nc': False},
     {},
     {'stop_nc': True, 'ol_nc': False, 'reset': True, 'power': False},
     {'stop_nc': True}]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [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]]],
  ['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]]],
  ['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 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: scenario 15',
   [[{},
     {},
     {'ol_nc': False},
     {'start': True},
     {'reset': True},
     {'stop_nc': True},
     {'stop_nc': False, 'reset': True},
     {'start': True, 'ol_nc': False, 'reset': True},
     {'ol_nc': False},
     {},
     {'start': False, 'power': False},
     {},
     {'start': True, 'stop_nc': False},
     {'start': True}]],
   [[False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, False],
    [False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [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]]],
  ['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]]],
  ['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 19',
   [[{'stop_nc': True, 'reset': True},
     {'start': True, 'stop_nc': False},
     {'ol_nc': True},
     {'start': True, 'ol_nc': False},
     {'stop_nc': True},
     {'start': True, 'stop_nc': False},
     {'start': False, 'stop_nc': True, 'reset': True, 'power': False},
     {'start': False},
     {'ol_nc': True},
     {'start': True, 'stop_nc': False},
     {'start': True, 'power': False}]],
   [[False, False],
    [False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True]]],
  ['regression: scenario 39',
   [[{'ol_nc': False},
     {'start': False, 'stop_nc': True},
     {'start': True},
     {'start': True},
     {'start': True, 'stop_nc': False, 'ol_nc': True},
     {'start': False, 'stop_nc': False},
     {'start': True, 'stop_nc': True, 'ol_nc': True, 'power': False},
     {'start': True, 'power': False},
     {},
     {'stop_nc': True, 'power': False},
     {'start': False, 'stop_nc': True, 'ol_nc': True},
     {'start': False, 'stop_nc': False},
     {'ol_nc': True}]],
   [[False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [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]]],
  ['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]]],
  ['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:
Cycling control power clears a latched overload trip so the motor can restart without reset.

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
            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
        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: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['regression: scenario 4',
   [[{'start': True, 'reset': True},
     {'stop_nc': True, 'power': False},
     {'stop_nc': True},
     {'stop_nc': False, 'ol_nc': False},
     {'start': True, 'stop_nc': True},
     {'ol_nc': False},
     {'reset': True, 'power': False},
     {'start': True, 'reset': True},
     {'stop_nc': True},
     {'stop_nc': False},
     {'start': True}]],
   [[True, False],
    [False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, False],
    [False, False],
    [False, 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: 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: scenario 23',
   [[{'power': False},
     {},
     {},
     {'start': True, 'reset': True, 'power': False},
     {'start': True, 'ol_nc': True},
     {'start': False},
     {'start': True, 'stop_nc': True},
     {'stop_nc': False},
     {'start': True, 'stop_nc': True, 'ol_nc': False},
     {},
     {'start': True, 'ol_nc': False},
     {'stop_nc': False},
     {'ol_nc': True}]],
   [[False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [True, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True]]],
  ['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]]],
  ['control: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['regression: 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 20',
   [[{'stop_nc': True},
     {'stop_nc': False, 'power': False},
     {'start': True},
     {},
     {'ol_nc': True},
     {'start': True, 'stop_nc': False},
     {'stop_nc': True, 'ol_nc': True, 'reset': True},
     {'reset': True},
     {'stop_nc': True, 'power': False}]],
   [[False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False]]],
  ['regression: scenario 33',
   [[{'start': True, 'reset': True},
     {'stop_nc': True, 'reset': True},
     {'power': False},
     {'start': True, 'stop_nc': True},
     {'stop_nc': True, 'power': False},
     {'start': False, 'stop_nc': False},
     {'start': False},
     {'start': False, 'stop_nc': True, 'ol_nc': True, 'power': False},
     {'stop_nc': True},
     {'stop_nc': False},
     {'start': True},
     {'start': True, 'stop_nc': True, 'reset': True}]],
   [[True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, 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]]],
  ['regression: 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: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['regression: scenario 48',
   [[{'stop_nc': True},
     {},
     {},
     {'stop_nc': True},
     {'start': True, 'stop_nc': False},
     {'stop_nc': False, 'power': False},
     {'start': True, 'stop_nc': True},
     {},
     {}]],
   [[False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, 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: 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: scenario 60',
   [[{'start': False, 'stop_nc': False, 'reset': True},
     {'start': True, 'stop_nc': True, 'reset': True},
     {'power': False},
     {'start': True},
     {'stop_nc': True, 'ol_nc': False},
     {},
     {'ol_nc': True},
     {'stop_nc': True, 'ol_nc': False, 'reset': True},
     {},
     {'stop_nc': True}]],
   [[False, False],
    [True, False],
    [False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True]]],
  ['regression: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, 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: 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]]]]]
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 or (motor 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: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['regression: scenario 4',
   [[{'start': True, 'reset': True},
     {'stop_nc': True, 'power': False},
     {'stop_nc': True},
     {'stop_nc': False, 'ol_nc': False},
     {'start': True, 'stop_nc': True},
     {'ol_nc': False},
     {'reset': True, 'power': False},
     {'start': True, 'reset': True},
     {'stop_nc': True},
     {'stop_nc': False},
     {'start': True}]],
   [[True, False],
    [False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, False],
    [False, False],
    [False, 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: 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: scenario 23',
   [[{'power': False},
     {},
     {},
     {'start': True, 'reset': True, 'power': False},
     {'start': True, 'ol_nc': True},
     {'start': False},
     {'start': True, 'stop_nc': True},
     {'stop_nc': False},
     {'start': True, 'stop_nc': True, 'ol_nc': False},
     {},
     {'start': True, 'ol_nc': False},
     {'stop_nc': False},
     {'ol_nc': True}]],
   [[False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [True, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True]]],
  ['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]]],
  ['control: start seal stop',
   [[{'start': True}, {}, {'stop_nc': False}, {}, {'start': True}]],
   [[True, False], [True, False], [False, False], [False, False], [True, False]]],
  ['regression: 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 20',
   [[{'stop_nc': True},
     {'stop_nc': False, 'power': False},
     {'start': True},
     {},
     {'ol_nc': True},
     {'start': True, 'stop_nc': False},
     {'stop_nc': True, 'ol_nc': True, 'reset': True},
     {'reset': True},
     {'stop_nc': True, 'power': False}]],
   [[False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False]]],
  ['regression: scenario 33',
   [[{'start': True, 'reset': True},
     {'stop_nc': True, 'reset': True},
     {'power': False},
     {'start': True, 'stop_nc': True},
     {'stop_nc': True, 'power': False},
     {'start': False, 'stop_nc': False},
     {'start': False},
     {'start': False, 'stop_nc': True, 'ol_nc': True, 'power': False},
     {'stop_nc': True},
     {'stop_nc': False},
     {'start': True},
     {'start': True, 'stop_nc': True, 'reset': True}]],
   [[True, False],
    [True, False],
    [False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, 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]]],
  ['regression: 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: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, False], [True, False]]],
  ['regression: scenario 48',
   [[{'stop_nc': True},
     {},
     {},
     {'stop_nc': True},
     {'start': True, 'stop_nc': False},
     {'stop_nc': False, 'power': False},
     {'start': True, 'stop_nc': True},
     {},
     {}]],
   [[False, False],
    [False, False],
    [False, False],
    [False, False],
    [False, 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: 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: scenario 60',
   [[{'start': False, 'stop_nc': False, 'reset': True},
     {'start': True, 'stop_nc': True, 'reset': True},
     {'power': False},
     {'start': True},
     {'stop_nc': True, 'ol_nc': False},
     {},
     {'ol_nc': True},
     {'stop_nc': True, 'ol_nc': False, 'reset': True},
     {},
     {'stop_nc': True}]],
   [[False, False],
    [True, False],
    [False, False],
    [False, False],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True],
    [False, True]]],
  ['regression: power loss with start held',
   [[{'start': True}, {'power': False}, {'start': True}, {}, {'start': True}]],
   [[True, False], [False, False], [False, False], [False, 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: 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]]]]]
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 jammed or held start button restarts the machine automatically when power is restored.

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