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

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    ids=[None]*size
    depths=[float('inf')]*size
    out=[]
    for cmd in commands:
        if cmd[0]=='clear':
            for x in set(cmd[1])&full: ids[x]=None
        elif cmd[0]=='draw':
            _,key,coverage,clip,depth,test,write=cmd
            for x in set(coverage)&set(clip)&full:
                if test and depth>=depths[x]: continue
                if test: depths[x]=depth
                if write: ids[x]=key
        else:
            out.append([ids[x] if x in full else None for x in cmd[1]])
    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([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 4), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 4), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 4), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 4), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 4), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 4), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 4), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 4), [[None]])
if N == 2:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 5), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 5), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 5), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 5), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 5), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 5), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 5), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 5), [[None]])
if N == 3:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 6), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 6), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 6), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 6), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 6), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 6), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 6), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 6), [[None]])
if N == 4:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 7), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 7), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 7), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 7), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 7), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 7), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 7), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 7), [[None]])
if N == 5:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 8), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 8), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 8), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 8), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 8), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 8), [[None, 'a', None, 'a']])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 8), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 8), [[None]])
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))
    ids=[None]*size
    depths=[float('inf')]*size
    out=[]
    for cmd in commands:
        if cmd[0]=='clear':
            for x in set(cmd[1])&full: ids[x]=None; depths[x]=0
        elif cmd[0]=='draw':
            _,key,coverage,clip,depth,test,write=cmd
            for x in set(coverage)&set(clip)&full:
                if test and depth>=depths[x]: continue
                if test: depths[x]=depth
                if write: ids[x]=key
        else:
            out.append([ids[x] if x in full else None for x in cmd[1]])
    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([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 4), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 4), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 4), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 4), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 4), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 4), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 4), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 4), [[None]])
if N == 2:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 5), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 5), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 5), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 5), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 5), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 5), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 5), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 5), [[None]])
if N == 3:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 6), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 6), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 6), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 6), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 6), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 6), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 6), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 6), [[None]])
if N == 4:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 7), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 7), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 7), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 7), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 7), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 7), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 7), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 7), [[None]])
if N == 5:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 8), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 8), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 8), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 8), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 8), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 8), [[None, 'a', None, 'a']])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 8), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 8), [[None]])
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:
Clearing the pick sample leaves old depth that rejects new objects.

Each draw has an object ID, coverage samples, clip samples, integer depth, depth-test flag and ID-write flag. ID zero is a valid object. Pick samples start empty with infinite depth. With depth test enabled, strictly nearer fragments replace stored IDs and depth; equal depth keeps the earlier fragment. Disabled depth testing writes without changing depth. ID-write-disabled draws still update depth when tested. Queries return IDs or null for out-of-target samples.

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))
    ids=[None]*size
    depths=[float('inf')]*size
    out=[]
    for cmd in commands:
        if cmd[0]=='clear':
            for x in full: ids[x]=None; depths[x]=float('inf')
        elif cmd[0]=='draw':
            _,key,coverage,clip,depth,test,write=cmd
            for x in set(coverage)&set(clip)&full:
                if test and depth>=depths[x]: continue
                if test: depths[x]=depth
                if write: ids[x]=key
        else:
            out.append([ids[x] if x in full else None for x in cmd[1]])
    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([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 4), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 4), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 4), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 4), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 4), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 4), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 4), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 4), [[None]])
if N == 2:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 5), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 5), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 5), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 5), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 5), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 5), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 5), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 5), [[None]])
if N == 3:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 6), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 6), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 6), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 6), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 6), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 6), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 6), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 6), [[None]])
if N == 4:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 7), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 7), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 7), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 7), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 7), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 7), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 7), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 7), [[None]])
if N == 5:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 8), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 8), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 8), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 8), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 8), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 8), [[None, 'a', None, 'a']])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 8), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 8), [[None]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    ids=[None]*size
    depths=[float('inf')]*size
    out=[]
    for cmd in commands:
        if cmd[0]=='clear':
            for x in set(cmd[1])&full if cmd[1] else full: ids[x]=None; depths[x]=float('inf')
        elif cmd[0]=='draw':
            _,key,coverage,clip,depth,test,write=cmd
            for x in set(coverage)&set(clip)&full:
                if test and depth>=depths[x]: continue
                if test: depths[x]=depth
                if write: ids[x]=key
        else:
            out.append([ids[x] if x in full else None for x in cmd[1]])
    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([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 4), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 4), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 4), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 4), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 4), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 4), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 4), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 4), [[None]])
if N == 2:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 5), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 5), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 5), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 5), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 5), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 5), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 5), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 5), [[None]])
if N == 3:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 6), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 6), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 6), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 6), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 6), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 6), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 6), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 6), [[None]])
if N == 4:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 7), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 7), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 7), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 7), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 7), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 7), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 7), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 7), [[None]])
if N == 5:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 8), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 8), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 8), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 8), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 8), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 8), [[None, 'a', None, 'a']])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 8), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 8), [[None]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A clipped clear erases pick samples outside the requested clear region.

Each draw has an object ID, coverage samples, clip samples, integer depth, depth-test flag and ID-write flag. ID zero is a valid object. Pick samples start empty with infinite depth. With depth test enabled, strictly nearer fragments replace stored IDs and depth; equal depth keeps the earlier fragment. Disabled depth testing writes without changing depth. ID-write-disabled draws still update depth when tested. Queries return IDs or null for out-of-target samples.

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))
    ids=[None]*size
    depths=[float('inf')]*size
    out=[]
    for cmd in commands:
        if cmd[0]=='clear':
            for x in set(cmd[1])&full: ids[x]=None; depths[x]=float('inf')
        elif cmd[0]=='draw':
            _,key,coverage,clip,depth,test,write=cmd
            for x in set(coverage)&set(clip)&full:
                if test and depth>=depths[x]: continue
                if test: depths[x]=depth
                if write: ids[x]=key
        else:
            out.append([ids[min(size-1,max(0,x))] for x in cmd[1]])
    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([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 4), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 4), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 4), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 4), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 4), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 4), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 4), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 4), [[None]])
if N == 2:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 5), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 5), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 5), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 5), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 5), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 5), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 5), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 5), [[None]])
if N == 3:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 6), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 6), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 6), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 6), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 6), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 6), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 6), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 6), [[None]])
if N == 4:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 7), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 7), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 7), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 7), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 7), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 7), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 7), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 7), [[None]])
if N == 5:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 8), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 8), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 8), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 8), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 8), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 8), [[None, 'a', None, 'a']])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 8), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 8), [[None]])
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))
    ids=[None]*size
    depths=[float('inf')]*size
    out=[]
    for cmd in commands:
        if cmd[0]=='clear':
            for x in set(cmd[1])&full: ids[x]=None; depths[x]=float('inf')
        elif cmd[0]=='draw':
            _,key,coverage,clip,depth,test,write=cmd
            for x in set(coverage)&set(clip)&full:
                if test and depth>=depths[x]: continue
                if test: depths[x]=depth
                if write: ids[x]=key
        else:
            out.append([ids[x] if -size<=x<size else None for x in cmd[1]])
    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([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 4), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 4), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 4), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 4), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 4), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 4), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 4), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 4), [[None]])
if N == 2:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 5), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 5), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 5), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 5), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 5), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 5), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 5), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 5), [[None]])
if N == 3:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 6), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 6), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 6), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 6), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 6), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 6), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 6), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 6), [[None]])
if N == 4:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 7), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 7), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 7), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 7), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 7), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 7), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 7), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 7), [[None]])
if N == 5:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 8), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 8), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 8), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 8), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 8), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 8), [[None, 'a', None, 'a']])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 8), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 8), [[None]])
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:
Out-of-target picking clamps to an edge object instead of returning no hit.

Each draw has an object ID, coverage samples, clip samples, integer depth, depth-test flag and ID-write flag. ID zero is a valid object. Pick samples start empty with infinite depth. With depth test enabled, strictly nearer fragments replace stored IDs and depth; equal depth keeps the earlier fragment. Disabled depth testing writes without changing depth. ID-write-disabled draws still update depth when tested. Queries return IDs or null for out-of-target samples.

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))
    ids=[None]*size
    depths=[float('inf')]*size
    out=[]
    for cmd in commands:
        if cmd[0]=='clear':
            for x in set(cmd[1])&full: ids[x]=None; depths[x]=float('inf')
        elif cmd[0]=='draw':
            _,key,coverage,clip,depth,test,write=cmd
            for x in set(coverage)&set(clip)&full:
                if test and depth>=depths[x]: continue
                if test: depths[x]=depth
                if write: ids[x]=key
        else:
            out.append([ids[x] if x in full else None for x in sorted(cmd[1])])
    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([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 4), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 4), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 4), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 4), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 4), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 4), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 4), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 4), [[None]])
if N == 2:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 5), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 5), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 5), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 5), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 5), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 5), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 5), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 5), [[None]])
if N == 3:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 6), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 6), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 6), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 6), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 6), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 6), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 6), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 6), [[None]])
if N == 4:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 7), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 7), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 7), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 7), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 7), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 7), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 7), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 7), [[None]])
if N == 5:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 8), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 8), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 8), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 8), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 8), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 8), [[None, 'a', None, 'a']])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 8), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 8), [[None]])
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))
    ids=[None]*size
    depths=[float('inf')]*size
    out=[]
    for cmd in commands:
        if cmd[0]=='clear':
            for x in set(cmd[1])&full: ids[x]=None; depths[x]=float('inf')
        elif cmd[0]=='draw':
            _,key,coverage,clip,depth,test,write=cmd
            for x in set(coverage)&set(clip)&full:
                if test and depth>=depths[x]: continue
                if test: depths[x]=depth
                if write: ids[x]=key
        else:
            out.append([ids[x] if x in full else None for x in sorted(set(cmd[1]))])
    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([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 4), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 4), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 4), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 4), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 4), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 4), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 4), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 4), [[None]])
if N == 2:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 5), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 5), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 5), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 5), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 5), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 5), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 5), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 5), [[None]])
if N == 3:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 6), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 6), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 6), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 6), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 6), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 6), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 6), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 6), [[None]])
if N == 4:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 7), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 7), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 7), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 7), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 7), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 7), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 7), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 7), [[None]])
if N == 5:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 8), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 8), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 8), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 8), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 8), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 8), [[None, 'a', None, 'a']])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 8), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 8), [[None]])
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:
Pick results are sorted by sample coordinate rather than matching request order.

Each draw has an object ID, coverage samples, clip samples, integer depth, depth-test flag and ID-write flag. ID zero is a valid object. Pick samples start empty with infinite depth. With depth test enabled, strictly nearer fragments replace stored IDs and depth; equal depth keeps the earlier fragment. Disabled depth testing writes without changing depth. ID-write-disabled draws still update depth when tested. Queries return IDs or null for out-of-target samples.

split: open-access


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

N = 1
observations = []
def solve(commands, size):
    out=[]
    for clips,culls,clip_mask,cull_mask,discard in commands:
        if not clips: out.append('discarded'); continue
        reject=False
        partial=False
        for plane in range(size):
            if clip_mask & (1<<plane):
                values=[v[plane] if plane<len(v) else 0 for v in clips]
                if all(x<0 for x in values): reject=True
                if any(x<0 for x in values): partial=True
            if cull_mask & (1<<plane):
                values=[v[plane] if plane<len(v) else 0 for v in culls]
                if values and all(x<0 for x in values): reject=True
        out.append('discarded' if reject else 'clipped' if partial else 'accepted')
    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([[[[1], [1]], [[1], [1]], 1, 0, True]], 4), ['discarded'])
    check('explicit sequence 1', solve([[[[-1], [1]], [[0], [0]], 1, 0, False]], 4), ['clipped'])
    check('explicit sequence 2', solve([[[[1], [-1]], [[0], [0]], 1, 0, False]], 4), ['clipped'])
    check('explicit sequence 3', solve([[[[1], [1]], [[-3], [1]], 0, 1, False]], 4), ['accepted'])
    check('explicit sequence 4', solve([[[[1], [1]], [[-1], [1]], 0, 1, False]], 4), ['accepted'])
    check('explicit sequence 5', solve([[[[-1], [-1]], [[0], [0]], 2, 0, False]], 4), ['accepted'])
    check('explicit sequence 6', solve([[[[0], [0]], [[-1], [-1]], 0, 2, False]], 4), ['accepted'])
    check('explicit sequence 7', solve([[[[1], [1]], [[-1], [-1]], 0, 1, False]], 4), ['discarded'])
    check('explicit sequence 8', solve([[[[-1], [1]], [[-1], [-1]], 1, 0, False]], 4), ['clipped'])
    check('explicit sequence 9', solve([[[[-1, 1], [1, 1]], [[-1], [-1]], 1, 1, False]], 4), ['discarded'])
    check('explicit sequence 10', solve([[[[1, 1, 1, 1, -1], [1, 1, 1, 1, -1]], [[0], [0]], 16, 0, False]], 4), ['accepted'])
    check('explicit sequence 11', solve([[[], [], 0, 0, False]], 4), ['discarded'])
    check('explicit sequence 12', solve([[[[0], [0]], [[0], [0]], 1, 1, False]], 4), ['accepted'])
    check('explicit sequence 13', solve([[[[-1], [-1], [1]], [[0], [0], [0]], 1, 0, False]], 4), ['clipped'])
    check('explicit sequence 14', solve([[[[-1], [1]], [[0], [0]], 0, 1, False]], 4), ['accepted'])
if N == 2:
    check('explicit sequence 0', solve([[[[1], [1]], [[1], [1]], 1, 0, True]], 5), ['discarded'])
    check('explicit sequence 1', solve([[[[-1], [1]], [[0], [0]], 1, 0, False]], 5), ['clipped'])
    check('explicit sequence 2', solve([[[[1], [-1]], [[0], [0]], 1, 0, False]], 5), ['clipped'])
    check('explicit sequence 3', solve([[[[1], [1]], [[-3], [1]], 0, 1, False]], 5), ['accepted'])
    check('explicit sequence 4', solve([[[[1], [1]], [[-1], [1]], 0, 1, False]], 5), ['accepted'])
    check('explicit sequence 5', solve([[[[-1], [-1]], [[0], [0]], 2, 0, False]], 5), ['accepted'])
    check('explicit sequence 6', solve([[[[0], [0]], [[-1], [-1]], 0, 2, False]], 5), ['accepted'])
    check('explicit sequence 7', solve([[[[1], [1]], [[-1], [-1]], 0, 1, False]], 5), ['discarded'])
    check('explicit sequence 8', solve([[[[-1], [1]], [[-1], [-1]], 1, 0, False]], 5), ['clipped'])
    check('explicit sequence 9', solve([[[[-1, 1], [1, 1]], [[-1], [-1]], 1, 1, False]], 5), ['discarded'])
    check('explicit sequence 10', solve([[[[1, 1, 1, 1, -1], [1, 1, 1, 1, -1]], [[0], [0]], 16, 0, False]], 5), ['discarded'])
    check('explicit sequence 11', solve([[[], [], 0, 0, False]], 5), ['discarded'])
    check('explicit sequence 12', solve([[[[0], [0]], [[0], [0]], 1, 1, False]], 5), ['accepted'])
    check('explicit sequence 13', solve([[[[-1], [-1], [1]], [[0], [0], [0]], 1, 0, False]], 5), ['clipped'])
    check('explicit sequence 14', solve([[[[-1], [1]], [[0], [0]], 0, 1, False]], 5), ['accepted'])
if N == 3:
    check('explicit sequence 0', solve([[[[1], [1]], [[1], [1]], 1, 0, True]], 6), ['discarded'])
    check('explicit sequence 1', solve([[[[-1], [1]], [[0], [0]], 1, 0, False]], 6), ['clipped'])
    check('explicit sequence 2', solve([[[[1], [-1]], [[0], [0]], 1, 0, False]], 6), ['clipped'])
    check('explicit sequence 3', solve([[[[1], [1]], [[-3], [1]], 0, 1, False]], 6), ['accepted'])
    check('explicit sequence 4', solve([[[[1], [1]], [[-1], [1]], 0, 1, False]], 6), ['accepted'])
    check('explicit sequence 5', solve([[[[-1], [-1]], [[0], [0]], 2, 0, False]], 6), ['accepted'])
    check('explicit sequence 6', solve([[[[0], [0]], [[-1], [-1]], 0, 2, False]], 6), ['accepted'])
    check('explicit sequence 7', solve([[[[1], [1]], [[-1], [-1]], 0, 1, False]], 6), ['discarded'])
    check('explicit sequence 8', solve([[[[-1], [1]], [[-1], [-1]], 1, 0, False]], 6), ['clipped'])
    check('explicit sequence 9', solve([[[[-1, 1], [1, 1]], [[-1], [-1]], 1, 1, False]], 6), ['discarded'])
    check('explicit sequence 10', solve([[[[1, 1, 1, 1, -1], [1, 1, 1, 1, -1]], [[0], [0]], 16, 0, False]], 6), ['discarded'])
    check('explicit sequence 11', solve([[[], [], 0, 0, False]], 6), ['discarded'])
    check('explicit sequence 12', solve([[[[0], [0]], [[0], [0]], 1, 1, False]], 6), ['accepted'])
    check('explicit sequence 13', solve([[[[-1], [-1], [1]], [[0], [0], [0]], 1, 0, False]], 6), ['clipped'])
    check('explicit sequence 14', solve([[[[-1], [1]], [[0], [0]], 0, 1, False]], 6), ['accepted'])
if N == 4:
    check('explicit sequence 0', solve([[[[1], [1]], [[1], [1]], 1, 0, True]], 7), ['discarded'])
    check('explicit sequence 1', solve([[[[-1], [1]], [[0], [0]], 1, 0, False]], 7), ['clipped'])
    check('explicit sequence 2', solve([[[[1], [-1]], [[0], [0]], 1, 0, False]], 7), ['clipped'])
    check('explicit sequence 3', solve([[[[1], [1]], [[-3], [1]], 0, 1, False]], 7), ['accepted'])
    check('explicit sequence 4', solve([[[[1], [1]], [[-1], [1]], 0, 1, False]], 7), ['accepted'])
    check('explicit sequence 5', solve([[[[-1], [-1]], [[0], [0]], 2, 0, False]], 7), ['accepted'])
    check('explicit sequence 6', solve([[[[0], [0]], [[-1], [-1]], 0, 2, False]], 7), ['accepted'])
    check('explicit sequence 7', solve([[[[1], [1]], [[-1], [-1]], 0, 1, False]], 7), ['discarded'])
    check('explicit sequence 8', solve([[[[-1], [1]], [[-1], [-1]], 1, 0, False]], 7), ['clipped'])
    check('explicit sequence 9', solve([[[[-1, 1], [1, 1]], [[-1], [-1]], 1, 1, False]], 7), ['discarded'])
    check('explicit sequence 10', solve([[[[1, 1, 1, 1, -1], [1, 1, 1, 1, -1]], [[0], [0]], 16, 0, False]], 7), ['discarded'])
    check('explicit sequence 11', solve([[[], [], 0, 0, False]], 7), ['discarded'])
    check('explicit sequence 12', solve([[[[0], [0]], [[0], [0]], 1, 1, False]], 7), ['accepted'])
    check('explicit sequence 13', solve([[[[-1], [-1], [1]], [[0], [0], [0]], 1, 0, False]], 7), ['clipped'])
    check('explicit sequence 14', solve([[[[-1], [1]], [[0], [0]], 0, 1, False]], 7), ['accepted'])
if N == 5:
    check('explicit sequence 0', solve([[[[1], [1]], [[1], [1]], 1, 0, True]], 8), ['discarded'])
    check('explicit sequence 1', solve([[[[-1], [1]], [[0], [0]], 1, 0, False]], 8), ['clipped'])
    check('explicit sequence 2', solve([[[[1], [-1]], [[0], [0]], 1, 0, False]], 8), ['clipped'])
    check('explicit sequence 3', solve([[[[1], [1]], [[-3], [1]], 0, 1, False]], 8), ['accepted'])
    check('explicit sequence 4', solve([[[[1], [1]], [[-1], [1]], 0, 1, False]], 8), ['accepted'])
    check('explicit sequence 5', solve([[[[-1], [-1]], [[0], [0]], 2, 0, False]], 8), ['accepted'])
    check('explicit sequence 6', solve([[[[0], [0]], [[-1], [-1]], 0, 2, False]], 8), ['accepted'])
    check('explicit sequence 7', solve([[[[1], [1]], [[-1], [-1]], 0, 1, False]], 8), ['discarded'])
    check('explicit sequence 8', solve([[[[-1], [1]], [[-1], [-1]], 1, 0, False]], 8), ['clipped'])
    check('explicit sequence 9', solve([[[[-1, 1], [1, 1]], [[-1], [-1]], 1, 1, False]], 8), ['discarded'])
    check('explicit sequence 10', solve([[[[1, 1, 1, 1, -1], [1, 1, 1, 1, -1]], [[0], [0]], 16, 0, False]], 8), ['discarded'])
    check('explicit sequence 11', solve([[[], [], 0, 0, False]], 8), ['discarded'])
    check('explicit sequence 12', solve([[[[0], [0]], [[0], [0]], 1, 1, False]], 8), ['accepted'])
    check('explicit sequence 13', solve([[[[-1], [-1], [1]], [[0], [0], [0]], 1, 0, False]], 8), ['clipped'])
    check('explicit sequence 14', solve([[[[-1], [1]], [[0], [0]], 0, 1, False]], 8), ['accepted'])
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 clips,culls,clip_mask,cull_mask,discard in commands:
        if (discard and not clip_mask) or not clips: out.append('discarded'); continue
        reject=False
        partial=False
        for plane in range(size):
            if clip_mask & (1<<plane):
                values=[v[plane] if plane<len(v) else 0 for v in clips]
                if all(x<0 for x in values): reject=True
                if any(x<0 for x in values): partial=True
            if cull_mask & (1<<plane):
                values=[v[plane] if plane<len(v) else 0 for v in culls]
                if values and all(x<0 for x in values): reject=True
        out.append('discarded' if reject else 'clipped' if partial else 'accepted')
    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([[[[1], [1]], [[1], [1]], 1, 0, True]], 4), ['discarded'])
    check('explicit sequence 1', solve([[[[-1], [1]], [[0], [0]], 1, 0, False]], 4), ['clipped'])
    check('explicit sequence 2', solve([[[[1], [-1]], [[0], [0]], 1, 0, False]], 4), ['clipped'])
    check('explicit sequence 3', solve([[[[1], [1]], [[-3], [1]], 0, 1, False]], 4), ['accepted'])
    check('explicit sequence 4', solve([[[[1], [1]], [[-1], [1]], 0, 1, False]], 4), ['accepted'])
    check('explicit sequence 5', solve([[[[-1], [-1]], [[0], [0]], 2, 0, False]], 4), ['accepted'])
    check('explicit sequence 6', solve([[[[0], [0]], [[-1], [-1]], 0, 2, False]], 4), ['accepted'])
    check('explicit sequence 7', solve([[[[1], [1]], [[-1], [-1]], 0, 1, False]], 4), ['discarded'])
    check('explicit sequence 8', solve([[[[-1], [1]], [[-1], [-1]], 1, 0, False]], 4), ['clipped'])
    check('explicit sequence 9', solve([[[[-1, 1], [1, 1]], [[-1], [-1]], 1, 1, False]], 4), ['discarded'])
    check('explicit sequence 10', solve([[[[1, 1, 1, 1, -1], [1, 1, 1, 1, -1]], [[0], [0]], 16, 0, False]], 4), ['accepted'])
    check('explicit sequence 11', solve([[[], [], 0, 0, False]], 4), ['discarded'])
    check('explicit sequence 12', solve([[[[0], [0]], [[0], [0]], 1, 1, False]], 4), ['accepted'])
    check('explicit sequence 13', solve([[[[-1], [-1], [1]], [[0], [0], [0]], 1, 0, False]], 4), ['clipped'])
    check('explicit sequence 14', solve([[[[-1], [1]], [[0], [0]], 0, 1, False]], 4), ['accepted'])
if N == 2:
    check('explicit sequence 0', solve([[[[1], [1]], [[1], [1]], 1, 0, True]], 5), ['discarded'])
    check('explicit sequence 1', solve([[[[-1], [1]], [[0], [0]], 1, 0, False]], 5), ['clipped'])
    check('explicit sequence 2', solve([[[[1], [-1]], [[0], [0]], 1, 0, False]], 5), ['clipped'])
    check('explicit sequence 3', solve([[[[1], [1]], [[-3], [1]], 0, 1, False]], 5), ['accepted'])
    check('explicit sequence 4', solve([[[[1], [1]], [[-1], [1]], 0, 1, False]], 5), ['accepted'])
    check('explicit sequence 5', solve([[[[-1], [-1]], [[0], [0]], 2, 0, False]], 5), ['accepted'])
    check('explicit sequence 6', solve([[[[0], [0]], [[-1], [-1]], 0, 2, False]], 5), ['accepted'])
    check('explicit sequence 7', solve([[[[1], [1]], [[-1], [-1]], 0, 1, False]], 5), ['discarded'])
    check('explicit sequence 8', solve([[[[-1], [1]], [[-1], [-1]], 1, 0, False]], 5), ['clipped'])
    check('explicit sequence 9', solve([[[[-1, 1], [1, 1]], [[-1], [-1]], 1, 1, False]], 5), ['discarded'])
    check('explicit sequence 10', solve([[[[1, 1, 1, 1, -1], [1, 1, 1, 1, -1]], [[0], [0]], 16, 0, False]], 5), ['discarded'])
    check('explicit sequence 11', solve([[[], [], 0, 0, False]], 5), ['discarded'])
    check('explicit sequence 12', solve([[[[0], [0]], [[0], [0]], 1, 1, False]], 5), ['accepted'])
    check('explicit sequence 13', solve([[[[-1], [-1], [1]], [[0], [0], [0]], 1, 0, False]], 5), ['clipped'])
    check('explicit sequence 14', solve([[[[-1], [1]], [[0], [0]], 0, 1, False]], 5), ['accepted'])
if N == 3:
    check('explicit sequence 0', solve([[[[1], [1]], [[1], [1]], 1, 0, True]], 6), ['discarded'])
    check('explicit sequence 1', solve([[[[-1], [1]], [[0], [0]], 1, 0, False]], 6), ['clipped'])
    check('explicit sequence 2', solve([[[[1], [-1]], [[0], [0]], 1, 0, False]], 6), ['clipped'])
    check('explicit sequence 3', solve([[[[1], [1]], [[-3], [1]], 0, 1, False]], 6), ['accepted'])
    check('explicit sequence 4', solve([[[[1], [1]], [[-1], [1]], 0, 1, False]], 6), ['accepted'])
    check('explicit sequence 5', solve([[[[-1], [-1]], [[0], [0]], 2, 0, False]], 6), ['accepted'])
    check('explicit sequence 6', solve([[[[0], [0]], [[-1], [-1]], 0, 2, False]], 6), ['accepted'])
    check('explicit sequence 7', solve([[[[1], [1]], [[-1], [-1]], 0, 1, False]], 6), ['discarded'])
    check('explicit sequence 8', solve([[[[-1], [1]], [[-1], [-1]], 1, 0, False]], 6), ['clipped'])
    check('explicit sequence 9', solve([[[[-1, 1], [1, 1]], [[-1], [-1]], 1, 1, False]], 6), ['discarded'])
    check('explicit sequence 10', solve([[[[1, 1, 1, 1, -1], [1, 1, 1, 1, -1]], [[0], [0]], 16, 0, False]], 6), ['discarded'])
    check('explicit sequence 11', solve([[[], [], 0, 0, False]], 6), ['discarded'])
    check('explicit sequence 12', solve([[[[0], [0]], [[0], [0]], 1, 1, False]], 6), ['accepted'])
    check('explicit sequence 13', solve([[[[-1], [-1], [1]], [[0], [0], [0]], 1, 0, False]], 6), ['clipped'])
    check('explicit sequence 14', solve([[[[-1], [1]], [[0], [0]], 0, 1, False]], 6), ['accepted'])
if N == 4:
    check('explicit sequence 0', solve([[[[1], [1]], [[1], [1]], 1, 0, True]], 7), ['discarded'])
    check('explicit sequence 1', solve([[[[-1], [1]], [[0], [0]], 1, 0, False]], 7), ['clipped'])
    check('explicit sequence 2', solve([[[[1], [-1]], [[0], [0]], 1, 0, False]], 7), ['clipped'])
    check('explicit sequence 3', solve([[[[1], [1]], [[-3], [1]], 0, 1, False]], 7), ['accepted'])
    check('explicit sequence 4', solve([[[[1], [1]], [[-1], [1]], 0, 1, False]], 7), ['accepted'])
    check('explicit sequence 5', solve([[[[-1], [-1]], [[0], [0]], 2, 0, False]], 7), ['accepted'])
    check('explicit sequence 6', solve([[[[0], [0]], [[-1], [-1]], 0, 2, False]], 7), ['accepted'])
    check('explicit sequence 7', solve([[[[1], [1]], [[-1], [-1]], 0, 1, False]], 7), ['discarded'])
    check('explicit sequence 8', solve([[[[-1], [1]], [[-1], [-1]], 1, 0, False]], 7), ['clipped'])
    check('explicit sequence 9', solve([[[[-1, 1], [1, 1]], [[-1], [-1]], 1, 1, False]], 7), ['discarded'])
    check('explicit sequence 10', solve([[[[1, 1, 1, 1, -1], [1, 1, 1, 1, -1]], [[0], [0]], 16, 0, False]], 7), ['discarded'])
    check('explicit sequence 11', solve([[[], [], 0, 0, False]], 7), ['discarded'])
    check('explicit sequence 12', solve([[[[0], [0]], [[0], [0]], 1, 1, False]], 7), ['accepted'])
    check('explicit sequence 13', solve([[[[-1], [-1], [1]], [[0], [0], [0]], 1, 0, False]], 7), ['clipped'])
    check('explicit sequence 14', solve([[[[-1], [1]], [[0], [0]], 0, 1, False]], 7), ['accepted'])
if N == 5:
    check('explicit sequence 0', solve([[[[1], [1]], [[1], [1]], 1, 0, True]], 8), ['discarded'])
    check('explicit sequence 1', solve([[[[-1], [1]], [[0], [0]], 1, 0, False]], 8), ['clipped'])
    check('explicit sequence 2', solve([[[[1], [-1]], [[0], [0]], 1, 0, False]], 8), ['clipped'])
    check('explicit sequence 3', solve([[[[1], [1]], [[-3], [1]], 0, 1, False]], 8), ['accepted'])
    check('explicit sequence 4', solve([[[[1], [1]], [[-1], [1]], 0, 1, False]], 8), ['accepted'])
    check('explicit sequence 5', solve([[[[-1], [-1]], [[0], [0]], 2, 0, False]], 8), ['accepted'])
    check('explicit sequence 6', solve([[[[0], [0]], [[-1], [-1]], 0, 2, False]], 8), ['accepted'])
    check('explicit sequence 7', solve([[[[1], [1]], [[-1], [-1]], 0, 1, False]], 8), ['discarded'])
    check('explicit sequence 8', solve([[[[-1], [1]], [[-1], [-1]], 1, 0, False]], 8), ['clipped'])
    check('explicit sequence 9', solve([[[[-1, 1], [1, 1]], [[-1], [-1]], 1, 1, False]], 8), ['discarded'])
    check('explicit sequence 10', solve([[[[1, 1, 1, 1, -1], [1, 1, 1, 1, -1]], [[0], [0]], 16, 0, False]], 8), ['discarded'])
    check('explicit sequence 11', solve([[[], [], 0, 0, False]], 8), ['discarded'])
    check('explicit sequence 12', solve([[[[0], [0]], [[0], [0]], 1, 1, False]], 8), ['accepted'])
    check('explicit sequence 13', solve([[[[-1], [-1], [1]], [[0], [0], [0]], 1, 0, False]], 8), ['clipped'])
    check('explicit sequence 14', solve([[[[-1], [1]], [[0], [0]], 0, 1, False]], 8), ['accepted'])
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:
Rasterizer discard is ignored by the distance-classification stage.

Each primitive carries per-vertex clip-distance and cull-distance arrays, active bitmasks and a raster-discard flag. A primitive is rejected if every vertex is negative on any one enabled clip or cull plane. Surviving primitives need clipping if any enabled clip distance is negative; cull distances never cause partial clipping. Missing components default to zero and disabled plane bits are ignored. Empty primitives and raster-discarded primitives emit discarded. Only low size plane slots exist.

split: open-access