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:
            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 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]]],
  ['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]]],
  ['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',
   [[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]]],
  ['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 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 21',
   [[35992, 43053, 59445],
    65535,
    52164,
    [[False, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, True],
     [False, False]]],
   [[0, 52164],
    [1, 43053],
    [1, 43053],
    [2, 59445],
    [2, 59445],
    [1, 43053],
    [1, 43053],
    [2, 59445],
    [2, 59445],
    [2, 59445],
    [2, 59445],
    [0, 59445],
    [0, 59445]]],
  ['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]]],
  ['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 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 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 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: 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]]],
  ['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]]],
  ['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 6',
   [[41259, 64194, 24167],
    255,
    50548,
    [[True, False],
     [False, False],
     [True, True],
     [False, False],
     [True, False],
     [True, False],
     [False, False]]],
   [[1, 50626], [1, 50626], [0, 50626], [0, 50626], [1, 50626], [1, 50626], [1, 50626]]],
  ['regression: scenario 34',
   [[14407, 35134, 61773],
    65535,
    32422,
    [[True, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False]]],
   [[1, 35134],
    [1, 35134],
    [2, 61773],
    [2, 61773],
    [2, 61773],
    [1, 35134],
    [1, 35134],
    [2, 61773],
    [2, 61773],
    [2, 61773],
    [2, 61773],
    [2, 61773],
    [2, 61773]]],
  ['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]]],
  ['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',
   [[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 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 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: scenario 46',
   [[23503, 30684, 5429],
    61440,
    58681,
    [[True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False]]],
   [[1, 30009],
    [1, 30009],
    [1, 30009],
    [1, 30009],
    [2, 5433],
    [2, 5433],
    [2, 5433],
    [2, 5433],
    [2, 5433],
    [2, 5433],
    [2, 5433],
    [2, 5433],
    [1, 30009]]],
  ['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]]],
  ['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',
   [[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 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)

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 and pos < length:
            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 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]]],
  ['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]]],
  ['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',
   [[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]]],
  ['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 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 21',
   [[35992, 43053, 59445],
    65535,
    52164,
    [[False, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, True],
     [False, False]]],
   [[0, 52164],
    [1, 43053],
    [1, 43053],
    [2, 59445],
    [2, 59445],
    [1, 43053],
    [1, 43053],
    [2, 59445],
    [2, 59445],
    [2, 59445],
    [2, 59445],
    [0, 59445],
    [0, 59445]]],
  ['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]]],
  ['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 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 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 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: 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]]],
  ['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]]],
  ['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 6',
   [[41259, 64194, 24167],
    255,
    50548,
    [[True, False],
     [False, False],
     [True, True],
     [False, False],
     [True, False],
     [True, False],
     [False, False]]],
   [[1, 50626], [1, 50626], [0, 50626], [0, 50626], [1, 50626], [1, 50626], [1, 50626]]],
  ['regression: scenario 34',
   [[14407, 35134, 61773],
    65535,
    32422,
    [[True, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False]]],
   [[1, 35134],
    [1, 35134],
    [2, 61773],
    [2, 61773],
    [2, 61773],
    [1, 35134],
    [1, 35134],
    [2, 61773],
    [2, 61773],
    [2, 61773],
    [2, 61773],
    [2, 61773],
    [2, 61773]]],
  ['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]]],
  ['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',
   [[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 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 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: scenario 46',
   [[23503, 30684, 5429],
    61440,
    58681,
    [[True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False]]],
   [[1, 30009],
    [1, 30009],
    [1, 30009],
    [1, 30009],
    [2, 5433],
    [2, 5433],
    [2, 5433],
    [2, 5433],
    [2, 5433],
    [2, 5433],
    [2, 5433],
    [2, 5433],
    [1, 30009]]],
  ['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]]],
  ['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',
   [[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 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:
Holding the step input races through the whole sequence.

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
            dest = (dest & ~mask & 0xFFFF) | (words[0] & mask)
        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: 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',
   [[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: 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]]],
  ['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 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: 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 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]]],
  ['control: 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]]],
  ['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',
   [[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 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 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: 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]]],
  ['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',
   [[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 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 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 6',
   [[41259, 64194, 24167],
    255,
    50548,
    [[True, False],
     [False, False],
     [True, True],
     [False, False],
     [True, False],
     [True, False],
     [False, False]]],
   [[1, 50626], [1, 50626], [0, 50626], [0, 50626], [1, 50626], [1, 50626], [1, 50626]]],
  ['control: 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]]],
  ['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',
   [[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 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 5',
   [[50120, 43705, 18219, 64249, 48621],
    65535,
    42460,
    [[False, False],
     [False, True],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False]]],
   [[0, 42460], [0, 42460], [0, 42460], [0, 42460], [1, 43705], [1, 43705], [1, 43705], [2, 18219]]],
  ['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]]],
  ['control: 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]]],
  ['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]]],
  ['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]]]]]
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
            dest = dest & ~mask & 0xFFFF
        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: 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',
   [[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: 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]]],
  ['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 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: 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 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]]],
  ['control: 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]]],
  ['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',
   [[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 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 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: 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]]],
  ['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',
   [[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 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 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 6',
   [[41259, 64194, 24167],
    255,
    50548,
    [[True, False],
     [False, False],
     [True, True],
     [False, False],
     [True, False],
     [True, False],
     [False, False]]],
   [[1, 50626], [1, 50626], [0, 50626], [0, 50626], [1, 50626], [1, 50626], [1, 50626]]],
  ['control: 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]]],
  ['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',
   [[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 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 5',
   [[50120, 43705, 18219, 64249, 48621],
    65535,
    42460,
    [[False, False],
     [False, True],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False]]],
   [[0, 42460], [0, 42460], [0, 42460], [0, 42460], [1, 43705], [1, 43705], [1, 43705], [2, 18219]]],
  ['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]]],
  ['control: 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]]],
  ['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]]],
  ['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]]]]]
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:
Resetting the sequencer changes the machine outputs instead of only rewinding the position.

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 en and not prev:
            pos += 1
            if pos > length:
                pos = 1
            dest = (dest & ~mask & 0xFFFF) | (words[pos] & mask)
        if res:
            pos = 0
        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: 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 6',
   [[29507, 12756, 63003, 15441, 3378],
    61440,
    54790,
    [[False, False],
     [False, False],
     [True, True],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False]]],
   [[0, 54790],
    [0, 54790],
    [0, 54790],
    [0, 54790],
    [0, 54790],
    [0, 54790],
    [1, 13830],
    [1, 13830],
    [1, 13830],
    [2, 62982]]],
  ['control: 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]]],
  ['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]]],
  ['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]]],
  ['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: 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 8',
   [[65487, 45479, 8754],
    61440,
    1982,
    [[False, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, True],
     [False, False],
     [False, False],
     [False, False],
     [True, True],
     [True, False]]],
   [[0, 1982],
    [1, 47038],
    [1, 47038],
    [1, 47038],
    [1, 47038],
    [1, 47038],
    [2, 10174],
    [0, 10174],
    [0, 10174],
    [0, 10174],
    [0, 10174],
    [0, 10174],
    [0, 10174]]],
  ['regression: scenario 31',
   [[26490, 1121, 33414, 24311],
    65535,
    26582,
    [[True, True],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [False, True],
     [False, False],
     [False, False],
     [True, True],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False]]],
   [[0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582]]],
  ['control: 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]]],
  ['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]]],
  ['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]]],
  ['control: 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]]]],
 [['regression: scenario 5',
   [[8300, 19450, 62969],
    255,
    8070,
    [[True, True],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False]]],
   [[0, 8070],
    [0, 8070],
    [0, 8070],
    [1, 8186],
    [1, 8186],
    [1, 8186],
    [1, 8186],
    [2, 8185],
    [2, 8185],
    [2, 8185],
    [2, 8185],
    [2, 8185],
    [1, 8186],
    [1, 8186]]],
  ['regression: scenario 20',
   [[27683, 27069, 29983],
    255,
    29648,
    [[False, False],
     [True, False],
     [False, True],
     [False, False],
     [False, False],
     [False, False],
     [True, True],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [False, True]]],
   [[0, 29648],
    [1, 29629],
    [0, 29629],
    [0, 29629],
    [0, 29629],
    [0, 29629],
    [0, 29629],
    [0, 29629],
    [0, 29629],
    [0, 29629],
    [0, 29629],
    [0, 29629]]],
  ['control: 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]]],
  ['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]]],
  ['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]]],
  ['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]]],
  ['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 23',
   [[17706, 2201, 35072],
    3855,
    50743,
    [[True, True], [True, False], [False, False], [False, True], [True, False], [False, False]]],
   [[0, 50743], [0, 50743], [0, 50743], [0, 50743], [1, 51257], [1, 51257]]],
  ['regression: scenario 37',
   [[46144, 38157],
    61440,
    18798,
    [[False, True], [False, False], [False, False], [False, False], [True, True], [True, False]]],
   [[0, 18798], [0, 18798], [0, 18798], [0, 18798], [0, 18798], [0, 18798]]],
  ['control: 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]]],
  ['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]]],
  ['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]]],
  ['control: 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 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 10',
   [[42427, 61110, 22519, 20082, 65253],
    65535,
    32195,
    [[True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, True],
     [False, False],
     [False, False],
     [False, False]]],
   [[1, 61110],
    [1, 61110],
    [2, 22519],
    [2, 22519],
    [3, 20082],
    [3, 20082],
    [3, 20082],
    [3, 20082],
    [3, 20082],
    [0, 20082],
    [0, 20082],
    [0, 20082],
    [0, 20082]]],
  ['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]]],
  ['control: 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]]],
  ['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]]],
  ['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]]],
  ['control: 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 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)

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 if not res else prev
        out.append([pos, dest])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['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 6',
   [[29507, 12756, 63003, 15441, 3378],
    61440,
    54790,
    [[False, False],
     [False, False],
     [True, True],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False]]],
   [[0, 54790],
    [0, 54790],
    [0, 54790],
    [0, 54790],
    [0, 54790],
    [0, 54790],
    [1, 13830],
    [1, 13830],
    [1, 13830],
    [2, 62982]]],
  ['control: 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]]],
  ['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]]],
  ['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]]],
  ['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: 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 8',
   [[65487, 45479, 8754],
    61440,
    1982,
    [[False, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [False, False],
     [True, False],
     [True, True],
     [False, False],
     [False, False],
     [False, False],
     [True, True],
     [True, False]]],
   [[0, 1982],
    [1, 47038],
    [1, 47038],
    [1, 47038],
    [1, 47038],
    [1, 47038],
    [2, 10174],
    [0, 10174],
    [0, 10174],
    [0, 10174],
    [0, 10174],
    [0, 10174],
    [0, 10174]]],
  ['regression: scenario 31',
   [[26490, 1121, 33414, 24311],
    65535,
    26582,
    [[True, True],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [False, True],
     [False, False],
     [False, False],
     [True, True],
     [True, False],
     [True, False],
     [True, False],
     [True, False],
     [True, False]]],
   [[0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582],
    [0, 26582]]],
  ['control: 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]]],
  ['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]]],
  ['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]]],
  ['control: 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]]]],
 [['regression: scenario 5',
   [[8300, 19450, 62969],
    255,
    8070,
    [[True, True],
     [False, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [False, False],
     [True, False],
     [True, False]]],
   [[0, 8070],
    [0, 8070],
    [0, 8070],
    [1, 8186],
    [1, 8186],
    [1, 8186],
    [1, 8186],
    [2, 8185],
    [2, 8185],
    [2, 8185],
    [2, 8185],
    [2, 8185],
    [1, 8186],
    [1, 8186]]],
  ['regression: scenario 20',
   [[27683, 27069, 29983],
    255,
    29648,
    [[False, False],
     [True, False],
     [False, True],
     [False, False],
     [False, False],
     [False, False],
     [True, True],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [False, True]]],
   [[0, 29648],
    [1, 29629],
    [0, 29629],
    [0, 29629],
    [0, 29629],
    [0, 29629],
    [0, 29629],
    [0, 29629],
    [0, 29629],
    [0, 29629],
    [0, 29629],
    [0, 29629]]],
  ['control: 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]]],
  ['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]]],
  ['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]]],
  ['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]]],
  ['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 23',
   [[17706, 2201, 35072],
    3855,
    50743,
    [[True, True], [True, False], [False, False], [False, True], [True, False], [False, False]]],
   [[0, 50743], [0, 50743], [0, 50743], [0, 50743], [1, 51257], [1, 51257]]],
  ['regression: scenario 37',
   [[46144, 38157],
    61440,
    18798,
    [[False, True], [False, False], [False, False], [False, False], [True, True], [True, False]]],
   [[0, 18798], [0, 18798], [0, 18798], [0, 18798], [0, 18798], [0, 18798]]],
  ['control: 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]]],
  ['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]]],
  ['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]]],
  ['control: 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 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 10',
   [[42427, 61110, 22519, 20082, 65253],
    65535,
    32195,
    [[True, False],
     [False, False],
     [True, False],
     [False, False],
     [True, False],
     [True, False],
     [False, False],
     [False, False],
     [False, False],
     [True, True],
     [False, False],
     [False, False],
     [False, False]]],
   [[1, 61110],
    [1, 61110],
    [2, 22519],
    [2, 22519],
    [3, 20082],
    [3, 20082],
    [3, 20082],
    [3, 20082],
    [3, 20082],
    [0, 20082],
    [0, 20082],
    [0, 20082],
    [0, 20082]]],
  ['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]]],
  ['control: 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]]],
  ['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]]],
  ['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]]],
  ['control: 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 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:
A reset coinciding with a step pulse outputs the next step pattern while the position reads 0.

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


prompt:
The reject gate acts on the part that is still one position upstream.

Bit shift left (BSL) register tracking parts on a conveyor. On each rising edge of the encoder clock the bit at the far end (index length-1) moves to the unload bit, every bit moves one position toward the far end, and bit 0 loads the part-present sensor sampled on that same scan. The unload bit holds its value until the next shift. pulses is a list of [clock, sensor]; return [register string index 0 first, unload] per scan.

split: open-access


prompt:
Part-present bits travel backwards along the conveyor model.

Bit shift left (BSL) register tracking parts on a conveyor. On each rising edge of the encoder clock the bit at the far end (index length-1) moves to the unload bit, every bit moves one position toward the far end, and bit 0 loads the part-present sensor sampled on that same scan. The unload bit holds its value until the next shift. pulses is a list of [clock, sensor]; return [register string index 0 first, unload] per scan.

split: open-access


prompt:
Tracking runs ahead of the conveyor when the encoder pulse spans several scans.

Bit shift left (BSL) register tracking parts on a conveyor. On each rising edge of the encoder clock the bit at the far end (index length-1) moves to the unload bit, every bit moves one position toward the far end, and bit 0 loads the part-present sensor sampled on that same scan. The unload bit holds its value until the next shift. pulses is a list of [clock, sensor]; return [register string index 0 first, unload] per scan.

split: open-access


prompt:
A part that arrives on the same scan as the encoder edge is not tracked.

Bit shift left (BSL) register tracking parts on a conveyor. On each rising edge of the encoder clock the bit at the far end (index length-1) moves to the unload bit, every bit moves one position toward the far end, and bit 0 loads the part-present sensor sampled on that same scan. The unload bit holds its value until the next shift. pulses is a list of [clock, sensor]; return [register string index 0 first, unload] per scan.

split: open-access


prompt:
The reject solenoid only sees the unloaded part for the single edge scan.

Bit shift left (BSL) register tracking parts on a conveyor. On each rising edge of the encoder clock the bit at the far end (index length-1) moves to the unload bit, every bit moves one position toward the far end, and bit 0 loads the part-present sensor sampled on that same scan. The unload bit holds its value until the next shift. pulses is a list of [clock, sensor]; return [register string index 0 first, unload] per scan.

split: open-access