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

N = 1
observations = []
def solve(commands, size):
    out=[]
    for stream in commands:
        history=[]
        parity=0
        draws=[]
        planes=(1<<size)-1
        for vertex in stream:
            if vertex is None:
                history=[]; parity=0
                continue
            history.append(vertex)
            if len(history)<3: continue
            tri=history[-3:]
            if parity%2: tri=[tri[1],tri[0],tri[2]]
            parity+=1
            if len({v[0] for v in tri})<3: parity-=1; continue
            common=(tri[0][1]&tri[1][1]&tri[2][1]) & planes
            if common: continue
            draws.append([v[0] for v in tri])
        out.append(draws)
    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([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 4), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 4), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 4), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 4), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 4), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 2:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 5), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 5), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 5), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 5), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 5), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 3:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 6), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 6), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 6), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 6), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 6), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 6), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 4:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 7), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 7), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 7), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 7), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 7), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 7), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 5:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 8), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 8), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 8), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 8), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 8), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 8), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
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):
    out=[]
    for stream in commands:
        history=[]
        parity=0
        draws=[]
        planes=(1<<size)-1
        for vertex in stream:
            if vertex is None:
                history=[]; parity=0
                continue
            history.append(vertex)
            if len(history)<3: continue
            tri=history[-3:]
            if parity%2: tri=[tri[1],tri[0],tri[2]]
            parity+=1
            if len({v[0] for v in tri})<3: parity=0; continue
            common=(tri[0][1]&tri[1][1]&tri[2][1]) & planes
            if common: continue
            draws.append([v[0] for v in tri])
        out.append(draws)
    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([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 4), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 4), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 4), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 4), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 4), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 2:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 5), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 5), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 5), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 5), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 5), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 3:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 6), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 6), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 6), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 6), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 6), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 6), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 4:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 7), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 7), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 7), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 7), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 7), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 7), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 5:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 8), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 8), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 8), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 8), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 8), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 8), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
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:
Degenerate primitives do not advance strip parity and misorient later visible triangles.

A vertex is [ID,outside-plane-bits]. Restart is null. Emit oriented triangle-strip primitives only when three distinct IDs exist and the three outside-plane masks have no common active bit. Strip parity advances for every assembled triangle including rejected/degenerate ones; restart clears both vertex history and parity. Only low size plane bits are active.

split: open-access


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

N = 1
observations = []
def solve(commands, size):
    out=[]
    for stream in commands:
        history=[]
        parity=0
        draws=[]
        planes=(1<<size)-1
        for vertex in stream:
            if vertex is None:
                history=[]; parity=0
                continue
            history.append(vertex)
            if len(history)<3: continue
            tri=history[-3:]
            if parity%2: tri=[tri[1],tri[0],tri[2]]
            parity+=1
            if len({v[0] for v in tri})<3: continue
            common=(tri[0][1]&tri[1][1]&tri[2][1]) & planes
            if common: parity-=1; continue
            draws.append([v[0] for v in tri])
        out.append(draws)
    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([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 4), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 4), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 4), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 4), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 4), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 2:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 5), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 5), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 5), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 5), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 5), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 3:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 6), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 6), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 6), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 6), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 6), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 6), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 4:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 7), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 7), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 7), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 7), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 7), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 7), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 5:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 8), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 8), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 8), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 8), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 8), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 8), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
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):
    out=[]
    for stream in commands:
        history=[]
        parity=0
        draws=[]
        planes=(1<<size)-1
        for vertex in stream:
            if vertex is None:
                history=[]; parity=0
                continue
            history.append(vertex)
            if len(history)<3: continue
            tri=history[-3:]
            if parity%2: tri=[tri[1],tri[0],tri[2]]
            parity+=1
            if len({v[0] for v in tri})<3: continue
            common=(tri[0][1]&tri[1][1]&tri[2][1]) & planes
            if common: parity=0; continue
            draws.append([v[0] for v in tri])
        out.append(draws)
    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([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 4), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 4), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 4), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 4), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 4), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 2:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 5), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 5), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 5), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 5), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 5), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 3:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 6), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 6), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 6), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 6), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 6), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 6), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 4:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 7), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 7), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 7), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 7), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 7), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 7), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 5:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 8), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 8), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 8), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 8), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 8), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 8), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
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:
Culled triangles fail to advance strip parity before later visible triangles.

A vertex is [ID,outside-plane-bits]. Restart is null. Emit oriented triangle-strip primitives only when three distinct IDs exist and the three outside-plane masks have no common active bit. Strip parity advances for every assembled triangle including rejected/degenerate ones; restart clears both vertex history and parity. Only low size plane bits are active.

split: open-access


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

N = 1
observations = []
def solve(commands, size):
    out=[]
    for stream in commands:
        history=[]
        parity=0
        draws=[]
        planes=(1<<size)-1
        for vertex in stream:
            if vertex is None:
                history=[]; parity=0
                continue
            history.append(vertex)
            if len(history)<3: continue
            tri=history[-3:]
            if parity%2: tri=[tri[1],tri[0],tri[2]]
            parity+=1
            if len({v[0] for v in tri})<3: continue
            common=(tri[0][1]|tri[1][1]|tri[2][1]) & planes
            if common: continue
            draws.append([v[0] for v in tri])
        out.append(draws)
    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([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 4), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 4), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 4), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 4), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 4), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 2:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 5), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 5), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 5), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 5), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 5), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 3:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 6), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 6), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 6), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 6), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 6), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 6), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 4:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 7), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 7), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 7), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 7), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 7), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 7), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 5:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 8), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 8), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 8), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 8), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 8), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 8), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
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):
    out=[]
    for stream in commands:
        history=[]
        parity=0
        draws=[]
        planes=(1<<size)-1
        for vertex in stream:
            if vertex is None:
                history=[]; parity=0
                continue
            history.append(vertex)
            if len(history)<3: continue
            tri=history[-3:]
            if parity%2: tri=[tri[1],tri[0],tri[2]]
            parity+=1
            if len({v[0] for v in tri})<3: continue
            common=(tri[0][1]&tri[1][1]) & planes
            if common: continue
            draws.append([v[0] for v in tri])
        out.append(draws)
    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([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 4), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 4), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 4), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 4), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 4), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 2:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 5), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 5), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 5), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 5), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 5), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 3:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 6), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 6), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 6), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 6), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 6), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 6), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 4:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 7), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 7), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 7), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 7), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 7), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 7), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 5:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 8), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 8), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 8), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 8), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 8), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 8), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
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:
Culling combines vertex outside masks by union and rejects plane-crossing triangles.

A vertex is [ID,outside-plane-bits]. Restart is null. Emit oriented triangle-strip primitives only when three distinct IDs exist and the three outside-plane masks have no common active bit. Strip parity advances for every assembled triangle including rejected/degenerate ones; restart clears both vertex history and parity. Only low size plane bits are active.

split: open-access


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

N = 1
observations = []
def solve(commands, size):
    out=[]
    for stream in commands:
        history=[]
        parity=0
        draws=[]
        planes=(1<<size)-1
        for vertex in stream:
            if vertex is None:
                history=[]; parity=0
                continue
            history.append(vertex)
            if len(history)<3: continue
            tri=history[-3:]
            if parity%2: tri=[tri[1],tri[0],tri[2]]
            parity+=1
            if len({v[0] for v in tri})<3: continue
            common=tri[0][1]&tri[1][1]&tri[2][1]
            if common: continue
            draws.append([v[0] for v in tri])
        out.append(draws)
    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([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 4), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 4), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 4), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 4), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 4), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 2:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 5), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 5), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 5), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 5), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 5), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 3:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 6), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 6), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 6), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 6), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 6), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 6), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 4:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 7), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 7), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 7), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 7), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 7), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 7), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 5:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 8), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 8), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 8), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 8), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 8), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 8), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
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):
    out=[]
    for stream in commands:
        history=[]
        parity=0
        draws=[]
        planes=(1<<size)-1
        for vertex in stream:
            if vertex is None:
                history=[]; parity=0
                continue
            history.append(vertex)
            if len(history)<3: continue
            tri=history[-3:]
            if parity%2: tri=[tri[1],tri[0],tri[2]]
            parity+=1
            if len({v[0] for v in tri})<3: continue
            common=(tri[0][1]&tri[1][1]&tri[2][1]) & (planes<<1)
            if common: continue
            draws.append([v[0] for v in tri])
        out.append(draws)
    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([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 4), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 4), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 4), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 4), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 4), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 2:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 5), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 5), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 5), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 5), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 5), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 3:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 6), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 6), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 6), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 6), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 6), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 6), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 4:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 7), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 7), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 7), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 7), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 7), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 7), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 5:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 8), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 8), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 8), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 8), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 8), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 8), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
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:
Inactive user-plane bits participate in primitive rejection.

A vertex is [ID,outside-plane-bits]. Restart is null. Emit oriented triangle-strip primitives only when three distinct IDs exist and the three outside-plane masks have no common active bit. Strip parity advances for every assembled triangle including rejected/degenerate ones; restart clears both vertex history and parity. Only low size plane bits are active.

split: open-access


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

N = 1
observations = []
def solve(commands, size):
    out=[]
    for stream in commands:
        history=[]
        parity=0
        draws=[]
        planes=(1<<size)-1
        for vertex in stream:
            if vertex is None:
                history=[]; parity=0
                continue
            history.append(vertex)
            if len(history)<3: continue
            tri=history[-3:]
            if parity%2: tri=[tri[1],tri[0],tri[2]]
            parity+=1
            if len({v[0] for v in tri})<2: continue
            common=(tri[0][1]&tri[1][1]&tri[2][1]) & planes
            if common: continue
            draws.append([v[0] for v in tri])
        out.append(draws)
    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([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 4), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 4), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 4), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 4), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 4), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 2:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 5), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 5), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 5), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 5), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 5), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 3:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 6), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 6), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 6), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 6), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 6), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 6), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 4:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 7), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 7), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 7), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 7), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 7), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 7), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 5:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 8), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 8), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 8), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 8), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 8), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 8), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
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):
    out=[]
    for stream in commands:
        history=[]
        parity=0
        draws=[]
        planes=(1<<size)-1
        for vertex in stream:
            if vertex is None:
                history=[]; parity=0
                continue
            history.append(vertex)
            if len(history)<3: continue
            tri=history[-3:]
            if parity%2: tri=[tri[1],tri[0],tri[2]]
            parity+=1
            if tri[0][0]==tri[1][0]: continue
            common=(tri[0][1]&tri[1][1]&tri[2][1]) & planes
            if common: continue
            draws.append([v[0] for v in tri])
        out.append(draws)
    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([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 4), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 4), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 4), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 4), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 4), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 4), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 4), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 4), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 2:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 5), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 5), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 5), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 5), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 5), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 5), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 5), [[[0, 1, 2]]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 5), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 3:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 6), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 6), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 6), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 6), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 6), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 6), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 6), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 6), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 6), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 4:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 7), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 7), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 7), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 7), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 7), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 7), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 7), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 7), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 7), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
if N == 5:
    check('explicit sequence 0', solve([[[0, 0], [1, 0], [2, 0], None, [3, 0], [4, 0], [5, 0]]], 8), [[[0, 1, 2], [3, 4, 5]]])
    check('explicit sequence 1', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 2', solve([[[0, 0], [1, 0], [1, 0], [2, 0], [3, 0], [4, 0]]], 8), [[[1, 2, 3], [3, 2, 4]]])
    check('explicit sequence 3', solve([[[0, 1], [1, 1], [2, 1], [3, 0], [4, 0]]], 8), [[[2, 1, 3], [2, 3, 4]]])
    check('explicit sequence 4', solve([[[0, 1], [1, 1], [2, 0]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 5', solve([[[0, 512], [1, 512], [2, 512]]], 8), [[[0, 1, 2]]])
    check('explicit sequence 6', solve([[[0, 1], [1, 1], [2, 1]]], 8), [[]])
    check('explicit sequence 7', solve([[[0, 0], [1, 0], [0, 0], [2, 0], [3, 0]]], 8), [[[0, 1, 2], [0, 2, 3]]])
    check('explicit sequence 8', solve([[None, [0, 0], [1, 0]]], 8), [[]])
    check('explicit sequence 9', solve([[[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], None, [5, 0], [6, 0], [7, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [2, 3, 4], [5, 6, 7]]])
    check('explicit sequence 10', solve([[[0, 32], [1, 32], [2, 32]]], 8), [[]])
    check('explicit sequence 11', solve([[[0, 0], [1, 0], [2, 0], [3, 0], None, [4, 0], [5, 0], [6, 0]]], 8), [[[0, 1, 2], [2, 1, 3], [4, 5, 6]]])
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:
Triangles with two equal IDs pass the degenerate filter.

A vertex is [ID,outside-plane-bits]. Restart is null. Emit oriented triangle-strip primitives only when three distinct IDs exist and the three outside-plane masks have no common active bit. Strip parity advances for every assembled triangle including rejected/degenerate ones; restart clears both vertex history and parity. Only low size plane bits are active.

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))
    clip=set(full)
    lanes=set(full)
    results={}
    active=None
    query_enabled=True
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip=set(cmd[1])&full
        elif op=='lanes': lanes=set(cmd[1])&full
        elif op=='begin': active=cmd[1]; results[active]=0
        elif op=='end': active=None
        elif op=='enable-query': query_enabled=cmd[1]
        elif op in ('draw','conditional'):
            samples=cmd[1]
            if op=='conditional' and (cmd[2]==active or results.get(cmd[2],0)==0): continue
            visible=set(samples)&lanes
            if active is not None and query_enabled: results[active]+=len(visible)
        elif op=='read': out.append(None if cmd[1]==active else results.get(cmd[1],0))
    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([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 4), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 4), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 4), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 4), [4])
if N == 2:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 5), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 5), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 5), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 5), [5])
if N == 3:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 6), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 6), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 6), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 6), [6])
if N == 4:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 7), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 7), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 7), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 7), [7])
if N == 5:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 8), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 8), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 8), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 8), [8])
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))
    clip=set(full)
    lanes=set(full)
    results={}
    active=None
    query_enabled=True
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='clip': clip=set(cmd[1])&full
        elif op=='lanes': lanes=set(cmd[1])&full
        elif op=='begin': active=cmd[1]; results[active]=0
        elif op=='end': active=None
        elif op=='enable-query': query_enabled=cmd[1]
        elif op in ('draw','conditional'):
            samples=cmd[1]
            if op=='conditional' and (cmd[2]==active or results.get(cmd[2],0)==0): continue
            visible=set(samples)&clip
            if active is not None and query_enabled: results[active]+=len(visible)
        elif op=='read': out.append(None if cmd[1]==active else results.get(cmd[1],0))
    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([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 4), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 4), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 4), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 4), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 4), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 4), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 4), [4])
if N == 2:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 5), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 5), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 5), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 5), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 5), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 5), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 5), [5])
if N == 3:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 6), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 6), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 6), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 6), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 6), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 6), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 6), [6])
if N == 4:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 7), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 7), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 7), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 7), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 7), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 7), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 7), [7])
if N == 5:
    check('explicit sequence 0', solve([['clip', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 1', solve([['lanes', [0]], ['begin', 'q'], ['draw', [0, 1]], ['end'], ['read', 'q']], 8), [1])
    check('explicit sequence 2', solve([['begin', 'q'], ['draw', [0, 0, 1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 3', solve([['begin', 'q'], ['draw', [0]], ['draw', [1]], ['end'], ['read', 'q']], 8), [2])
    check('explicit sequence 4', solve([['begin', 'q'], ['draw', [0]], ['end'], ['begin', 'q'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 5', solve([['begin', 'q'], ['draw', [0]], ['end'], ['draw', [1]], ['read', 'q']], 8), [1])
    check('explicit sequence 6', solve([['begin', 'q'], ['enable-query', False], ['draw', [0]], ['enable-query', True], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 7', solve([['begin', 'q'], ['draw', [0]], ['read', 'q'], ['conditional', [1], 'q'], ['end'], ['read', 'q']], 8), [None, 1])
    check('explicit sequence 8', solve([['begin', 'q'], ['conditional', [0], 'missing'], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 9', solve([['begin', 'a'], ['draw', [0]], ['end'], ['begin', 'b'], ['end'], ['read', 'b']], 8), [0])
    check('explicit sequence 10', solve([['clip', []], ['begin', 'q'], ['draw', [0]], ['end'], ['read', 'q']], 8), [0])
    check('explicit sequence 11', solve([['begin', 'q'], ['draw', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], ['end'], ['read', 'q']], 8), [8])
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:
Occlusion counting happens before applying the path clip.

Queries count distinct covered sample IDs per draw after path clipping and sample enable masking. Multiple draws accumulate independently, while duplicate sample IDs within one draw count once. Begin resets a named result and activates it; end makes it readable. Result reads while active return null. Conditional draws consult only completed query counts. Disabling queries pauses accumulation without disabling clipping.

split: open-access