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

N = 1
observations = []
def solve(commands, size):
    values=[0]*size
    out=[]
    for cmd in commands:
        if cmd[0]=='seed': values=[cmd[1][i%len(cmd[1])] & 7 for i in range(size)]; continue
        mask,reference,readmask,writemask,comparison,onpass,onfail=cmd
        for i in range(size):
            if not mask: continue
            old=values[i]
            left=old & readmask
            right=reference & readmask
            passed=(left==right if comparison=='equal' else left<right if comparison=='less' else left!=right)
            op=onpass if passed else onfail
            if op=='keep': new=old
            elif op=='zero': new=0
            elif op=='replace': new=reference
            elif op=='inc': new=min(7,old+1)
            elif op=='dec': new=max(0,old-1)
            else: new=old^7
            values[i]=((old & (~writemask & 7)) | (new & writemask)) & 7
        out.append(list(values))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 4), [[1, 2, 7, 0]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 4), [[0, 0, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 4), [[2, 2, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 4), [[4, 4, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 4), [[7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 4), [[0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 4), [[4, 4, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 4), [[7, 7, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 4), [[0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 4), [[2, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 4), [[0, 1, 0, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 4), [[2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 4), [[5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 4), [[6, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 4), [[4, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 4), [[2, 5, 5, 5]])
if N == 2:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 5), [[1, 2, 7, 0, 1]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 5), [[0, 0, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 5), [[2, 2, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 5), [[4, 4, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 5), [[7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 5), [[0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 5), [[4, 4, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 5), [[7, 7, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 5), [[0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 5), [[2, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 5), [[0, 1, 0, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 5), [[2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 5), [[5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 5), [[6, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 5), [[4, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 5), [[2, 5, 5, 5, 5]])
if N == 3:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 6), [[1, 2, 7, 0, 1, 2]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 6), [[0, 0, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 6), [[2, 2, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 6), [[4, 4, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 6), [[7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 6), [[0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 6), [[4, 4, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 6), [[7, 7, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 6), [[0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 6), [[2, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 6), [[0, 1, 0, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 6), [[2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 6), [[5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 6), [[6, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 6), [[4, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 6), [[2, 5, 5, 5, 5, 5]])
if N == 4:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 7), [[1, 2, 7, 0, 1, 2, 7]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 7), [[0, 0, 5, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 7), [[2, 2, 1, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 7), [[4, 4, 0, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 7), [[7, 7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 7), [[0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 7), [[4, 4, 3, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 7), [[7, 7, 6, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 7), [[0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 7), [[2, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 7), [[0, 1, 0, 1, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 7), [[2, 2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 7), [[5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 7), [[6, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 7), [[4, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 7), [[2, 5, 5, 5, 5, 5, 5]])
if N == 5:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 8), [[1, 2, 7, 0, 1, 2, 7, 0]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 8), [[0, 0, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 8), [[2, 2, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 8), [[4, 4, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 8), [[7, 7, 7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 8), [[0, 0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 8), [[4, 4, 3, 3, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 8), [[7, 7, 6, 6, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 8), [[0, 0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 8), [[2, 1, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 8), [[0, 1, 0, 1, 1, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 8), [[2, 2, 2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 8), [[5, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 8), [[6, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 8), [[4, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 8), [[2, 5, 5, 5, 5, 5, 5, 5]])
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(commands, size):
    values=[0]*size
    out=[]
    for cmd in commands:
        if cmd[0]=='seed': values=[cmd[1][i%len(cmd[1])] & 7 for i in range(size)]; continue
        mask,reference,readmask,writemask,comparison,onpass,onfail=cmd
        for i in range(size):
            if i<min(mask,default=size) or i>max(mask,default=-1): continue
            old=values[i]
            left=old & readmask
            right=reference & readmask
            passed=(left==right if comparison=='equal' else left<right if comparison=='less' else left!=right)
            op=onpass if passed else onfail
            if op=='keep': new=old
            elif op=='zero': new=0
            elif op=='replace': new=reference
            elif op=='inc': new=min(7,old+1)
            elif op=='dec': new=max(0,old-1)
            else: new=old^7
            values[i]=((old & (~writemask & 7)) | (new & writemask)) & 7
        out.append(list(values))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 4), [[1, 2, 7, 0]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 4), [[0, 0, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 4), [[2, 2, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 4), [[4, 4, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 4), [[7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 4), [[0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 4), [[4, 4, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 4), [[7, 7, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 4), [[0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 4), [[2, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 4), [[0, 1, 0, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 4), [[2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 4), [[5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 4), [[6, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 4), [[4, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 4), [[2, 5, 5, 5]])
if N == 2:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 5), [[1, 2, 7, 0, 1]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 5), [[0, 0, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 5), [[2, 2, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 5), [[4, 4, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 5), [[7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 5), [[0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 5), [[4, 4, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 5), [[7, 7, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 5), [[0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 5), [[2, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 5), [[0, 1, 0, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 5), [[2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 5), [[5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 5), [[6, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 5), [[4, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 5), [[2, 5, 5, 5, 5]])
if N == 3:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 6), [[1, 2, 7, 0, 1, 2]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 6), [[0, 0, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 6), [[2, 2, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 6), [[4, 4, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 6), [[7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 6), [[0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 6), [[4, 4, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 6), [[7, 7, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 6), [[0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 6), [[2, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 6), [[0, 1, 0, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 6), [[2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 6), [[5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 6), [[6, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 6), [[4, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 6), [[2, 5, 5, 5, 5, 5]])
if N == 4:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 7), [[1, 2, 7, 0, 1, 2, 7]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 7), [[0, 0, 5, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 7), [[2, 2, 1, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 7), [[4, 4, 0, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 7), [[7, 7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 7), [[0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 7), [[4, 4, 3, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 7), [[7, 7, 6, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 7), [[0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 7), [[2, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 7), [[0, 1, 0, 1, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 7), [[2, 2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 7), [[5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 7), [[6, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 7), [[4, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 7), [[2, 5, 5, 5, 5, 5, 5]])
if N == 5:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 8), [[1, 2, 7, 0, 1, 2, 7, 0]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 8), [[0, 0, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 8), [[2, 2, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 8), [[4, 4, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 8), [[7, 7, 7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 8), [[0, 0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 8), [[4, 4, 3, 3, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 8), [[7, 7, 6, 6, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 8), [[0, 0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 8), [[2, 1, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 8), [[0, 1, 0, 1, 1, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 8), [[2, 2, 2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 8), [[5, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 8), [[6, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 8), [[4, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 8), [[2, 5, 5, 5, 5, 5, 5, 5]])
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:
Stencil operations run on every sample whenever incoming coverage is nonempty.

Finite integer stencil values use three low bits. A clip pass compares masked stored values to masked reference, then applies distinct pass/fail operations only inside the incoming coverage set. Write masking preserves unrelated bits. Supported operations keep, zero, replace, saturating increment/decrement and invert.

split: open-access


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

N = 1
observations = []
def solve(commands, size):
    values=[0]*size
    out=[]
    for cmd in commands:
        if cmd[0]=='seed': values=[cmd[1][i%len(cmd[1])] & 7 for i in range(size)]; continue
        mask,reference,readmask,writemask,comparison,onpass,onfail=cmd
        for i in range(size):
            if i not in mask: continue
            old=values[i]
            left=old & readmask
            right=reference
            passed=(left==right if comparison=='equal' else left<right if comparison=='less' else left!=right)
            op=onpass if passed else onfail
            if op=='keep': new=old
            elif op=='zero': new=0
            elif op=='replace': new=reference
            elif op=='inc': new=min(7,old+1)
            elif op=='dec': new=max(0,old-1)
            else: new=old^7
            values[i]=((old & (~writemask & 7)) | (new & writemask)) & 7
        out.append(list(values))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 4), [[1, 2, 7, 0]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 4), [[0, 0, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 4), [[2, 2, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 4), [[4, 4, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 4), [[7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 4), [[0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 4), [[4, 4, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 4), [[7, 7, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 4), [[0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 4), [[2, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 4), [[0, 1, 0, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 4), [[2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 4), [[5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 4), [[6, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 4), [[4, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 4), [[2, 5, 5, 5]])
if N == 2:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 5), [[1, 2, 7, 0, 1]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 5), [[0, 0, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 5), [[2, 2, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 5), [[4, 4, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 5), [[7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 5), [[0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 5), [[4, 4, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 5), [[7, 7, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 5), [[0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 5), [[2, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 5), [[0, 1, 0, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 5), [[2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 5), [[5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 5), [[6, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 5), [[4, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 5), [[2, 5, 5, 5, 5]])
if N == 3:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 6), [[1, 2, 7, 0, 1, 2]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 6), [[0, 0, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 6), [[2, 2, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 6), [[4, 4, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 6), [[7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 6), [[0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 6), [[4, 4, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 6), [[7, 7, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 6), [[0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 6), [[2, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 6), [[0, 1, 0, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 6), [[2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 6), [[5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 6), [[6, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 6), [[4, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 6), [[2, 5, 5, 5, 5, 5]])
if N == 4:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 7), [[1, 2, 7, 0, 1, 2, 7]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 7), [[0, 0, 5, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 7), [[2, 2, 1, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 7), [[4, 4, 0, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 7), [[7, 7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 7), [[0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 7), [[4, 4, 3, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 7), [[7, 7, 6, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 7), [[0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 7), [[2, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 7), [[0, 1, 0, 1, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 7), [[2, 2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 7), [[5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 7), [[6, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 7), [[4, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 7), [[2, 5, 5, 5, 5, 5, 5]])
if N == 5:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 8), [[1, 2, 7, 0, 1, 2, 7, 0]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 8), [[0, 0, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 8), [[2, 2, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 8), [[4, 4, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 8), [[7, 7, 7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 8), [[0, 0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 8), [[4, 4, 3, 3, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 8), [[7, 7, 6, 6, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 8), [[0, 0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 8), [[2, 1, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 8), [[0, 1, 0, 1, 1, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 8), [[2, 2, 2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 8), [[5, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 8), [[6, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 8), [[4, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 8), [[2, 5, 5, 5, 5, 5, 5, 5]])
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(commands, size):
    values=[0]*size
    out=[]
    for cmd in commands:
        if cmd[0]=='seed': values=[cmd[1][i%len(cmd[1])] & 7 for i in range(size)]; continue
        mask,reference,readmask,writemask,comparison,onpass,onfail=cmd
        for i in range(size):
            if i not in mask: continue
            old=values[i]
            left=old & readmask
            right=reference & 7
            passed=(left==right if comparison=='equal' else left<right if comparison=='less' else left!=right)
            op=onpass if passed else onfail
            if op=='keep': new=old
            elif op=='zero': new=0
            elif op=='replace': new=reference
            elif op=='inc': new=min(7,old+1)
            elif op=='dec': new=max(0,old-1)
            else: new=old^7
            values[i]=((old & (~writemask & 7)) | (new & writemask)) & 7
        out.append(list(values))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 4), [[1, 2, 7, 0]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 4), [[0, 0, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 4), [[2, 2, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 4), [[4, 4, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 4), [[7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 4), [[0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 4), [[4, 4, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 4), [[7, 7, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 4), [[0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 4), [[2, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 4), [[0, 1, 0, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 4), [[2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 4), [[5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 4), [[6, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 4), [[4, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 4), [[2, 5, 5, 5]])
if N == 2:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 5), [[1, 2, 7, 0, 1]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 5), [[0, 0, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 5), [[2, 2, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 5), [[4, 4, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 5), [[7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 5), [[0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 5), [[4, 4, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 5), [[7, 7, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 5), [[0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 5), [[2, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 5), [[0, 1, 0, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 5), [[2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 5), [[5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 5), [[6, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 5), [[4, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 5), [[2, 5, 5, 5, 5]])
if N == 3:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 6), [[1, 2, 7, 0, 1, 2]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 6), [[0, 0, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 6), [[2, 2, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 6), [[4, 4, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 6), [[7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 6), [[0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 6), [[4, 4, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 6), [[7, 7, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 6), [[0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 6), [[2, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 6), [[0, 1, 0, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 6), [[2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 6), [[5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 6), [[6, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 6), [[4, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 6), [[2, 5, 5, 5, 5, 5]])
if N == 4:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 7), [[1, 2, 7, 0, 1, 2, 7]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 7), [[0, 0, 5, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 7), [[2, 2, 1, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 7), [[4, 4, 0, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 7), [[7, 7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 7), [[0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 7), [[4, 4, 3, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 7), [[7, 7, 6, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 7), [[0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 7), [[2, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 7), [[0, 1, 0, 1, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 7), [[2, 2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 7), [[5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 7), [[6, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 7), [[4, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 7), [[2, 5, 5, 5, 5, 5, 5]])
if N == 5:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 8), [[1, 2, 7, 0, 1, 2, 7, 0]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 8), [[0, 0, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 8), [[2, 2, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 8), [[4, 4, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 8), [[7, 7, 7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 8), [[0, 0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 8), [[4, 4, 3, 3, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 8), [[7, 7, 6, 6, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 8), [[0, 0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 8), [[2, 1, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 8), [[0, 1, 0, 1, 1, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 8), [[2, 2, 2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 8), [[5, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 8), [[6, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 8), [[4, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 8), [[2, 5, 5, 5, 5, 5, 5, 5]])
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:
Stencil comparison masks stored bits but leaves reference metadata bits unmasked.

Finite integer stencil values use three low bits. A clip pass compares masked stored values to masked reference, then applies distinct pass/fail operations only inside the incoming coverage set. Write masking preserves unrelated bits. Supported operations keep, zero, replace, saturating increment/decrement and invert.

split: open-access


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

N = 1
observations = []
def solve(commands, size):
    values=[0]*size
    out=[]
    for cmd in commands:
        if cmd[0]=='seed': values=[cmd[1][i%len(cmd[1])] & 7 for i in range(size)]; continue
        mask,reference,readmask,writemask,comparison,onpass,onfail=cmd
        for i in range(size):
            if i not in mask: continue
            old=values[i]
            left=old & readmask
            right=reference & readmask
            passed=(left==right if comparison=='equal' else right<left if comparison=='less' else left!=right)
            op=onpass if passed else onfail
            if op=='keep': new=old
            elif op=='zero': new=0
            elif op=='replace': new=reference
            elif op=='inc': new=min(7,old+1)
            elif op=='dec': new=max(0,old-1)
            else: new=old^7
            values[i]=((old & (~writemask & 7)) | (new & writemask)) & 7
        out.append(list(values))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 4), [[1, 2, 7, 0]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 4), [[0, 0, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 4), [[2, 2, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 4), [[4, 4, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 4), [[7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 4), [[0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 4), [[4, 4, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 4), [[7, 7, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 4), [[0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 4), [[2, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 4), [[0, 1, 0, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 4), [[2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 4), [[5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 4), [[6, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 4), [[4, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 4), [[2, 5, 5, 5]])
if N == 2:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 5), [[1, 2, 7, 0, 1]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 5), [[0, 0, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 5), [[2, 2, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 5), [[4, 4, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 5), [[7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 5), [[0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 5), [[4, 4, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 5), [[7, 7, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 5), [[0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 5), [[2, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 5), [[0, 1, 0, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 5), [[2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 5), [[5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 5), [[6, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 5), [[4, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 5), [[2, 5, 5, 5, 5]])
if N == 3:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 6), [[1, 2, 7, 0, 1, 2]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 6), [[0, 0, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 6), [[2, 2, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 6), [[4, 4, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 6), [[7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 6), [[0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 6), [[4, 4, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 6), [[7, 7, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 6), [[0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 6), [[2, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 6), [[0, 1, 0, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 6), [[2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 6), [[5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 6), [[6, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 6), [[4, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 6), [[2, 5, 5, 5, 5, 5]])
if N == 4:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 7), [[1, 2, 7, 0, 1, 2, 7]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 7), [[0, 0, 5, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 7), [[2, 2, 1, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 7), [[4, 4, 0, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 7), [[7, 7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 7), [[0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 7), [[4, 4, 3, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 7), [[7, 7, 6, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 7), [[0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 7), [[2, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 7), [[0, 1, 0, 1, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 7), [[2, 2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 7), [[5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 7), [[6, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 7), [[4, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 7), [[2, 5, 5, 5, 5, 5, 5]])
if N == 5:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 8), [[1, 2, 7, 0, 1, 2, 7, 0]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 8), [[0, 0, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 8), [[2, 2, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 8), [[4, 4, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 8), [[7, 7, 7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 8), [[0, 0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 8), [[4, 4, 3, 3, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 8), [[7, 7, 6, 6, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 8), [[0, 0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 8), [[2, 1, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 8), [[0, 1, 0, 1, 1, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 8), [[2, 2, 2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 8), [[5, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 8), [[6, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 8), [[4, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 8), [[2, 5, 5, 5, 5, 5, 5, 5]])
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(commands, size):
    values=[0]*size
    out=[]
    for cmd in commands:
        if cmd[0]=='seed': values=[cmd[1][i%len(cmd[1])] & 7 for i in range(size)]; continue
        mask,reference,readmask,writemask,comparison,onpass,onfail=cmd
        for i in range(size):
            if i not in mask: continue
            old=values[i]
            left=old & readmask
            right=reference & readmask
            passed=(left==right if comparison=='equal' else left<=right if comparison=='less' else left!=right)
            op=onpass if passed else onfail
            if op=='keep': new=old
            elif op=='zero': new=0
            elif op=='replace': new=reference
            elif op=='inc': new=min(7,old+1)
            elif op=='dec': new=max(0,old-1)
            else: new=old^7
            values[i]=((old & (~writemask & 7)) | (new & writemask)) & 7
        out.append(list(values))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 4), [[1, 2, 7, 0]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 4), [[0, 0, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 4), [[2, 2, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 4), [[4, 4, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 4), [[7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 4), [[0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 4), [[4, 4, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 4), [[7, 7, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 4), [[0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 4), [[2, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 4), [[0, 1, 0, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 4), [[2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 4), [[5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 4), [[6, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 4), [[4, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 4), [[2, 5, 5, 5]])
if N == 2:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 5), [[1, 2, 7, 0, 1]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 5), [[0, 0, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 5), [[2, 2, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 5), [[4, 4, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 5), [[7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 5), [[0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 5), [[4, 4, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 5), [[7, 7, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 5), [[0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 5), [[2, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 5), [[0, 1, 0, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 5), [[2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 5), [[5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 5), [[6, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 5), [[4, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 5), [[2, 5, 5, 5, 5]])
if N == 3:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 6), [[1, 2, 7, 0, 1, 2]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 6), [[0, 0, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 6), [[2, 2, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 6), [[4, 4, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 6), [[7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 6), [[0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 6), [[4, 4, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 6), [[7, 7, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 6), [[0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 6), [[2, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 6), [[0, 1, 0, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 6), [[2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 6), [[5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 6), [[6, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 6), [[4, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 6), [[2, 5, 5, 5, 5, 5]])
if N == 4:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 7), [[1, 2, 7, 0, 1, 2, 7]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 7), [[0, 0, 5, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 7), [[2, 2, 1, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 7), [[4, 4, 0, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 7), [[7, 7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 7), [[0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 7), [[4, 4, 3, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 7), [[7, 7, 6, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 7), [[0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 7), [[2, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 7), [[0, 1, 0, 1, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 7), [[2, 2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 7), [[5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 7), [[6, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 7), [[4, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 7), [[2, 5, 5, 5, 5, 5, 5]])
if N == 5:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 8), [[1, 2, 7, 0, 1, 2, 7, 0]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 8), [[0, 0, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 8), [[2, 2, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 8), [[4, 4, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 8), [[7, 7, 7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 8), [[0, 0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 8), [[4, 4, 3, 3, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 8), [[7, 7, 6, 6, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 8), [[0, 0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 8), [[2, 1, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 8), [[0, 1, 0, 1, 1, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 8), [[2, 2, 2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 8), [[5, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 8), [[6, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 8), [[4, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 8), [[2, 5, 5, 5, 5, 5, 5, 5]])
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 less comparison reverses reference and stored stencil operands.

Finite integer stencil values use three low bits. A clip pass compares masked stored values to masked reference, then applies distinct pass/fail operations only inside the incoming coverage set. Write masking preserves unrelated bits. Supported operations keep, zero, replace, saturating increment/decrement and invert.

split: open-access


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

N = 1
observations = []
def solve(commands, size):
    values=[0]*size
    out=[]
    for cmd in commands:
        if cmd[0]=='seed': values=[cmd[1][i%len(cmd[1])] & 7 for i in range(size)]; continue
        mask,reference,readmask,writemask,comparison,onpass,onfail=cmd
        for i in range(size):
            if i not in mask: continue
            old=values[i]
            left=old & readmask
            right=reference & readmask
            passed=(left==right if comparison=='equal' else left<right if comparison=='less' else left!=right)
            op=onpass
            if op=='keep': new=old
            elif op=='zero': new=0
            elif op=='replace': new=reference
            elif op=='inc': new=min(7,old+1)
            elif op=='dec': new=max(0,old-1)
            else: new=old^7
            values[i]=((old & (~writemask & 7)) | (new & writemask)) & 7
        out.append(list(values))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 4), [[1, 2, 7, 0]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 4), [[0, 0, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 4), [[2, 2, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 4), [[4, 4, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 4), [[7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 4), [[0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 4), [[4, 4, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 4), [[7, 7, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 4), [[0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 4), [[2, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 4), [[0, 1, 0, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 4), [[2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 4), [[5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 4), [[6, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 4), [[4, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 4), [[2, 5, 5, 5]])
if N == 2:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 5), [[1, 2, 7, 0, 1]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 5), [[0, 0, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 5), [[2, 2, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 5), [[4, 4, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 5), [[7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 5), [[0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 5), [[4, 4, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 5), [[7, 7, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 5), [[0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 5), [[2, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 5), [[0, 1, 0, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 5), [[2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 5), [[5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 5), [[6, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 5), [[4, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 5), [[2, 5, 5, 5, 5]])
if N == 3:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 6), [[1, 2, 7, 0, 1, 2]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 6), [[0, 0, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 6), [[2, 2, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 6), [[4, 4, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 6), [[7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 6), [[0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 6), [[4, 4, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 6), [[7, 7, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 6), [[0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 6), [[2, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 6), [[0, 1, 0, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 6), [[2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 6), [[5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 6), [[6, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 6), [[4, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 6), [[2, 5, 5, 5, 5, 5]])
if N == 4:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 7), [[1, 2, 7, 0, 1, 2, 7]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 7), [[0, 0, 5, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 7), [[2, 2, 1, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 7), [[4, 4, 0, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 7), [[7, 7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 7), [[0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 7), [[4, 4, 3, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 7), [[7, 7, 6, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 7), [[0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 7), [[2, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 7), [[0, 1, 0, 1, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 7), [[2, 2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 7), [[5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 7), [[6, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 7), [[4, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 7), [[2, 5, 5, 5, 5, 5, 5]])
if N == 5:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 8), [[1, 2, 7, 0, 1, 2, 7, 0]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 8), [[0, 0, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 8), [[2, 2, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 8), [[4, 4, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 8), [[7, 7, 7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 8), [[0, 0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 8), [[4, 4, 3, 3, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 8), [[7, 7, 6, 6, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 8), [[0, 0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 8), [[2, 1, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 8), [[0, 1, 0, 1, 1, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 8), [[2, 2, 2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 8), [[5, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 8), [[6, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 8), [[4, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 8), [[2, 5, 5, 5, 5, 5, 5, 5]])
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(commands, size):
    values=[0]*size
    out=[]
    for cmd in commands:
        if cmd[0]=='seed': values=[cmd[1][i%len(cmd[1])] & 7 for i in range(size)]; continue
        mask,reference,readmask,writemask,comparison,onpass,onfail=cmd
        for i in range(size):
            if i not in mask: continue
            old=values[i]
            left=old & readmask
            right=reference & readmask
            passed=(left==right if comparison=='equal' else left<right if comparison=='less' else left!=right)
            op=onpass if passed else 'keep'
            if op=='keep': new=old
            elif op=='zero': new=0
            elif op=='replace': new=reference
            elif op=='inc': new=min(7,old+1)
            elif op=='dec': new=max(0,old-1)
            else: new=old^7
            values[i]=((old & (~writemask & 7)) | (new & writemask)) & 7
        out.append(list(values))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 4), [[1, 2, 7, 0]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 4), [[0, 0, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 4), [[2, 2, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 4), [[4, 4, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 4), [[7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 4), [[0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 4), [[4, 4, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 4), [[7, 7, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 4), [[0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 4), [[2, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 4), [[0, 1, 0, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 4), [[2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 4), [[5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 4), [[6, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 4), [[4, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 4), [[2, 5, 5, 5]])
if N == 2:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 5), [[1, 2, 7, 0, 1]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 5), [[0, 0, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 5), [[2, 2, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 5), [[4, 4, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 5), [[7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 5), [[0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 5), [[4, 4, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 5), [[7, 7, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 5), [[0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 5), [[2, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 5), [[0, 1, 0, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 5), [[2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 5), [[5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 5), [[6, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 5), [[4, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 5), [[2, 5, 5, 5, 5]])
if N == 3:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 6), [[1, 2, 7, 0, 1, 2]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 6), [[0, 0, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 6), [[2, 2, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 6), [[4, 4, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 6), [[7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 6), [[0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 6), [[4, 4, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 6), [[7, 7, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 6), [[0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 6), [[2, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 6), [[0, 1, 0, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 6), [[2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 6), [[5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 6), [[6, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 6), [[4, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 6), [[2, 5, 5, 5, 5, 5]])
if N == 4:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 7), [[1, 2, 7, 0, 1, 2, 7]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 7), [[0, 0, 5, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 7), [[2, 2, 1, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 7), [[4, 4, 0, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 7), [[7, 7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 7), [[0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 7), [[4, 4, 3, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 7), [[7, 7, 6, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 7), [[0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 7), [[2, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 7), [[0, 1, 0, 1, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 7), [[2, 2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 7), [[5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 7), [[6, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 7), [[4, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 7), [[2, 5, 5, 5, 5, 5, 5]])
if N == 5:
    check('explicit sequence 0', solve([['seed', [1, 2, 7, 0]], [[0], 1, 7, 7, 'equal', 'keep', 'zero']], 8), [[1, 2, 7, 0, 1, 2, 7, 0]])
    check('explicit sequence 1', solve([['seed', [5]], [[0, 1], 1, 3, 7, 'equal', 'zero', 'keep']], 8), [[0, 0, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 2', solve([['seed', [1]], [[0, 1], 2, 7, 7, 'less', 'replace', 'zero']], 8), [[2, 2, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 3', solve([['seed', [0]], [[0, 1], 4, 0, 7, 'equal', 'replace', 'keep']], 8), [[4, 4, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 4', solve([['seed', [7]], [[0, 1], 0, 7, 7, 'equal', 'keep', 'inc']], 8), [[7, 7, 7, 7, 7, 7, 7, 7]])
    check('explicit sequence 5', solve([['seed', [0]], [[0, 1], 0, 7, 7, 'equal', 'dec', 'keep']], 8), [[0, 0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 6', solve([['seed', [3]], [[0, 1], 3, 7, 7, 'equal', 'invert', 'keep']], 8), [[4, 4, 3, 3, 3, 3, 3, 3]])
    check('explicit sequence 7', solve([['seed', [6]], [[0, 1], 1, 7, 1, 'not', 'replace', 'zero']], 8), [[7, 7, 6, 6, 6, 6, 6, 6]])
    check('explicit sequence 8', solve([['seed', [0]], [[], 0, 7, 7, 'equal', 'inc', 'keep']], 8), [[0, 0, 0, 0, 0, 0, 0, 0]])
    check('explicit sequence 9', solve([['seed', [1]], [[0], 2, 7, 7, 'equal', 'zero', 'replace']], 8), [[2, 1, 1, 1, 1, 1, 1, 1]])
    check('explicit sequence 10', solve([['seed', [1]], [[0, 2], 1, 7, 7, 'equal', 'zero', 'keep']], 8), [[0, 1, 0, 1, 1, 1, 1, 1]])
    check('explicit sequence 11', solve([['seed', [2]], [[0], 2, 7, 7, 'less', 'zero', 'keep']], 8), [[2, 2, 2, 2, 2, 2, 2, 2]])
    check('explicit sequence 12', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'keep', 'zero']], 8), [[5, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 13', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'inc', 'zero']], 8), [[6, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 14', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'dec', 'zero']], 8), [[4, 5, 5, 5, 5, 5, 5, 5]])
    check('explicit sequence 15', solve([['seed', [5]], [[0], 1, 3, 7, 'equal', 'invert', 'zero']], 8), [[2, 5, 5, 5, 5, 5, 5, 5]])
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:
Failed stencil comparisons execute the success operation.

Finite integer stencil values use three low bits. A clip pass compares masked stored values to masked reference, then applies distinct pass/fail operations only inside the incoming coverage set. Write masking preserves unrelated bits. Supported operations keep, zero, replace, saturating increment/decrement and invert.

split: open-access