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

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    current=set(full)
    pending=None
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='begin' and pending is None: pending=set(current)
        elif op=='subtract' and pending is not None: pending-=set(cmd[1])
        elif op=='add' and pending is not None: pending |= set(cmd[1]) & full
        elif op=='replace' and pending is not None: pending=set(cmd[1]) & full
        elif op=='commit' and pending is not None:
            current=set(pending)
            pending=None
        elif op=='abort':
            if pending is not None: current=set(pending)
            pending=None
        elif op=='resize':
            full=set(range(cmd[1]))
            current &= full
            if pending is not None: pending &= full
        elif op=='draw': out.append(sorted(current))
    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([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 4), [[0, 1, 2, 3], [1, 2, 3]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 4), [[2, 3]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 4), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 4), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 4), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 4), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 4), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 4), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 4), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 4), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 4), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 4), [[0]])
if N == 2:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 5), [[0, 1, 2, 3, 4], [1, 2, 3, 4]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 5), [[2, 3, 4]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 5), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 5), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 5), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 5), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 5), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 5), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 5), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 5), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 5), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 5), [[0]])
if N == 3:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 6), [[0, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 6), [[2, 3, 4, 5]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 6), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 6), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 6), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 6), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 6), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 6), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 6), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 6), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 6), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 6), [[0]])
if N == 4:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 7), [[2, 3, 4, 5, 6]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 7), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 7), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 7), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 7), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 7), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 7), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 7), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 7), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 7), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 7), [[0]])
if N == 5:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 8), [[2, 3, 4, 5, 6, 7]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 8), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 8), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 8), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 8), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 8), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 8), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 8), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 8), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 8), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 8), [[0]])
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):
    full=set(range(size))
    current=set(full)
    pending=None
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='begin' and pending is None: pending=set(current)
        elif op=='subtract' and pending is not None: pending-=set(cmd[1])
        elif op=='add' and pending is not None: pending |= set(cmd[1]) & full
        elif op=='replace' and pending is not None: pending=set(cmd[1]) & full
        elif op=='commit' and pending is not None:
            current=set(pending)
            pending=None
        elif op=='abort':
            pending=None
            current=set(full)
        elif op=='resize':
            full=set(range(cmd[1]))
            current &= full
            if pending is not None: pending &= full
        elif op=='draw': out.append(sorted(current))
    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([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 4), [[0, 1, 2, 3], [1, 2, 3]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 4), [[2, 3]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 4), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 4), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 4), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 4), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 4), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 4), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 4), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 4), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 4), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 4), [[0]])
if N == 2:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 5), [[0, 1, 2, 3, 4], [1, 2, 3, 4]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 5), [[2, 3, 4]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 5), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 5), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 5), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 5), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 5), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 5), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 5), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 5), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 5), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 5), [[0]])
if N == 3:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 6), [[0, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 6), [[2, 3, 4, 5]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 6), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 6), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 6), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 6), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 6), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 6), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 6), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 6), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 6), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 6), [[0]])
if N == 4:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 7), [[2, 3, 4, 5, 6]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 7), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 7), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 7), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 7), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 7), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 7), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 7), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 7), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 7), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 7), [[0]])
if N == 5:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 8), [[2, 3, 4, 5, 6, 7]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 8), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 8), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 8), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 8), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 8), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 8), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 8), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 8), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 8), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 8), [[0]])
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:
Abort publishes coverage intended to be discarded.

Begin stages clip edits against a copy. Commit publishes pending coverage atomically; abort discards it. Draw sees committed coverage. Beginning while already editing is ignored; edit outside a transaction is ignored. Resize clips both committed and pending regions.

split: open-access


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

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    current=set(full)
    pending=None
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='begin' and pending is None: pending=set(current)
        elif op=='subtract' and pending is not None: pending-=set(cmd[1])
        elif op=='add' and pending is not None: pending |= set(cmd[1]) & full
        elif op=='replace' and pending is not None: pending=set(cmd[1]) & full
        elif op=='commit' and pending is not None:
            current=set(pending)
            pending=None
        elif op=='abort': pending=None
        elif op=='resize':
            full=set(range(cmd[1]))
            current=set(full)
            if pending is not None: pending &= full
        elif op=='draw': out.append(sorted(current))
    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([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 4), [[0, 1, 2, 3], [1, 2, 3]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 4), [[2, 3]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 4), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 4), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 4), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 4), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 4), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 4), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 4), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 4), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 4), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 4), [[0]])
if N == 2:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 5), [[0, 1, 2, 3, 4], [1, 2, 3, 4]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 5), [[2, 3, 4]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 5), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 5), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 5), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 5), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 5), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 5), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 5), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 5), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 5), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 5), [[0]])
if N == 3:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 6), [[0, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 6), [[2, 3, 4, 5]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 6), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 6), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 6), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 6), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 6), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 6), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 6), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 6), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 6), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 6), [[0]])
if N == 4:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 7), [[2, 3, 4, 5, 6]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 7), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 7), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 7), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 7), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 7), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 7), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 7), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 7), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 7), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 7), [[0]])
if N == 5:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 8), [[2, 3, 4, 5, 6, 7]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 8), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 8), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 8), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 8), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 8), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 8), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 8), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 8), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 8), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 8), [[0]])
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):
    full=set(range(size))
    current=set(full)
    pending=None
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='begin' and pending is None: pending=set(current)
        elif op=='subtract' and pending is not None: pending-=set(cmd[1])
        elif op=='add' and pending is not None: pending |= set(cmd[1]) & full
        elif op=='replace' and pending is not None: pending=set(cmd[1]) & full
        elif op=='commit' and pending is not None:
            current=set(pending)
            pending=None
        elif op=='abort': pending=None
        elif op=='resize':
            full=set(range(cmd[1]))
            current = current & full if pending is not None else set(full)
            if pending is not None: pending &= full
        elif op=='draw': out.append(sorted(current))
    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([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 4), [[0, 1, 2, 3], [1, 2, 3]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 4), [[2, 3]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 4), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 4), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 4), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 4), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 4), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 4), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 4), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 4), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 4), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 4), [[0]])
if N == 2:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 5), [[0, 1, 2, 3, 4], [1, 2, 3, 4]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 5), [[2, 3, 4]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 5), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 5), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 5), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 5), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 5), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 5), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 5), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 5), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 5), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 5), [[0]])
if N == 3:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 6), [[0, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 6), [[2, 3, 4, 5]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 6), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 6), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 6), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 6), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 6), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 6), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 6), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 6), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 6), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 6), [[0]])
if N == 4:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 7), [[2, 3, 4, 5, 6]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 7), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 7), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 7), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 7), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 7), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 7), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 7), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 7), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 7), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 7), [[0]])
if N == 5:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 8), [[2, 3, 4, 5, 6, 7]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 8), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 8), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 8), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 8), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 8), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 8), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 8), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 8), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 8), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 8), [[0]])
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:
Resizing expands the clip to the entire new target instead of preserving exclusions.

Begin stages clip edits against a copy. Commit publishes pending coverage atomically; abort discards it. Draw sees committed coverage. Beginning while already editing is ignored; edit outside a transaction is ignored. Resize clips both committed and pending regions.

split: open-access


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

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    current=set(full)
    pending=None
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='begin' and pending is None: pending=set(current)
        elif op=='subtract' and pending is not None: pending-=set(cmd[1])
        elif op=='add' and pending is not None: pending |= set(cmd[1]) & full
        elif op=='replace' and pending is not None: pending=set(cmd[1]) & full
        elif op=='commit' and pending is not None:
            current=set(pending)
            pending=None
        elif op=='abort': pending=None
        elif op=='resize':
            full=set(range(cmd[1]))
            current &= full
            if pending is not None: pending=set(full)
        elif op=='draw': out.append(sorted(current))
    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([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 4), [[0, 1, 2, 3], [1, 2, 3]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 4), [[2, 3]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 4), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 4), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 4), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 4), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 4), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 4), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 4), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 4), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 4), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 4), [[0]])
if N == 2:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 5), [[0, 1, 2, 3, 4], [1, 2, 3, 4]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 5), [[2, 3, 4]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 5), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 5), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 5), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 5), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 5), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 5), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 5), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 5), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 5), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 5), [[0]])
if N == 3:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 6), [[0, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 6), [[2, 3, 4, 5]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 6), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 6), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 6), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 6), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 6), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 6), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 6), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 6), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 6), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 6), [[0]])
if N == 4:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 7), [[2, 3, 4, 5, 6]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 7), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 7), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 7), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 7), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 7), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 7), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 7), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 7), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 7), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 7), [[0]])
if N == 5:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 8), [[2, 3, 4, 5, 6, 7]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 8), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 8), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 8), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 8), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 8), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 8), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 8), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 8), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 8), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 8), [[0]])
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):
    full=set(range(size))
    current=set(full)
    pending=None
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='begin' and pending is None: pending=set(current)
        elif op=='subtract' and pending is not None: pending-=set(cmd[1])
        elif op=='add' and pending is not None: pending |= set(cmd[1]) & full
        elif op=='replace' and pending is not None: pending=set(cmd[1]) & full
        elif op=='commit' and pending is not None:
            current=set(pending)
            pending=None
        elif op=='abort': pending=None
        elif op=='resize':
            full=set(range(cmd[1]))
            current &= full
            if pending is not None: pending=current & full
        elif op=='draw': out.append(sorted(current))
    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([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 4), [[0, 1, 2, 3], [1, 2, 3]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 4), [[2, 3]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 4), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 4), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 4), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 4), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 4), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 4), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 4), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 4), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 4), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 4), [[0]])
if N == 2:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 5), [[0, 1, 2, 3, 4], [1, 2, 3, 4]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 5), [[2, 3, 4]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 5), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 5), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 5), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 5), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 5), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 5), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 5), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 5), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 5), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 5), [[0]])
if N == 3:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 6), [[0, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 6), [[2, 3, 4, 5]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 6), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 6), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 6), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 6), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 6), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 6), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 6), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 6), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 6), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 6), [[0]])
if N == 4:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 7), [[2, 3, 4, 5, 6]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 7), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 7), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 7), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 7), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 7), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 7), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 7), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 7), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 7), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 7), [[0]])
if N == 5:
    check('explicit sequence 0', solve([['begin'], ['subtract', [0]], ['draw'], ['commit'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 1', solve([['begin'], ['subtract', [0]], ['begin'], ['subtract', [1]], ['commit'], ['draw']], 8), [[2, 3, 4, 5, 6, 7]])
    check('explicit sequence 2', solve([['begin'], ['replace', [0]], ['add', [1, 99, -1]], ['commit'], ['draw']], 8), [[0, 1]])
    check('explicit sequence 3', solve([['begin'], ['replace', [0]], ['replace', [2]], ['commit'], ['draw']], 8), [[2]])
    check('explicit sequence 4', solve([['begin'], ['replace', [0]], ['abort'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 5', solve([['begin'], ['replace', [1]], ['commit'], ['subtract', [1]], ['commit'], ['draw']], 8), [[1]])
    check('explicit sequence 6', solve([['begin'], ['replace', [1, 2]], ['resize', 2], ['commit'], ['draw']], 8), [[1]])
    check('explicit sequence 7', solve([['begin'], ['replace', [1]], ['commit'], ['resize', 3], ['draw']], 8), [[1]])
    check('explicit sequence 8', solve([['commit'], ['abort'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 9', solve([['begin'], ['replace', []], ['commit'], ['draw']], 8), [[]])
    check('explicit sequence 10', solve([['begin'], ['replace', []], ['commit'], ['begin'], ['add', [0]], ['commit'], ['draw']], 8), [[0]])
    check('explicit sequence 11', solve([['begin'], ['replace', []], ['begin'], ['add', [0]], ['commit'], ['draw']], 8), [[0]])
    check('explicit sequence 12', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['add', [1]], ['commit'], ['draw']], 8), [[0, 1]])
    check('explicit sequence 13', solve([['begin'], ['replace', [0]], ['commit'], ['begin'], ['subtract', [0]], ['abort'], ['draw']], 8), [[0]])
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:
Resizing resets staged edits before commit.

Begin stages clip edits against a copy. Commit publishes pending coverage atomically; abort discards it. Draw sees committed coverage. Beginning while already editing is ignored; edit outside a transaction is ignored. Resize clips both committed and pending regions.

split: open-access


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

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    masks={}
    active=None
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='define': masks[cmd[1]]=set(cmd[2])
        elif op=='bind': active=cmd[1]
        elif op=='delete': masks.pop(cmd[1],None)
        elif op=='clone': masks[cmd[2]]=set(masks.get(cmd[1],set()))
        elif op=='subtract' and cmd[1] in masks: masks[cmd[1]]-=set(cmd[2])
        elif op=='rename' and cmd[1] in masks:
            masks[cmd[2]]=masks.pop(cmd[1])
            if active==cmd[1]: active=cmd[2]
        elif op=='reset': masks={}; active=None
        elif op=='draw': out.append(sorted(masks.get(active,set())))
    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([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 4), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 4), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 4), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 4), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 4), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 4), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 4), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 4), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 4), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 4), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 4), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 4), [[0, 1, 2, 3]])
if N == 2:
    check('explicit sequence 0', solve([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 5), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 5), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 5), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 5), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 5), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 5), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 5), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 5), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 5), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 5), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 5), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 5), [[0, 1, 2, 3, 4]])
if N == 3:
    check('explicit sequence 0', solve([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 6), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 6), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 6), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 6), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 6), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 6), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 6), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 6), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 6), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 6), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 6), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
if N == 4:
    check('explicit sequence 0', solve([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 7), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 7), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 7), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 7), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 7), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 7), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 7), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 7), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 7), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 7), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 7), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
if N == 5:
    check('explicit sequence 0', solve([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 8), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 8), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 8), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 8), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 8), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 8), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 8), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 8), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 8), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 8), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 8), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
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):
    full=set(range(size))
    masks={}
    active=None
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='define': masks[cmd[1]]={x for x in cmd[2] if x>=0}
        elif op=='bind': active=cmd[1]
        elif op=='delete': masks.pop(cmd[1],None)
        elif op=='clone': masks[cmd[2]]=set(masks.get(cmd[1],set()))
        elif op=='subtract' and cmd[1] in masks: masks[cmd[1]]-=set(cmd[2])
        elif op=='rename' and cmd[1] in masks:
            masks[cmd[2]]=masks.pop(cmd[1])
            if active==cmd[1]: active=cmd[2]
        elif op=='reset': masks={}; active=None
        elif op=='draw': out.append(sorted(masks.get(active,set())))
    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([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 4), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 4), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 4), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 4), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 4), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 4), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 4), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 4), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 4), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 4), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 4), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 4), [[0, 1, 2, 3]])
if N == 2:
    check('explicit sequence 0', solve([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 5), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 5), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 5), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 5), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 5), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 5), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 5), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 5), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 5), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 5), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 5), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 5), [[0, 1, 2, 3, 4]])
if N == 3:
    check('explicit sequence 0', solve([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 6), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 6), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 6), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 6), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 6), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 6), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 6), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 6), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 6), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 6), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 6), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
if N == 4:
    check('explicit sequence 0', solve([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 7), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 7), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 7), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 7), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 7), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 7), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 7), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 7), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 7), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 7), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 7), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
if N == 5:
    check('explicit sequence 0', solve([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 8), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 8), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 8), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 8), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 8), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 8), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 8), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 8), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 8), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 8), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 8), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
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:
Mask definition accepts sample positions outside the surface.

Named clip masks are immutable snapshots clipped to target extent. Bind selects a name, edits replace the named mask, deletion of the active mask makes drawing empty. Renaming preserves active binding; clone is independent; reset clears registry and active binding.

split: open-access


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

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    masks={}
    active=None
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='define': masks[cmd[1]]=set(cmd[2]) & full
        elif op=='bind':
            if active is None: active=cmd[1]
        elif op=='delete': masks.pop(cmd[1],None)
        elif op=='clone': masks[cmd[2]]=set(masks.get(cmd[1],set()))
        elif op=='subtract' and cmd[1] in masks: masks[cmd[1]]-=set(cmd[2])
        elif op=='rename' and cmd[1] in masks:
            masks[cmd[2]]=masks.pop(cmd[1])
            if active==cmd[1]: active=cmd[2]
        elif op=='reset': masks={}; active=None
        elif op=='draw': out.append(sorted(masks.get(active,set())))
    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([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 4), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 4), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 4), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 4), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 4), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 4), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 4), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 4), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 4), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 4), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 4), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 4), [[0, 1, 2, 3]])
if N == 2:
    check('explicit sequence 0', solve([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 5), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 5), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 5), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 5), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 5), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 5), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 5), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 5), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 5), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 5), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 5), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 5), [[0, 1, 2, 3, 4]])
if N == 3:
    check('explicit sequence 0', solve([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 6), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 6), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 6), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 6), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 6), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 6), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 6), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 6), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 6), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 6), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 6), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
if N == 4:
    check('explicit sequence 0', solve([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 7), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 7), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 7), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 7), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 7), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 7), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 7), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 7), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 7), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 7), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 7), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
if N == 5:
    check('explicit sequence 0', solve([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 8), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 8), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 8), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 8), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 8), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 8), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 8), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 8), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 8), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 8), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 8), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
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):
    full=set(range(size))
    masks={}
    active=None
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='define': masks[cmd[1]]=set(cmd[2]) & full
        elif op=='bind':
            if active is None or active not in masks: active=cmd[1]
        elif op=='delete': masks.pop(cmd[1],None)
        elif op=='clone': masks[cmd[2]]=set(masks.get(cmd[1],set()))
        elif op=='subtract' and cmd[1] in masks: masks[cmd[1]]-=set(cmd[2])
        elif op=='rename' and cmd[1] in masks:
            masks[cmd[2]]=masks.pop(cmd[1])
            if active==cmd[1]: active=cmd[2]
        elif op=='reset': masks={}; active=None
        elif op=='draw': out.append(sorted(masks.get(active,set())))
    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([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 4), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 4), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 4), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 4), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 4), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 4), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 4), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 4), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 4), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 4), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 4), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 4), [[0, 1, 2, 3]])
if N == 2:
    check('explicit sequence 0', solve([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 5), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 5), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 5), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 5), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 5), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 5), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 5), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 5), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 5), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 5), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 5), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 5), [[0, 1, 2, 3, 4]])
if N == 3:
    check('explicit sequence 0', solve([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 6), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 6), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 6), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 6), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 6), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 6), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 6), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 6), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 6), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 6), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 6), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
if N == 4:
    check('explicit sequence 0', solve([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 7), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 7), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 7), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 7), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 7), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 7), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 7), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 7), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 7), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 7), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 7), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
if N == 5:
    check('explicit sequence 0', solve([['define', 'a', [0, 99, -1]], ['bind', 'a'], ['draw']], 8), [[0]])
    check('explicit sequence 1', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['draw'], ['bind', 'b'], ['draw']], 8), [[0], [1]])
    check('explicit sequence 2', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['delete', 'b'], ['draw']], 8), [[0]])
    check('explicit sequence 3', solve([['define', 'a', [0, 1]], ['clone', 'a', 'b'], ['subtract', 'a', [0]], ['bind', 'b'], ['draw'], ['bind', 'a'], ['draw']], 8), [[0, 1], [1]])
    check('explicit sequence 4', solve([['define', 'a', [0]], ['bind', 'a'], ['rename', 'a', 'b'], ['draw'], ['bind', 'a'], ['draw']], 8), [[0], []])
    check('explicit sequence 5', solve([['define', 'a', [0]], ['reset'], ['bind', 'a'], ['draw']], 8), [[]])
    check('explicit sequence 6', solve([['bind', 'missing'], ['draw']], 8), [[]])
    check('explicit sequence 7', solve([['define', 'a', [0]], ['define', 'a', [2]], ['bind', 'a'], ['draw']], 8), [[2]])
    check('explicit sequence 8', solve([['define', 'e', []], ['bind', 'e'], ['draw']], 8), [[]])
    check('explicit sequence 9', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['rename', 'b', 'c'], ['draw']], 8), [[0]])
    check('explicit sequence 10', solve([['define', 'a', [0]], ['define', 'b', [1]], ['bind', 'a'], ['reset'], ['bind', 'b'], ['draw']], 8), [[]])
    check('explicit sequence 11', solve([['define', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['bind', 'a'], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
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:
Binding never switches away from the first clip mask.

Named clip masks are immutable snapshots clipped to target extent. Bind selects a name, edits replace the named mask, deletion of the active mask makes drawing empty. Renaming preserves active binding; clone is independent; reset clears registry and active binding.

split: open-access