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

N = 1
observations = []
def solve(*args):
    regs, stmts, cycles = args
    regs = dict(regs)
    hist = []
    def ev(op, a, b, env):
        if op == 'copy': return env[a]
        if op == 'inv': return 1 - env[a]
        if op == 'and': return env[a] & env[b]
        return env[a] ^ env[b]
    for _ in range(cycles):
        cur = dict(regs)
        nba = []
        for kind, lhs, op, a, b in stmts:
            v = ev(op, a, b, cur)
            if kind == 'b':
                cur[lhs] = v
            else:
                nba.append((lhs, v))
        for lhs, v in nba:
            cur[lhs] = v
        regs.update(dict(nba))
        hist.append([regs[k] for k in sorted(regs)])
    return hist
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('non-blocking swap', [{'a': 1, 'b': 0}, [['nb', 'a', 'copy', 'b', None], ['nb', 'b', 'copy', 'a', None]], 1], [[0, 1]]), ('blocking chain inside one step', [{'a': 1, 't': 0, 'u': 0}, [['b', 't', 'inv', 'a', None], ['b', 'u', 'copy', 't', None], ['nb', 'a', 'copy', 'u', None]], 2], [[0, 0, 0], [1, 1, 1]]), ('later non-blocking write wins', [{'a': 1, 'c': 0}, [['nb', 'c', 'copy', 'a', None], ['nb', 'c', 'inv', 'a', None], ['nb', 'a', 'inv', 'a', None]], 2], [[0, 0], [1, 1]]), ('blocking temp persists across cycles', [{'t': 0, 'c': 0}, [['nb', 'c', 'copy', 't', None], ['b', 't', 'inv', 't', None]], 2], [[0, 1], [1, 0]]), ('shift register with non-blocking', [{'s0': 1, 's1': 0, 's2': 0}, [['nb', 's1', 'copy', 's0', None], ['nb', 's2', 'copy', 's1', None], ['nb', 's0', 'xor', 's2', 's1']], 3], [[0, 1, 0], [1, 0, 1], [1, 1, 0]]), ('non-blocking reads blocking result', [{'a': 1, 'b': 1, 'y': 0, 'm': 0}, [['b', 'm', 'and', 'a', 'b'], ['nb', 'y', 'xor', 'm', 'y'], ['nb', 'a', 'inv', 'b', None]], 1], [[0, 1, 1, 1]])], [('non-blocking swap', [{'a': 1, 'b': 0}, [['nb', 'a', 'copy', 'b', None], ['nb', 'b', 'copy', 'a', None]], 2], [[0, 1], [1, 0]]), ('blocking chain inside one step', [{'a': 0, 't': 0, 'u': 0}, [['b', 't', 'inv', 'a', None], ['b', 'u', 'copy', 't', None], ['nb', 'a', 'copy', 'u', None]], 2], [[1, 1, 1], [0, 0, 0]]), ('later non-blocking write wins', [{'a': 1, 'c': 0}, [['nb', 'c', 'copy', 'a', None], ['nb', 'c', 'inv', 'a', None], ['nb', 'a', 'inv', 'a', None]], 3], [[0, 0], [1, 1], [0, 0]]), ('blocking temp persists across cycles', [{'t': 0, 'c': 0}, [['nb', 'c', 'copy', 't', None], ['b', 't', 'inv', 't', None]], 3], [[0, 1], [1, 0], [0, 1]]), ('shift register with non-blocking', [{'s0': 1, 's1': 0, 's2': 0}, [['nb', 's1', 'copy', 's0', None], ['nb', 's2', 'copy', 's1', None], ['nb', 's0', 'xor', 's2', 's1']], 4], [[0, 1, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]), ('non-blocking reads blocking result', [{'a': 1, 'b': 1, 'y': 0, 'm': 0}, [['b', 'm', 'and', 'a', 'b'], ['nb', 'y', 'xor', 'm', 'y'], ['nb', 'a', 'inv', 'b', None]], 2], [[0, 1, 1, 1], [0, 1, 0, 1]])], [('non-blocking swap', [{'a': 1, 'b': 0}, [['nb', 'a', 'copy', 'b', None], ['nb', 'b', 'copy', 'a', None]], 3], [[0, 1], [1, 0], [0, 1]]), ('blocking chain inside one step', [{'a': 1, 't': 0, 'u': 0}, [['b', 't', 'inv', 'a', None], ['b', 'u', 'copy', 't', None], ['nb', 'a', 'copy', 'u', None]], 2], [[0, 0, 0], [1, 1, 1]]), ('later non-blocking write wins', [{'a': 1, 'c': 0}, [['nb', 'c', 'copy', 'a', None], ['nb', 'c', 'inv', 'a', None], ['nb', 'a', 'inv', 'a', None]], 4], [[0, 0], [1, 1], [0, 0], [1, 1]]), ('blocking temp persists across cycles', [{'t': 0, 'c': 0}, [['nb', 'c', 'copy', 't', None], ['b', 't', 'inv', 't', None]], 4], [[0, 1], [1, 0], [0, 1], [1, 0]]), ('shift register with non-blocking', [{'s0': 1, 's1': 0, 's2': 0}, [['nb', 's1', 'copy', 's0', None], ['nb', 's2', 'copy', 's1', None], ['nb', 's0', 'xor', 's2', 's1']], 5], [[0, 1, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1], [0, 1, 1]]), ('non-blocking reads blocking result', [{'a': 1, 'b': 1, 'y': 0, 'm': 0}, [['b', 'm', 'and', 'a', 'b'], ['nb', 'y', 'xor', 'm', 'y'], ['nb', 'a', 'inv', 'b', None]], 3], [[0, 1, 1, 1], [0, 1, 0, 1], [0, 1, 0, 1]])], [('non-blocking swap', [{'a': 1, 'b': 0}, [['nb', 'a', 'copy', 'b', None], ['nb', 'b', 'copy', 'a', None]], 4], [[0, 1], [1, 0], [0, 1], [1, 0]]), ('blocking chain inside one step', [{'a': 0, 't': 0, 'u': 0}, [['b', 't', 'inv', 'a', None], ['b', 'u', 'copy', 't', None], ['nb', 'a', 'copy', 'u', None]], 2], [[1, 1, 1], [0, 0, 0]]), ('later non-blocking write wins', [{'a': 1, 'c': 0}, [['nb', 'c', 'copy', 'a', None], ['nb', 'c', 'inv', 'a', None], ['nb', 'a', 'inv', 'a', None]], 5], [[0, 0], [1, 1], [0, 0], [1, 1], [0, 0]]), ('blocking temp persists across cycles', [{'t': 0, 'c': 0}, [['nb', 'c', 'copy', 't', None], ['b', 't', 'inv', 't', None]], 5], [[0, 1], [1, 0], [0, 1], [1, 0], [0, 1]]), ('shift register with non-blocking', [{'s0': 1, 's1': 0, 's2': 0}, [['nb', 's1', 'copy', 's0', None], ['nb', 's2', 'copy', 's1', None], ['nb', 's0', 'xor', 's2', 's1']], 6], [[0, 1, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1], [0, 1, 1], [0, 0, 1]]), ('non-blocking reads blocking result', [{'a': 1, 'b': 1, 'y': 0, 'm': 0}, [['b', 'm', 'and', 'a', 'b'], ['nb', 'y', 'xor', 'm', 'y'], ['nb', 'a', 'inv', 'b', None]], 4], [[0, 1, 1, 1], [0, 1, 0, 1], [0, 1, 0, 1], [0, 1, 0, 1]])], [('non-blocking swap', [{'a': 1, 'b': 0}, [['nb', 'a', 'copy', 'b', None], ['nb', 'b', 'copy', 'a', None]], 5], [[0, 1], [1, 0], [0, 1], [1, 0], [0, 1]]), ('blocking chain inside one step', [{'a': 1, 't': 0, 'u': 0}, [['b', 't', 'inv', 'a', None], ['b', 'u', 'copy', 't', None], ['nb', 'a', 'copy', 'u', None]], 2], [[0, 0, 0], [1, 1, 1]]), ('later non-blocking write wins', [{'a': 1, 'c': 0}, [['nb', 'c', 'copy', 'a', None], ['nb', 'c', 'inv', 'a', None], ['nb', 'a', 'inv', 'a', None]], 6], [[0, 0], [1, 1], [0, 0], [1, 1], [0, 0], [1, 1]]), ('blocking temp persists across cycles', [{'t': 0, 'c': 0}, [['nb', 'c', 'copy', 't', None], ['b', 't', 'inv', 't', None]], 6], [[0, 1], [1, 0], [0, 1], [1, 0], [0, 1], [1, 0]]), ('shift register with non-blocking', [{'s0': 1, 's1': 0, 's2': 0}, [['nb', 's1', 'copy', 's0', None], ['nb', 's2', 'copy', 's1', None], ['nb', 's0', 'xor', 's2', 's1']], 7], [[0, 1, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1], [0, 1, 1], [0, 0, 1], [1, 0, 0]]), ('non-blocking reads blocking result', [{'a': 1, 'b': 1, 'y': 0, 'm': 0}, [['b', 'm', 'and', 'a', 'b'], ['nb', 'y', 'xor', 'm', 'y'], ['nb', 'a', 'inv', 'b', None]], 5], [[0, 1, 1, 1], [0, 1, 0, 1], [0, 1, 0, 1], [0, 1, 0, 1], [0, 1, 0, 1]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(*args):
    regs, stmts, cycles = args
    regs = dict(regs)
    hist = []
    def ev(op, a, b, env):
        if op == 'copy': return env[a]
        if op == 'inv': return 1 - env[a]
        if op == 'and': return env[a] & env[b]
        return env[a] ^ env[b]
    for _ in range(cycles):
        cur = dict(regs)
        nba = []
        for kind, lhs, op, a, b in stmts:
            v = ev(op, a, b, cur)
            if kind == 'b':
                cur[lhs] = v
            else:
                nba.append((lhs, v))
        for lhs, v in nba:
            cur[lhs] = v
        regs.update({k: v for k, v in cur.items() if any(s[1] == k and s[0] == 'nb' for s in stmts)})
        hist.append([regs[k] for k in sorted(regs)])
    return hist
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('non-blocking swap', [{'a': 1, 'b': 0}, [['nb', 'a', 'copy', 'b', None], ['nb', 'b', 'copy', 'a', None]], 1], [[0, 1]]), ('blocking chain inside one step', [{'a': 1, 't': 0, 'u': 0}, [['b', 't', 'inv', 'a', None], ['b', 'u', 'copy', 't', None], ['nb', 'a', 'copy', 'u', None]], 2], [[0, 0, 0], [1, 1, 1]]), ('later non-blocking write wins', [{'a': 1, 'c': 0}, [['nb', 'c', 'copy', 'a', None], ['nb', 'c', 'inv', 'a', None], ['nb', 'a', 'inv', 'a', None]], 2], [[0, 0], [1, 1]]), ('blocking temp persists across cycles', [{'t': 0, 'c': 0}, [['nb', 'c', 'copy', 't', None], ['b', 't', 'inv', 't', None]], 2], [[0, 1], [1, 0]]), ('shift register with non-blocking', [{'s0': 1, 's1': 0, 's2': 0}, [['nb', 's1', 'copy', 's0', None], ['nb', 's2', 'copy', 's1', None], ['nb', 's0', 'xor', 's2', 's1']], 3], [[0, 1, 0], [1, 0, 1], [1, 1, 0]]), ('non-blocking reads blocking result', [{'a': 1, 'b': 1, 'y': 0, 'm': 0}, [['b', 'm', 'and', 'a', 'b'], ['nb', 'y', 'xor', 'm', 'y'], ['nb', 'a', 'inv', 'b', None]], 1], [[0, 1, 1, 1]])], [('non-blocking swap', [{'a': 1, 'b': 0}, [['nb', 'a', 'copy', 'b', None], ['nb', 'b', 'copy', 'a', None]], 2], [[0, 1], [1, 0]]), ('blocking chain inside one step', [{'a': 0, 't': 0, 'u': 0}, [['b', 't', 'inv', 'a', None], ['b', 'u', 'copy', 't', None], ['nb', 'a', 'copy', 'u', None]], 2], [[1, 1, 1], [0, 0, 0]]), ('later non-blocking write wins', [{'a': 1, 'c': 0}, [['nb', 'c', 'copy', 'a', None], ['nb', 'c', 'inv', 'a', None], ['nb', 'a', 'inv', 'a', None]], 3], [[0, 0], [1, 1], [0, 0]]), ('blocking temp persists across cycles', [{'t': 0, 'c': 0}, [['nb', 'c', 'copy', 't', None], ['b', 't', 'inv', 't', None]], 3], [[0, 1], [1, 0], [0, 1]]), ('shift register with non-blocking', [{'s0': 1, 's1': 0, 's2': 0}, [['nb', 's1', 'copy', 's0', None], ['nb', 's2', 'copy', 's1', None], ['nb', 's0', 'xor', 's2', 's1']], 4], [[0, 1, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]), ('non-blocking reads blocking result', [{'a': 1, 'b': 1, 'y': 0, 'm': 0}, [['b', 'm', 'and', 'a', 'b'], ['nb', 'y', 'xor', 'm', 'y'], ['nb', 'a', 'inv', 'b', None]], 2], [[0, 1, 1, 1], [0, 1, 0, 1]])], [('non-blocking swap', [{'a': 1, 'b': 0}, [['nb', 'a', 'copy', 'b', None], ['nb', 'b', 'copy', 'a', None]], 3], [[0, 1], [1, 0], [0, 1]]), ('blocking chain inside one step', [{'a': 1, 't': 0, 'u': 0}, [['b', 't', 'inv', 'a', None], ['b', 'u', 'copy', 't', None], ['nb', 'a', 'copy', 'u', None]], 2], [[0, 0, 0], [1, 1, 1]]), ('later non-blocking write wins', [{'a': 1, 'c': 0}, [['nb', 'c', 'copy', 'a', None], ['nb', 'c', 'inv', 'a', None], ['nb', 'a', 'inv', 'a', None]], 4], [[0, 0], [1, 1], [0, 0], [1, 1]]), ('blocking temp persists across cycles', [{'t': 0, 'c': 0}, [['nb', 'c', 'copy', 't', None], ['b', 't', 'inv', 't', None]], 4], [[0, 1], [1, 0], [0, 1], [1, 0]]), ('shift register with non-blocking', [{'s0': 1, 's1': 0, 's2': 0}, [['nb', 's1', 'copy', 's0', None], ['nb', 's2', 'copy', 's1', None], ['nb', 's0', 'xor', 's2', 's1']], 5], [[0, 1, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1], [0, 1, 1]]), ('non-blocking reads blocking result', [{'a': 1, 'b': 1, 'y': 0, 'm': 0}, [['b', 'm', 'and', 'a', 'b'], ['nb', 'y', 'xor', 'm', 'y'], ['nb', 'a', 'inv', 'b', None]], 3], [[0, 1, 1, 1], [0, 1, 0, 1], [0, 1, 0, 1]])], [('non-blocking swap', [{'a': 1, 'b': 0}, [['nb', 'a', 'copy', 'b', None], ['nb', 'b', 'copy', 'a', None]], 4], [[0, 1], [1, 0], [0, 1], [1, 0]]), ('blocking chain inside one step', [{'a': 0, 't': 0, 'u': 0}, [['b', 't', 'inv', 'a', None], ['b', 'u', 'copy', 't', None], ['nb', 'a', 'copy', 'u', None]], 2], [[1, 1, 1], [0, 0, 0]]), ('later non-blocking write wins', [{'a': 1, 'c': 0}, [['nb', 'c', 'copy', 'a', None], ['nb', 'c', 'inv', 'a', None], ['nb', 'a', 'inv', 'a', None]], 5], [[0, 0], [1, 1], [0, 0], [1, 1], [0, 0]]), ('blocking temp persists across cycles', [{'t': 0, 'c': 0}, [['nb', 'c', 'copy', 't', None], ['b', 't', 'inv', 't', None]], 5], [[0, 1], [1, 0], [0, 1], [1, 0], [0, 1]]), ('shift register with non-blocking', [{'s0': 1, 's1': 0, 's2': 0}, [['nb', 's1', 'copy', 's0', None], ['nb', 's2', 'copy', 's1', None], ['nb', 's0', 'xor', 's2', 's1']], 6], [[0, 1, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1], [0, 1, 1], [0, 0, 1]]), ('non-blocking reads blocking result', [{'a': 1, 'b': 1, 'y': 0, 'm': 0}, [['b', 'm', 'and', 'a', 'b'], ['nb', 'y', 'xor', 'm', 'y'], ['nb', 'a', 'inv', 'b', None]], 4], [[0, 1, 1, 1], [0, 1, 0, 1], [0, 1, 0, 1], [0, 1, 0, 1]])], [('non-blocking swap', [{'a': 1, 'b': 0}, [['nb', 'a', 'copy', 'b', None], ['nb', 'b', 'copy', 'a', None]], 5], [[0, 1], [1, 0], [0, 1], [1, 0], [0, 1]]), ('blocking chain inside one step', [{'a': 1, 't': 0, 'u': 0}, [['b', 't', 'inv', 'a', None], ['b', 'u', 'copy', 't', None], ['nb', 'a', 'copy', 'u', None]], 2], [[0, 0, 0], [1, 1, 1]]), ('later non-blocking write wins', [{'a': 1, 'c': 0}, [['nb', 'c', 'copy', 'a', None], ['nb', 'c', 'inv', 'a', None], ['nb', 'a', 'inv', 'a', None]], 6], [[0, 0], [1, 1], [0, 0], [1, 1], [0, 0], [1, 1]]), ('blocking temp persists across cycles', [{'t': 0, 'c': 0}, [['nb', 'c', 'copy', 't', None], ['b', 't', 'inv', 't', None]], 6], [[0, 1], [1, 0], [0, 1], [1, 0], [0, 1], [1, 0]]), ('shift register with non-blocking', [{'s0': 1, 's1': 0, 's2': 0}, [['nb', 's1', 'copy', 's0', None], ['nb', 's2', 'copy', 's1', None], ['nb', 's0', 'xor', 's2', 's1']], 7], [[0, 1, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1], [0, 1, 1], [0, 0, 1], [1, 0, 0]]), ('non-blocking reads blocking result', [{'a': 1, 'b': 1, 'y': 0, 'm': 0}, [['b', 'm', 'and', 'a', 'b'], ['nb', 'y', 'xor', 'm', 'y'], ['nb', 'a', 'inv', 'b', None]], 5], [[0, 1, 1, 1], [0, 1, 0, 1], [0, 1, 0, 1], [0, 1, 0, 1], [0, 1, 0, 1]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A variable updated only by blocking assignment restarts from its initial value every step.

Input [regs, stmts, cycles]. Each clock step executes stmts [kind, lhs, op, a, b] in order (ops copy/inv/and/xor on 0/1). Blocking ('b') statements update the working state immediately; non-blocking ('nb') statements evaluate their right side at the statement against the working state and queue the update. After all statements, queued updates apply in statement order (last write wins). Every variable, blocking or not, keeps its value into the next step. Return per-step values sorted by variable name.

split: open-access


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

N = 1
observations = []
def solve(*args):
    seq = args[0]
    lvl = {'0': 0, '1': 2, 'z': 2}
    pos, neg = [], []
    prev = None
    for i, b in enumerate(seq):
        a, prev = prev, b
        if a is None or a == b:
            continue
        la, lb = lvl.get(a, 1), lvl.get(b, 1)
        if la < lb:
            pos.append(i)
        elif la > lb:
            neg.append(i)
    return [pos, neg]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain binary toggles', ['010110'], [[1, 3], [2, 5]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xzx1z'], [[3], [4]]), ('floating rising and falling', ['z1z0z'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xz0'], [[], [1, 3]]), ('starts high without a predecessor', ['110'], [[], [2]]), ('low through unknown to high', ['0x1x0'], [[1, 2], [3, 4]])], [('plain binary toggles', ['0101110'], [[1, 3], [2, 6]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxzx1z'], [[4], [5]]), ('floating rising and falling', ['z1z0zz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxz0'], [[], [1, 4]]), ('starts high without a predecessor', ['1100'], [[], [2]]), ('low through unknown to high', ['00x1x0'], [[2, 3], [4, 5]])], [('plain binary toggles', ['01011110'], [[1, 3], [2, 7]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxzx1z'], [[5], [6]]), ('floating rising and falling', ['z1z0zzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxz0'], [[], [1, 5]]), ('starts high without a predecessor', ['11000'], [[], [2]]), ('low through unknown to high', ['000x1x0'], [[3, 4], [5, 6]])], [('plain binary toggles', ['010111110'], [[1, 3], [2, 8]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxzx1z'], [[6], [7]]), ('floating rising and falling', ['z1z0zzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxz0'], [[], [1, 6]]), ('starts high without a predecessor', ['110000'], [[], [2]]), ('low through unknown to high', ['0000x1x0'], [[4, 5], [6, 7]])], [('plain binary toggles', ['0101111110'], [[1, 3], [2, 9]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxxzx1z'], [[7], [8]]), ('floating rising and falling', ['z1z0zzzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxxz0'], [[], [1, 7]]), ('starts high without a predecessor', ['1100000'], [[], [2]]), ('low through unknown to high', ['00000x1x0'], [[5, 6], [7, 8]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(*args):
    seq = args[0]
    lvl = {'0': 0, '1': 2, 'z': 0}
    pos, neg = [], []
    prev = None
    for i, b in enumerate(seq):
        a, prev = prev, b
        if a is None or a == b:
            continue
        la, lb = lvl.get(a, 1), lvl.get(b, 1)
        if la < lb:
            pos.append(i)
        elif la > lb:
            neg.append(i)
    return [pos, neg]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain binary toggles', ['010110'], [[1, 3], [2, 5]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xzx1z'], [[3], [4]]), ('floating rising and falling', ['z1z0z'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xz0'], [[], [1, 3]]), ('starts high without a predecessor', ['110'], [[], [2]]), ('low through unknown to high', ['0x1x0'], [[1, 2], [3, 4]])], [('plain binary toggles', ['0101110'], [[1, 3], [2, 6]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxzx1z'], [[4], [5]]), ('floating rising and falling', ['z1z0zz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxz0'], [[], [1, 4]]), ('starts high without a predecessor', ['1100'], [[], [2]]), ('low through unknown to high', ['00x1x0'], [[2, 3], [4, 5]])], [('plain binary toggles', ['01011110'], [[1, 3], [2, 7]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxzx1z'], [[5], [6]]), ('floating rising and falling', ['z1z0zzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxz0'], [[], [1, 5]]), ('starts high without a predecessor', ['11000'], [[], [2]]), ('low through unknown to high', ['000x1x0'], [[3, 4], [5, 6]])], [('plain binary toggles', ['010111110'], [[1, 3], [2, 8]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxzx1z'], [[6], [7]]), ('floating rising and falling', ['z1z0zzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxz0'], [[], [1, 6]]), ('starts high without a predecessor', ['110000'], [[], [2]]), ('low through unknown to high', ['0000x1x0'], [[4, 5], [6, 7]])], [('plain binary toggles', ['0101111110'], [[1, 3], [2, 9]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxxzx1z'], [[7], [8]]), ('floating rising and falling', ['z1z0zzzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxxz0'], [[], [1, 7]]), ('starts high without a predecessor', ['1100000'], [[], [2]]), ('low through unknown to high', ['00000x1x0'], [[5, 6], [7, 8]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Transitions into z are classified as rising and z->1 is not an edge.

Input [seq]: a string of samples over '0','1','x','z'. Levels order 0 < {x,z} < 1 (x and z are the same middle level). A change to a higher level is a posedge (0->1, 0->x, 0->z, x->1, z->1), to a lower level a negedge; x<->z is no edge. The first sample has no predecessor. Return [posedge indices, negedge indices].

split: open-access


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

N = 1
observations = []
def solve(*args):
    seq = args[0]
    lvl = {'0': 0, '1': 2}
    pos, neg = [], []
    prev = None
    for i, b in enumerate(seq):
        a, prev = prev, b
        if a is None or a == b:
            continue
        la, lb = lvl.get(a, 1), lvl.get(b, 1)
        if la <= lb:
            pos.append(i)
        elif la > lb:
            neg.append(i)
    return [pos, neg]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain binary toggles', ['010110'], [[1, 3], [2, 5]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xzx1z'], [[3], [4]]), ('floating rising and falling', ['z1z0z'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xz0'], [[], [1, 3]]), ('starts high without a predecessor', ['110'], [[], [2]]), ('low through unknown to high', ['0x1x0'], [[1, 2], [3, 4]])], [('plain binary toggles', ['0101110'], [[1, 3], [2, 6]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxzx1z'], [[4], [5]]), ('floating rising and falling', ['z1z0zz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxz0'], [[], [1, 4]]), ('starts high without a predecessor', ['1100'], [[], [2]]), ('low through unknown to high', ['00x1x0'], [[2, 3], [4, 5]])], [('plain binary toggles', ['01011110'], [[1, 3], [2, 7]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxzx1z'], [[5], [6]]), ('floating rising and falling', ['z1z0zzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxz0'], [[], [1, 5]]), ('starts high without a predecessor', ['11000'], [[], [2]]), ('low through unknown to high', ['000x1x0'], [[3, 4], [5, 6]])], [('plain binary toggles', ['010111110'], [[1, 3], [2, 8]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxzx1z'], [[6], [7]]), ('floating rising and falling', ['z1z0zzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxz0'], [[], [1, 6]]), ('starts high without a predecessor', ['110000'], [[], [2]]), ('low through unknown to high', ['0000x1x0'], [[4, 5], [6, 7]])], [('plain binary toggles', ['0101111110'], [[1, 3], [2, 9]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxxzx1z'], [[7], [8]]), ('floating rising and falling', ['z1z0zzzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxxz0'], [[], [1, 7]]), ('starts high without a predecessor', ['1100000'], [[], [2]]), ('low through unknown to high', ['00000x1x0'], [[5, 6], [7, 8]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(*args):
    seq = args[0]
    lvl = {'0': 0, '1': 2}
    pos, neg = [], []
    prev = None
    for i, b in enumerate(seq):
        a, prev = prev, b
        if a is None or a == b:
            continue
        la, lb = lvl.get(a, 1), lvl.get(b, 1)
        if la < lb or (la == lb and b == 'z'):
            pos.append(i)
        elif la > lb:
            neg.append(i)
    return [pos, neg]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain binary toggles', ['010110'], [[1, 3], [2, 5]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xzx1z'], [[3], [4]]), ('floating rising and falling', ['z1z0z'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xz0'], [[], [1, 3]]), ('starts high without a predecessor', ['110'], [[], [2]]), ('low through unknown to high', ['0x1x0'], [[1, 2], [3, 4]])], [('plain binary toggles', ['0101110'], [[1, 3], [2, 6]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxzx1z'], [[4], [5]]), ('floating rising and falling', ['z1z0zz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxz0'], [[], [1, 4]]), ('starts high without a predecessor', ['1100'], [[], [2]]), ('low through unknown to high', ['00x1x0'], [[2, 3], [4, 5]])], [('plain binary toggles', ['01011110'], [[1, 3], [2, 7]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxzx1z'], [[5], [6]]), ('floating rising and falling', ['z1z0zzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxz0'], [[], [1, 5]]), ('starts high without a predecessor', ['11000'], [[], [2]]), ('low through unknown to high', ['000x1x0'], [[3, 4], [5, 6]])], [('plain binary toggles', ['010111110'], [[1, 3], [2, 8]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxzx1z'], [[6], [7]]), ('floating rising and falling', ['z1z0zzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxz0'], [[], [1, 6]]), ('starts high without a predecessor', ['110000'], [[], [2]]), ('low through unknown to high', ['0000x1x0'], [[4, 5], [6, 7]])], [('plain binary toggles', ['0101111110'], [[1, 3], [2, 9]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxxzx1z'], [[7], [8]]), ('floating rising and falling', ['z1z0zzzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxxz0'], [[], [1, 7]]), ('starts high without a predecessor', ['1100000'], [[], [2]]), ('low through unknown to high', ['00000x1x0'], [[5, 6], [7, 8]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
An x->z or z->x transition triggers posedge event controls.

Input [seq]: a string of samples over '0','1','x','z'. Levels order 0 < {x,z} < 1 (x and z are the same middle level). A change to a higher level is a posedge (0->1, 0->x, 0->z, x->1, z->1), to a lower level a negedge; x<->z is no edge. The first sample has no predecessor. Return [posedge indices, negedge indices].

split: open-access


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

N = 1
observations = []
def solve(*args):
    seq = args[0]
    lvl = {'0': 0, '1': 2}
    pos, neg = [], []
    prev = 'x'
    for i, b in enumerate(seq):
        a, prev = prev, b
        if a is None or a == b:
            continue
        la, lb = lvl.get(a, 1), lvl.get(b, 1)
        if la < lb:
            pos.append(i)
        elif la > lb:
            neg.append(i)
    return [pos, neg]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain binary toggles', ['010110'], [[1, 3], [2, 5]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xzx1z'], [[3], [4]]), ('floating rising and falling', ['z1z0z'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xz0'], [[], [1, 3]]), ('starts high without a predecessor', ['110'], [[], [2]]), ('low through unknown to high', ['0x1x0'], [[1, 2], [3, 4]])], [('plain binary toggles', ['0101110'], [[1, 3], [2, 6]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxzx1z'], [[4], [5]]), ('floating rising and falling', ['z1z0zz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxz0'], [[], [1, 4]]), ('starts high without a predecessor', ['1100'], [[], [2]]), ('low through unknown to high', ['00x1x0'], [[2, 3], [4, 5]])], [('plain binary toggles', ['01011110'], [[1, 3], [2, 7]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxzx1z'], [[5], [6]]), ('floating rising and falling', ['z1z0zzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxz0'], [[], [1, 5]]), ('starts high without a predecessor', ['11000'], [[], [2]]), ('low through unknown to high', ['000x1x0'], [[3, 4], [5, 6]])], [('plain binary toggles', ['010111110'], [[1, 3], [2, 8]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxzx1z'], [[6], [7]]), ('floating rising and falling', ['z1z0zzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxz0'], [[], [1, 6]]), ('starts high without a predecessor', ['110000'], [[], [2]]), ('low through unknown to high', ['0000x1x0'], [[4, 5], [6, 7]])], [('plain binary toggles', ['0101111110'], [[1, 3], [2, 9]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxxzx1z'], [[7], [8]]), ('floating rising and falling', ['z1z0zzzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxxz0'], [[], [1, 7]]), ('starts high without a predecessor', ['1100000'], [[], [2]]), ('low through unknown to high', ['00000x1x0'], [[5, 6], [7, 8]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(*args):
    seq = args[0]
    lvl = {'0': 0, '1': 2}
    pos, neg = [], []
    prev = '0'
    for i, b in enumerate(seq):
        a, prev = prev, b
        if a is None or a == b:
            continue
        la, lb = lvl.get(a, 1), lvl.get(b, 1)
        if la < lb:
            pos.append(i)
        elif la > lb:
            neg.append(i)
    return [pos, neg]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain binary toggles', ['010110'], [[1, 3], [2, 5]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xzx1z'], [[3], [4]]), ('floating rising and falling', ['z1z0z'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xz0'], [[], [1, 3]]), ('starts high without a predecessor', ['110'], [[], [2]]), ('low through unknown to high', ['0x1x0'], [[1, 2], [3, 4]])], [('plain binary toggles', ['0101110'], [[1, 3], [2, 6]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxzx1z'], [[4], [5]]), ('floating rising and falling', ['z1z0zz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxz0'], [[], [1, 4]]), ('starts high without a predecessor', ['1100'], [[], [2]]), ('low through unknown to high', ['00x1x0'], [[2, 3], [4, 5]])], [('plain binary toggles', ['01011110'], [[1, 3], [2, 7]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxzx1z'], [[5], [6]]), ('floating rising and falling', ['z1z0zzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxz0'], [[], [1, 5]]), ('starts high without a predecessor', ['11000'], [[], [2]]), ('low through unknown to high', ['000x1x0'], [[3, 4], [5, 6]])], [('plain binary toggles', ['010111110'], [[1, 3], [2, 8]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxzx1z'], [[6], [7]]), ('floating rising and falling', ['z1z0zzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxz0'], [[], [1, 6]]), ('starts high without a predecessor', ['110000'], [[], [2]]), ('low through unknown to high', ['0000x1x0'], [[4, 5], [6, 7]])], [('plain binary toggles', ['0101111110'], [[1, 3], [2, 9]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxxzx1z'], [[7], [8]]), ('floating rising and falling', ['z1z0zzzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxxz0'], [[], [1, 7]]), ('starts high without a predecessor', ['1100000'], [[], [2]]), ('low through unknown to high', ['00000x1x0'], [[5, 6], [7, 8]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A signal that starts at 1 or 0 reports an edge at index 0.

Input [seq]: a string of samples over '0','1','x','z'. Levels order 0 < {x,z} < 1 (x and z are the same middle level). A change to a higher level is a posedge (0->1, 0->x, 0->z, x->1, z->1), to a lower level a negedge; x<->z is no edge. The first sample has no predecessor. Return [posedge indices, negedge indices].

split: open-access


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

N = 1
observations = []
def solve(*args):
    seq = args[0]
    lvl = {'0': 0, '1': 2}
    pos, neg = [], []
    prev = None
    for i, b in enumerate(seq):
        a, prev = prev, b
        if a is None or a == b:
            continue
        la, lb = lvl.get(a, 1), lvl.get(b, 1)
        if (a, b) == ('0', '1'):
            pos.append(i)
        elif la > lb:
            neg.append(i)
    return [pos, neg]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain binary toggles', ['010110'], [[1, 3], [2, 5]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xzx1z'], [[3], [4]]), ('floating rising and falling', ['z1z0z'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xz0'], [[], [1, 3]]), ('starts high without a predecessor', ['110'], [[], [2]]), ('low through unknown to high', ['0x1x0'], [[1, 2], [3, 4]])], [('plain binary toggles', ['0101110'], [[1, 3], [2, 6]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxzx1z'], [[4], [5]]), ('floating rising and falling', ['z1z0zz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxz0'], [[], [1, 4]]), ('starts high without a predecessor', ['1100'], [[], [2]]), ('low through unknown to high', ['00x1x0'], [[2, 3], [4, 5]])], [('plain binary toggles', ['01011110'], [[1, 3], [2, 7]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxzx1z'], [[5], [6]]), ('floating rising and falling', ['z1z0zzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxz0'], [[], [1, 5]]), ('starts high without a predecessor', ['11000'], [[], [2]]), ('low through unknown to high', ['000x1x0'], [[3, 4], [5, 6]])], [('plain binary toggles', ['010111110'], [[1, 3], [2, 8]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxzx1z'], [[6], [7]]), ('floating rising and falling', ['z1z0zzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxz0'], [[], [1, 6]]), ('starts high without a predecessor', ['110000'], [[], [2]]), ('low through unknown to high', ['0000x1x0'], [[4, 5], [6, 7]])], [('plain binary toggles', ['0101111110'], [[1, 3], [2, 9]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxxzx1z'], [[7], [8]]), ('floating rising and falling', ['z1z0zzzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxxz0'], [[], [1, 7]]), ('starts high without a predecessor', ['1100000'], [[], [2]]), ('low through unknown to high', ['00000x1x0'], [[5, 6], [7, 8]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(*args):
    seq = args[0]
    lvl = {'0': 0, '1': 2}
    pos, neg = [], []
    prev = None
    for i, b in enumerate(seq):
        a, prev = prev, b
        if a is None or a == b:
            continue
        la, lb = lvl.get(a, 1), lvl.get(b, 1)
        if la < lb and b == '1':
            pos.append(i)
        elif la > lb:
            neg.append(i)
    return [pos, neg]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain binary toggles', ['010110'], [[1, 3], [2, 5]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xzx1z'], [[3], [4]]), ('floating rising and falling', ['z1z0z'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xz0'], [[], [1, 3]]), ('starts high without a predecessor', ['110'], [[], [2]]), ('low through unknown to high', ['0x1x0'], [[1, 2], [3, 4]])], [('plain binary toggles', ['0101110'], [[1, 3], [2, 6]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxzx1z'], [[4], [5]]), ('floating rising and falling', ['z1z0zz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxz0'], [[], [1, 4]]), ('starts high without a predecessor', ['1100'], [[], [2]]), ('low through unknown to high', ['00x1x0'], [[2, 3], [4, 5]])], [('plain binary toggles', ['01011110'], [[1, 3], [2, 7]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxzx1z'], [[5], [6]]), ('floating rising and falling', ['z1z0zzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxz0'], [[], [1, 5]]), ('starts high without a predecessor', ['11000'], [[], [2]]), ('low through unknown to high', ['000x1x0'], [[3, 4], [5, 6]])], [('plain binary toggles', ['010111110'], [[1, 3], [2, 8]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxzx1z'], [[6], [7]]), ('floating rising and falling', ['z1z0zzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxz0'], [[], [1, 6]]), ('starts high without a predecessor', ['110000'], [[], [2]]), ('low through unknown to high', ['0000x1x0'], [[4, 5], [6, 7]])], [('plain binary toggles', ['0101111110'], [[1, 3], [2, 9]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxxzx1z'], [[7], [8]]), ('floating rising and falling', ['z1z0zzzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxxz0'], [[], [1, 7]]), ('starts high without a predecessor', ['1100000'], [[], [2]]), ('low through unknown to high', ['00000x1x0'], [[5, 6], [7, 8]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Rising transitions through unknown values (0->x, x->1, z->1) do not trigger posedge.

Input [seq]: a string of samples over '0','1','x','z'. Levels order 0 < {x,z} < 1 (x and z are the same middle level). A change to a higher level is a posedge (0->1, 0->x, 0->z, x->1, z->1), to a lower level a negedge; x<->z is no edge. The first sample has no predecessor. Return [posedge indices, negedge indices].

split: open-access


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

N = 1
observations = []
def solve(*args):
    seq = args[0]
    lvl = {'0': 0, '1': 2}
    pos, neg = [], []
    prev = None
    for i, b in enumerate(seq):
        a, prev = prev, b
        if a is None or a == b:
            continue
        la, lb = lvl.get(a, 1), lvl.get(b, 1)
        if la < lb:
            pos.append(i)
        elif b == '0':
            neg.append(i)
    return [pos, neg]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain binary toggles', ['010110'], [[1, 3], [2, 5]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xzx1z'], [[3], [4]]), ('floating rising and falling', ['z1z0z'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xz0'], [[], [1, 3]]), ('starts high without a predecessor', ['110'], [[], [2]]), ('low through unknown to high', ['0x1x0'], [[1, 2], [3, 4]])], [('plain binary toggles', ['0101110'], [[1, 3], [2, 6]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxzx1z'], [[4], [5]]), ('floating rising and falling', ['z1z0zz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxz0'], [[], [1, 4]]), ('starts high without a predecessor', ['1100'], [[], [2]]), ('low through unknown to high', ['00x1x0'], [[2, 3], [4, 5]])], [('plain binary toggles', ['01011110'], [[1, 3], [2, 7]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxzx1z'], [[5], [6]]), ('floating rising and falling', ['z1z0zzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxz0'], [[], [1, 5]]), ('starts high without a predecessor', ['11000'], [[], [2]]), ('low through unknown to high', ['000x1x0'], [[3, 4], [5, 6]])], [('plain binary toggles', ['010111110'], [[1, 3], [2, 8]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxzx1z'], [[6], [7]]), ('floating rising and falling', ['z1z0zzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxz0'], [[], [1, 6]]), ('starts high without a predecessor', ['110000'], [[], [2]]), ('low through unknown to high', ['0000x1x0'], [[4, 5], [6, 7]])], [('plain binary toggles', ['0101111110'], [[1, 3], [2, 9]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxxzx1z'], [[7], [8]]), ('floating rising and falling', ['z1z0zzzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxxz0'], [[], [1, 7]]), ('starts high without a predecessor', ['1100000'], [[], [2]]), ('low through unknown to high', ['00000x1x0'], [[5, 6], [7, 8]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(*args):
    seq = args[0]
    lvl = {'0': 0, '1': 2}
    pos, neg = [], []
    prev = None
    for i, b in enumerate(seq):
        a, prev = prev, b
        if a is None or a == b:
            continue
        la, lb = lvl.get(a, 1), lvl.get(b, 1)
        if la < lb:
            pos.append(i)
        elif a == '1':
            neg.append(i)
    return [pos, neg]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('plain binary toggles', ['010110'], [[1, 3], [2, 5]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xzx1z'], [[3], [4]]), ('floating rising and falling', ['z1z0z'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xz0'], [[], [1, 3]]), ('starts high without a predecessor', ['110'], [[], [2]]), ('low through unknown to high', ['0x1x0'], [[1, 2], [3, 4]])], [('plain binary toggles', ['0101110'], [[1, 3], [2, 6]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxzx1z'], [[4], [5]]), ('floating rising and falling', ['z1z0zz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxz0'], [[], [1, 4]]), ('starts high without a predecessor', ['1100'], [[], [2]]), ('low through unknown to high', ['00x1x0'], [[2, 3], [4, 5]])], [('plain binary toggles', ['01011110'], [[1, 3], [2, 7]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxzx1z'], [[5], [6]]), ('floating rising and falling', ['z1z0zzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxz0'], [[], [1, 5]]), ('starts high without a predecessor', ['11000'], [[], [2]]), ('low through unknown to high', ['000x1x0'], [[3, 4], [5, 6]])], [('plain binary toggles', ['010111110'], [[1, 3], [2, 8]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxzx1z'], [[6], [7]]), ('floating rising and falling', ['z1z0zzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxz0'], [[], [1, 6]]), ('starts high without a predecessor', ['110000'], [[], [2]]), ('low through unknown to high', ['0000x1x0'], [[4, 5], [6, 7]])], [('plain binary toggles', ['0101111110'], [[1, 3], [2, 9]]), ('edges through unknown and floating', ['0x1z0'], [[1, 2], [3, 4]]), ('unknown to floating is no edge', ['xxxxxzx1z'], [[7], [8]]), ('floating rising and falling', ['z1z0zzzzz'], [[1, 4], [2, 3]]), ('high to floating then low', ['1xxxxxz0'], [[], [1, 7]]), ('starts high without a predecessor', ['1100000'], [[], [2]]), ('low through unknown to high', ['00000x1x0'], [[5, 6], [7, 8]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
1->x and 1->z transitions are not reported as negedges.

Input [seq]: a string of samples over '0','1','x','z'. Levels order 0 < {x,z} < 1 (x and z are the same middle level). A change to a higher level is a posedge (0->1, 0->x, 0->z, x->1, z->1), to a lower level a negedge; x<->z is no edge. The first sample has no predecessor. Return [posedge indices, negedge indices].

split: open-access


prompt:
Outputs appear one cycle early, behaving like a Mealy machine.

Input [table, start, stream]: table[state] = {'out': o, 'next': {bit: state}}; stream items are [bit, rst] with bit 0/1/'x'. Each cycle outputs the current state's output (or 'x' in the unknown state 'X'), then clocks: rst==1 -> start (synchronous), else unknown input or state 'X' -> 'X', else follow next[bit], staying put if that transition is absent. Return [outputs, final state].

split: open-access


prompt:
The reset state output appears in the cycle reset is asserted instead of the following cycle.

Input [table, start, stream]: table[state] = {'out': o, 'next': {bit: state}}; stream items are [bit, rst] with bit 0/1/'x'. Each cycle outputs the current state's output (or 'x' in the unknown state 'X'), then clocks: rst==1 -> start (synchronous), else unknown input or state 'X' -> 'X', else follow next[bit], staying put if that transition is absent. Return [outputs, final state].

split: open-access


prompt:
An input with no listed transition resets the machine instead of holding its state.

Input [table, start, stream]: table[state] = {'out': o, 'next': {bit: state}}; stream items are [bit, rst] with bit 0/1/'x'. Each cycle outputs the current state's output (or 'x' in the unknown state 'X'), then clocks: rst==1 -> start (synchronous), else unknown input or state 'X' -> 'X', else follow next[bit], staying put if that transition is absent. Return [outputs, final state].

split: open-access


prompt:
An 'x' input leaves the machine in a definite state instead of the unknown state.

Input [table, start, stream]: table[state] = {'out': o, 'next': {bit: state}}; stream items are [bit, rst] with bit 0/1/'x'. Each cycle outputs the current state's output (or 'x' in the unknown state 'X'), then clocks: rst==1 -> start (synchronous), else unknown input or state 'X' -> 'X', else follow next[bit], staying put if that transition is absent. Return [outputs, final state].

split: open-access


prompt:
While the state register is unknown the output reads 0 instead of 'x'.

Input [table, start, stream]: table[state] = {'out': o, 'next': {bit: state}}; stream items are [bit, rst] with bit 0/1/'x'. Each cycle outputs the current state's output (or 'x' in the unknown state 'X'), then clocks: rst==1 -> start (synchronous), else unknown input or state 'X' -> 'X', else follow next[bit], staying put if that transition is absent. Return [outputs, final state].

split: open-access


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

N = 1
observations = []
def solve(*args):
    depth, mode, ops = args
    mem = [0] * depth
    out = []
    for we, addr, wdata, be, re in ops:
        ok = 0 <= addr < depth
        old = mem[addr] if ok else None
        new = old
        if we and ok:
            for lane in range(2):
                if be >> lane & 1:
                    mask = 0xFF << (8 * (1 - lane))
                    new = (new & ~mask) | (wdata & mask)
            mem[addr] = new
        if re:
            if not ok:
                out.append('x')
            else:
                out.append(new if mode == 'write_first' else old)
        else:
            out.append(None)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23041, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 6, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 8738, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 8738])], [('full write then read-first read', [4, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [4, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [4, 'read_first', [[1, 3, 23042, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [4, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [4, 'read_first', [[1, -1, 30583, 3, 1], [0, 3, 0, 0, 1]]], ['x', 0]), ('out of range read', [4, 'read_first', [[0, 6, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [4, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 17476, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 17476])], [('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23043, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 8, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 26214, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 26214])], [('full write then read-first read', [4, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [4, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [4, 'read_first', [[1, 3, 23044, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [4, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [4, 'read_first', [[1, -1, 30583, 3, 1], [0, 3, 0, 0, 1]]], ['x', 0]), ('out of range read', [4, 'read_first', [[0, 8, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [4, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 34952, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 34952])], [('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23045, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 10, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 43690, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 43690])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(*args):
    depth, mode, ops = args
    mem = [0] * depth
    out = []
    for we, addr, wdata, be, re in ops:
        ok = 0 <= addr < depth
        old = mem[addr] if ok else None
        new = old
        if we and ok:
            for lane in range(2):
                if be >> lane & 1:
                    mask = 0xFFFF if be == 3 else 0xFF << (8 * (1 - lane))
                    new = (new & ~mask) | (wdata & mask)
            mem[addr] = new
        if re:
            if not ok:
                out.append('x')
            else:
                out.append(new if mode == 'write_first' else old)
        else:
            out.append(None)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23041, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 6, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 8738, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 8738])], [('full write then read-first read', [4, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [4, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [4, 'read_first', [[1, 3, 23042, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [4, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [4, 'read_first', [[1, -1, 30583, 3, 1], [0, 3, 0, 0, 1]]], ['x', 0]), ('out of range read', [4, 'read_first', [[0, 6, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [4, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 17476, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 17476])], [('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23043, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 8, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 26214, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 26214])], [('full write then read-first read', [4, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [4, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [4, 'read_first', [[1, 3, 23044, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [4, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [4, 'read_first', [[1, -1, 30583, 3, 1], [0, 3, 0, 0, 1]]], ['x', 0]), ('out of range read', [4, 'read_first', [[0, 8, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [4, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 34952, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 34952])], [('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23045, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 10, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 43690, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 43690])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Writing with only the low-byte enable modifies the high byte.

Input [depth, mode, ops]; memory holds 16-bit words initialised to 0. Each op [we, addr, wdata, be, re]: be bit k enables byte lane k (bits 8k..8k+7). Addresses outside 0..depth-1 ignore writes and read 'x'. A read in the same cycle as a write returns the old word in mode 'read_first' and the merged new word in 'write_first'. re=0 yields None.

split: open-access


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

N = 1
observations = []
def solve(*args):
    depth, mode, ops = args
    mem = [0] * depth
    out = []
    for we, addr, wdata, be, re in ops:
        ok = 0 <= addr < depth
        old = mem[addr] if ok else None
        new = old
        if we and ok:
            for lane in range(2):
                if be >> lane & 1:
                    mask = 0xFF << (8 * lane)
                    new = (new & ~mask) | (wdata & mask)
            mem[addr] = new
        if re:
            if not ok:
                out.append('x')
            else:
                out.append(old)
        else:
            out.append(None)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23041, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 6, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 8738, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 8738])], [('full write then read-first read', [4, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [4, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [4, 'read_first', [[1, 3, 23042, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [4, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [4, 'read_first', [[1, -1, 30583, 3, 1], [0, 3, 0, 0, 1]]], ['x', 0]), ('out of range read', [4, 'read_first', [[0, 6, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [4, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 17476, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 17476])], [('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23043, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 8, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 26214, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 26214])], [('full write then read-first read', [4, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [4, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [4, 'read_first', [[1, 3, 23044, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [4, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [4, 'read_first', [[1, -1, 30583, 3, 1], [0, 3, 0, 0, 1]]], ['x', 0]), ('out of range read', [4, 'read_first', [[0, 8, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [4, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 34952, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 34952])], [('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23045, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 10, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 43690, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 43690])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(*args):
    depth, mode, ops = args
    mem = [0] * depth
    out = []
    for we, addr, wdata, be, re in ops:
        ok = 0 <= addr < depth
        old = mem[addr] if ok else None
        new = old
        if we and ok:
            for lane in range(2):
                if be >> lane & 1:
                    mask = 0xFF << (8 * lane)
                    new = (new & ~mask) | (wdata & mask)
            mem[addr] = new
        if re:
            if not ok:
                out.append('x')
            else:
                out.append(new if mode == 'read_first' else old)
        else:
            out.append(None)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23041, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 6, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 8738, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 8738])], [('full write then read-first read', [4, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [4, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [4, 'read_first', [[1, 3, 23042, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [4, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [4, 'read_first', [[1, -1, 30583, 3, 1], [0, 3, 0, 0, 1]]], ['x', 0]), ('out of range read', [4, 'read_first', [[0, 6, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [4, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 17476, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 17476])], [('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23043, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 8, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 26214, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 26214])], [('full write then read-first read', [4, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [4, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [4, 'read_first', [[1, 3, 23044, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [4, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [4, 'read_first', [[1, -1, 30583, 3, 1], [0, 3, 0, 0, 1]]], ['x', 0]), ('out of range read', [4, 'read_first', [[0, 8, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [4, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 34952, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 34952])], [('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23045, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 10, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 43690, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 43690])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
In write-first mode a read in the same cycle as a write returns the previous word.

Input [depth, mode, ops]; memory holds 16-bit words initialised to 0. Each op [we, addr, wdata, be, re]: be bit k enables byte lane k (bits 8k..8k+7). Addresses outside 0..depth-1 ignore writes and read 'x'. A read in the same cycle as a write returns the old word in mode 'read_first' and the merged new word in 'write_first'. re=0 yields None.

split: open-access


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

N = 1
observations = []
def solve(*args):
    depth, mode, ops = args
    mem = [0] * depth
    out = []
    for we, addr, wdata, be, re in ops:
        ok = 0 <= addr < depth
        old = mem[addr] if ok else None
        new = old
        if we and ok:
            for lane in range(2):
                if be:
                    mask = 0xFF << (8 * lane)
                    new = (new & ~mask) | (wdata & mask)
            mem[addr] = new
        if re:
            if not ok:
                out.append('x')
            else:
                out.append(new if mode == 'write_first' else old)
        else:
            out.append(None)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23041, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 6, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 8738, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 8738])], [('full write then read-first read', [4, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [4, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [4, 'read_first', [[1, 3, 23042, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [4, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [4, 'read_first', [[1, -1, 30583, 3, 1], [0, 3, 0, 0, 1]]], ['x', 0]), ('out of range read', [4, 'read_first', [[0, 6, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [4, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 17476, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 17476])], [('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23043, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 8, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 26214, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 26214])], [('full write then read-first read', [4, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [4, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [4, 'read_first', [[1, 3, 23044, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [4, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [4, 'read_first', [[1, -1, 30583, 3, 1], [0, 3, 0, 0, 1]]], ['x', 0]), ('out of range read', [4, 'read_first', [[0, 8, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [4, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 34952, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 34952])], [('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23045, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 10, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 43690, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 43690])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(*args):
    depth, mode, ops = args
    mem = [0] * depth
    out = []
    for we, addr, wdata, be, re in ops:
        ok = 0 <= addr < depth
        old = mem[addr] if ok else None
        new = old
        if we and ok:
            for lane in range(2):
                if be >> lane:
                    mask = 0xFF << (8 * lane)
                    new = (new & ~mask) | (wdata & mask)
            mem[addr] = new
        if re:
            if not ok:
                out.append('x')
            else:
                out.append(new if mode == 'write_first' else old)
        else:
            out.append(None)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23041, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 6, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 8738, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 8738])], [('full write then read-first read', [4, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [4, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [4, 'read_first', [[1, 3, 23042, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [4, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [4, 'read_first', [[1, -1, 30583, 3, 1], [0, 3, 0, 0, 1]]], ['x', 0]), ('out of range read', [4, 'read_first', [[0, 6, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [4, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 17476, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 17476])], [('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23043, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 8, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 26214, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 26214])], [('full write then read-first read', [4, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [4, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [4, 'read_first', [[1, 3, 23044, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [4, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [4, 'read_first', [[1, -1, 30583, 3, 1], [0, 3, 0, 0, 1]]], ['x', 0]), ('out of range read', [4, 'read_first', [[0, 8, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [4, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 34952, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 34952])], [('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23045, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 10, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 43690, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 43690])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A single-lane write clobbers the other byte lane.

Input [depth, mode, ops]; memory holds 16-bit words initialised to 0. Each op [we, addr, wdata, be, re]: be bit k enables byte lane k (bits 8k..8k+7). Addresses outside 0..depth-1 ignore writes and read 'x'. A read in the same cycle as a write returns the old word in mode 'read_first' and the merged new word in 'write_first'. re=0 yields None.

split: open-access


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

N = 1
observations = []
def solve(*args):
    depth, mode, ops = args
    mem = [0] * depth
    out = []
    for we, addr, wdata, be, re in ops:
        ok = addr < depth
        old = mem[addr] if ok else None
        new = old
        if we and ok:
            for lane in range(2):
                if be >> lane & 1:
                    mask = 0xFF << (8 * lane)
                    new = (new & ~mask) | (wdata & mask)
            mem[addr] = new
        if re:
            if not ok:
                out.append('x')
            else:
                out.append(new if mode == 'write_first' else old)
        else:
            out.append(None)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23041, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 6, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 8738, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 8738])], [('full write then read-first read', [4, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [4, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [4, 'read_first', [[1, 3, 23042, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [4, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [4, 'read_first', [[1, -1, 30583, 3, 1], [0, 3, 0, 0, 1]]], ['x', 0]), ('out of range read', [4, 'read_first', [[0, 6, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [4, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 17476, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 17476])], [('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23043, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 8, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 26214, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 26214])], [('full write then read-first read', [4, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [4, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [4, 'read_first', [[1, 3, 23044, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [4, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [4, 'read_first', [[1, -1, 30583, 3, 1], [0, 3, 0, 0, 1]]], ['x', 0]), ('out of range read', [4, 'read_first', [[0, 8, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [4, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 34952, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 34952])], [('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23045, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 10, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 43690, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 43690])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(*args):
    depth, mode, ops = args
    mem = [0] * depth
    out = []
    for we, addr, wdata, be, re in ops:
        ok = 0 < addr < depth
        old = mem[addr] if ok else None
        new = old
        if we and ok:
            for lane in range(2):
                if be >> lane & 1:
                    mask = 0xFF << (8 * lane)
                    new = (new & ~mask) | (wdata & mask)
            mem[addr] = new
        if re:
            if not ok:
                out.append('x')
            else:
                out.append(new if mode == 'write_first' else old)
        else:
            out.append(None)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23041, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 6, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 8738, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 8738])], [('full write then read-first read', [4, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [4, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [4, 'read_first', [[1, 3, 23042, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [4, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [4, 'read_first', [[1, -1, 30583, 3, 1], [0, 3, 0, 0, 1]]], ['x', 0]), ('out of range read', [4, 'read_first', [[0, 6, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [4, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 17476, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 17476])], [('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23043, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 8, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 26214, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 26214])], [('full write then read-first read', [4, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [4, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [4, 'read_first', [[1, 3, 23044, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [4, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [4, 'read_first', [[1, -1, 30583, 3, 1], [0, 3, 0, 0, 1]]], ['x', 0]), ('out of range read', [4, 'read_first', [[0, 8, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [4, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 34952, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 34952])], [('full write then read-first read', [5, 'read_first', [[1, 1, 43981, 3, 1], [0, 1, 0, 0, 1]]], [0, 43981]), ('write-first partial write', [5, 'write_first', [[1, 2, 4660, 3, 0], [1, 2, 65535, 1, 1], [0, 2, 0, 0, 1]]], [None, 4863, 4863]), ('high lane only', [5, 'read_first', [[1, 3, 23045, 2, 0], [0, 3, 0, 0, 1]]], [None, 23040]), ('address zero', [5, 'write_first', [[1, 0, 3855, 3, 1], [0, 0, 0, 0, 1]]], [3855, 3855]), ('negative address rejected', [5, 'read_first', [[1, -1, 30583, 3, 1], [0, 4, 0, 0, 1]]], ['x', 0]), ('out of range read', [5, 'read_first', [[0, 10, 0, 0, 1], [0, 1, 0, 0, 0]]], ['x', None]), ('read-first returns old data', [5, 'read_first', [[1, 1, 4369, 3, 0], [1, 1, 43690, 3, 1], [0, 1, 0, 0, 1]]], [None, 4369, 43690])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A write to address -1 lands in the last word.

Input [depth, mode, ops]; memory holds 16-bit words initialised to 0. Each op [we, addr, wdata, be, re]: be bit k enables byte lane k (bits 8k..8k+7). Addresses outside 0..depth-1 ignore writes and read 'x'. A read in the same cycle as a write returns the old word in mode 'read_first' and the merged new word in 'write_first'. re=0 yields None.

split: open-access