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

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    history=[]
    current=set()
    redraw=set()
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='damage': current |= set(cmd[1]) & full
        elif op=='full': current=set(full)
        elif op=='begin':
            age=cmd[1]
            if age==0 or age-1>len(history): redraw=set(full)
            else:
                redraw=set(current)
                for old in history[:age-1]: redraw |= old
        elif op=='draw': out.append(sorted(redraw))
        elif op=='present':
            if True:
                history.insert(0,set(current))
                history=history[:3]
                current.clear()
        elif op=='resize':
            full=set(range(cmd[1]))
            history=[]
            current=set(full)
            redraw=set(full)
    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([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 4), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 4), [[0, 1, 2, 3], [0, 1, 2, 3]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 4), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 4), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 4), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 4), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 4), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 4), [[3]])
if N == 2:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 5), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 5), [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 5), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 5), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 5), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 5), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 5), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 5), [[3]])
if N == 3:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 6), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 6), [[0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 6), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 6), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 6), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 6), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 6), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 6), [[3]])
if N == 4:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 7), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 7), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 7), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 7), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 7), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 7), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 7), [[3]])
if N == 5:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 8), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 8), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 8), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 8), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 8), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 8), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 8), [[3]])
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))
    history=[]
    current=set()
    redraw=set()
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='damage': current |= set(cmd[1]) & full
        elif op=='full': current=set(full)
        elif op=='begin':
            age=cmd[1]
            if age==0 or age-1>len(history): redraw=set(full)
            else:
                redraw=set(current)
                for old in history[:age-1]: redraw |= old
        elif op=='draw': out.append(sorted(redraw))
        elif op=='present':
            if cmd[1] or not history:
                history.insert(0,set(current))
                history=history[:3]
                current.clear()
        elif op=='resize':
            full=set(range(cmd[1]))
            history=[]
            current=set(full)
            redraw=set(full)
    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([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 4), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 4), [[0, 1, 2, 3], [0, 1, 2, 3]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 4), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 4), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 4), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 4), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 4), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 4), [[3]])
if N == 2:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 5), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 5), [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 5), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 5), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 5), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 5), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 5), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 5), [[3]])
if N == 3:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 6), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 6), [[0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 6), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 6), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 6), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 6), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 6), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 6), [[3]])
if N == 4:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 7), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 7), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 7), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 7), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 7), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 7), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 7), [[3]])
if N == 5:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 8), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 8), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 8), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 8), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 8), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 8), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 8), [[3]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Failed presentation advances history even though the backbuffer was not swapped.

Each frame begins with current damage and backbuffer age. Age zero requires full redraw; age k includes current damage and the last k-1 successfully presented frames. Failed presentation neither stores history nor clears accumulated damage. Bounds are applied before drawing; explicit full damage survives incremental additions.

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))
    history=[]
    current=set()
    redraw=set()
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='damage': current |= set(cmd[1]) & full
        elif op=='full': current=set(full)
        elif op=='begin':
            age=cmd[1]
            if age==0 or age-1>len(history): redraw=set(full)
            else:
                redraw=set(current)
                for old in history[:age-1]: redraw |= old
        elif op=='draw': out.append(sorted(redraw))
        elif op=='present':
            if cmd[1]:
                history.insert(0,set(current))
                history=history[:3]
                pass
        elif op=='resize':
            full=set(range(cmd[1]))
            history=[]
            current=set(full)
            redraw=set(full)
    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([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 4), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 4), [[0, 1, 2, 3], [0, 1, 2, 3]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 4), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 4), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 4), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 4), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 4), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 4), [[3]])
if N == 2:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 5), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 5), [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 5), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 5), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 5), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 5), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 5), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 5), [[3]])
if N == 3:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 6), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 6), [[0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 6), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 6), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 6), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 6), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 6), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 6), [[3]])
if N == 4:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 7), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 7), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 7), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 7), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 7), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 7), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 7), [[3]])
if N == 5:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 8), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 8), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 8), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 8), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 8), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 8), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 8), [[3]])
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))
    history=[]
    current=set()
    redraw=set()
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='damage': current |= set(cmd[1]) & full
        elif op=='full': current=set(full)
        elif op=='begin':
            age=cmd[1]
            if age==0 or age-1>len(history): redraw=set(full)
            else:
                redraw=set(current)
                for old in history[:age-1]: redraw |= old
        elif op=='draw': out.append(sorted(redraw))
        elif op=='present':
            if cmd[1]:
                history.insert(0,set(current))
                history=history[:3]
                current -= redraw
        elif op=='resize':
            full=set(range(cmd[1]))
            history=[]
            current=set(full)
            redraw=set(full)
    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([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 4), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 4), [[0, 1, 2, 3], [0, 1, 2, 3]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 4), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 4), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 4), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 4), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 4), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 4), [[3]])
if N == 2:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 5), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 5), [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 5), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 5), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 5), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 5), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 5), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 5), [[3]])
if N == 3:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 6), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 6), [[0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 6), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 6), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 6), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 6), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 6), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 6), [[3]])
if N == 4:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 7), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 7), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 7), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 7), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 7), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 7), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 7), [[3]])
if N == 5:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 8), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 8), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 8), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 8), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 8), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 8), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 8), [[3]])
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:
Successfully presented damage remains in the next frame current-damage set.

Each frame begins with current damage and backbuffer age. Age zero requires full redraw; age k includes current damage and the last k-1 successfully presented frames. Failed presentation neither stores history nor clears accumulated damage. Bounds are applied before drawing; explicit full damage survives incremental additions.

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))
    history=[]
    current=set()
    redraw=set()
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='damage': current |= set(cmd[1]) & full
        elif op=='full': current=set(full)
        elif op=='begin':
            age=cmd[1]
            if age==0 or age-1>len(history): redraw=set(full)
            else:
                redraw=set(current)
                for old in history[:age-1]: redraw |= old
        elif op=='draw': out.append(sorted(redraw))
        elif op=='present':
            if cmd[1]:
                history.insert(0,set(current))
                history=history[:1]
                current.clear()
        elif op=='resize':
            full=set(range(cmd[1]))
            history=[]
            current=set(full)
            redraw=set(full)
    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([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 4), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 4), [[0, 1, 2, 3], [0, 1, 2, 3]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 4), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 4), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 4), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 4), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 4), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 4), [[3]])
if N == 2:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 5), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 5), [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 5), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 5), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 5), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 5), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 5), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 5), [[3]])
if N == 3:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 6), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 6), [[0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 6), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 6), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 6), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 6), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 6), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 6), [[3]])
if N == 4:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 7), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 7), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 7), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 7), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 7), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 7), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 7), [[3]])
if N == 5:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 8), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 8), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 8), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 8), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 8), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 8), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 8), [[3]])
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))
    history=[]
    current=set()
    redraw=set()
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='damage': current |= set(cmd[1]) & full
        elif op=='full': current=set(full)
        elif op=='begin':
            age=cmd[1]
            if age==0 or age-1>len(history): redraw=set(full)
            else:
                redraw=set(current)
                for old in history[:age-1]: redraw |= old
        elif op=='draw': out.append(sorted(redraw))
        elif op=='present':
            if cmd[1]:
                history.insert(0,set(current))
                history=history[-3:]
                current.clear()
        elif op=='resize':
            full=set(range(cmd[1]))
            history=[]
            current=set(full)
            redraw=set(full)
    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([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 4), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 4), [[0, 1, 2, 3], [0, 1, 2, 3]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 4), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 4), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 4), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 4), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 4), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 4), [[3]])
if N == 2:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 5), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 5), [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 5), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 5), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 5), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 5), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 5), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 5), [[3]])
if N == 3:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 6), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 6), [[0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 6), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 6), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 6), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 6), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 6), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 6), [[3]])
if N == 4:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 7), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 7), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 7), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 7), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 7), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 7), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 7), [[3]])
if N == 5:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 8), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 8), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 8), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 8), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 8), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 8), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 8), [[3]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The history cache evicts a damage frame still needed by supported backbuffer ages.

Each frame begins with current damage and backbuffer age. Age zero requires full redraw; age k includes current damage and the last k-1 successfully presented frames. Failed presentation neither stores history nor clears accumulated damage. Bounds are applied before drawing; explicit full damage survives incremental additions.

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))
    history=[]
    current=set()
    redraw=set()
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='damage': current |= set(cmd[1]) & full
        elif op=='full': current=set(full)
        elif op=='begin':
            age=cmd[1]
            if age==0 or age-1>len(history): redraw=set(full)
            else:
                redraw=set(current)
                for old in history[:age-1]: redraw |= old
        elif op=='draw': out.append(sorted(redraw))
        elif op=='present':
            if cmd[1]:
                history.insert(0,set(current))
                history=history[:3]
                current.clear()
        elif op=='resize':
            full=set(range(cmd[1]))
            history=[]
            current=current & full
            redraw=set(full)
    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([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 4), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 4), [[0, 1, 2, 3], [0, 1, 2, 3]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 4), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 4), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 4), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 4), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 4), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 4), [[3]])
if N == 2:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 5), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 5), [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 5), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 5), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 5), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 5), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 5), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 5), [[3]])
if N == 3:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 6), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 6), [[0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 6), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 6), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 6), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 6), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 6), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 6), [[3]])
if N == 4:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 7), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 7), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 7), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 7), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 7), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 7), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 7), [[3]])
if N == 5:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 8), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 8), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 8), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 8), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 8), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 8), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 8), [[3]])
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))
    history=[]
    current=set()
    redraw=set()
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='damage': current |= set(cmd[1]) & full
        elif op=='full': current=set(full)
        elif op=='begin':
            age=cmd[1]
            if age==0 or age-1>len(history): redraw=set(full)
            else:
                redraw=set(current)
                for old in history[:age-1]: redraw |= old
        elif op=='draw': out.append(sorted(redraw))
        elif op=='present':
            if cmd[1]:
                history.insert(0,set(current))
                history=history[:3]
                current.clear()
        elif op=='resize':
            full=set(range(cmd[1]))
            history=[]
            current=current | (full-set(range(size)))
            redraw=set(full)
    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([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 4), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 4), [[0, 1, 2, 3], [0, 1, 2, 3]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 4), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 4), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 4), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 4), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 4), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 4), [[3]])
if N == 2:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 5), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 5), [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 5), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 5), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 5), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 5), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 5), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 5), [[3]])
if N == 3:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 6), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 6), [[0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 6), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 6), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 6), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 6), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 6), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 6), [[3]])
if N == 4:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 7), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 7), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 7), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 7), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 7), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 7), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 7), [[3]])
if N == 5:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 8), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 8), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 8), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 8), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 8), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 8), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 8), [[3]])
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:
Resize fails to mark newly allocated samples dirty.

Each frame begins with current damage and backbuffer age. Age zero requires full redraw; age k includes current damage and the last k-1 successfully presented frames. Failed presentation neither stores history nor clears accumulated damage. Bounds are applied before drawing; explicit full damage survives incremental additions.

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))
    history=[]
    current=set()
    redraw=set()
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='damage': current |= set(cmd[1])
        elif op=='full': current=set(full)
        elif op=='begin':
            age=cmd[1]
            if age==0 or age-1>len(history): redraw=set(full)
            else:
                redraw=set(current)
                for old in history[:age-1]: redraw |= old
        elif op=='draw': out.append(sorted(redraw))
        elif op=='present':
            if cmd[1]:
                history.insert(0,set(current))
                history=history[:3]
                current.clear()
        elif op=='resize':
            full=set(range(cmd[1]))
            history=[]
            current=set(full)
            redraw=set(full)
    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([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 4), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 4), [[0, 1, 2, 3], [0, 1, 2, 3]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 4), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 4), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 4), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 4), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 4), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 4), [[3]])
if N == 2:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 5), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 5), [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 5), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 5), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 5), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 5), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 5), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 5), [[3]])
if N == 3:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 6), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 6), [[0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 6), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 6), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 6), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 6), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 6), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 6), [[3]])
if N == 4:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 7), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 7), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 7), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 7), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 7), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 7), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 7), [[3]])
if N == 5:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 8), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 8), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 8), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 8), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 8), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 8), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 8), [[3]])
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))
    history=[]
    current=set()
    redraw=set()
    out=[]
    for cmd in commands:
        op=cmd[0]
        if op=='damage': current |= {x for x in cmd[1] if x>=0}
        elif op=='full': current=set(full)
        elif op=='begin':
            age=cmd[1]
            if age==0 or age-1>len(history): redraw=set(full)
            else:
                redraw=set(current)
                for old in history[:age-1]: redraw |= old
        elif op=='draw': out.append(sorted(redraw))
        elif op=='present':
            if cmd[1]:
                history.insert(0,set(current))
                history=history[:3]
                current.clear()
        elif op=='resize':
            full=set(range(cmd[1]))
            history=[]
            current=set(full)
            redraw=set(full)
    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([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 4), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 4), [[0, 1, 2, 3], [0, 1, 2, 3]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 4), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 4), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 4), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 4), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 4), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 4), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 4), [[0, 1, 2, 3]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 4), [[3]])
if N == 2:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 5), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 5), [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 5), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 5), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 5), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 5), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 5), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 5), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 5), [[0, 1, 2, 3, 4]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 5), [[3]])
if N == 3:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 6), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 6), [[0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 6), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 6), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 6), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 6), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 6), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 6), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 6), [[0, 1, 2, 3, 4, 5]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 6), [[3]])
if N == 4:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 7), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 7), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 7), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 7), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 7), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 7), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 7), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 7), [[0, 1, 2, 3, 4, 5, 6]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 7), [[3]])
if N == 5:
    check('explicit sequence 0', solve([['damage', [0]], ['damage', [1]], ['begin', 1], ['draw']], 8), [[0, 1]])
    check('explicit sequence 1', solve([['damage', [0]], ['begin', 0], ['draw'], ['begin', 3], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 2', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['begin', 2], ['draw'], ['begin', 3], ['draw']], 8), [[1, 2], [0, 1, 2]])
    check('explicit sequence 3', solve([['damage', [0]], ['present', True], ['begin', 2], ['draw']], 8), [[0]])
    check('explicit sequence 4', solve([['damage', [0]], ['present', False], ['begin', 1], ['draw']], 8), [[0]])
    check('explicit sequence 5', solve([['damage', [0]], ['present', True], ['begin', 1], ['draw']], 8), [[]])
    check('explicit sequence 6', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['resize', 3], ['present', True], ['begin', 3], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 7', solve([['damage', [0]], ['present', True], ['resize', 3], ['begin', 1], ['draw']], 8), [[0, 1, 2]])
    check('explicit sequence 8', solve([['damage', [99, -1, 2]], ['begin', 1], ['draw']], 8), [[2]])
    check('explicit sequence 9', solve([['full'], ['damage', [0]], ['begin', 1], ['draw']], 8), [[0, 1, 2, 3, 4, 5, 6, 7]])
    check('explicit sequence 10', solve([['damage', [0]], ['present', True], ['damage', [1]], ['present', True], ['damage', [2]], ['present', True], ['damage', [3]], ['present', True], ['begin', 2], ['draw']], 8), [[3]])
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:
Damage commands retain nonexistent surface samples in the redraw clip.

Each frame begins with current damage and backbuffer age. Age zero requires full redraw; age k includes current damage and the last k-1 successfully presented frames. Failed presentation neither stores history nor clears accumulated damage. Bounds are applied before drawing; explicit full damage survives incremental additions.

split: open-access