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

N = 1
observations = []
def solve(period, watchdog, exec_times):
    t_free = 0
    starts = []
    overlaps = 0
    fault = None
    for k, ex in enumerate(exec_times):
        trig = starts[-1] + period if starts else 0
        if trig < t_free:
            overlaps += 1
            continue
        starts.append(trig)
        if ex > watchdog:
            fault = trig + watchdog
            break
        t_free = trig + ex
    return [starts, overlaps, fault]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: mixed overlaps', [10, 50, [5, 15, 3, 10, 12, 4]], [[0, 10, 30, 40], 2, None]],
  ['regression: exact watchdog', [20, 30, [30, 5, 5, 5]], [[0, 40, 60], 1, None]],
  ['control: watchdog exceeded', [10, 12, [5, 13, 4]], [[0, 10], 0, 22]],
  ['control: first execution overruns', [10, 25, [30, 5]], [[0], 0, 25]],
  ['regression: skip then drift', [10, 100, [25, 1, 1, 1, 1, 1]], [[0, 30, 40, 50], 2, None]],
  ['regression: scenario 1', [50, 100, [100, 100, 100, 100, 50, 25]], [[0, 100, 200, 250], 2, None]],
  ['regression: scenario 2', [20, 100, [100, 100, 60, 39, 20, 40, 54, 40]], [[0, 100, 140], 5, None]],
  ['control: scenario 3', [50, 40, [50, 100, 50, 100, 100, 40]], [[0], 0, 40]]],
 [['regression: exact watchdog', [20, 30, [30, 5, 5, 5]], [[0, 40, 60], 1, None]],
  ['regression: skip then drift', [10, 100, [25, 1, 1, 1, 1, 1]], [[0, 30, 40, 50], 2, None]],
  ['regression: mixed overlaps', [10, 50, [5, 15, 3, 10, 12, 4]], [[0, 10, 30, 40], 2, None]],
  ['control: watchdog exceeded', [10, 12, [5, 13, 4]], [[0, 10], 0, 22]],
  ['control: first execution overruns', [10, 25, [30, 5]], [[0], 0, 25]],
  ['regression: scenario 1', [20, 60, [60, 20, 36, 40, 20]], [[0, 60], 3, None]],
  ['regression: scenario 2',
   [10, 100, [10, 10, 10, 10, 10, 20, 100, 3, 20, 10, 100]],
   [[0, 10, 20, 30, 40, 50, 70, 80, 100], 2, None]],
  ['regression: scenario 3', [20, 100, [40, 40, 51, 40, 100]], [[0, 40], 3, None]]],
 [['regression: skip then drift', [10, 100, [25, 1, 1, 1, 1, 1]], [[0, 30, 40, 50], 2, None]],
  ['regression: scenario 1', [20, 100, [100, 20, 60, 100, 40, 20, 30, 12]], [[0, 100, 120], 5, None]],
  ['regression: mixed overlaps', [10, 50, [5, 15, 3, 10, 12, 4]], [[0, 10, 30, 40], 2, None]],
  ['control: watchdog exceeded', [10, 12, [5, 13, 4]], [[0, 10], 0, 22]],
  ['regression: exact watchdog', [20, 30, [30, 5, 5, 5]], [[0, 40, 60], 1, None]],
  ['control: first execution overruns', [10, 25, [30, 5]], [[0], 0, 25]],
  ['control: scenario 2', [10, 40, [50, 40, 10, 40, 10, 61, 60, 40, 20, 20, 10, 10]], [[0], 0, 40]],
  ['regression: scenario 3',
   [20, 30, [20, 30, 6, 30, 40, 39, 61, 36, 40, 40, 30, 20]],
   [[0, 20, 60, 100], 2, 130]]],
 [['regression: scenario 1',
   [20, 30, [21, 20, 20, 20, 40, 30, 20, 30, 40, 30, 40]],
   [[0, 40, 60, 80], 1, 110]],
  ['regression: scenario 2',
   [50, 100, [100, 100, 100, 50, 100, 50, 100, 50, 100, 15, 100, 50]],
   [[0, 100, 200, 300, 400, 500], 6, None]],
  ['regression: mixed overlaps', [10, 50, [5, 15, 3, 10, 12, 4]], [[0, 10, 30, 40], 2, None]],
  ['control: watchdog exceeded', [10, 12, [5, 13, 4]], [[0, 10], 0, 22]],
  ['regression: exact watchdog', [20, 30, [30, 5, 5, 5]], [[0, 40, 60], 1, None]],
  ['control: first execution overruns', [10, 25, [30, 5]], [[0], 0, 25]],
  ['regression: skip then drift', [10, 100, [25, 1, 1, 1, 1, 1]], [[0, 30, 40, 50], 2, None]],
  ['regression: scenario 3',
   [10, 40, [20, 20, 20, 20, 10, 61, 55, 66, 20, 37, 40, 40]],
   [[0, 20, 40, 50], 2, 90]]],
 [['regression: scenario 5', [25, 40, [25, 40, 40, 40, 24, 25, 50, 40, 50]], [[0, 25, 75, 125, 150], 2, 190]],
  ['regression: scenario 6', [20, 30, [30, 20, 30, 24, 49, 59, 40, 49, 30, 50, 20]], [[0, 40, 80], 2, 110]],
  ['regression: mixed overlaps', [10, 50, [5, 15, 3, 10, 12, 4]], [[0, 10, 30, 40], 2, None]],
  ['control: watchdog exceeded', [10, 12, [5, 13, 4]], [[0, 10], 0, 22]],
  ['regression: exact watchdog', [20, 30, [30, 5, 5, 5]], [[0, 40, 60], 1, None]],
  ['control: first execution overruns', [10, 25, [30, 5]], [[0], 0, 25]],
  ['regression: skip then drift', [10, 100, [25, 1, 1, 1, 1, 1]], [[0, 30, 40, 50], 2, None]],
  ['control: scenario 1', [25, 60, [70, 25, 60, 35, 25, 15, 60, 60, 25, 50, 25, 4]], [[0], 0, 60]]]]
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(period, watchdog, exec_times):
    t_free = 0
    starts = []
    overlaps = 0
    fault = None
    for k, ex in enumerate(exec_times):
        trig = (starts[-1] + period * (k - len(starts) + 1)) if starts else 0
        if trig < t_free:
            overlaps += 1
            continue
        starts.append(trig)
        if ex > watchdog:
            fault = trig + watchdog
            break
        t_free = trig + ex
    return [starts, overlaps, fault]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: mixed overlaps', [10, 50, [5, 15, 3, 10, 12, 4]], [[0, 10, 30, 40], 2, None]],
  ['regression: exact watchdog', [20, 30, [30, 5, 5, 5]], [[0, 40, 60], 1, None]],
  ['control: watchdog exceeded', [10, 12, [5, 13, 4]], [[0, 10], 0, 22]],
  ['control: first execution overruns', [10, 25, [30, 5]], [[0], 0, 25]],
  ['regression: skip then drift', [10, 100, [25, 1, 1, 1, 1, 1]], [[0, 30, 40, 50], 2, None]],
  ['regression: scenario 1', [50, 100, [100, 100, 100, 100, 50, 25]], [[0, 100, 200, 250], 2, None]],
  ['regression: scenario 2', [20, 100, [100, 100, 60, 39, 20, 40, 54, 40]], [[0, 100, 140], 5, None]],
  ['control: scenario 3', [50, 40, [50, 100, 50, 100, 100, 40]], [[0], 0, 40]]],
 [['regression: exact watchdog', [20, 30, [30, 5, 5, 5]], [[0, 40, 60], 1, None]],
  ['regression: skip then drift', [10, 100, [25, 1, 1, 1, 1, 1]], [[0, 30, 40, 50], 2, None]],
  ['regression: mixed overlaps', [10, 50, [5, 15, 3, 10, 12, 4]], [[0, 10, 30, 40], 2, None]],
  ['control: watchdog exceeded', [10, 12, [5, 13, 4]], [[0, 10], 0, 22]],
  ['control: first execution overruns', [10, 25, [30, 5]], [[0], 0, 25]],
  ['regression: scenario 1', [20, 60, [60, 20, 36, 40, 20]], [[0, 60], 3, None]],
  ['regression: scenario 2',
   [10, 100, [10, 10, 10, 10, 10, 20, 100, 3, 20, 10, 100]],
   [[0, 10, 20, 30, 40, 50, 70, 80, 100], 2, None]],
  ['regression: scenario 3', [20, 100, [40, 40, 51, 40, 100]], [[0, 40], 3, None]]],
 [['regression: skip then drift', [10, 100, [25, 1, 1, 1, 1, 1]], [[0, 30, 40, 50], 2, None]],
  ['regression: scenario 1', [20, 100, [100, 20, 60, 100, 40, 20, 30, 12]], [[0, 100, 120], 5, None]],
  ['regression: mixed overlaps', [10, 50, [5, 15, 3, 10, 12, 4]], [[0, 10, 30, 40], 2, None]],
  ['control: watchdog exceeded', [10, 12, [5, 13, 4]], [[0, 10], 0, 22]],
  ['regression: exact watchdog', [20, 30, [30, 5, 5, 5]], [[0, 40, 60], 1, None]],
  ['control: first execution overruns', [10, 25, [30, 5]], [[0], 0, 25]],
  ['control: scenario 2', [10, 40, [50, 40, 10, 40, 10, 61, 60, 40, 20, 20, 10, 10]], [[0], 0, 40]],
  ['regression: scenario 3',
   [20, 30, [20, 30, 6, 30, 40, 39, 61, 36, 40, 40, 30, 20]],
   [[0, 20, 60, 100], 2, 130]]],
 [['regression: scenario 1',
   [20, 30, [21, 20, 20, 20, 40, 30, 20, 30, 40, 30, 40]],
   [[0, 40, 60, 80], 1, 110]],
  ['regression: scenario 2',
   [50, 100, [100, 100, 100, 50, 100, 50, 100, 50, 100, 15, 100, 50]],
   [[0, 100, 200, 300, 400, 500], 6, None]],
  ['regression: mixed overlaps', [10, 50, [5, 15, 3, 10, 12, 4]], [[0, 10, 30, 40], 2, None]],
  ['control: watchdog exceeded', [10, 12, [5, 13, 4]], [[0, 10], 0, 22]],
  ['regression: exact watchdog', [20, 30, [30, 5, 5, 5]], [[0, 40, 60], 1, None]],
  ['control: first execution overruns', [10, 25, [30, 5]], [[0], 0, 25]],
  ['regression: skip then drift', [10, 100, [25, 1, 1, 1, 1, 1]], [[0, 30, 40, 50], 2, None]],
  ['regression: scenario 3',
   [10, 40, [20, 20, 20, 20, 10, 61, 55, 66, 20, 37, 40, 40]],
   [[0, 20, 40, 50], 2, 90]]],
 [['regression: scenario 5', [25, 40, [25, 40, 40, 40, 24, 25, 50, 40, 50]], [[0, 25, 75, 125, 150], 2, 190]],
  ['regression: scenario 6', [20, 30, [30, 20, 30, 24, 49, 59, 40, 49, 30, 50, 20]], [[0, 40, 80], 2, 110]],
  ['regression: mixed overlaps', [10, 50, [5, 15, 3, 10, 12, 4]], [[0, 10, 30, 40], 2, None]],
  ['control: watchdog exceeded', [10, 12, [5, 13, 4]], [[0, 10], 0, 22]],
  ['regression: exact watchdog', [20, 30, [30, 5, 5, 5]], [[0, 40, 60], 1, None]],
  ['control: first execution overruns', [10, 25, [30, 5]], [[0], 0, 25]],
  ['regression: skip then drift', [10, 100, [25, 1, 1, 1, 1, 1]], [[0, 30, 40, 50], 2, None]],
  ['control: scenario 1', [25, 60, [70, 25, 60, 35, 25, 15, 60, 60, 25, 50, 25, 4]], [[0], 0, 60]]]]
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:
After a skipped trigger the task phase shifts permanently instead of returning to the fixed period grid.

Periodic task triggered every period ms from t=0; exec_times[k] is how long the k-th triggered execution would take. A trigger arriving while the previous execution is still running (trigger time < completion time) is an overlap: it is counted and skipped, not queued; a trigger exactly at completion starts normally. An execution longer than watchdog raises a major fault at start + watchdog and scheduling stops. Return [start_times, overlap_count, fault_time or None].

split: open-access


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

N = 1
observations = []
def solve(words, mask, start_dest, steps):
    pos = 0
    dest = start_dest
    prev = False
    length = len(words) - 1
    out = []
    for en, res in steps:
        en = bool(en)
        if res:
            pos = 0
        elif en and not prev:
            pos += 1
            if pos > length:
                pos = 0
            dest = (dest & ~mask & 0xFFFF) | (words[pos] & mask)
        prev = en
        out.append([pos, dest])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['regression: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['control: scenario 1',
   [[26918, 50611, 8879, 59828],
    65535,
    52597,
    [[False, False],
     [False, False],
     [False, False],
     [True, True],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False]]],
   [[0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [1, 50611],
    [1, 50611],
    [1, 50611]]],
  ['control: scenario 2',
   [[42968, 29173, 43546],
    255,
    5794,
    [[True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, True],
     [False, False]]],
   [[1, 5877],
    [1, 5877],
    [1, 5877],
    [1, 5877],
    [2, 5658],
    [2, 5658],
    [2, 5658],
    [2, 5658],
    [0, 5658],
    [0, 5658]]],
  ['control: scenario 3',
   [[16785, 47110, 21847, 45361],
    61440,
    41889,
    [[True, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False]]],
   [[1, 45985], [1, 45985], [1, 45985], [1, 45985], [1, 45985], [1, 45985], [1, 45985]]],
  ['control: scenario 4',
   [[26660, 61415, 54040],
    65535,
    45106,
    [[True, False], [True, False], [True, False], [False, False], [False, False], [True, False]]],
   [[1, 61415], [1, 61415], [1, 61415], [1, 61415], [1, 61415], [2, 54040]]]],
 [['regression: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['regression: scenario 7',
   [[52955, 10653],
    61440,
    49142,
    [[False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False]]],
   [[0, 49142],
    [0, 49142],
    [0, 49142],
    [1, 12278],
    [1, 12278],
    [1, 12278],
    [1, 12278],
    [1, 12278],
    [1, 12278],
    [1, 12278],
    [1, 12278],
    [1, 12278],
    [1, 12278],
    [1, 12278]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['regression: scenario 1',
   [[8488, 43469, 38296, 4034],
    255,
    44563,
    [[False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False]]],
   [[0, 44563],
    [1, 44749],
    [1, 44749],
    [1, 44749],
    [1, 44749],
    [2, 44696],
    [2, 44696],
    [3, 44738],
    [3, 44738],
    [1, 44749],
    [1, 44749],
    [2, 44696]]],
  ['control: scenario 2',
   [[43079, 20640, 23622, 26553],
    255,
    15109,
    [[False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [False, True]]],
   [[0, 15109],
    [0, 15109],
    [1, 15264],
    [1, 15264],
    [1, 15264],
    [1, 15264],
    [2, 15174],
    [2, 15174],
    [2, 15174],
    [2, 15174],
    [3, 15289],
    [0, 15289]]],
  ['control: scenario 3',
   [[16618, 36272, 41924, 55813],
    3855,
    48911,
    [[True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False]]],
   [[1, 48384], [1, 48384], [1, 48384], [1, 48384], [1, 48384], [2, 45828], [2, 45828]]]],
 [['regression: scenario 2',
   [[36741, 30504],
    65535,
    26589,
    [[True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, True],
     [True, False],
     [False, False]]],
   [[1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [0, 30504],
    [0, 30504],
    [0, 30504]]],
  ['regression: scenario 18',
   [[6005, 39810],
    255,
    1846,
    [[False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, True],
     [False, False]]],
   [[0, 1846],
    [1, 1922],
    [1, 1922],
    [1, 1922],
    [1, 1922],
    [1, 1922],
    [1, 1922],
    [1, 1922],
    [0, 1922],
    [0, 1922]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['regression: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['control: scenario 1',
   [[38610, 2229],
    65535,
    14704,
    [[False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, True],
     [False, False]]],
   [[0, 14704], [0, 14704], [0, 14704], [0, 14704], [0, 14704], [1, 2229], [1, 2229], [0, 2229], [0, 2229]]],
  ['control: scenario 3',
   [[45414, 65173, 31151, 4829],
    3855,
    46402,
    [[False, True],
     [False, False],
     [True, True],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False]]],
   [[0, 46402],
    [0, 46402],
    [0, 46402],
    [0, 46402],
    [0, 46402],
    [0, 46402],
    [1, 48709],
    [1, 48709],
    [1, 48709]]]],
 [['regression: scenario 2',
   [[57902, 51779],
    61440,
    26811,
    [[True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False]]],
   [[1, 51387], [1, 51387], [1, 51387], [1, 51387], [1, 51387], [1, 51387], [1, 51387], [1, 51387]]],
  ['regression: scenario 20',
   [[9876, 56752],
    255,
    50114,
    [[False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False]]],
   [[0, 50114],
    [0, 50114],
    [0, 50114],
    [0, 50114],
    [0, 50114],
    [0, 50114],
    [1, 50096],
    [1, 50096],
    [1, 50096],
    [1, 50096],
    [1, 50096],
    [1, 50096]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['regression: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['regression: scenario 1',
   [[61786, 58708],
    255,
    45362,
    [[False, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False]]],
   [[0, 45362], [0, 45362], [0, 45362], [1, 45396], [1, 45396], [1, 45396], [1, 45396]]],
  ['control: scenario 3',
   [[35305, 48952, 41314, 29239, 28773],
    65535,
    11028,
    [[False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, True]]],
   [[0, 11028],
    [0, 11028],
    [1, 48952],
    [1, 48952],
    [1, 48952],
    [1, 48952],
    [2, 41314],
    [2, 41314],
    [2, 41314],
    [2, 41314],
    [2, 41314],
    [0, 41314]]]],
 [['regression: scenario 15',
   [[10064, 26257],
    255,
    24919,
    [[True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, True],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False]]],
   [[1, 24977],
    [1, 24977],
    [1, 24977],
    [1, 24977],
    [1, 24977],
    [1, 24977],
    [1, 24977],
    [0, 24977],
    [1, 24977],
    [1, 24977],
    [1, 24977],
    [1, 24977],
    [1, 24977],
    [1, 24977]]],
  ['regression: scenario 21',
   [[12086, 47767],
    65535,
    46065,
    [[False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, True],
     [True, True],
     [True, False],
     [False, False],
     [False, False]]],
   [[0, 46065],
    [0, 46065],
    [1, 47767],
    [1, 47767],
    [1, 47767],
    [1, 47767],
    [1, 47767],
    [1, 47767],
    [1, 47767],
    [0, 47767],
    [0, 47767],
    [0, 47767],
    [0, 47767],
    [0, 47767]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['regression: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['regression: scenario 1',
   [[39974, 26951],
    3855,
    4546,
    [[False, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, True]]],
   [[0, 4546],
    [0, 4546],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [0, 6599]]],
  ['control: scenario 2',
   [[43067, 57880, 6921, 33106, 51712],
    255,
    13830,
    [[True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, True],
     [True, True],
     [False, False],
     [True, False],
     [False, False]]],
   [[1, 13848],
    [1, 13848],
    [1, 13848],
    [2, 13833],
    [2, 13833],
    [2, 13833],
    [3, 13906],
    [3, 13906],
    [0, 13906],
    [0, 13906],
    [0, 13906],
    [1, 13848],
    [1, 13848]]]]]
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(words, mask, start_dest, steps):
    pos = 0
    dest = start_dest
    prev = False
    length = len(words) - 1
    out = []
    for en, res in steps:
        en = bool(en)
        if res:
            pos = 0
        elif en and not prev:
            pos += 1
            if pos > length:
                pos = pos % length
            dest = (dest & ~mask & 0xFFFF) | (words[pos] & mask)
        prev = en
        out.append([pos, dest])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['regression: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['control: scenario 1',
   [[26918, 50611, 8879, 59828],
    65535,
    52597,
    [[False, False],
     [False, False],
     [False, False],
     [True, True],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False]]],
   [[0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [1, 50611],
    [1, 50611],
    [1, 50611]]],
  ['control: scenario 2',
   [[42968, 29173, 43546],
    255,
    5794,
    [[True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, True],
     [False, False]]],
   [[1, 5877],
    [1, 5877],
    [1, 5877],
    [1, 5877],
    [2, 5658],
    [2, 5658],
    [2, 5658],
    [2, 5658],
    [0, 5658],
    [0, 5658]]],
  ['control: scenario 3',
   [[16785, 47110, 21847, 45361],
    61440,
    41889,
    [[True, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False]]],
   [[1, 45985], [1, 45985], [1, 45985], [1, 45985], [1, 45985], [1, 45985], [1, 45985]]],
  ['control: scenario 4',
   [[26660, 61415, 54040],
    65535,
    45106,
    [[True, False], [True, False], [True, False], [False, False], [False, False], [True, False]]],
   [[1, 61415], [1, 61415], [1, 61415], [1, 61415], [1, 61415], [2, 54040]]]],
 [['regression: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['regression: scenario 7',
   [[52955, 10653],
    61440,
    49142,
    [[False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False]]],
   [[0, 49142],
    [0, 49142],
    [0, 49142],
    [1, 12278],
    [1, 12278],
    [1, 12278],
    [1, 12278],
    [1, 12278],
    [1, 12278],
    [1, 12278],
    [1, 12278],
    [1, 12278],
    [1, 12278],
    [1, 12278]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['regression: scenario 1',
   [[8488, 43469, 38296, 4034],
    255,
    44563,
    [[False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False]]],
   [[0, 44563],
    [1, 44749],
    [1, 44749],
    [1, 44749],
    [1, 44749],
    [2, 44696],
    [2, 44696],
    [3, 44738],
    [3, 44738],
    [1, 44749],
    [1, 44749],
    [2, 44696]]],
  ['control: scenario 2',
   [[43079, 20640, 23622, 26553],
    255,
    15109,
    [[False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [False, True]]],
   [[0, 15109],
    [0, 15109],
    [1, 15264],
    [1, 15264],
    [1, 15264],
    [1, 15264],
    [2, 15174],
    [2, 15174],
    [2, 15174],
    [2, 15174],
    [3, 15289],
    [0, 15289]]],
  ['control: scenario 3',
   [[16618, 36272, 41924, 55813],
    3855,
    48911,
    [[True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False]]],
   [[1, 48384], [1, 48384], [1, 48384], [1, 48384], [1, 48384], [2, 45828], [2, 45828]]]],
 [['regression: scenario 2',
   [[36741, 30504],
    65535,
    26589,
    [[True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, True],
     [True, False],
     [False, False]]],
   [[1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [0, 30504],
    [0, 30504],
    [0, 30504]]],
  ['regression: scenario 18',
   [[6005, 39810],
    255,
    1846,
    [[False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, True],
     [False, False]]],
   [[0, 1846],
    [1, 1922],
    [1, 1922],
    [1, 1922],
    [1, 1922],
    [1, 1922],
    [1, 1922],
    [1, 1922],
    [0, 1922],
    [0, 1922]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['regression: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['control: scenario 1',
   [[38610, 2229],
    65535,
    14704,
    [[False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, True],
     [False, False]]],
   [[0, 14704], [0, 14704], [0, 14704], [0, 14704], [0, 14704], [1, 2229], [1, 2229], [0, 2229], [0, 2229]]],
  ['control: scenario 3',
   [[45414, 65173, 31151, 4829],
    3855,
    46402,
    [[False, True],
     [False, False],
     [True, True],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False]]],
   [[0, 46402],
    [0, 46402],
    [0, 46402],
    [0, 46402],
    [0, 46402],
    [0, 46402],
    [1, 48709],
    [1, 48709],
    [1, 48709]]]],
 [['regression: scenario 2',
   [[57902, 51779],
    61440,
    26811,
    [[True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False]]],
   [[1, 51387], [1, 51387], [1, 51387], [1, 51387], [1, 51387], [1, 51387], [1, 51387], [1, 51387]]],
  ['regression: scenario 20',
   [[9876, 56752],
    255,
    50114,
    [[False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False]]],
   [[0, 50114],
    [0, 50114],
    [0, 50114],
    [0, 50114],
    [0, 50114],
    [0, 50114],
    [1, 50096],
    [1, 50096],
    [1, 50096],
    [1, 50096],
    [1, 50096],
    [1, 50096]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['regression: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['regression: scenario 1',
   [[61786, 58708],
    255,
    45362,
    [[False, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False]]],
   [[0, 45362], [0, 45362], [0, 45362], [1, 45396], [1, 45396], [1, 45396], [1, 45396]]],
  ['control: scenario 3',
   [[35305, 48952, 41314, 29239, 28773],
    65535,
    11028,
    [[False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, True]]],
   [[0, 11028],
    [0, 11028],
    [1, 48952],
    [1, 48952],
    [1, 48952],
    [1, 48952],
    [2, 41314],
    [2, 41314],
    [2, 41314],
    [2, 41314],
    [2, 41314],
    [0, 41314]]]],
 [['regression: scenario 15',
   [[10064, 26257],
    255,
    24919,
    [[True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, True],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False]]],
   [[1, 24977],
    [1, 24977],
    [1, 24977],
    [1, 24977],
    [1, 24977],
    [1, 24977],
    [1, 24977],
    [0, 24977],
    [1, 24977],
    [1, 24977],
    [1, 24977],
    [1, 24977],
    [1, 24977],
    [1, 24977]]],
  ['regression: scenario 21',
   [[12086, 47767],
    65535,
    46065,
    [[False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, True],
     [True, True],
     [True, False],
     [False, False],
     [False, False]]],
   [[0, 46065],
    [0, 46065],
    [1, 47767],
    [1, 47767],
    [1, 47767],
    [1, 47767],
    [1, 47767],
    [1, 47767],
    [1, 47767],
    [0, 47767],
    [0, 47767],
    [0, 47767],
    [0, 47767],
    [0, 47767]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['regression: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['regression: scenario 1',
   [[39974, 26951],
    3855,
    4546,
    [[False, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, True]]],
   [[0, 4546],
    [0, 4546],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [0, 6599]]],
  ['control: scenario 2',
   [[43067, 57880, 6921, 33106, 51712],
    255,
    13830,
    [[True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, True],
     [True, True],
     [False, False],
     [True, False],
     [False, False]]],
   [[1, 13848],
    [1, 13848],
    [1, 13848],
    [2, 13833],
    [2, 13833],
    [2, 13833],
    [3, 13906],
    [3, 13906],
    [0, 13906],
    [0, 13906],
    [0, 13906],
    [1, 13848],
    [1, 13848]]]]]
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:
After the last step the machine outputs the home pattern and needs an extra advance before step 1.

Sequencer output (SQO). words is the sequencer file whose element 0 is the home step; position starts at 0. On each rising edge of enable the position advances; past the last element it wraps to 1 (not 0). Each advance writes dest = (dest AND NOT mask) OR (word AND mask) in 16 bits. A reset input returns position to 0 without writing dest and has priority over a coincident advance; the enable edge memory is always updated. steps is a list of [enable, reset]; return [position, dest] per scan.

split: open-access


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

N = 1
observations = []
def solve(words, mask, start_dest, steps):
    pos = 0
    dest = start_dest
    prev = False
    length = len(words) - 1
    out = []
    for en, res in steps:
        en = bool(en)
        if res:
            pos = 0
        elif en and not prev:
            pos += 1
            if pos >= length:
                pos = 1
            dest = (dest & ~mask & 0xFFFF) | (words[pos] & mask)
        prev = en
        out.append([pos, dest])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['regression: scenario 2',
   [[42968, 29173, 43546],
    255,
    5794,
    [[True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, True],
     [False, False]]],
   [[1, 5877],
    [1, 5877],
    [1, 5877],
    [1, 5877],
    [2, 5658],
    [2, 5658],
    [2, 5658],
    [2, 5658],
    [0, 5658],
    [0, 5658]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['control: scenario 1',
   [[26918, 50611, 8879, 59828],
    65535,
    52597,
    [[False, False],
     [False, False],
     [False, False],
     [True, True],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False]]],
   [[0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [1, 50611],
    [1, 50611],
    [1, 50611]]],
  ['control: scenario 3',
   [[16785, 47110, 21847, 45361],
    61440,
    41889,
    [[True, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False]]],
   [[1, 45985], [1, 45985], [1, 45985], [1, 45985], [1, 45985], [1, 45985], [1, 45985]]],
  ['regression: scenario 4',
   [[26660, 61415, 54040],
    65535,
    45106,
    [[True, False], [True, False], [True, False], [False, False], [False, False], [True, False]]],
   [[1, 61415], [1, 61415], [1, 61415], [1, 61415], [1, 61415], [2, 54040]]],
  ['regression: scenario 5',
   [[31779, 18767, 26849],
    3855,
    17424,
    [[True, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False]]],
   [[1, 18719],
    [1, 18719],
    [1, 18719],
    [2, 18449],
    [2, 18449],
    [2, 18449],
    [2, 18449],
    [2, 18449],
    [2, 18449],
    [2, 18449],
    [1, 18719],
    [1, 18719]]]],
 [['regression: scenario 1',
   [[8488, 43469, 38296, 4034],
    255,
    44563,
    [[False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False]]],
   [[0, 44563],
    [1, 44749],
    [1, 44749],
    [1, 44749],
    [1, 44749],
    [2, 44696],
    [2, 44696],
    [3, 44738],
    [3, 44738],
    [1, 44749],
    [1, 44749],
    [2, 44696]]],
  ['regression: scenario 2',
   [[43079, 20640, 23622, 26553],
    255,
    15109,
    [[False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [False, True]]],
   [[0, 15109],
    [0, 15109],
    [1, 15264],
    [1, 15264],
    [1, 15264],
    [1, 15264],
    [2, 15174],
    [2, 15174],
    [2, 15174],
    [2, 15174],
    [3, 15289],
    [0, 15289]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['control: scenario 3',
   [[16618, 36272, 41924, 55813],
    3855,
    48911,
    [[True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False]]],
   [[1, 48384], [1, 48384], [1, 48384], [1, 48384], [1, 48384], [2, 45828], [2, 45828]]],
  ['control: scenario 5',
   [[2273, 56456, 65022, 11147, 34043],
    65535,
    43372,
    [[True, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False]]],
   [[1, 56456],
    [1, 56456],
    [1, 56456],
    [1, 56456],
    [1, 56456],
    [1, 56456],
    [1, 56456],
    [1, 56456],
    [1, 56456],
    [2, 65022]]],
  ['control: scenario 6',
   [[49034, 36252],
    255,
    16341,
    [[True, False],
     [True, False],
     [True, False],
     [True, True],
     [True, False],
     [True, False],
     [False, False],
     [False, True],
     [True, False]]],
   [[1, 16284],
    [1, 16284],
    [1, 16284],
    [0, 16284],
    [0, 16284],
    [0, 16284],
    [0, 16284],
    [0, 16284],
    [1, 16284]]]],
 [['regression: scenario 6',
   [[53426, 5627, 11199, 28564],
    3855,
    26531,
    [[True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False]]],
   [[1, 26027],
    [1, 26027],
    [1, 26027],
    [2, 27567],
    [2, 27567],
    [2, 27567],
    [2, 27567],
    [3, 28580],
    [3, 28580],
    [3, 28580],
    [1, 26027],
    [1, 26027],
    [1, 26027],
    [1, 26027]]],
  ['regression: scenario 10',
   [[49269, 29259, 58835, 30456],
    3855,
    32866,
    [[True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False]]],
   [[1, 33387],
    [1, 33387],
    [1, 33387],
    [2, 34147],
    [2, 34147],
    [2, 34147],
    [2, 34147],
    [2, 34147],
    [3, 34408]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['control: scenario 1',
   [[38610, 2229],
    65535,
    14704,
    [[False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, True],
     [False, False]]],
   [[0, 14704], [0, 14704], [0, 14704], [0, 14704], [0, 14704], [1, 2229], [1, 2229], [0, 2229], [0, 2229]]],
  ['control: scenario 3',
   [[45414, 65173, 31151, 4829],
    3855,
    46402,
    [[False, True],
     [False, False],
     [True, True],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False]]],
   [[0, 46402],
    [0, 46402],
    [0, 46402],
    [0, 46402],
    [0, 46402],
    [0, 46402],
    [1, 48709],
    [1, 48709],
    [1, 48709]]],
  ['control: scenario 4',
   [[29784, 63854],
    255,
    25258,
    [[False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, True],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, True],
     [False, False],
     [False, False],
     [True, False],
     [True, True]]],
   [[0, 25258],
    [1, 25198],
    [1, 25198],
    [1, 25198],
    [0, 25198],
    [0, 25198],
    [0, 25198],
    [1, 25198],
    [1, 25198],
    [0, 25198],
    [0, 25198],
    [0, 25198],
    [1, 25198],
    [0, 25198]]]],
 [['regression: scenario 12',
   [[10930, 58067, 34332, 5386],
    255,
    33885,
    [[False, False],
     [False, False],
     [False, True],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False]]],
   [[0, 33885],
    [0, 33885],
    [0, 33885],
    [1, 34003],
    [1, 34003],
    [1, 34003],
    [1, 34003],
    [1, 34003],
    [1, 34003],
    [2, 33820],
    [2, 33820],
    [3, 33802]]],
  ['regression: scenario 13',
   [[49950, 26245, 48254],
    61440,
    9574,
    [[False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False]]],
   [[0, 9574],
    [0, 9574],
    [1, 25958],
    [1, 25958],
    [1, 25958],
    [2, 46438],
    [2, 46438],
    [2, 46438],
    [1, 25958]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['control: scenario 3',
   [[35305, 48952, 41314, 29239, 28773],
    65535,
    11028,
    [[False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, True]]],
   [[0, 11028],
    [0, 11028],
    [1, 48952],
    [1, 48952],
    [1, 48952],
    [1, 48952],
    [2, 41314],
    [2, 41314],
    [2, 41314],
    [2, 41314],
    [2, 41314],
    [0, 41314]]],
  ['control: scenario 4',
   [[49309, 10384],
    61440,
    9568,
    [[True, False],
     [True, False],
     [True, False],
     [True, False],
     [True, True],
     [False, False],
     [False, False]]],
   [[1, 9568], [1, 9568], [1, 9568], [1, 9568], [0, 9568], [0, 9568], [0, 9568]]],
  ['regression: scenario 5',
   [[47154, 32327, 23912, 32399],
    3855,
    21368,
    [[False, True],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, True]]],
   [[0, 21368],
    [0, 21368],
    [0, 21368],
    [1, 24183],
    [1, 24183],
    [1, 24183],
    [2, 23928],
    [2, 23928],
    [2, 23928],
    [3, 24191],
    [0, 24191]]]],
 [['regression: scenario 19',
   [[7514, 21129, 31492],
    61440,
    5749,
    [[True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, True],
     [True, False],
     [False, False]]],
   [[1, 22133],
    [1, 22133],
    [1, 22133],
    [1, 22133],
    [2, 30325],
    [2, 30325],
    [2, 30325],
    [0, 30325],
    [1, 22133],
    [1, 22133]]],
  ['regression: scenario 33',
   [[32413, 34158, 29106],
    65535,
    55217,
    [[True, False],
     [False, False],
     [True, False],
     [True, True],
     [False, False],
     [True, False],
     [False, False],
     [False, False]]],
   [[1, 34158], [1, 34158], [2, 29106], [0, 29106], [0, 29106], [1, 34158], [1, 34158], [1, 34158]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['control: scenario 2',
   [[43067, 57880, 6921, 33106, 51712],
    255,
    13830,
    [[True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, True],
     [True, True],
     [False, False],
     [True, False],
     [False, False]]],
   [[1, 13848],
    [1, 13848],
    [1, 13848],
    [2, 13833],
    [2, 13833],
    [2, 13833],
    [3, 13906],
    [3, 13906],
    [0, 13906],
    [0, 13906],
    [0, 13906],
    [1, 13848],
    [1, 13848]]],
  ['regression: scenario 3',
   [[62662, 46394, 25376, 46313],
    3855,
    7057,
    [[False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False]]],
   [[0, 7057],
    [0, 7057],
    [0, 7057],
    [0, 7057],
    [0, 7057],
    [1, 5530],
    [1, 5530],
    [2, 5008],
    [2, 5008],
    [2, 5008],
    [2, 5008],
    [3, 5273],
    [3, 5273]]],
  ['regression: scenario 4',
   [[30732, 47166, 61273],
    3855,
    7380,
    [[False, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [False, True],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False]]],
   [[0, 7380],
    [1, 6366],
    [1, 6366],
    [2, 8153],
    [2, 8153],
    [0, 8153],
    [0, 8153],
    [1, 6366],
    [1, 6366],
    [1, 6366],
    [1, 6366],
    [1, 6366]]]]]
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(words, mask, start_dest, steps):
    pos = 0
    dest = start_dest
    prev = False
    length = len(words) - 1
    out = []
    for en, res in steps:
        en = bool(en)
        if res:
            pos = 0
        elif en and not prev:
            pos += 1
            if pos >= length and length > 1:
                pos = 1
            dest = (dest & ~mask & 0xFFFF) | (words[pos] & mask)
        prev = en
        out.append([pos, dest])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['regression: scenario 2',
   [[42968, 29173, 43546],
    255,
    5794,
    [[True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, True],
     [False, False]]],
   [[1, 5877],
    [1, 5877],
    [1, 5877],
    [1, 5877],
    [2, 5658],
    [2, 5658],
    [2, 5658],
    [2, 5658],
    [0, 5658],
    [0, 5658]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['control: scenario 1',
   [[26918, 50611, 8879, 59828],
    65535,
    52597,
    [[False, False],
     [False, False],
     [False, False],
     [True, True],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False]]],
   [[0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [1, 50611],
    [1, 50611],
    [1, 50611]]],
  ['control: scenario 3',
   [[16785, 47110, 21847, 45361],
    61440,
    41889,
    [[True, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False]]],
   [[1, 45985], [1, 45985], [1, 45985], [1, 45985], [1, 45985], [1, 45985], [1, 45985]]],
  ['regression: scenario 4',
   [[26660, 61415, 54040],
    65535,
    45106,
    [[True, False], [True, False], [True, False], [False, False], [False, False], [True, False]]],
   [[1, 61415], [1, 61415], [1, 61415], [1, 61415], [1, 61415], [2, 54040]]],
  ['regression: scenario 5',
   [[31779, 18767, 26849],
    3855,
    17424,
    [[True, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False]]],
   [[1, 18719],
    [1, 18719],
    [1, 18719],
    [2, 18449],
    [2, 18449],
    [2, 18449],
    [2, 18449],
    [2, 18449],
    [2, 18449],
    [2, 18449],
    [1, 18719],
    [1, 18719]]]],
 [['regression: scenario 1',
   [[8488, 43469, 38296, 4034],
    255,
    44563,
    [[False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False]]],
   [[0, 44563],
    [1, 44749],
    [1, 44749],
    [1, 44749],
    [1, 44749],
    [2, 44696],
    [2, 44696],
    [3, 44738],
    [3, 44738],
    [1, 44749],
    [1, 44749],
    [2, 44696]]],
  ['regression: scenario 2',
   [[43079, 20640, 23622, 26553],
    255,
    15109,
    [[False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [False, True]]],
   [[0, 15109],
    [0, 15109],
    [1, 15264],
    [1, 15264],
    [1, 15264],
    [1, 15264],
    [2, 15174],
    [2, 15174],
    [2, 15174],
    [2, 15174],
    [3, 15289],
    [0, 15289]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['control: scenario 3',
   [[16618, 36272, 41924, 55813],
    3855,
    48911,
    [[True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False]]],
   [[1, 48384], [1, 48384], [1, 48384], [1, 48384], [1, 48384], [2, 45828], [2, 45828]]],
  ['control: scenario 5',
   [[2273, 56456, 65022, 11147, 34043],
    65535,
    43372,
    [[True, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False]]],
   [[1, 56456],
    [1, 56456],
    [1, 56456],
    [1, 56456],
    [1, 56456],
    [1, 56456],
    [1, 56456],
    [1, 56456],
    [1, 56456],
    [2, 65022]]],
  ['control: scenario 6',
   [[49034, 36252],
    255,
    16341,
    [[True, False],
     [True, False],
     [True, False],
     [True, True],
     [True, False],
     [True, False],
     [False, False],
     [False, True],
     [True, False]]],
   [[1, 16284],
    [1, 16284],
    [1, 16284],
    [0, 16284],
    [0, 16284],
    [0, 16284],
    [0, 16284],
    [0, 16284],
    [1, 16284]]]],
 [['regression: scenario 6',
   [[53426, 5627, 11199, 28564],
    3855,
    26531,
    [[True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False]]],
   [[1, 26027],
    [1, 26027],
    [1, 26027],
    [2, 27567],
    [2, 27567],
    [2, 27567],
    [2, 27567],
    [3, 28580],
    [3, 28580],
    [3, 28580],
    [1, 26027],
    [1, 26027],
    [1, 26027],
    [1, 26027]]],
  ['regression: scenario 10',
   [[49269, 29259, 58835, 30456],
    3855,
    32866,
    [[True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False]]],
   [[1, 33387],
    [1, 33387],
    [1, 33387],
    [2, 34147],
    [2, 34147],
    [2, 34147],
    [2, 34147],
    [2, 34147],
    [3, 34408]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['control: scenario 1',
   [[38610, 2229],
    65535,
    14704,
    [[False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, True],
     [False, False]]],
   [[0, 14704], [0, 14704], [0, 14704], [0, 14704], [0, 14704], [1, 2229], [1, 2229], [0, 2229], [0, 2229]]],
  ['control: scenario 3',
   [[45414, 65173, 31151, 4829],
    3855,
    46402,
    [[False, True],
     [False, False],
     [True, True],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False]]],
   [[0, 46402],
    [0, 46402],
    [0, 46402],
    [0, 46402],
    [0, 46402],
    [0, 46402],
    [1, 48709],
    [1, 48709],
    [1, 48709]]],
  ['control: scenario 4',
   [[29784, 63854],
    255,
    25258,
    [[False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, True],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, True],
     [False, False],
     [False, False],
     [True, False],
     [True, True]]],
   [[0, 25258],
    [1, 25198],
    [1, 25198],
    [1, 25198],
    [0, 25198],
    [0, 25198],
    [0, 25198],
    [1, 25198],
    [1, 25198],
    [0, 25198],
    [0, 25198],
    [0, 25198],
    [1, 25198],
    [0, 25198]]]],
 [['regression: scenario 12',
   [[10930, 58067, 34332, 5386],
    255,
    33885,
    [[False, False],
     [False, False],
     [False, True],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False]]],
   [[0, 33885],
    [0, 33885],
    [0, 33885],
    [1, 34003],
    [1, 34003],
    [1, 34003],
    [1, 34003],
    [1, 34003],
    [1, 34003],
    [2, 33820],
    [2, 33820],
    [3, 33802]]],
  ['regression: scenario 13',
   [[49950, 26245, 48254],
    61440,
    9574,
    [[False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False]]],
   [[0, 9574],
    [0, 9574],
    [1, 25958],
    [1, 25958],
    [1, 25958],
    [2, 46438],
    [2, 46438],
    [2, 46438],
    [1, 25958]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['control: scenario 3',
   [[35305, 48952, 41314, 29239, 28773],
    65535,
    11028,
    [[False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, True]]],
   [[0, 11028],
    [0, 11028],
    [1, 48952],
    [1, 48952],
    [1, 48952],
    [1, 48952],
    [2, 41314],
    [2, 41314],
    [2, 41314],
    [2, 41314],
    [2, 41314],
    [0, 41314]]],
  ['control: scenario 4',
   [[49309, 10384],
    61440,
    9568,
    [[True, False],
     [True, False],
     [True, False],
     [True, False],
     [True, True],
     [False, False],
     [False, False]]],
   [[1, 9568], [1, 9568], [1, 9568], [1, 9568], [0, 9568], [0, 9568], [0, 9568]]],
  ['regression: scenario 5',
   [[47154, 32327, 23912, 32399],
    3855,
    21368,
    [[False, True],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, True]]],
   [[0, 21368],
    [0, 21368],
    [0, 21368],
    [1, 24183],
    [1, 24183],
    [1, 24183],
    [2, 23928],
    [2, 23928],
    [2, 23928],
    [3, 24191],
    [0, 24191]]]],
 [['regression: scenario 19',
   [[7514, 21129, 31492],
    61440,
    5749,
    [[True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, True],
     [True, False],
     [False, False]]],
   [[1, 22133],
    [1, 22133],
    [1, 22133],
    [1, 22133],
    [2, 30325],
    [2, 30325],
    [2, 30325],
    [0, 30325],
    [1, 22133],
    [1, 22133]]],
  ['regression: scenario 33',
   [[32413, 34158, 29106],
    65535,
    55217,
    [[True, False],
     [False, False],
     [True, False],
     [True, True],
     [False, False],
     [True, False],
     [False, False],
     [False, False]]],
   [[1, 34158], [1, 34158], [2, 29106], [0, 29106], [0, 29106], [1, 34158], [1, 34158], [1, 34158]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['control: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['control: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['control: scenario 2',
   [[43067, 57880, 6921, 33106, 51712],
    255,
    13830,
    [[True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, True],
     [True, True],
     [False, False],
     [True, False],
     [False, False]]],
   [[1, 13848],
    [1, 13848],
    [1, 13848],
    [2, 13833],
    [2, 13833],
    [2, 13833],
    [3, 13906],
    [3, 13906],
    [0, 13906],
    [0, 13906],
    [0, 13906],
    [1, 13848],
    [1, 13848]]],
  ['regression: scenario 3',
   [[62662, 46394, 25376, 46313],
    3855,
    7057,
    [[False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False]]],
   [[0, 7057],
    [0, 7057],
    [0, 7057],
    [0, 7057],
    [0, 7057],
    [1, 5530],
    [1, 5530],
    [2, 5008],
    [2, 5008],
    [2, 5008],
    [2, 5008],
    [3, 5273],
    [3, 5273]]],
  ['regression: scenario 4',
   [[30732, 47166, 61273],
    3855,
    7380,
    [[False, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [False, True],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False]]],
   [[0, 7380],
    [1, 6366],
    [1, 6366],
    [2, 8153],
    [2, 8153],
    [0, 8153],
    [0, 8153],
    [1, 6366],
    [1, 6366],
    [1, 6366],
    [1, 6366],
    [1, 6366]]]]]
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 final element of the sequencer file is never output.

Sequencer output (SQO). words is the sequencer file whose element 0 is the home step; position starts at 0. On each rising edge of enable the position advances; past the last element it wraps to 1 (not 0). Each advance writes dest = (dest AND NOT mask) OR (word AND mask) in 16 bits. A reset input returns position to 0 without writing dest and has priority over a coincident advance; the enable edge memory is always updated. steps is a list of [enable, reset]; return [position, dest] per scan.

split: open-access


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

N = 1
observations = []
def solve(words, mask, start_dest, steps):
    pos = 0
    dest = start_dest
    prev = False
    length = len(words) - 1
    out = []
    for en, res in steps:
        en = bool(en)
        if res:
            pos = 0
        elif en and not prev:
            pos += 1
            if pos > length:
                pos = 1
            dest = words[pos] & mask
        prev = en
        out.append([pos, dest])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['regression: scenario 1',
   [[26918, 50611, 8879, 59828],
    65535,
    52597,
    [[False, False],
     [False, False],
     [False, False],
     [True, True],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False]]],
   [[0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [1, 50611],
    [1, 50611],
    [1, 50611]]],
  ['control: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['regression: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['regression: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['regression: scenario 2',
   [[42968, 29173, 43546],
    255,
    5794,
    [[True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, True],
     [False, False]]],
   [[1, 5877],
    [1, 5877],
    [1, 5877],
    [1, 5877],
    [2, 5658],
    [2, 5658],
    [2, 5658],
    [2, 5658],
    [0, 5658],
    [0, 5658]]],
  ['regression: scenario 3',
   [[16785, 47110, 21847, 45361],
    61440,
    41889,
    [[True, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False]]],
   [[1, 45985], [1, 45985], [1, 45985], [1, 45985], [1, 45985], [1, 45985], [1, 45985]]],
  ['regression: scenario 4',
   [[26660, 61415, 54040],
    65535,
    45106,
    [[True, False], [True, False], [True, False], [False, False], [False, False], [True, False]]],
   [[1, 61415], [1, 61415], [1, 61415], [1, 61415], [1, 61415], [2, 54040]]]],
 [['regression: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['regression: scenario 1',
   [[8488, 43469, 38296, 4034],
    255,
    44563,
    [[False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False]]],
   [[0, 44563],
    [1, 44749],
    [1, 44749],
    [1, 44749],
    [1, 44749],
    [2, 44696],
    [2, 44696],
    [3, 44738],
    [3, 44738],
    [1, 44749],
    [1, 44749],
    [2, 44696]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['control: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['regression: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['regression: scenario 2',
   [[43079, 20640, 23622, 26553],
    255,
    15109,
    [[False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [False, True]]],
   [[0, 15109],
    [0, 15109],
    [1, 15264],
    [1, 15264],
    [1, 15264],
    [1, 15264],
    [2, 15174],
    [2, 15174],
    [2, 15174],
    [2, 15174],
    [3, 15289],
    [0, 15289]]],
  ['regression: scenario 3',
   [[16618, 36272, 41924, 55813],
    3855,
    48911,
    [[True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False]]],
   [[1, 48384], [1, 48384], [1, 48384], [1, 48384], [1, 48384], [2, 45828], [2, 45828]]],
  ['regression: scenario 4',
   [[45574, 2941],
    255,
    15355,
    [[False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False]]],
   [[0, 15355],
    [0, 15355],
    [1, 15229],
    [1, 15229],
    [1, 15229],
    [1, 15229],
    [1, 15229],
    [1, 15229],
    [1, 15229],
    [1, 15229],
    [1, 15229],
    [1, 15229],
    [1, 15229]]]],
 [['regression: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['regression: scenario 2',
   [[36741, 30504],
    65535,
    26589,
    [[True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, True],
     [True, False],
     [False, False]]],
   [[1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [0, 30504],
    [0, 30504],
    [0, 30504]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['control: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['regression: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['regression: scenario 1',
   [[38610, 2229],
    65535,
    14704,
    [[False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, True],
     [False, False]]],
   [[0, 14704], [0, 14704], [0, 14704], [0, 14704], [0, 14704], [1, 2229], [1, 2229], [0, 2229], [0, 2229]]],
  ['regression: scenario 3',
   [[45414, 65173, 31151, 4829],
    3855,
    46402,
    [[False, True],
     [False, False],
     [True, True],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False]]],
   [[0, 46402],
    [0, 46402],
    [0, 46402],
    [0, 46402],
    [0, 46402],
    [0, 46402],
    [1, 48709],
    [1, 48709],
    [1, 48709]]],
  ['regression: scenario 4',
   [[29784, 63854],
    255,
    25258,
    [[False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, True],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, True],
     [False, False],
     [False, False],
     [True, False],
     [True, True]]],
   [[0, 25258],
    [1, 25198],
    [1, 25198],
    [1, 25198],
    [0, 25198],
    [0, 25198],
    [0, 25198],
    [1, 25198],
    [1, 25198],
    [0, 25198],
    [0, 25198],
    [0, 25198],
    [1, 25198],
    [0, 25198]]]],
 [['regression: scenario 1',
   [[61786, 58708],
    255,
    45362,
    [[False, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False]]],
   [[0, 45362], [0, 45362], [0, 45362], [1, 45396], [1, 45396], [1, 45396], [1, 45396]]],
  ['regression: scenario 5',
   [[47154, 32327, 23912, 32399],
    3855,
    21368,
    [[False, True],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, True]]],
   [[0, 21368],
    [0, 21368],
    [0, 21368],
    [1, 24183],
    [1, 24183],
    [1, 24183],
    [2, 23928],
    [2, 23928],
    [2, 23928],
    [3, 24191],
    [0, 24191]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['control: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['regression: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['regression: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['regression: scenario 2',
   [[57902, 51779],
    61440,
    26811,
    [[True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False]]],
   [[1, 51387], [1, 51387], [1, 51387], [1, 51387], [1, 51387], [1, 51387], [1, 51387], [1, 51387]]],
  ['regression: scenario 3',
   [[35305, 48952, 41314, 29239, 28773],
    65535,
    11028,
    [[False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, True]]],
   [[0, 11028],
    [0, 11028],
    [1, 48952],
    [1, 48952],
    [1, 48952],
    [1, 48952],
    [2, 41314],
    [2, 41314],
    [2, 41314],
    [2, 41314],
    [2, 41314],
    [0, 41314]]]],
 [['regression: scenario 2',
   [[43067, 57880, 6921, 33106, 51712],
    255,
    13830,
    [[True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, True],
     [True, True],
     [False, False],
     [True, False],
     [False, False]]],
   [[1, 13848],
    [1, 13848],
    [1, 13848],
    [2, 13833],
    [2, 13833],
    [2, 13833],
    [3, 13906],
    [3, 13906],
    [0, 13906],
    [0, 13906],
    [0, 13906],
    [1, 13848],
    [1, 13848]]],
  ['regression: scenario 6',
   [[49875, 17863, 34135],
    3855,
    57202,
    [[False, False], [True, False], [True, False], [True, True], [False, False], [False, False]]],
   [[0, 57202], [1, 54647], [1, 54647], [0, 54647], [0, 54647], [0, 54647]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['control: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['regression: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['regression: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['regression: scenario 1',
   [[39974, 26951],
    3855,
    4546,
    [[False, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, True]]],
   [[0, 4546],
    [0, 4546],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [0, 6599]]],
  ['regression: scenario 3',
   [[62662, 46394, 25376, 46313],
    3855,
    7057,
    [[False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False]]],
   [[0, 7057],
    [0, 7057],
    [0, 7057],
    [0, 7057],
    [0, 7057],
    [1, 5530],
    [1, 5530],
    [2, 5008],
    [2, 5008],
    [2, 5008],
    [2, 5008],
    [3, 5273],
    [3, 5273]]]]]
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(words, mask, start_dest, steps):
    pos = 0
    dest = start_dest
    prev = False
    length = len(words) - 1
    out = []
    for en, res in steps:
        en = bool(en)
        if res:
            pos = 0
        elif en and not prev:
            pos += 1
            if pos > length:
                pos = 1
            dest = dest | (words[pos] & mask)
        prev = en
        out.append([pos, dest])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['regression: scenario 1',
   [[26918, 50611, 8879, 59828],
    65535,
    52597,
    [[False, False],
     [False, False],
     [False, False],
     [True, True],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False]]],
   [[0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [0, 52597],
    [1, 50611],
    [1, 50611],
    [1, 50611]]],
  ['control: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['regression: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['regression: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['regression: scenario 2',
   [[42968, 29173, 43546],
    255,
    5794,
    [[True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, True],
     [False, False]]],
   [[1, 5877],
    [1, 5877],
    [1, 5877],
    [1, 5877],
    [2, 5658],
    [2, 5658],
    [2, 5658],
    [2, 5658],
    [0, 5658],
    [0, 5658]]],
  ['regression: scenario 3',
   [[16785, 47110, 21847, 45361],
    61440,
    41889,
    [[True, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False]]],
   [[1, 45985], [1, 45985], [1, 45985], [1, 45985], [1, 45985], [1, 45985], [1, 45985]]],
  ['regression: scenario 4',
   [[26660, 61415, 54040],
    65535,
    45106,
    [[True, False], [True, False], [True, False], [False, False], [False, False], [True, False]]],
   [[1, 61415], [1, 61415], [1, 61415], [1, 61415], [1, 61415], [2, 54040]]]],
 [['regression: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['regression: scenario 1',
   [[8488, 43469, 38296, 4034],
    255,
    44563,
    [[False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False]]],
   [[0, 44563],
    [1, 44749],
    [1, 44749],
    [1, 44749],
    [1, 44749],
    [2, 44696],
    [2, 44696],
    [3, 44738],
    [3, 44738],
    [1, 44749],
    [1, 44749],
    [2, 44696]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['control: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['regression: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['regression: scenario 2',
   [[43079, 20640, 23622, 26553],
    255,
    15109,
    [[False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [False, True]]],
   [[0, 15109],
    [0, 15109],
    [1, 15264],
    [1, 15264],
    [1, 15264],
    [1, 15264],
    [2, 15174],
    [2, 15174],
    [2, 15174],
    [2, 15174],
    [3, 15289],
    [0, 15289]]],
  ['regression: scenario 3',
   [[16618, 36272, 41924, 55813],
    3855,
    48911,
    [[True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False]]],
   [[1, 48384], [1, 48384], [1, 48384], [1, 48384], [1, 48384], [2, 45828], [2, 45828]]],
  ['regression: scenario 4',
   [[45574, 2941],
    255,
    15355,
    [[False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False]]],
   [[0, 15355],
    [0, 15355],
    [1, 15229],
    [1, 15229],
    [1, 15229],
    [1, 15229],
    [1, 15229],
    [1, 15229],
    [1, 15229],
    [1, 15229],
    [1, 15229],
    [1, 15229],
    [1, 15229]]]],
 [['regression: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['regression: scenario 2',
   [[36741, 30504],
    65535,
    26589,
    [[True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, True],
     [True, False],
     [False, False]]],
   [[1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [1, 30504],
    [0, 30504],
    [0, 30504],
    [0, 30504]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['control: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['regression: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['regression: scenario 1',
   [[38610, 2229],
    65535,
    14704,
    [[False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, True],
     [False, False]]],
   [[0, 14704], [0, 14704], [0, 14704], [0, 14704], [0, 14704], [1, 2229], [1, 2229], [0, 2229], [0, 2229]]],
  ['regression: scenario 3',
   [[45414, 65173, 31151, 4829],
    3855,
    46402,
    [[False, True],
     [False, False],
     [True, True],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False]]],
   [[0, 46402],
    [0, 46402],
    [0, 46402],
    [0, 46402],
    [0, 46402],
    [0, 46402],
    [1, 48709],
    [1, 48709],
    [1, 48709]]],
  ['regression: scenario 4',
   [[29784, 63854],
    255,
    25258,
    [[False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, True],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, True],
     [False, False],
     [False, False],
     [True, False],
     [True, True]]],
   [[0, 25258],
    [1, 25198],
    [1, 25198],
    [1, 25198],
    [0, 25198],
    [0, 25198],
    [0, 25198],
    [1, 25198],
    [1, 25198],
    [0, 25198],
    [0, 25198],
    [0, 25198],
    [1, 25198],
    [0, 25198]]]],
 [['regression: scenario 1',
   [[61786, 58708],
    255,
    45362,
    [[False, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False]]],
   [[0, 45362], [0, 45362], [0, 45362], [1, 45396], [1, 45396], [1, 45396], [1, 45396]]],
  ['regression: scenario 5',
   [[47154, 32327, 23912, 32399],
    3855,
    21368,
    [[False, True],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, True]]],
   [[0, 21368],
    [0, 21368],
    [0, 21368],
    [1, 24183],
    [1, 24183],
    [1, 24183],
    [2, 23928],
    [2, 23928],
    [2, 23928],
    [3, 24191],
    [0, 24191]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['control: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['regression: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['regression: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['regression: scenario 2',
   [[57902, 51779],
    61440,
    26811,
    [[True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False]]],
   [[1, 51387], [1, 51387], [1, 51387], [1, 51387], [1, 51387], [1, 51387], [1, 51387], [1, 51387]]],
  ['regression: scenario 3',
   [[35305, 48952, 41314, 29239, 28773],
    65535,
    11028,
    [[False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, True]]],
   [[0, 11028],
    [0, 11028],
    [1, 48952],
    [1, 48952],
    [1, 48952],
    [1, 48952],
    [2, 41314],
    [2, 41314],
    [2, 41314],
    [2, 41314],
    [2, 41314],
    [0, 41314]]]],
 [['regression: scenario 2',
   [[43067, 57880, 6921, 33106, 51712],
    255,
    13830,
    [[True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, True],
     [True, True],
     [False, False],
     [True, False],
     [False, False]]],
   [[1, 13848],
    [1, 13848],
    [1, 13848],
    [2, 13833],
    [2, 13833],
    [2, 13833],
    [3, 13906],
    [3, 13906],
    [0, 13906],
    [0, 13906],
    [0, 13906],
    [1, 13848],
    [1, 13848]]],
  ['regression: scenario 6',
   [[49875, 17863, 34135],
    3855,
    57202,
    [[False, False], [True, False], [True, False], [True, True], [False, False], [False, False]]],
   [[0, 57202], [1, 54647], [1, 54647], [0, 54647], [0, 54647], [0, 54647]]],
  ['regression: wrap past last step',
   [[0, 17, 34],
    255,
    43776,
    [[True, False], [False, False], [True, False], [False, False], [True, False], [True, False]]],
   [[1, 43793], [1, 43793], [2, 43810], [2, 43810], [1, 43793], [1, 43793]]],
  ['control: two element file',
   [[5, 9], 65535, 0, [[True, False], [False, False], [True, False], [False, False], [True, False]]],
   [[1, 9], [1, 9], [1, 9], [1, 9], [1, 9]]],
  ['regression: reset while enabled',
   [[0, 3, 12], 15, 65520, [[True, False], [True, True], [False, False], [True, False]]],
   [[1, 65523], [0, 65523], [0, 65523], [1, 65523]]],
  ['regression: reset with advance',
   [[0, 256, 512], 65280, 170, [[False, False], [True, True], [False, False], [True, False]]],
   [[0, 170], [0, 170], [0, 170], [1, 426]]],
  ['regression: scenario 1',
   [[39974, 26951],
    3855,
    4546,
    [[False, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, True]]],
   [[0, 4546],
    [0, 4546],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [1, 6599],
    [0, 6599]]],
  ['regression: scenario 3',
   [[62662, 46394, 25376, 46313],
    3855,
    7057,
    [[False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False]]],
   [[0, 7057],
    [0, 7057],
    [0, 7057],
    [0, 7057],
    [0, 7057],
    [1, 5530],
    [1, 5530],
    [2, 5008],
    [2, 5008],
    [2, 5008],
    [2, 5008],
    [3, 5273],
    [3, 5273]]]]]
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:
Outputs that other rungs control on the same word are cleared on every sequencer step.

Sequencer output (SQO). words is the sequencer file whose element 0 is the home step; position starts at 0. On each rising edge of enable the position advances; past the last element it wraps to 1 (not 0). Each advance writes dest = (dest AND NOT mask) OR (word AND mask) in 16 bits. A reset input returns position to 0 without writing dest and has priority over a coincident advance; the enable edge memory is always updated. steps is a list of [enable, reset]; return [position, dest] per scan.

split: open-access