FA-92046 / PLC ladder logic scan cycles / Open access
Latch and unlatch rungs are evaluated bottom-up · case 01
When latch and unlatch conditions are true together the opposite rung wins from what the program order dictates.
ROOT CAUSE
The rung loop iterates the program in reverse order.
VERIFIED REPAIR
Execute rungs top to bottom so the later rung wins.
Unsuccessful approach: Always applying OTU rungs last makes unlatch win even when the latch rung is later in the program.
Case contract
Latch (OTL), unlatch (OTU) and non-retentive output (OTE) rungs executed in program order each scan. rungs is a list of [instr, bit, condition_tag]; the rung is true when the condition input is true, or, for condition S:FS, on the first scan after power-up. A scan item {"power_cycle": true} models a power cycle: prescan clears only OTE destination bits, OTL/OTU bits are retentive, and the next scan is a first scan; it also reports the post-prescan state. OTL sets and OTU clears its bit only when its rung is true; the later rung wins. Return the sorted true bits after each item.
Why this case matters
Ladder programs are executed as repeated scans; each defect here changes what a rung, timer, counter or data-table instruction reports on a particular scan, which is how commissioning and field faults are actually observed.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(rungs, scans):
bits = {}
first = True
out = []
for scan in scans:
if scan.get('power_cycle'):
for instr, bit, cond in rungs:
if instr == 'OTE':
bits[bit] = False
first = True
out.append(sorted(b for b, v in bits.items() if v))
continue
for instr, bit, cond in reversed(rungs):
rung = first if cond == 'S:FS' else bool(scan.get(cond, False))
if instr == 'OTE':
bits[bit] = rung
elif rung and instr == 'OTL':
bits[bit] = True
elif rung and instr == 'OTU':
bits[bit] = False
first = False
out.append(sorted(b for b, v in bits.items() if v))
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: unlatch listed before latch',
[[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
[['B:3'], ['B:3'], []]],
['regression: scenario 6',
[[['OTU', 'B:2', 'I:0'],
['OTU', 'B:0', 'I:1'],
['OTL', 'B:2', 'I:2'],
['OTL', 'B:0', 'I:0'],
['OTL', 'B:2', 'I:1'],
['OTL', 'B:2', 'I:2']],
[{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': True},
{'power_cycle': True},
{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False}]],
[[], ['B:2'], ['B:2'], ['B:2'], ['B:0', 'B:2'], ['B:0', 'B:2']]],
['control: latched through power cycle',
[[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
[{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
[['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
['control: first-scan output then power cycle',
[[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
[['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
['control: latch then idle',
[[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
[['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
['regression: scenario 1',
[[['OTL', 'B:3', 'I:2'],
['OTL', 'B:0', 'I:0'],
['OTE', 'B:0', 'S:FS'],
['OTL', 'B:1', 'S:FS'],
['OTU', 'B:1', 'S:FS'],
['OTE', 'B:2', 'I:1']],
[{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': True}]],
[['B:0'], [], ['B:2', 'B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:2', 'B:3'], ['B:2', 'B:3'], ['B:3']]],
['control: scenario 2',
[[['OTU', 'B:2', 'I:1'], ['OTL', 'B:1', 'I:1'], ['OTL', 'B:1', 'I:2'], ['OTL', 'B:0', 'I:0']],
[{'I:0': True, 'I:1': False, 'I:2': False},
{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': True},
{'power_cycle': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': True}]],
[['B:0'],
['B:0'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1']]],
['control: scenario 3',
[[['OTE', 'B:3', 'I:2'],
['OTE', 'B:1', 'I:1'],
['OTL', 'B:2', 'I:0'],
['OTL', 'B:2', 'I:2'],
['OTL', 'B:2', 'I:0']],
[{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'power_cycle': True}]],
[['B:1', 'B:2', 'B:3'], ['B:2', 'B:3'], ['B:1', 'B:2'], ['B:2'], ['B:2']]]],
[['regression: scenario 4',
[[['OTL', 'B:0', 'I:0'],
['OTE', 'B:3', 'I:2'],
['OTE', 'B:0', 'I:2'],
['OTL', 'B:1', 'I:0'],
['OTU', 'B:3', 'I:2']],
[{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'power_cycle': True},
{'power_cycle': True},
{'power_cycle': True}]],
[['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:1'],
['B:1'],
['B:1'],
['B:1']]],
['regression: scenario 5',
[[['OTE', 'B:2', 'I:2'],
['OTE', 'B:0', 'I:0'],
['OTE', 'B:2', 'I:2'],
['OTU', 'B:2', 'I:1'],
['OTL', 'B:2', 'I:0']],
[{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': True, 'I:1': False, 'I:2': True},
{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': True},
{'power_cycle': True},
{'power_cycle': True}]],
[['B:0', 'B:2'], ['B:0', 'B:2'], [], [], ['B:0', 'B:2'], [], []]],
['control: latched through power cycle',
[[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
[{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
[['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
['regression: unlatch listed before latch',
[[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
[['B:3'], ['B:3'], []]],
['control: first-scan output then power cycle',
[[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
[['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
['control: latch then idle',
[[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
[['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
['control: scenario 1',
[[['OTE', 'B:3', 'S:FS'], ['OTL', 'B:0', 'S:FS'], ['OTL', 'B:0', 'I:0'], ['OTE', 'B:0', 'S:FS']],
[{'I:0': True, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False}]],
[['B:0', 'B:3'], [], [], [], [], []]],
['control: scenario 2',
[[['OTL', 'B:2', 'I:1'], ['OTL', 'B:3', 'I:2'], ['OTU', 'B:0', 'I:0'], ['OTL', 'B:0', 'S:FS']],
[{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': True, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': False},
{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False}]],
[['B:0', 'B:3'],
['B:2', 'B:3'],
['B:2', 'B:3'],
['B:2', 'B:3'],
['B:2', 'B:3'],
['B:0', 'B:2', 'B:3'],
['B:0', 'B:2', 'B:3']]]],
[['regression: scenario 3',
[[['OTU', 'B:0', 'I:0'], ['OTL', 'B:0', 'I:0'], ['OTE', 'B:3', 'I:0']],
[{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': True},
{'power_cycle': True},
{'I:0': True, 'I:1': False, 'I:2': False},
{'power_cycle': True}]],
[[], [], [], [], ['B:0', 'B:3'], ['B:0']]],
['regression: scenario 7',
[[['OTU', 'B:3', 'I:2'],
['OTU', 'B:0', 'I:1'],
['OTL', 'B:0', 'I:2'],
['OTU', 'B:2', 'I:0'],
['OTL', 'B:0', 'S:FS'],
['OTL', 'B:1', 'S:FS']],
[{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'power_cycle': True}]],
[['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1']]],
['control: latched through power cycle',
[[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
[{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
[['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
['regression: unlatch listed before latch',
[[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
[['B:3'], ['B:3'], []]],
['control: first-scan output then power cycle',
[[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
[['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
['control: latch then idle',
[[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
[['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
['control: scenario 1',
[[['OTL', 'B:3', 'I:2'], ['OTE', 'B:1', 'I:0'], ['OTL', 'B:1', 'I:0']],
[{'power_cycle': True},
{'power_cycle': True},
{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': True, 'I:1': False, 'I:2': False},
{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': True}]],
[[], [], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:3'], ['B:3']]],
['regression: scenario 2',
[[['OTL', 'B:0', 'I:2'], ['OTL', 'B:2', 'S:FS'], ['OTU', 'B:0', 'I:2'], ['OTU', 'B:3', 'I:2']],
[{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': True},
{'power_cycle': True},
{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': True}]],
[['B:2'], ['B:2'], ['B:2'], ['B:2'], ['B:2']]]],
[['regression: scenario 3',
[[['OTU', 'B:3', 'I:0'],
['OTL', 'B:1', 'I:0'],
['OTE', 'B:1', 'S:FS'],
['OTU', 'B:2', 'S:FS'],
['OTL', 'B:2', 'I:1'],
['OTU', 'B:1', 'S:FS']],
[{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': True, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': False},
{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False}]],
[[], [], ['B:2'], ['B:2'], ['B:2'], ['B:2'], [], []]],
['regression: scenario 15',
[[['OTU', 'B:2', 'I:1'], ['OTU', 'B:3', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:3', 'I:1']],
[{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'power_cycle': True},
{'power_cycle': True}]],
[[], ['B:1'], [], ['B:3'], [], ['B:3'], [], []]],
['control: latched through power cycle',
[[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
[{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
[['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
['regression: unlatch listed before latch',
[[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
[['B:3'], ['B:3'], []]],
['control: first-scan output then power cycle',
[[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
[['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
['control: latch then idle',
[[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
[['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
['regression: scenario 1',
[[['OTL', 'B:3', 'I:1'],
['OTL', 'B:1', 'S:FS'],
['OTU', 'B:1', 'S:FS'],
['OTL', 'B:0', 'S:FS'],
['OTE', 'B:2', 'I:0']],
[{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': False},
{'power_cycle': True},
{'power_cycle': True}]],
[['B:0', 'B:2'], ['B:0', 'B:3'], ['B:0', 'B:2', 'B:3'], ['B:0', 'B:3'], ['B:0', 'B:3']]],
['regression: scenario 2',
[[['OTE', 'B:1', 'I:1'],
['OTU', 'B:3', 'I:2'],
['OTL', 'B:1', 'I:0'],
['OTL', 'B:1', 'I:0'],
['OTL', 'B:3', 'I:2'],
['OTL', 'B:3', 'I:1']],
[{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': True, 'I:1': False, 'I:2': False}]],
[['B:1', 'B:3'], ['B:3'], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:1', 'B:3']]]],
[['regression: scenario 9',
[[['OTU', 'B:0', 'I:1'],
['OTE', 'B:3', 'S:FS'],
['OTL', 'B:2', 'I:0'],
['OTL', 'B:0', 'S:FS'],
['OTL', 'B:3', 'S:FS'],
['OTL', 'B:3', 'I:1']],
[{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'power_cycle': True},
{'I:0': True, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': True}]],
[['B:0', 'B:3'], ['B:0'], ['B:0'], ['B:0', 'B:2', 'B:3'], ['B:0', 'B:2'], ['B:0', 'B:2']]],
['regression: scenario 36',
[[['OTL', 'B:1', 'S:FS'], ['OTU', 'B:2', 'I:1'], ['OTL', 'B:2', 'I:1']],
[{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': False},
{'power_cycle': True},
{'power_cycle': True},
{'I:0': True, 'I:1': False, 'I:2': True}]],
[['B:1', 'B:2'],
['B:1', 'B:2'],
['B:1', 'B:2'],
['B:1', 'B:2'],
['B:1', 'B:2'],
['B:1', 'B:2'],
['B:1', 'B:2'],
['B:1', 'B:2']]],
['control: latched through power cycle',
[[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
[{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
[['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
['regression: unlatch listed before latch',
[[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
[['B:3'], ['B:3'], []]],
['control: first-scan output then power cycle',
[[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
[['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
['control: latch then idle',
[[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
[['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
['control: scenario 1',
[[['OTL', 'B:3', 'S:FS'],
['OTL', 'B:1', 'I:1'],
['OTL', 'B:2', 'S:FS'],
['OTL', 'B:1', 'I:0'],
['OTL', 'B:1', 'I:1']],
[{'power_cycle': True},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False}]],
[[],
['B:1', 'B:2', 'B:3'],
['B:1', 'B:2', 'B:3'],
['B:1', 'B:2', 'B:3'],
['B:1', 'B:2', 'B:3'],
['B:1', 'B:2', 'B:3'],
['B:1', 'B:2', 'B:3']]],
['control: scenario 2',
[[['OTU', 'B:0', 'I:2'], ['OTE', 'B:2', 'I:0'], ['OTL', 'B:1', 'I:2']],
[{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': True},
{'I:0': True, 'I:1': True, 'I:2': False},
{'power_cycle': True},
{'I:0': False, 'I:1': True, 'I:2': False}]],
[[], [], ['B:2'], ['B:2'], ['B:2'], ['B:1', 'B:2'], ['B:1', 'B:2'], ['B:1'], ['B:1']]]]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: unlatch listed before latch | [[], [], []] | [['B:3'], ['B:3'], []] | Failed |
| regression: scenario 6 | [[], ['B:2'], ['B:2'], ['B:2'], [], []] | [[], ['B:2'], ['B:2'], ['B:2'], ['B:0', 'B:2'], ['B:0', 'B:2']] | Failed |
| control: latched through power cycle | [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []] | [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []] | Passed |
| control: first-scan output then power cycle | [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']] | [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']] | Passed |
| control: latch then idle | [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']] | [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']] | Passed |
| regression: scenario 1 | [['B:0', 'B:1'], ['B:1'], ['B:1', 'B:2', 'B:3'], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:0', 'B:1', 'B:3'], ['B:1', 'B:2', 'B:3'], ['B:1', 'B:2', 'B:3'], ['B:0', 'B:1', 'B:3']] | [['B:0'], [], ['B:2', 'B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:2', 'B:3'], ['B:2', 'B:3'], ['B:3']] | Failed |
| control: scenario 2 | [['B:0'], ['B:0'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1']] | [['B:0'], ['B:0'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1']] | Passed |
| control: scenario 3 | [['B:1', 'B:2', 'B:3'], ['B:2', 'B:3'], ['B:1', 'B:2'], ['B:2'], ['B:2']] | [['B:1', 'B:2', 'B:3'], ['B:2', 'B:3'], ['B:1', 'B:2'], ['B:2'], ['B:2']] | Passed |
SHA-256 / 043ec93657f2097d873c633abf109b2416243b0656afe0c5112bb21b2e573eb4
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(rungs, scans):
bits = {}
first = True
out = []
for scan in scans:
if scan.get('power_cycle'):
for instr, bit, cond in rungs:
if instr == 'OTE':
bits[bit] = False
first = True
out.append(sorted(b for b, v in bits.items() if v))
continue
for instr, bit, cond in sorted(rungs, key=lambda r: r[0] == 'OTU'):
rung = first if cond == 'S:FS' else bool(scan.get(cond, False))
if instr == 'OTE':
bits[bit] = rung
elif rung and instr == 'OTL':
bits[bit] = True
elif rung and instr == 'OTU':
bits[bit] = False
first = False
out.append(sorted(b for b, v in bits.items() if v))
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: unlatch listed before latch',
[[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
[['B:3'], ['B:3'], []]],
['regression: scenario 6',
[[['OTU', 'B:2', 'I:0'],
['OTU', 'B:0', 'I:1'],
['OTL', 'B:2', 'I:2'],
['OTL', 'B:0', 'I:0'],
['OTL', 'B:2', 'I:1'],
['OTL', 'B:2', 'I:2']],
[{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': True},
{'power_cycle': True},
{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False}]],
[[], ['B:2'], ['B:2'], ['B:2'], ['B:0', 'B:2'], ['B:0', 'B:2']]],
['control: latched through power cycle',
[[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
[{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
[['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
['control: first-scan output then power cycle',
[[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
[['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
['control: latch then idle',
[[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
[['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
['regression: scenario 1',
[[['OTL', 'B:3', 'I:2'],
['OTL', 'B:0', 'I:0'],
['OTE', 'B:0', 'S:FS'],
['OTL', 'B:1', 'S:FS'],
['OTU', 'B:1', 'S:FS'],
['OTE', 'B:2', 'I:1']],
[{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': True}]],
[['B:0'], [], ['B:2', 'B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:2', 'B:3'], ['B:2', 'B:3'], ['B:3']]],
['control: scenario 2',
[[['OTU', 'B:2', 'I:1'], ['OTL', 'B:1', 'I:1'], ['OTL', 'B:1', 'I:2'], ['OTL', 'B:0', 'I:0']],
[{'I:0': True, 'I:1': False, 'I:2': False},
{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': True},
{'power_cycle': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': True}]],
[['B:0'],
['B:0'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1']]],
['control: scenario 3',
[[['OTE', 'B:3', 'I:2'],
['OTE', 'B:1', 'I:1'],
['OTL', 'B:2', 'I:0'],
['OTL', 'B:2', 'I:2'],
['OTL', 'B:2', 'I:0']],
[{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'power_cycle': True}]],
[['B:1', 'B:2', 'B:3'], ['B:2', 'B:3'], ['B:1', 'B:2'], ['B:2'], ['B:2']]]],
[['regression: scenario 4',
[[['OTL', 'B:0', 'I:0'],
['OTE', 'B:3', 'I:2'],
['OTE', 'B:0', 'I:2'],
['OTL', 'B:1', 'I:0'],
['OTU', 'B:3', 'I:2']],
[{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'power_cycle': True},
{'power_cycle': True},
{'power_cycle': True}]],
[['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:1'],
['B:1'],
['B:1'],
['B:1']]],
['regression: scenario 5',
[[['OTE', 'B:2', 'I:2'],
['OTE', 'B:0', 'I:0'],
['OTE', 'B:2', 'I:2'],
['OTU', 'B:2', 'I:1'],
['OTL', 'B:2', 'I:0']],
[{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': True, 'I:1': False, 'I:2': True},
{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': True},
{'power_cycle': True},
{'power_cycle': True}]],
[['B:0', 'B:2'], ['B:0', 'B:2'], [], [], ['B:0', 'B:2'], [], []]],
['control: latched through power cycle',
[[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
[{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
[['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
['regression: unlatch listed before latch',
[[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
[['B:3'], ['B:3'], []]],
['control: first-scan output then power cycle',
[[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
[['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
['control: latch then idle',
[[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
[['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
['control: scenario 1',
[[['OTE', 'B:3', 'S:FS'], ['OTL', 'B:0', 'S:FS'], ['OTL', 'B:0', 'I:0'], ['OTE', 'B:0', 'S:FS']],
[{'I:0': True, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False}]],
[['B:0', 'B:3'], [], [], [], [], []]],
['control: scenario 2',
[[['OTL', 'B:2', 'I:1'], ['OTL', 'B:3', 'I:2'], ['OTU', 'B:0', 'I:0'], ['OTL', 'B:0', 'S:FS']],
[{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': True, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': False},
{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False}]],
[['B:0', 'B:3'],
['B:2', 'B:3'],
['B:2', 'B:3'],
['B:2', 'B:3'],
['B:2', 'B:3'],
['B:0', 'B:2', 'B:3'],
['B:0', 'B:2', 'B:3']]]],
[['regression: scenario 3',
[[['OTU', 'B:0', 'I:0'], ['OTL', 'B:0', 'I:0'], ['OTE', 'B:3', 'I:0']],
[{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': True},
{'power_cycle': True},
{'I:0': True, 'I:1': False, 'I:2': False},
{'power_cycle': True}]],
[[], [], [], [], ['B:0', 'B:3'], ['B:0']]],
['regression: scenario 7',
[[['OTU', 'B:3', 'I:2'],
['OTU', 'B:0', 'I:1'],
['OTL', 'B:0', 'I:2'],
['OTU', 'B:2', 'I:0'],
['OTL', 'B:0', 'S:FS'],
['OTL', 'B:1', 'S:FS']],
[{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'power_cycle': True}]],
[['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1']]],
['control: latched through power cycle',
[[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
[{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
[['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
['regression: unlatch listed before latch',
[[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
[['B:3'], ['B:3'], []]],
['control: first-scan output then power cycle',
[[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
[['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
['control: latch then idle',
[[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
[['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
['control: scenario 1',
[[['OTL', 'B:3', 'I:2'], ['OTE', 'B:1', 'I:0'], ['OTL', 'B:1', 'I:0']],
[{'power_cycle': True},
{'power_cycle': True},
{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': True, 'I:1': False, 'I:2': False},
{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': True}]],
[[], [], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:3'], ['B:3']]],
['regression: scenario 2',
[[['OTL', 'B:0', 'I:2'], ['OTL', 'B:2', 'S:FS'], ['OTU', 'B:0', 'I:2'], ['OTU', 'B:3', 'I:2']],
[{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': True},
{'power_cycle': True},
{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': True}]],
[['B:2'], ['B:2'], ['B:2'], ['B:2'], ['B:2']]]],
[['regression: scenario 3',
[[['OTU', 'B:3', 'I:0'],
['OTL', 'B:1', 'I:0'],
['OTE', 'B:1', 'S:FS'],
['OTU', 'B:2', 'S:FS'],
['OTL', 'B:2', 'I:1'],
['OTU', 'B:1', 'S:FS']],
[{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': True, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': False},
{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False}]],
[[], [], ['B:2'], ['B:2'], ['B:2'], ['B:2'], [], []]],
['regression: scenario 15',
[[['OTU', 'B:2', 'I:1'], ['OTU', 'B:3', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:3', 'I:1']],
[{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'power_cycle': True},
{'power_cycle': True}]],
[[], ['B:1'], [], ['B:3'], [], ['B:3'], [], []]],
['control: latched through power cycle',
[[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
[{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
[['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
['regression: unlatch listed before latch',
[[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
[['B:3'], ['B:3'], []]],
['control: first-scan output then power cycle',
[[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
[['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
['control: latch then idle',
[[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
[['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
['regression: scenario 1',
[[['OTL', 'B:3', 'I:1'],
['OTL', 'B:1', 'S:FS'],
['OTU', 'B:1', 'S:FS'],
['OTL', 'B:0', 'S:FS'],
['OTE', 'B:2', 'I:0']],
[{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': False},
{'power_cycle': True},
{'power_cycle': True}]],
[['B:0', 'B:2'], ['B:0', 'B:3'], ['B:0', 'B:2', 'B:3'], ['B:0', 'B:3'], ['B:0', 'B:3']]],
['regression: scenario 2',
[[['OTE', 'B:1', 'I:1'],
['OTU', 'B:3', 'I:2'],
['OTL', 'B:1', 'I:0'],
['OTL', 'B:1', 'I:0'],
['OTL', 'B:3', 'I:2'],
['OTL', 'B:3', 'I:1']],
[{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': True, 'I:1': False, 'I:2': False}]],
[['B:1', 'B:3'], ['B:3'], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:1', 'B:3']]]],
[['regression: scenario 9',
[[['OTU', 'B:0', 'I:1'],
['OTE', 'B:3', 'S:FS'],
['OTL', 'B:2', 'I:0'],
['OTL', 'B:0', 'S:FS'],
['OTL', 'B:3', 'S:FS'],
['OTL', 'B:3', 'I:1']],
[{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'power_cycle': True},
{'I:0': True, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': True}]],
[['B:0', 'B:3'], ['B:0'], ['B:0'], ['B:0', 'B:2', 'B:3'], ['B:0', 'B:2'], ['B:0', 'B:2']]],
['regression: scenario 36',
[[['OTL', 'B:1', 'S:FS'], ['OTU', 'B:2', 'I:1'], ['OTL', 'B:2', 'I:1']],
[{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': False},
{'power_cycle': True},
{'power_cycle': True},
{'I:0': True, 'I:1': False, 'I:2': True}]],
[['B:1', 'B:2'],
['B:1', 'B:2'],
['B:1', 'B:2'],
['B:1', 'B:2'],
['B:1', 'B:2'],
['B:1', 'B:2'],
['B:1', 'B:2'],
['B:1', 'B:2']]],
['control: latched through power cycle',
[[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
[{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
[['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
['regression: unlatch listed before latch',
[[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
[['B:3'], ['B:3'], []]],
['control: first-scan output then power cycle',
[[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
[['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
['control: latch then idle',
[[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
[['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
['control: scenario 1',
[[['OTL', 'B:3', 'S:FS'],
['OTL', 'B:1', 'I:1'],
['OTL', 'B:2', 'S:FS'],
['OTL', 'B:1', 'I:0'],
['OTL', 'B:1', 'I:1']],
[{'power_cycle': True},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False}]],
[[],
['B:1', 'B:2', 'B:3'],
['B:1', 'B:2', 'B:3'],
['B:1', 'B:2', 'B:3'],
['B:1', 'B:2', 'B:3'],
['B:1', 'B:2', 'B:3'],
['B:1', 'B:2', 'B:3']]],
['control: scenario 2',
[[['OTU', 'B:0', 'I:2'], ['OTE', 'B:2', 'I:0'], ['OTL', 'B:1', 'I:2']],
[{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': True},
{'I:0': True, 'I:1': True, 'I:2': False},
{'power_cycle': True},
{'I:0': False, 'I:1': True, 'I:2': False}]],
[[], [], ['B:2'], ['B:2'], ['B:2'], ['B:1', 'B:2'], ['B:1', 'B:2'], ['B:1'], ['B:1']]]]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: unlatch listed before latch | [[], [], []] | [['B:3'], ['B:3'], []] | Failed |
| regression: scenario 6 | [[], ['B:2'], ['B:2'], ['B:2'], [], []] | [[], ['B:2'], ['B:2'], ['B:2'], ['B:0', 'B:2'], ['B:0', 'B:2']] | Failed |
| control: latched through power cycle | [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []] | [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []] | Passed |
| control: first-scan output then power cycle | [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']] | [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']] | Passed |
| control: latch then idle | [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']] | [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']] | Passed |
| regression: scenario 1 | [['B:0'], [], ['B:2', 'B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:2', 'B:3'], ['B:2', 'B:3'], ['B:3']] | [['B:0'], [], ['B:2', 'B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:2', 'B:3'], ['B:2', 'B:3'], ['B:3']] | Passed |
| control: scenario 2 | [['B:0'], ['B:0'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1']] | [['B:0'], ['B:0'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1']] | Passed |
| control: scenario 3 | [['B:1', 'B:2', 'B:3'], ['B:2', 'B:3'], ['B:1', 'B:2'], ['B:2'], ['B:2']] | [['B:1', 'B:2', 'B:3'], ['B:2', 'B:3'], ['B:1', 'B:2'], ['B:2'], ['B:2']] | Passed |
SHA-256 / 7bdfa70ea9faad630f4d8dd82807284243f8f9b54efc31f95838c6573e93b182
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(rungs, scans):
bits = {}
first = True
out = []
for scan in scans:
if scan.get('power_cycle'):
for instr, bit, cond in rungs:
if instr == 'OTE':
bits[bit] = False
first = True
out.append(sorted(b for b, v in bits.items() if v))
continue
for instr, bit, cond in rungs:
rung = first if cond == 'S:FS' else bool(scan.get(cond, False))
if instr == 'OTE':
bits[bit] = rung
elif rung and instr == 'OTL':
bits[bit] = True
elif rung and instr == 'OTU':
bits[bit] = False
first = False
out.append(sorted(b for b, v in bits.items() if v))
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: unlatch listed before latch',
[[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
[['B:3'], ['B:3'], []]],
['regression: scenario 6',
[[['OTU', 'B:2', 'I:0'],
['OTU', 'B:0', 'I:1'],
['OTL', 'B:2', 'I:2'],
['OTL', 'B:0', 'I:0'],
['OTL', 'B:2', 'I:1'],
['OTL', 'B:2', 'I:2']],
[{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': True},
{'power_cycle': True},
{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False}]],
[[], ['B:2'], ['B:2'], ['B:2'], ['B:0', 'B:2'], ['B:0', 'B:2']]],
['control: latched through power cycle',
[[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
[{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
[['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
['control: first-scan output then power cycle',
[[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
[['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
['control: latch then idle',
[[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
[['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
['regression: scenario 1',
[[['OTL', 'B:3', 'I:2'],
['OTL', 'B:0', 'I:0'],
['OTE', 'B:0', 'S:FS'],
['OTL', 'B:1', 'S:FS'],
['OTU', 'B:1', 'S:FS'],
['OTE', 'B:2', 'I:1']],
[{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': True}]],
[['B:0'], [], ['B:2', 'B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:2', 'B:3'], ['B:2', 'B:3'], ['B:3']]],
['control: scenario 2',
[[['OTU', 'B:2', 'I:1'], ['OTL', 'B:1', 'I:1'], ['OTL', 'B:1', 'I:2'], ['OTL', 'B:0', 'I:0']],
[{'I:0': True, 'I:1': False, 'I:2': False},
{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': True},
{'power_cycle': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': True}]],
[['B:0'],
['B:0'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1']]],
['control: scenario 3',
[[['OTE', 'B:3', 'I:2'],
['OTE', 'B:1', 'I:1'],
['OTL', 'B:2', 'I:0'],
['OTL', 'B:2', 'I:2'],
['OTL', 'B:2', 'I:0']],
[{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'power_cycle': True}]],
[['B:1', 'B:2', 'B:3'], ['B:2', 'B:3'], ['B:1', 'B:2'], ['B:2'], ['B:2']]]],
[['regression: scenario 4',
[[['OTL', 'B:0', 'I:0'],
['OTE', 'B:3', 'I:2'],
['OTE', 'B:0', 'I:2'],
['OTL', 'B:1', 'I:0'],
['OTU', 'B:3', 'I:2']],
[{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'power_cycle': True},
{'power_cycle': True},
{'power_cycle': True}]],
[['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:1'],
['B:1'],
['B:1'],
['B:1']]],
['regression: scenario 5',
[[['OTE', 'B:2', 'I:2'],
['OTE', 'B:0', 'I:0'],
['OTE', 'B:2', 'I:2'],
['OTU', 'B:2', 'I:1'],
['OTL', 'B:2', 'I:0']],
[{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': True, 'I:1': False, 'I:2': True},
{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': True},
{'power_cycle': True},
{'power_cycle': True}]],
[['B:0', 'B:2'], ['B:0', 'B:2'], [], [], ['B:0', 'B:2'], [], []]],
['control: latched through power cycle',
[[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
[{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
[['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
['regression: unlatch listed before latch',
[[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
[['B:3'], ['B:3'], []]],
['control: first-scan output then power cycle',
[[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
[['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
['control: latch then idle',
[[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
[['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
['control: scenario 1',
[[['OTE', 'B:3', 'S:FS'], ['OTL', 'B:0', 'S:FS'], ['OTL', 'B:0', 'I:0'], ['OTE', 'B:0', 'S:FS']],
[{'I:0': True, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False}]],
[['B:0', 'B:3'], [], [], [], [], []]],
['control: scenario 2',
[[['OTL', 'B:2', 'I:1'], ['OTL', 'B:3', 'I:2'], ['OTU', 'B:0', 'I:0'], ['OTL', 'B:0', 'S:FS']],
[{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': True, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': False},
{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False}]],
[['B:0', 'B:3'],
['B:2', 'B:3'],
['B:2', 'B:3'],
['B:2', 'B:3'],
['B:2', 'B:3'],
['B:0', 'B:2', 'B:3'],
['B:0', 'B:2', 'B:3']]]],
[['regression: scenario 3',
[[['OTU', 'B:0', 'I:0'], ['OTL', 'B:0', 'I:0'], ['OTE', 'B:3', 'I:0']],
[{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': True},
{'power_cycle': True},
{'I:0': True, 'I:1': False, 'I:2': False},
{'power_cycle': True}]],
[[], [], [], [], ['B:0', 'B:3'], ['B:0']]],
['regression: scenario 7',
[[['OTU', 'B:3', 'I:2'],
['OTU', 'B:0', 'I:1'],
['OTL', 'B:0', 'I:2'],
['OTU', 'B:2', 'I:0'],
['OTL', 'B:0', 'S:FS'],
['OTL', 'B:1', 'S:FS']],
[{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'power_cycle': True}]],
[['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1'],
['B:0', 'B:1']]],
['control: latched through power cycle',
[[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
[{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
[['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
['regression: unlatch listed before latch',
[[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
[['B:3'], ['B:3'], []]],
['control: first-scan output then power cycle',
[[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
[['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
['control: latch then idle',
[[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
[['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
['control: scenario 1',
[[['OTL', 'B:3', 'I:2'], ['OTE', 'B:1', 'I:0'], ['OTL', 'B:1', 'I:0']],
[{'power_cycle': True},
{'power_cycle': True},
{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': True, 'I:1': False, 'I:2': False},
{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': True}]],
[[], [], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:3'], ['B:3']]],
['regression: scenario 2',
[[['OTL', 'B:0', 'I:2'], ['OTL', 'B:2', 'S:FS'], ['OTU', 'B:0', 'I:2'], ['OTU', 'B:3', 'I:2']],
[{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': True},
{'power_cycle': True},
{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': True}]],
[['B:2'], ['B:2'], ['B:2'], ['B:2'], ['B:2']]]],
[['regression: scenario 3',
[[['OTU', 'B:3', 'I:0'],
['OTL', 'B:1', 'I:0'],
['OTE', 'B:1', 'S:FS'],
['OTU', 'B:2', 'S:FS'],
['OTL', 'B:2', 'I:1'],
['OTU', 'B:1', 'S:FS']],
[{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': True, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': False},
{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False}]],
[[], [], ['B:2'], ['B:2'], ['B:2'], ['B:2'], [], []]],
['regression: scenario 15',
[[['OTU', 'B:2', 'I:1'], ['OTU', 'B:3', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:3', 'I:1']],
[{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'power_cycle': True},
{'power_cycle': True}]],
[[], ['B:1'], [], ['B:3'], [], ['B:3'], [], []]],
['control: latched through power cycle',
[[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
[{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
[['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
['regression: unlatch listed before latch',
[[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
[['B:3'], ['B:3'], []]],
['control: first-scan output then power cycle',
[[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
[['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
['control: latch then idle',
[[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
[['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
['regression: scenario 1',
[[['OTL', 'B:3', 'I:1'],
['OTL', 'B:1', 'S:FS'],
['OTU', 'B:1', 'S:FS'],
['OTL', 'B:0', 'S:FS'],
['OTE', 'B:2', 'I:0']],
[{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': False},
{'power_cycle': True},
{'power_cycle': True}]],
[['B:0', 'B:2'], ['B:0', 'B:3'], ['B:0', 'B:2', 'B:3'], ['B:0', 'B:3'], ['B:0', 'B:3']]],
['regression: scenario 2',
[[['OTE', 'B:1', 'I:1'],
['OTU', 'B:3', 'I:2'],
['OTL', 'B:1', 'I:0'],
['OTL', 'B:1', 'I:0'],
['OTL', 'B:3', 'I:2'],
['OTL', 'B:3', 'I:1']],
[{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': True, 'I:1': False, 'I:2': False}]],
[['B:1', 'B:3'], ['B:3'], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:1', 'B:3']]]],
[['regression: scenario 9',
[[['OTU', 'B:0', 'I:1'],
['OTE', 'B:3', 'S:FS'],
['OTL', 'B:2', 'I:0'],
['OTL', 'B:0', 'S:FS'],
['OTL', 'B:3', 'S:FS'],
['OTL', 'B:3', 'I:1']],
[{'I:0': False, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': True},
{'power_cycle': True},
{'I:0': True, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': True}]],
[['B:0', 'B:3'], ['B:0'], ['B:0'], ['B:0', 'B:2', 'B:3'], ['B:0', 'B:2'], ['B:0', 'B:2']]],
['regression: scenario 36',
[[['OTL', 'B:1', 'S:FS'], ['OTU', 'B:2', 'I:1'], ['OTL', 'B:2', 'I:1']],
[{'I:0': True, 'I:1': True, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': False, 'I:1': True, 'I:2': False},
{'power_cycle': True},
{'power_cycle': True},
{'I:0': True, 'I:1': False, 'I:2': True}]],
[['B:1', 'B:2'],
['B:1', 'B:2'],
['B:1', 'B:2'],
['B:1', 'B:2'],
['B:1', 'B:2'],
['B:1', 'B:2'],
['B:1', 'B:2'],
['B:1', 'B:2']]],
['control: latched through power cycle',
[[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
[{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
[['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
['regression: unlatch listed before latch',
[[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
[['B:3'], ['B:3'], []]],
['control: first-scan output then power cycle',
[[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
[['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
['control: latch then idle',
[[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
[['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
['control: scenario 1',
[[['OTL', 'B:3', 'S:FS'],
['OTL', 'B:1', 'I:1'],
['OTL', 'B:2', 'S:FS'],
['OTL', 'B:1', 'I:0'],
['OTL', 'B:1', 'I:1']],
[{'power_cycle': True},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': False},
{'I:0': False, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': True},
{'I:0': False, 'I:1': False, 'I:2': False}]],
[[],
['B:1', 'B:2', 'B:3'],
['B:1', 'B:2', 'B:3'],
['B:1', 'B:2', 'B:3'],
['B:1', 'B:2', 'B:3'],
['B:1', 'B:2', 'B:3'],
['B:1', 'B:2', 'B:3']]],
['control: scenario 2',
[[['OTU', 'B:0', 'I:2'], ['OTE', 'B:2', 'I:0'], ['OTL', 'B:1', 'I:2']],
[{'power_cycle': True},
{'I:0': False, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': True, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': False},
{'I:0': True, 'I:1': False, 'I:2': True},
{'I:0': True, 'I:1': True, 'I:2': False},
{'power_cycle': True},
{'I:0': False, 'I:1': True, 'I:2': False}]],
[[], [], ['B:2'], ['B:2'], ['B:2'], ['B:1', 'B:2'], ['B:1', 'B:2'], ['B:1'], ['B:1']]]]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: unlatch listed before latch | [['B:3'], ['B:3'], []] | [['B:3'], ['B:3'], []] | Passed |
| regression: scenario 6 | [[], ['B:2'], ['B:2'], ['B:2'], ['B:0', 'B:2'], ['B:0', 'B:2']] | [[], ['B:2'], ['B:2'], ['B:2'], ['B:0', 'B:2'], ['B:0', 'B:2']] | Passed |
| control: latched through power cycle | [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []] | [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []] | Passed |
| control: first-scan output then power cycle | [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']] | [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']] | Passed |
| control: latch then idle | [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']] | [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']] | Passed |
| regression: scenario 1 | [['B:0'], [], ['B:2', 'B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:2', 'B:3'], ['B:2', 'B:3'], ['B:3']] | [['B:0'], [], ['B:2', 'B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:2', 'B:3'], ['B:2', 'B:3'], ['B:3']] | Passed |
| control: scenario 2 | [['B:0'], ['B:0'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1']] | [['B:0'], ['B:0'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1']] | Passed |
| control: scenario 3 | [['B:1', 'B:2', 'B:3'], ['B:2', 'B:3'], ['B:1', 'B:2'], ['B:2'], ['B:2']] | [['B:1', 'B:2', 'B:3'], ['B:2', 'B:3'], ['B:1', 'B:2'], ['B:2'], ['B:2']] | Passed |
SHA-256 / 7f0c340b9d580ab472d129944e260f968d5ee1ee44daee64751f50dc2ce13ee7
Verification & scope
A deterministic bounded teaching model of one PLC instruction or rung pattern evaluated scan by scan. The stated contract is a stipulated toy convention, not a claim of conformance to any vendor controller or IEC 61131-3 runtime. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:51:41.878915+00:00.
Case digest / fb687497295fb598324a077c5f8d080675993d31c9c1c3af9fc09e42c7db6d07