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

N = 1
observations = []
def solve(d):
    try:
        points,intervals=d
        out=[]
        for ident,key,time in points:
            candidates=sorted(intervals,key=lambda r:(r[2],r[0]))
            for other,k,start,end in candidates:
                if key is None or key!=k: continue
                if start<=time and time<end:
                    out.append([time,other])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('end expired', solve([[[10, 'a', 3]], [[20, 'a', 1, 3]]]), [])
    check('start active', solve([[[10, 'a', 1]], [[20, 'a', 1, 3]]]), [[10, 20]])
    check('future inactive', solve([[[10, 'a', 1]], [[20, 'a', 2, 4]]]), [])
    check('overlap order', solve([[[10, 'a', 3]], [[20, 'a', 2, 5], [21, 'a', 1, 4]]]), [[10, 21], [10, 20]])
    check('other keys', solve([[[10, 'a', 2]], [[20, 'b', 1, 4], [21, None, 1, 4]]]), [])
    check('empty interval', solve([[[10, 'a', 1]], [[20, 'a', 1, 1]]]), [])
    check('null probe', solve([[[10, None, 2]], [[20, None, 1, 4]]]), [])
elif N == 2:
    check('end expired', solve([[[10, 'a', 4]], [[20, 'a', 2, 4]]]), [])
    check('start active', solve([[[10, 'a', 2]], [[20, 'a', 2, 4]]]), [[10, 20]])
    check('future inactive', solve([[[10, 'a', 2]], [[20, 'a', 3, 5]]]), [])
    check('overlap order', solve([[[10, 'a', 4]], [[20, 'a', 3, 6], [21, 'a', 2, 5]]]), [[10, 21], [10, 20]])
    check('other keys', solve([[[10, 'a', 3]], [[20, 'b', 2, 5], [21, None, 2, 5]]]), [])
    check('empty interval', solve([[[10, 'a', 2]], [[20, 'a', 2, 2]]]), [])
    check('null probe', solve([[[10, None, 3]], [[20, None, 2, 5]]]), [])
elif N == 3:
    check('end expired', solve([[[10, 'a', 5]], [[20, 'a', 3, 5]]]), [])
    check('start active', solve([[[10, 'a', 3]], [[20, 'a', 3, 5]]]), [[10, 20]])
    check('future inactive', solve([[[10, 'a', 3]], [[20, 'a', 4, 6]]]), [])
    check('overlap order', solve([[[10, 'a', 5]], [[20, 'a', 4, 7], [21, 'a', 3, 6]]]), [[10, 21], [10, 20]])
    check('other keys', solve([[[10, 'a', 4]], [[20, 'b', 3, 6], [21, None, 3, 6]]]), [])
    check('empty interval', solve([[[10, 'a', 3]], [[20, 'a', 3, 3]]]), [])
    check('null probe', solve([[[10, None, 4]], [[20, None, 3, 6]]]), [])
elif N == 4:
    check('end expired', solve([[[10, 'a', 6]], [[20, 'a', 4, 6]]]), [])
    check('start active', solve([[[10, 'a', 4]], [[20, 'a', 4, 6]]]), [[10, 20]])
    check('future inactive', solve([[[10, 'a', 4]], [[20, 'a', 5, 7]]]), [])
    check('overlap order', solve([[[10, 'a', 6]], [[20, 'a', 5, 8], [21, 'a', 4, 7]]]), [[10, 21], [10, 20]])
    check('other keys', solve([[[10, 'a', 5]], [[20, 'b', 4, 7], [21, None, 4, 7]]]), [])
    check('empty interval', solve([[[10, 'a', 4]], [[20, 'a', 4, 4]]]), [])
    check('null probe', solve([[[10, None, 5]], [[20, None, 4, 7]]]), [])
elif N == 5:
    check('end expired', solve([[[10, 'a', 7]], [[20, 'a', 5, 7]]]), [])
    check('start active', solve([[[10, 'a', 5]], [[20, 'a', 5, 7]]]), [[10, 20]])
    check('future inactive', solve([[[10, 'a', 5]], [[20, 'a', 6, 8]]]), [])
    check('overlap order', solve([[[10, 'a', 7]], [[20, 'a', 6, 9], [21, 'a', 5, 8]]]), [[10, 21], [10, 20]])
    check('other keys', solve([[[10, 'a', 6]], [[20, 'b', 5, 8], [21, None, 5, 8]]]), [])
    check('empty interval', solve([[[10, 'a', 5]], [[20, 'a', 5, 5]]]), [])
    check('null probe', solve([[[10, None, 6]], [[20, None, 5, 8]]]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        points,intervals=d
        out=[]
        for ident,key,time in points:
            candidates=sorted(intervals,key=lambda r:(r[2],r[0]))
            for other,k,start,end in candidates:
                if key is None or key!=k: continue
                if start<=time and time<end:
                    out.append([key,other])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('end expired', solve([[[10, 'a', 3]], [[20, 'a', 1, 3]]]), [])
    check('start active', solve([[[10, 'a', 1]], [[20, 'a', 1, 3]]]), [[10, 20]])
    check('future inactive', solve([[[10, 'a', 1]], [[20, 'a', 2, 4]]]), [])
    check('overlap order', solve([[[10, 'a', 3]], [[20, 'a', 2, 5], [21, 'a', 1, 4]]]), [[10, 21], [10, 20]])
    check('other keys', solve([[[10, 'a', 2]], [[20, 'b', 1, 4], [21, None, 1, 4]]]), [])
    check('empty interval', solve([[[10, 'a', 1]], [[20, 'a', 1, 1]]]), [])
    check('null probe', solve([[[10, None, 2]], [[20, None, 1, 4]]]), [])
elif N == 2:
    check('end expired', solve([[[10, 'a', 4]], [[20, 'a', 2, 4]]]), [])
    check('start active', solve([[[10, 'a', 2]], [[20, 'a', 2, 4]]]), [[10, 20]])
    check('future inactive', solve([[[10, 'a', 2]], [[20, 'a', 3, 5]]]), [])
    check('overlap order', solve([[[10, 'a', 4]], [[20, 'a', 3, 6], [21, 'a', 2, 5]]]), [[10, 21], [10, 20]])
    check('other keys', solve([[[10, 'a', 3]], [[20, 'b', 2, 5], [21, None, 2, 5]]]), [])
    check('empty interval', solve([[[10, 'a', 2]], [[20, 'a', 2, 2]]]), [])
    check('null probe', solve([[[10, None, 3]], [[20, None, 2, 5]]]), [])
elif N == 3:
    check('end expired', solve([[[10, 'a', 5]], [[20, 'a', 3, 5]]]), [])
    check('start active', solve([[[10, 'a', 3]], [[20, 'a', 3, 5]]]), [[10, 20]])
    check('future inactive', solve([[[10, 'a', 3]], [[20, 'a', 4, 6]]]), [])
    check('overlap order', solve([[[10, 'a', 5]], [[20, 'a', 4, 7], [21, 'a', 3, 6]]]), [[10, 21], [10, 20]])
    check('other keys', solve([[[10, 'a', 4]], [[20, 'b', 3, 6], [21, None, 3, 6]]]), [])
    check('empty interval', solve([[[10, 'a', 3]], [[20, 'a', 3, 3]]]), [])
    check('null probe', solve([[[10, None, 4]], [[20, None, 3, 6]]]), [])
elif N == 4:
    check('end expired', solve([[[10, 'a', 6]], [[20, 'a', 4, 6]]]), [])
    check('start active', solve([[[10, 'a', 4]], [[20, 'a', 4, 6]]]), [[10, 20]])
    check('future inactive', solve([[[10, 'a', 4]], [[20, 'a', 5, 7]]]), [])
    check('overlap order', solve([[[10, 'a', 6]], [[20, 'a', 5, 8], [21, 'a', 4, 7]]]), [[10, 21], [10, 20]])
    check('other keys', solve([[[10, 'a', 5]], [[20, 'b', 4, 7], [21, None, 4, 7]]]), [])
    check('empty interval', solve([[[10, 'a', 4]], [[20, 'a', 4, 4]]]), [])
    check('null probe', solve([[[10, None, 5]], [[20, None, 4, 7]]]), [])
elif N == 5:
    check('end expired', solve([[[10, 'a', 7]], [[20, 'a', 5, 7]]]), [])
    check('start active', solve([[[10, 'a', 5]], [[20, 'a', 5, 7]]]), [[10, 20]])
    check('future inactive', solve([[[10, 'a', 5]], [[20, 'a', 6, 8]]]), [])
    check('overlap order', solve([[[10, 'a', 7]], [[20, 'a', 6, 9], [21, 'a', 5, 8]]]), [[10, 21], [10, 20]])
    check('other keys', solve([[[10, 'a', 6]], [[20, 'b', 5, 8], [21, None, 5, 8]]]), [])
    check('empty interval', solve([[[10, 'a', 5]], [[20, 'a', 5, 5]]]), [])
    check('null probe', solve([[[10, None, 6]], [[20, None, 5, 8]]]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Interval join emits timestamp in place of probe identity.

Join probe points [id,key,time] to interval rows [id,key,start,end] under start<=time<end and ordinary non-null key equality. Emit probe-major [probe-id,interval-id] pairs, with matching intervals ordered by (start,id). Empty intervals never match; overlapping intervals all produce rows.

split: open-access


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

N = 1
observations = []
def solve(x):
    cap, head, size, requested = x
    free = size
    grant = min(requested, free)
    tail = (head + size) % cap
    first = min(grant, cap - tail)
    second = grant - first
    return [grant, tail, first, second, free - grant]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped free region', solve([N+5, N+3, 1, 3]), [3,N+4,1,2,N+1])
check('limited free space', solve([N+5, 2, N+3, 4]), [2,0,2,0,0])
check('empty shifted ring', solve([N+5,N+4,0,4]), [4,N+4,1,3,N+1])
check('empty request', solve([N+5,1,2,0]), [0,3,0,0,N+3])
check('full ring', solve([N+5,2,N+5,3]), [0,2,0,0,0])
check('contiguous grant', solve([N+5,0,1,2]), [2,1,2,0,N+2])
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(x):
    cap, head, size, requested = x
    free = cap if size == 0 else size
    grant = min(requested, free)
    tail = (head + size) % cap
    first = min(grant, cap - tail)
    second = grant - first
    return [grant, tail, first, second, free - grant]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped free region', solve([N+5, N+3, 1, 3]), [3,N+4,1,2,N+1])
check('limited free space', solve([N+5, 2, N+3, 4]), [2,0,2,0,0])
check('empty shifted ring', solve([N+5,N+4,0,4]), [4,N+4,1,3,N+1])
check('empty request', solve([N+5,1,2,0]), [0,3,0,0,N+3])
check('full ring', solve([N+5,2,N+5,3]), [0,2,0,0,0])
check('contiguous grant', solve([N+5,0,1,2]), [2,1,2,0,N+2])
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:
Reservation counts occupied slots as available.

Reserve up to requested free positions in a reject-on-full ring. Return [grant,tail,first-span,second-span,free-after]. Head and size are valid, capacity positive.

split: open-access


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

N = 1
observations = []
def solve(x):
    cap, head, size, requested = x
    free = cap - size
    grant = requested
    tail = (head + size) % cap
    first = min(grant, cap - tail)
    second = grant - first
    return [grant, tail, first, second, free - grant]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped free region', solve([N+5, N+3, 1, 3]), [3,N+4,1,2,N+1])
check('limited free space', solve([N+5, 2, N+3, 4]), [2,0,2,0,0])
check('empty shifted ring', solve([N+5,N+4,0,4]), [4,N+4,1,3,N+1])
check('empty request', solve([N+5,1,2,0]), [0,3,0,0,N+3])
check('full ring', solve([N+5,2,N+5,3]), [0,2,0,0,0])
check('contiguous grant', solve([N+5,0,1,2]), [2,1,2,0,N+2])
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(x):
    cap, head, size, requested = x
    free = cap - size
    grant = 0 if free == 0 else requested
    tail = (head + size) % cap
    first = min(grant, cap - tail)
    second = grant - first
    return [grant, tail, first, second, free - grant]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped free region', solve([N+5, N+3, 1, 3]), [3,N+4,1,2,N+1])
check('limited free space', solve([N+5, 2, N+3, 4]), [2,0,2,0,0])
check('empty shifted ring', solve([N+5,N+4,0,4]), [4,N+4,1,3,N+1])
check('empty request', solve([N+5,1,2,0]), [0,3,0,0,N+3])
check('full ring', solve([N+5,2,N+5,3]), [0,2,0,0,0])
check('contiguous grant', solve([N+5,0,1,2]), [2,1,2,0,N+2])
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:
Reservation exceeds the available slot budget.

Reserve up to requested free positions in a reject-on-full ring. Return [grant,tail,first-span,second-span,free-after]. Head and size are valid, capacity positive.

split: open-access


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

N = 1
observations = []
def solve(x):
    cap, head, size, requested = x
    free = cap - size
    grant = min(requested, free)
    tail = head
    first = min(grant, cap - tail)
    second = grant - first
    return [grant, tail, first, second, free - grant]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped free region', solve([N+5, N+3, 1, 3]), [3,N+4,1,2,N+1])
check('limited free space', solve([N+5, 2, N+3, 4]), [2,0,2,0,0])
check('empty shifted ring', solve([N+5,N+4,0,4]), [4,N+4,1,3,N+1])
check('empty request', solve([N+5,1,2,0]), [0,3,0,0,N+3])
check('full ring', solve([N+5,2,N+5,3]), [0,2,0,0,0])
check('contiguous grant', solve([N+5,0,1,2]), [2,1,2,0,N+2])
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(x):
    cap, head, size, requested = x
    free = cap - size
    grant = min(requested, free)
    tail = (head + 1) % cap if size == 1 else head
    first = min(grant, cap - tail)
    second = grant - first
    return [grant, tail, first, second, free - grant]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped free region', solve([N+5, N+3, 1, 3]), [3,N+4,1,2,N+1])
check('limited free space', solve([N+5, 2, N+3, 4]), [2,0,2,0,0])
check('empty shifted ring', solve([N+5,N+4,0,4]), [4,N+4,1,3,N+1])
check('empty request', solve([N+5,1,2,0]), [0,3,0,0,N+3])
check('full ring', solve([N+5,2,N+5,3]), [0,2,0,0,0])
check('contiguous grant', solve([N+5,0,1,2]), [2,1,2,0,N+2])
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:
Reservation starts at the head instead of the write cursor.

Reserve up to requested free positions in a reject-on-full ring. Return [grant,tail,first-span,second-span,free-after]. Head and size are valid, capacity positive.

split: open-access


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

N = 1
observations = []
def solve(x):
    cap, head, size, requested = x
    free = cap - size
    grant = min(requested, free)
    tail = (head + size) % cap
    first = grant
    second = grant - first
    return [grant, tail, first, second, free - grant]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped free region', solve([N+5, N+3, 1, 3]), [3,N+4,1,2,N+1])
check('limited free space', solve([N+5, 2, N+3, 4]), [2,0,2,0,0])
check('empty shifted ring', solve([N+5,N+4,0,4]), [4,N+4,1,3,N+1])
check('empty request', solve([N+5,1,2,0]), [0,3,0,0,N+3])
check('full ring', solve([N+5,2,N+5,3]), [0,2,0,0,0])
check('contiguous grant', solve([N+5,0,1,2]), [2,1,2,0,N+2])
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(x):
    cap, head, size, requested = x
    free = cap - size
    grant = min(requested, free)
    tail = (head + size) % cap
    first = min(grant, cap) if tail else grant
    second = grant - first
    return [grant, tail, first, second, free - grant]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped free region', solve([N+5, N+3, 1, 3]), [3,N+4,1,2,N+1])
check('limited free space', solve([N+5, 2, N+3, 4]), [2,0,2,0,0])
check('empty shifted ring', solve([N+5,N+4,0,4]), [4,N+4,1,3,N+1])
check('empty request', solve([N+5,1,2,0]), [0,3,0,0,N+3])
check('full ring', solve([N+5,2,N+5,3]), [0,2,0,0,0])
check('contiguous grant', solve([N+5,0,1,2]), [2,1,2,0,N+2])
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:
Reservation treats a wrapping region as contiguous.

Reserve up to requested free positions in a reject-on-full ring. Return [grant,tail,first-span,second-span,free-after]. Head and size are valid, capacity positive.

split: open-access


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

N = 1
observations = []
def solve(x):
    cap, head, size, requested = x
    free = cap - size
    grant = min(requested, free)
    tail = (head + size) % cap
    first = min(grant, cap - tail)
    second = first
    return [grant, tail, first, second, free - grant]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped free region', solve([N+5, N+3, 1, 3]), [3,N+4,1,2,N+1])
check('limited free space', solve([N+5, 2, N+3, 4]), [2,0,2,0,0])
check('empty shifted ring', solve([N+5,N+4,0,4]), [4,N+4,1,3,N+1])
check('empty request', solve([N+5,1,2,0]), [0,3,0,0,N+3])
check('full ring', solve([N+5,2,N+5,3]), [0,2,0,0,0])
check('contiguous grant', solve([N+5,0,1,2]), [2,1,2,0,N+2])
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(x):
    cap, head, size, requested = x
    free = cap - size
    grant = min(requested, free)
    tail = (head + size) % cap
    first = min(grant, cap - tail)
    second = 0 if first == grant else first
    return [grant, tail, first, second, free - grant]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped free region', solve([N+5, N+3, 1, 3]), [3,N+4,1,2,N+1])
check('limited free space', solve([N+5, 2, N+3, 4]), [2,0,2,0,0])
check('empty shifted ring', solve([N+5,N+4,0,4]), [4,N+4,1,3,N+1])
check('empty request', solve([N+5,1,2,0]), [0,3,0,0,N+3])
check('full ring', solve([N+5,2,N+5,3]), [0,2,0,0,0])
check('contiguous grant', solve([N+5,0,1,2]), [2,1,2,0,N+2])
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:
Reservation reuses the first span as the wrapped span.

Reserve up to requested free positions in a reject-on-full ring. Return [grant,tail,first-span,second-span,free-after]. Head and size are valid, capacity positive.

split: open-access


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

N = 1
observations = []
def solve(x):
    cap, head, size, requested = x
    count = requested
    cleared = [(head + i) % cap for i in range(count)]
    new_head = (head + count) % cap
    remaining = size - count
    crossed = head + count > cap
    return [new_head, remaining, cleared, crossed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrap consume', solve([N+5,N+4,4,3]), [2,1,[N+4,0,1],True])
check('oversized consume', solve([N+5,1,2,4]), [3,0,[1,2],False])
check('empty', solve([N+5,2,0,4]), [2,0,[],False])
check('zero consume', solve([N+5,2,3,0]), [2,3,[],False])
check('exact boundary', solve([N+5,N+3,2,2]), [0,0,[N+3,N+4],False])
check('single retained', solve([N+5,1,3,2]), [3,1,[1,2],False])
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(x):
    cap, head, size, requested = x
    count = 0 if size == 0 else requested
    cleared = [(head + i) % cap for i in range(count)]
    new_head = (head + count) % cap
    remaining = size - count
    crossed = head + count > cap
    return [new_head, remaining, cleared, crossed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrap consume', solve([N+5,N+4,4,3]), [2,1,[N+4,0,1],True])
check('oversized consume', solve([N+5,1,2,4]), [3,0,[1,2],False])
check('empty', solve([N+5,2,0,4]), [2,0,[],False])
check('zero consume', solve([N+5,2,3,0]), [2,3,[],False])
check('exact boundary', solve([N+5,N+3,2,2]), [0,0,[N+3,N+4],False])
check('single retained', solve([N+5,1,3,2]), [3,1,[1,2],False])
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:
Bulk consume advances across unoccupied slots.

Consume min(requested,size) slots from a ring. Report new head, count, cleared physical slots, and whether its occupied arc crossed the physical boundary.

split: open-access


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

N = 1
observations = []
def solve(x):
    cap, head, size, requested = x
    count = min(requested, size)
    cleared = list(range(count))
    new_head = (head + count) % cap
    remaining = size - count
    crossed = head + count > cap
    return [new_head, remaining, cleared, crossed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrap consume', solve([N+5,N+4,4,3]), [2,1,[N+4,0,1],True])
check('oversized consume', solve([N+5,1,2,4]), [3,0,[1,2],False])
check('empty', solve([N+5,2,0,4]), [2,0,[],False])
check('zero consume', solve([N+5,2,3,0]), [2,3,[],False])
check('exact boundary', solve([N+5,N+3,2,2]), [0,0,[N+3,N+4],False])
check('single retained', solve([N+5,1,3,2]), [3,1,[1,2],False])
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(x):
    cap, head, size, requested = x
    count = min(requested, size)
    cleared = [(head + i) % cap for i in range(count)] if head == 1 else list(range(count))
    new_head = (head + count) % cap
    remaining = size - count
    crossed = head + count > cap
    return [new_head, remaining, cleared, crossed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrap consume', solve([N+5,N+4,4,3]), [2,1,[N+4,0,1],True])
check('oversized consume', solve([N+5,1,2,4]), [3,0,[1,2],False])
check('empty', solve([N+5,2,0,4]), [2,0,[],False])
check('zero consume', solve([N+5,2,3,0]), [2,3,[],False])
check('exact boundary', solve([N+5,N+3,2,2]), [0,0,[N+3,N+4],False])
check('single retained', solve([N+5,1,3,2]), [3,1,[1,2],False])
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:
Bulk consume clears slots relative to array zero.

Consume min(requested,size) slots from a ring. Report new head, count, cleared physical slots, and whether its occupied arc crossed the physical boundary.

split: open-access


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

N = 1
observations = []
def solve(x):
    cap, head, size, requested = x
    count = min(requested, size)
    cleared = [(head + i) % cap for i in range(count)]
    new_head = head + count
    remaining = size - count
    crossed = head + count > cap
    return [new_head, remaining, cleared, crossed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrap consume', solve([N+5,N+4,4,3]), [2,1,[N+4,0,1],True])
check('oversized consume', solve([N+5,1,2,4]), [3,0,[1,2],False])
check('empty', solve([N+5,2,0,4]), [2,0,[],False])
check('zero consume', solve([N+5,2,3,0]), [2,3,[],False])
check('exact boundary', solve([N+5,N+3,2,2]), [0,0,[N+3,N+4],False])
check('single retained', solve([N+5,1,3,2]), [3,1,[1,2],False])
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(x):
    cap, head, size, requested = x
    count = min(requested, size)
    cleared = [(head + i) % cap for i in range(count)]
    new_head = 0 if head + count == cap else head + count
    remaining = size - count
    crossed = head + count > cap
    return [new_head, remaining, cleared, crossed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrap consume', solve([N+5,N+4,4,3]), [2,1,[N+4,0,1],True])
check('oversized consume', solve([N+5,1,2,4]), [3,0,[1,2],False])
check('empty', solve([N+5,2,0,4]), [2,0,[],False])
check('zero consume', solve([N+5,2,3,0]), [2,3,[],False])
check('exact boundary', solve([N+5,N+3,2,2]), [0,0,[N+3,N+4],False])
check('single retained', solve([N+5,1,3,2]), [3,1,[1,2],False])
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:
Read cursor escapes the backing allocation after consume.

Consume min(requested,size) slots from a ring. Report new head, count, cleared physical slots, and whether its occupied arc crossed the physical boundary.

split: open-access


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

N = 1
observations = []
def solve(x):
    cap, head, size, requested = x
    count = min(requested, size)
    cleared = [(head + i) % cap for i in range(count)]
    new_head = (head + count) % cap
    remaining = count
    crossed = head + count > cap
    return [new_head, remaining, cleared, crossed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrap consume', solve([N+5,N+4,4,3]), [2,1,[N+4,0,1],True])
check('oversized consume', solve([N+5,1,2,4]), [3,0,[1,2],False])
check('empty', solve([N+5,2,0,4]), [2,0,[],False])
check('zero consume', solve([N+5,2,3,0]), [2,3,[],False])
check('exact boundary', solve([N+5,N+3,2,2]), [0,0,[N+3,N+4],False])
check('single retained', solve([N+5,1,3,2]), [3,1,[1,2],False])
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(x):
    cap, head, size, requested = x
    count = min(requested, size)
    cleared = [(head + i) % cap for i in range(count)]
    new_head = (head + count) % cap
    remaining = 0 if count == size else count
    crossed = head + count > cap
    return [new_head, remaining, cleared, crossed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrap consume', solve([N+5,N+4,4,3]), [2,1,[N+4,0,1],True])
check('oversized consume', solve([N+5,1,2,4]), [3,0,[1,2],False])
check('empty', solve([N+5,2,0,4]), [2,0,[],False])
check('zero consume', solve([N+5,2,3,0]), [2,3,[],False])
check('exact boundary', solve([N+5,N+3,2,2]), [0,0,[N+3,N+4],False])
check('single retained', solve([N+5,1,3,2]), [3,1,[1,2],False])
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:
Consume overwrites occupancy with the consumed length.

Consume min(requested,size) slots from a ring. Report new head, count, cleared physical slots, and whether its occupied arc crossed the physical boundary.

split: open-access


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

N = 1
observations = []
def solve(x):
    cap, head, size, requested = x
    count = min(requested, size)
    cleared = [(head + i) % cap for i in range(count)]
    new_head = (head + count) % cap
    remaining = size - count
    crossed = head + count >= cap
    return [new_head, remaining, cleared, crossed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrap consume', solve([N+5,N+4,4,3]), [2,1,[N+4,0,1],True])
check('oversized consume', solve([N+5,1,2,4]), [3,0,[1,2],False])
check('empty', solve([N+5,2,0,4]), [2,0,[],False])
check('zero consume', solve([N+5,2,3,0]), [2,3,[],False])
check('exact boundary', solve([N+5,N+3,2,2]), [0,0,[N+3,N+4],False])
check('single retained', solve([N+5,1,3,2]), [3,1,[1,2],False])
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(x):
    cap, head, size, requested = x
    count = min(requested, size)
    cleared = [(head + i) % cap for i in range(count)]
    new_head = (head + count) % cap
    remaining = size - count
    crossed = count > 0 and head + count >= cap
    return [new_head, remaining, cleared, crossed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrap consume', solve([N+5,N+4,4,3]), [2,1,[N+4,0,1],True])
check('oversized consume', solve([N+5,1,2,4]), [3,0,[1,2],False])
check('empty', solve([N+5,2,0,4]), [2,0,[],False])
check('zero consume', solve([N+5,2,3,0]), [2,3,[],False])
check('exact boundary', solve([N+5,N+3,2,2]), [0,0,[N+3,N+4],False])
check('single retained', solve([N+5,1,3,2]), [3,1,[1,2],False])
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:
Consume flags a boundary-touch as a split memory region.

Consume min(requested,size) slots from a ring. Report new head, count, cleared physical slots, and whether its occupied arc crossed the physical boundary.

split: open-access


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

N = 1
observations = []
def solve(x):
    slots, head, size, capacity = x
    old = len(slots)
    live = slots[:size]
    new = live + [None] * (capacity - size)
    new_head = 0
    write = size % capacity
    return [new, new_head, write, size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped live data', solve([[N,None,None,N+1,N+2],3,3,7]), [[N+1,N+2,N,None,None,None,None],0,3,3])
check('empty shifted ring', solve([[None]*4,3,0,6]), [[None]*6,0,0,0])
check('one shifted value', solve([[None,N,None],1,1,5]), [[N,None,None,None,None],0,1,1])
check('full old ring', solve([[N,N+1,N+2],1,3,5]), [[N+1,N+2,N,None,None],0,3,3])
check('head zero', solve([[N,N+1,None],0,2,6]), [[N,N+1,None,None,None,None],0,2,2])
check('two wrapped values', solve([[N,None,None,N+1],3,2,8]), [[N+1,N,None,None,None,None,None,None],0,2,2])
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(x):
    slots, head, size, capacity = x
    old = len(slots)
    live = slots[head:head+size] if head + size <= old else slots[:size]
    new = live + [None] * (capacity - size)
    new_head = 0
    write = size % capacity
    return [new, new_head, write, size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped live data', solve([[N,None,None,N+1,N+2],3,3,7]), [[N+1,N+2,N,None,None,None,None],0,3,3])
check('empty shifted ring', solve([[None]*4,3,0,6]), [[None]*6,0,0,0])
check('one shifted value', solve([[None,N,None],1,1,5]), [[N,None,None,None,None],0,1,1])
check('full old ring', solve([[N,N+1,N+2],1,3,5]), [[N+1,N+2,N,None,None],0,3,3])
check('head zero', solve([[N,N+1,None],0,2,6]), [[N,N+1,None,None,None,None],0,2,2])
check('two wrapped values', solve([[N,None,None,N+1],3,2,8]), [[N+1,N,None,None,None,None,None,None],0,2,2])
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:
Growing a wrapped ring copies physical order.

Grow a ring to larger positive capacity. Linearize occupied slots in logical order, clear unused storage, reset head and report next insertion index and unchanged logical count.

split: open-access


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

N = 1
observations = []
def solve(x):
    slots, head, size, capacity = x
    old = len(slots)
    live = [slots[(head + i) % old] for i in range(size)]
    new = live + [None] * (old - size)
    new_head = 0
    write = size % capacity
    return [new, new_head, write, size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped live data', solve([[N,None,None,N+1,N+2],3,3,7]), [[N+1,N+2,N,None,None,None,None],0,3,3])
check('empty shifted ring', solve([[None]*4,3,0,6]), [[None]*6,0,0,0])
check('one shifted value', solve([[None,N,None],1,1,5]), [[N,None,None,None,None],0,1,1])
check('full old ring', solve([[N,N+1,N+2],1,3,5]), [[N+1,N+2,N,None,None],0,3,3])
check('head zero', solve([[N,N+1,None],0,2,6]), [[N,N+1,None,None,None,None],0,2,2])
check('two wrapped values', solve([[N,None,None,N+1],3,2,8]), [[N+1,N,None,None,None,None,None,None],0,2,2])
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(x):
    slots, head, size, capacity = x
    old = len(slots)
    live = [slots[(head + i) % old] for i in range(size)]
    new = live + [None] * (capacity - size if size == 0 else old - size)
    new_head = 0
    write = size % capacity
    return [new, new_head, write, size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped live data', solve([[N,None,None,N+1,N+2],3,3,7]), [[N+1,N+2,N,None,None,None,None],0,3,3])
check('empty shifted ring', solve([[None]*4,3,0,6]), [[None]*6,0,0,0])
check('one shifted value', solve([[None,N,None],1,1,5]), [[N,None,None,None,None],0,1,1])
check('full old ring', solve([[N,N+1,N+2],1,3,5]), [[N+1,N+2,N,None,None],0,3,3])
check('head zero', solve([[N,N+1,None],0,2,6]), [[N,N+1,None,None,None,None],0,2,2])
check('two wrapped values', solve([[N,None,None,N+1],3,2,8]), [[N+1,N,None,None,None,None,None,None],0,2,2])
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:
Growth leaves old-capacity slack instead of new-capacity slack.

Grow a ring to larger positive capacity. Linearize occupied slots in logical order, clear unused storage, reset head and report next insertion index and unchanged logical count.

split: open-access


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

N = 1
observations = []
def solve(x):
    slots, head, size, capacity = x
    old = len(slots)
    live = [slots[(head + i) % old] for i in range(size)]
    new = live + [None] * (capacity - size)
    new_head = head
    write = size % capacity
    return [new, new_head, write, size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped live data', solve([[N,None,None,N+1,N+2],3,3,7]), [[N+1,N+2,N,None,None,None,None],0,3,3])
check('empty shifted ring', solve([[None]*4,3,0,6]), [[None]*6,0,0,0])
check('one shifted value', solve([[None,N,None],1,1,5]), [[N,None,None,None,None],0,1,1])
check('full old ring', solve([[N,N+1,N+2],1,3,5]), [[N+1,N+2,N,None,None],0,3,3])
check('head zero', solve([[N,N+1,None],0,2,6]), [[N,N+1,None,None,None,None],0,2,2])
check('two wrapped values', solve([[N,None,None,N+1],3,2,8]), [[N+1,N,None,None,None,None,None,None],0,2,2])
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(x):
    slots, head, size, capacity = x
    old = len(slots)
    live = [slots[(head + i) % old] for i in range(size)]
    new = live + [None] * (capacity - size)
    new_head = 0 if size == 0 else head
    write = size % capacity
    return [new, new_head, write, size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped live data', solve([[N,None,None,N+1,N+2],3,3,7]), [[N+1,N+2,N,None,None,None,None],0,3,3])
check('empty shifted ring', solve([[None]*4,3,0,6]), [[None]*6,0,0,0])
check('one shifted value', solve([[None,N,None],1,1,5]), [[N,None,None,None,None],0,1,1])
check('full old ring', solve([[N,N+1,N+2],1,3,5]), [[N+1,N+2,N,None,None],0,3,3])
check('head zero', solve([[N,N+1,None],0,2,6]), [[N,N+1,None,None,None,None],0,2,2])
check('two wrapped values', solve([[N,None,None,N+1],3,2,8]), [[N+1,N,None,None,None,None,None,None],0,2,2])
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:
Linearized growth retains the displaced read cursor.

Grow a ring to larger positive capacity. Linearize occupied slots in logical order, clear unused storage, reset head and report next insertion index and unchanged logical count.

split: open-access


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

N = 1
observations = []
def solve(x):
    slots, head, size, capacity = x
    old = len(slots)
    live = [slots[(head + i) % old] for i in range(size)]
    new = live + [None] * (capacity - size)
    new_head = 0
    write = old % capacity
    return [new, new_head, write, size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped live data', solve([[N,None,None,N+1,N+2],3,3,7]), [[N+1,N+2,N,None,None,None,None],0,3,3])
check('empty shifted ring', solve([[None]*4,3,0,6]), [[None]*6,0,0,0])
check('one shifted value', solve([[None,N,None],1,1,5]), [[N,None,None,None,None],0,1,1])
check('full old ring', solve([[N,N+1,N+2],1,3,5]), [[N+1,N+2,N,None,None],0,3,3])
check('head zero', solve([[N,N+1,None],0,2,6]), [[N,N+1,None,None,None,None],0,2,2])
check('two wrapped values', solve([[N,None,None,N+1],3,2,8]), [[N+1,N,None,None,None,None,None,None],0,2,2])
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(x):
    slots, head, size, capacity = x
    old = len(slots)
    live = [slots[(head + i) % old] for i in range(size)]
    new = live + [None] * (capacity - size)
    new_head = 0
    write = size % capacity if size < 2 else old % capacity
    return [new, new_head, write, size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped live data', solve([[N,None,None,N+1,N+2],3,3,7]), [[N+1,N+2,N,None,None,None,None],0,3,3])
check('empty shifted ring', solve([[None]*4,3,0,6]), [[None]*6,0,0,0])
check('one shifted value', solve([[None,N,None],1,1,5]), [[N,None,None,None,None],0,1,1])
check('full old ring', solve([[N,N+1,N+2],1,3,5]), [[N+1,N+2,N,None,None],0,3,3])
check('head zero', solve([[N,N+1,None],0,2,6]), [[N,N+1,None,None,None,None],0,2,2])
check('two wrapped values', solve([[N,None,None,N+1],3,2,8]), [[N+1,N,None,None,None,None,None,None],0,2,2])
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:
Growth writes the next element at old capacity.

Grow a ring to larger positive capacity. Linearize occupied slots in logical order, clear unused storage, reset head and report next insertion index and unchanged logical count.

split: open-access


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

N = 1
observations = []
def solve(x):
    slots, head, size, capacity = x
    old = len(slots)
    live = [slots[(head + i) % old] for i in range(size)]
    new = live + [None] * (capacity - size)
    new_head = 0
    write = size % capacity
    return [new, new_head, write, capacity]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped live data', solve([[N,None,None,N+1,N+2],3,3,7]), [[N+1,N+2,N,None,None,None,None],0,3,3])
check('empty shifted ring', solve([[None]*4,3,0,6]), [[None]*6,0,0,0])
check('one shifted value', solve([[None,N,None],1,1,5]), [[N,None,None,None,None],0,1,1])
check('full old ring', solve([[N,N+1,N+2],1,3,5]), [[N+1,N+2,N,None,None],0,3,3])
check('head zero', solve([[N,N+1,None],0,2,6]), [[N,N+1,None,None,None,None],0,2,2])
check('two wrapped values', solve([[N,None,None,N+1],3,2,8]), [[N+1,N,None,None,None,None,None,None],0,2,2])
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(x):
    slots, head, size, capacity = x
    old = len(slots)
    live = [slots[(head + i) % old] for i in range(size)]
    new = live + [None] * (capacity - size)
    new_head = 0
    write = size % capacity
    return [new, new_head, write, 0 if size == 0 else capacity]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('wrapped live data', solve([[N,None,None,N+1,N+2],3,3,7]), [[N+1,N+2,N,None,None,None,None],0,3,3])
check('empty shifted ring', solve([[None]*4,3,0,6]), [[None]*6,0,0,0])
check('one shifted value', solve([[None,N,None],1,1,5]), [[N,None,None,None,None],0,1,1])
check('full old ring', solve([[N,N+1,N+2],1,3,5]), [[N+1,N+2,N,None,None],0,3,3])
check('head zero', solve([[N,N+1,None],0,2,6]), [[N,N+1,None,None,None,None],0,2,2])
check('two wrapped values', solve([[N,None,None,N+1],3,2,8]), [[N+1,N,None,None,None,None,None,None],0,2,2])
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:
Growth exposes backing capacity as live length.

Grow a ring to larger positive capacity. Linearize occupied slots in logical order, clear unused storage, reset head and report next insertion index and unchanged logical count.

split: open-access


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

N = 1
observations = []
def solve(x):
    items, bound = x
    lost = min(bound, len(items))
    evicted = items[:lost]
    kept = items[lost:]
    slots = kept + [None] * (bound - len(kept))
    free = bound - len(kept)
    return [kept, evicted, slots, free]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('drop oldest pair', solve([[N,N+1,N+2,N+3],2]), [[N+2,N+3],[N,N+1],[N+2,N+3],0])
check('zero bound', solve([[N,N+1],0]), [[],[N,N+1],[],0])
check('spare capacity', solve([[N],3]), [[N],[],[N,None,None],2])
check('same bound', solve([[N,N+1],2]), [[N,N+1],[],[N,N+1],0])
check('empty', solve([[],2]), [[],[],[None,None],2])
check('drop one of three', solve([[N,N+1,N+2],2]), [[N+1,N+2],[N],[N+1,N+2],0])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    items, bound = x
    lost = 0 if len(items) <= bound else min(bound, len(items))
    evicted = items[:lost]
    kept = items[lost:]
    slots = kept + [None] * (bound - len(kept))
    free = bound - len(kept)
    return [kept, evicted, slots, free]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('drop oldest pair', solve([[N,N+1,N+2,N+3],2]), [[N+2,N+3],[N,N+1],[N+2,N+3],0])
check('zero bound', solve([[N,N+1],0]), [[],[N,N+1],[],0])
check('spare capacity', solve([[N],3]), [[N],[],[N,None,None],2])
check('same bound', solve([[N,N+1],2]), [[N,N+1],[],[N,N+1],0])
check('empty', solve([[],2]), [[],[],[None,None],2])
check('drop one of three', solve([[N,N+1,N+2],2]), [[N+1,N+2],[N],[N+1,N+2],0])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Shrink uses new capacity as the eviction count.

Shrink an occupied logical deque to a smaller bound, retaining the newest suffix. Return retained values, evicted prefix, a linear backing allocation, and free capacity.

split: open-access


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

N = 1
observations = []
def solve(x):
    items, bound = x
    lost = max(0, len(items) - bound)
    evicted = items[:lost][::-1]
    kept = items[lost:]
    slots = kept + [None] * (bound - len(kept))
    free = bound - len(kept)
    return [kept, evicted, slots, free]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('drop oldest pair', solve([[N,N+1,N+2,N+3],2]), [[N+2,N+3],[N,N+1],[N+2,N+3],0])
check('zero bound', solve([[N,N+1],0]), [[],[N,N+1],[],0])
check('spare capacity', solve([[N],3]), [[N],[],[N,None,None],2])
check('same bound', solve([[N,N+1],2]), [[N,N+1],[],[N,N+1],0])
check('empty', solve([[],2]), [[],[],[None,None],2])
check('drop one of three', solve([[N,N+1,N+2],2]), [[N+1,N+2],[N],[N+1,N+2],0])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    items, bound = x
    lost = max(0, len(items) - bound)
    evicted = items[:lost] if lost <= 1 else items[:lost][::-1]
    kept = items[lost:]
    slots = kept + [None] * (bound - len(kept))
    free = bound - len(kept)
    return [kept, evicted, slots, free]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('drop oldest pair', solve([[N,N+1,N+2,N+3],2]), [[N+2,N+3],[N,N+1],[N+2,N+3],0])
check('zero bound', solve([[N,N+1],0]), [[],[N,N+1],[],0])
check('spare capacity', solve([[N],3]), [[N],[],[N,None,None],2])
check('same bound', solve([[N,N+1],2]), [[N,N+1],[],[N,N+1],0])
check('empty', solve([[],2]), [[],[],[None,None],2])
check('drop one of three', solve([[N,N+1,N+2],2]), [[N+1,N+2],[N],[N+1,N+2],0])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Shrink reports evicted objects in reverse release order.

Shrink an occupied logical deque to a smaller bound, retaining the newest suffix. Return retained values, evicted prefix, a linear backing allocation, and free capacity.

split: open-access


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

N = 1
observations = []
def solve(x):
    items, bound = x
    lost = max(0, len(items) - bound)
    evicted = items[:lost]
    kept = items[lost:]
    slots = kept + [0] * (bound - len(kept))
    free = bound - len(kept)
    return [kept, evicted, slots, free]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('drop oldest pair', solve([[N,N+1,N+2,N+3],2]), [[N+2,N+3],[N,N+1],[N+2,N+3],0])
check('zero bound', solve([[N,N+1],0]), [[],[N,N+1],[],0])
check('spare capacity', solve([[N],3]), [[N],[],[N,None,None],2])
check('same bound', solve([[N,N+1],2]), [[N,N+1],[],[N,N+1],0])
check('empty', solve([[],2]), [[],[],[None,None],2])
check('drop one of three', solve([[N,N+1,N+2],2]), [[N+1,N+2],[N],[N+1,N+2],0])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    items, bound = x
    lost = max(0, len(items) - bound)
    evicted = items[:lost]
    kept = items[lost:]
    slots = kept + [None if not kept else kept[-1]] * (bound - len(kept))
    free = bound - len(kept)
    return [kept, evicted, slots, free]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('drop oldest pair', solve([[N,N+1,N+2,N+3],2]), [[N+2,N+3],[N,N+1],[N+2,N+3],0])
check('zero bound', solve([[N,N+1],0]), [[],[N,N+1],[],0])
check('spare capacity', solve([[N],3]), [[N],[],[N,None,None],2])
check('same bound', solve([[N,N+1],2]), [[N,N+1],[],[N,N+1],0])
check('empty', solve([[],2]), [[],[],[None,None],2])
check('drop one of three', solve([[N,N+1,N+2],2]), [[N+1,N+2],[N],[N+1,N+2],0])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Shrink keeps stale evicted references in free slots.

Shrink an occupied logical deque to a smaller bound, retaining the newest suffix. Return retained values, evicted prefix, a linear backing allocation, and free capacity.

split: open-access


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

N = 1
observations = []
def solve(x):
    items, bound = x
    lost = max(0, len(items) - bound)
    evicted = items[:lost]
    kept = items[lost:]
    slots = kept + [None] * (bound - len(kept))
    free = bound - len(items)
    return [kept, evicted, slots, free]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('drop oldest pair', solve([[N,N+1,N+2,N+3],2]), [[N+2,N+3],[N,N+1],[N+2,N+3],0])
check('zero bound', solve([[N,N+1],0]), [[],[N,N+1],[],0])
check('spare capacity', solve([[N],3]), [[N],[],[N,None,None],2])
check('same bound', solve([[N,N+1],2]), [[N,N+1],[],[N,N+1],0])
check('empty', solve([[],2]), [[],[],[None,None],2])
check('drop one of three', solve([[N,N+1,N+2],2]), [[N+1,N+2],[N],[N+1,N+2],0])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    items, bound = x
    lost = max(0, len(items) - bound)
    evicted = items[:lost]
    kept = items[lost:]
    slots = kept + [None] * (bound - len(kept))
    free = max(0, bound - len(items)) + lost
    return [kept, evicted, slots, free]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('drop oldest pair', solve([[N,N+1,N+2,N+3],2]), [[N+2,N+3],[N,N+1],[N+2,N+3],0])
check('zero bound', solve([[N,N+1],0]), [[],[N,N+1],[],0])
check('spare capacity', solve([[N],3]), [[N],[],[N,None,None],2])
check('same bound', solve([[N,N+1],2]), [[N,N+1],[],[N,N+1],0])
check('empty', solve([[],2]), [[],[],[None,None],2])
check('drop one of three', solve([[N,N+1,N+2],2]), [[N+1,N+2],[N],[N+1,N+2],0])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Shrink decrements available capacity by pre-shrink occupancy.

Shrink an occupied logical deque to a smaller bound, retaining the newest suffix. Return retained values, evicted prefix, a linear backing allocation, and free capacity.

split: open-access


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

N = 1
observations = []
def solve(x):
    ids, victim = x
    nodes = {'S': ['S','S']}
    for i, value in enumerate(ids):
        nodes[value] = [ids[i-1] if i else 'S', ids[i+1] if i+1 < len(ids) else 'S']
    if ids:
        nodes['S'] = [ids[-1],ids[0]]
    size = len(ids)
    left, right = nodes[victim]
    nodes[left][1] = victim
    nodes[right][0] = left
    nodes[victim] = [None,None]
    size -= 1
    forward = []
    current = nodes['S'][1]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        forward.append(current)
        current = nodes[current][1]
    backward = []
    current = nodes['S'][0]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        backward.append(current)
        current = nodes[current][0]
    valid = all(nodes[nodes[v][0]][1] == v and nodes[nodes[v][1]][0] == v for v in forward if nodes[v][0] is not None and nodes[v][1] is not None)
    return [forward,backward,nodes[victim],size,nodes['S'],valid]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('middle unlink', solve([[N,N+1,N+2],N+1]), [[N,N+2],[N+2,N],[None,None],2,[N+2,N],True])
check('head unlink', solve([[N,N+1,N+2],N]), [[N+1,N+2],[N+2,N+1],[None,None],2,[N+2,N+1],True])
check('tail unlink', solve([[N,N+1,N+2],N+2]), [[N,N+1],[N+1,N],[None,None],2,[N+1,N],True])
check('only node', solve([[N],N]), [[],[],[None,None],0,["S","S"],True])
check('pair head', solve([[N,N+1],N]), [[N+1],[N+1],[None,None],1,[N+1,N+1],True])
check('long middle', solve([[N,N+1,N+2,N+3,N+4],N+2]), [[N,N+1,N+3,N+4],[N+4,N+3,N+1,N],[None,None],4,[N+4,N],True])
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(x):
    ids, victim = x
    nodes = {'S': ['S','S']}
    for i, value in enumerate(ids):
        nodes[value] = [ids[i-1] if i else 'S', ids[i+1] if i+1 < len(ids) else 'S']
    if ids:
        nodes['S'] = [ids[-1],ids[0]]
    size = len(ids)
    left, right = nodes[victim]
    nodes[left][1] = right if left == "S" else victim
    nodes[right][0] = left
    nodes[victim] = [None,None]
    size -= 1
    forward = []
    current = nodes['S'][1]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        forward.append(current)
        current = nodes[current][1]
    backward = []
    current = nodes['S'][0]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        backward.append(current)
        current = nodes[current][0]
    valid = all(nodes[nodes[v][0]][1] == v and nodes[nodes[v][1]][0] == v for v in forward if nodes[v][0] is not None and nodes[v][1] is not None)
    return [forward,backward,nodes[victim],size,nodes['S'],valid]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('middle unlink', solve([[N,N+1,N+2],N+1]), [[N,N+2],[N+2,N],[None,None],2,[N+2,N],True])
check('head unlink', solve([[N,N+1,N+2],N]), [[N+1,N+2],[N+2,N+1],[None,None],2,[N+2,N+1],True])
check('tail unlink', solve([[N,N+1,N+2],N+2]), [[N,N+1],[N+1,N],[None,None],2,[N+1,N],True])
check('only node', solve([[N],N]), [[],[],[None,None],0,["S","S"],True])
check('pair head', solve([[N,N+1],N]), [[N+1],[N+1],[None,None],1,[N+1,N+1],True])
check('long middle', solve([[N,N+1,N+2,N+3,N+4],N+2]), [[N,N+1,N+3,N+4],[N+4,N+3,N+1,N],[None,None],4,[N+4,N],True])
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:
Unlink leaves the predecessor pointing at the detached node.

Unlink one selected node from a finite doubly linked deque with sentinel S. Nodes are keyed by identity; return forward IDs, backward IDs, removed node links, size, sentinel endpoint links and reciprocal-link validity. Every input ID is unique.

split: open-access


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

N = 1
observations = []
def solve(x):
    ids, victim = x
    nodes = {'S': ['S','S']}
    for i, value in enumerate(ids):
        nodes[value] = [ids[i-1] if i else 'S', ids[i+1] if i+1 < len(ids) else 'S']
    if ids:
        nodes['S'] = [ids[-1],ids[0]]
    size = len(ids)
    left, right = nodes[victim]
    nodes[left][1] = right
    nodes[right][0] = victim
    nodes[victim] = [None,None]
    size -= 1
    forward = []
    current = nodes['S'][1]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        forward.append(current)
        current = nodes[current][1]
    backward = []
    current = nodes['S'][0]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        backward.append(current)
        current = nodes[current][0]
    valid = all(nodes[nodes[v][0]][1] == v and nodes[nodes[v][1]][0] == v for v in forward if nodes[v][0] is not None and nodes[v][1] is not None)
    return [forward,backward,nodes[victim],size,nodes['S'],valid]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('middle unlink', solve([[N,N+1,N+2],N+1]), [[N,N+2],[N+2,N],[None,None],2,[N+2,N],True])
check('head unlink', solve([[N,N+1,N+2],N]), [[N+1,N+2],[N+2,N+1],[None,None],2,[N+2,N+1],True])
check('tail unlink', solve([[N,N+1,N+2],N+2]), [[N,N+1],[N+1,N],[None,None],2,[N+1,N],True])
check('only node', solve([[N],N]), [[],[],[None,None],0,["S","S"],True])
check('pair head', solve([[N,N+1],N]), [[N+1],[N+1],[None,None],1,[N+1,N+1],True])
check('long middle', solve([[N,N+1,N+2,N+3,N+4],N+2]), [[N,N+1,N+3,N+4],[N+4,N+3,N+1,N],[None,None],4,[N+4,N],True])
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(x):
    ids, victim = x
    nodes = {'S': ['S','S']}
    for i, value in enumerate(ids):
        nodes[value] = [ids[i-1] if i else 'S', ids[i+1] if i+1 < len(ids) else 'S']
    if ids:
        nodes['S'] = [ids[-1],ids[0]]
    size = len(ids)
    left, right = nodes[victim]
    nodes[left][1] = right
    nodes[right][0] = left if right == "S" else victim
    nodes[victim] = [None,None]
    size -= 1
    forward = []
    current = nodes['S'][1]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        forward.append(current)
        current = nodes[current][1]
    backward = []
    current = nodes['S'][0]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        backward.append(current)
        current = nodes[current][0]
    valid = all(nodes[nodes[v][0]][1] == v and nodes[nodes[v][1]][0] == v for v in forward if nodes[v][0] is not None and nodes[v][1] is not None)
    return [forward,backward,nodes[victim],size,nodes['S'],valid]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('middle unlink', solve([[N,N+1,N+2],N+1]), [[N,N+2],[N+2,N],[None,None],2,[N+2,N],True])
check('head unlink', solve([[N,N+1,N+2],N]), [[N+1,N+2],[N+2,N+1],[None,None],2,[N+2,N+1],True])
check('tail unlink', solve([[N,N+1,N+2],N+2]), [[N,N+1],[N+1,N],[None,None],2,[N+1,N],True])
check('only node', solve([[N],N]), [[],[],[None,None],0,["S","S"],True])
check('pair head', solve([[N,N+1],N]), [[N+1],[N+1],[None,None],1,[N+1,N+1],True])
check('long middle', solve([[N,N+1,N+2,N+3,N+4],N+2]), [[N,N+1,N+3,N+4],[N+4,N+3,N+1,N],[None,None],4,[N+4,N],True])
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:
Unlink leaves a successor back-link pointing to the detached node.

Unlink one selected node from a finite doubly linked deque with sentinel S. Nodes are keyed by identity; return forward IDs, backward IDs, removed node links, size, sentinel endpoint links and reciprocal-link validity. Every input ID is unique.

split: open-access


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

N = 1
observations = []
def solve(x):
    ids, victim = x
    nodes = {'S': ['S','S']}
    for i, value in enumerate(ids):
        nodes[value] = [ids[i-1] if i else 'S', ids[i+1] if i+1 < len(ids) else 'S']
    if ids:
        nodes['S'] = [ids[-1],ids[0]]
    size = len(ids)
    left, right = nodes[victim]
    nodes[left][1] = right
    nodes[right][0] = left
    nodes[victim] = [left,right]
    size -= 1
    forward = []
    current = nodes['S'][1]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        forward.append(current)
        current = nodes[current][1]
    backward = []
    current = nodes['S'][0]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        backward.append(current)
        current = nodes[current][0]
    valid = all(nodes[nodes[v][0]][1] == v and nodes[nodes[v][1]][0] == v for v in forward if nodes[v][0] is not None and nodes[v][1] is not None)
    return [forward,backward,nodes[victim],size,nodes['S'],valid]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('middle unlink', solve([[N,N+1,N+2],N+1]), [[N,N+2],[N+2,N],[None,None],2,[N+2,N],True])
check('head unlink', solve([[N,N+1,N+2],N]), [[N+1,N+2],[N+2,N+1],[None,None],2,[N+2,N+1],True])
check('tail unlink', solve([[N,N+1,N+2],N+2]), [[N,N+1],[N+1,N],[None,None],2,[N+1,N],True])
check('only node', solve([[N],N]), [[],[],[None,None],0,["S","S"],True])
check('pair head', solve([[N,N+1],N]), [[N+1],[N+1],[None,None],1,[N+1,N+1],True])
check('long middle', solve([[N,N+1,N+2,N+3,N+4],N+2]), [[N,N+1,N+3,N+4],[N+4,N+3,N+1,N],[None,None],4,[N+4,N],True])
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(x):
    ids, victim = x
    nodes = {'S': ['S','S']}
    for i, value in enumerate(ids):
        nodes[value] = [ids[i-1] if i else 'S', ids[i+1] if i+1 < len(ids) else 'S']
    if ids:
        nodes['S'] = [ids[-1],ids[0]]
    size = len(ids)
    left, right = nodes[victim]
    nodes[left][1] = right
    nodes[right][0] = left
    nodes[victim] = [None,right]
    size -= 1
    forward = []
    current = nodes['S'][1]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        forward.append(current)
        current = nodes[current][1]
    backward = []
    current = nodes['S'][0]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        backward.append(current)
        current = nodes[current][0]
    valid = all(nodes[nodes[v][0]][1] == v and nodes[nodes[v][1]][0] == v for v in forward if nodes[v][0] is not None and nodes[v][1] is not None)
    return [forward,backward,nodes[victim],size,nodes['S'],valid]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('middle unlink', solve([[N,N+1,N+2],N+1]), [[N,N+2],[N+2,N],[None,None],2,[N+2,N],True])
check('head unlink', solve([[N,N+1,N+2],N]), [[N+1,N+2],[N+2,N+1],[None,None],2,[N+2,N+1],True])
check('tail unlink', solve([[N,N+1,N+2],N+2]), [[N,N+1],[N+1,N],[None,None],2,[N+1,N],True])
check('only node', solve([[N],N]), [[],[],[None,None],0,["S","S"],True])
check('pair head', solve([[N,N+1],N]), [[N+1],[N+1],[None,None],1,[N+1,N+1],True])
check('long middle', solve([[N,N+1,N+2,N+3,N+4],N+2]), [[N,N+1,N+3,N+4],[N+4,N+3,N+1,N],[None,None],4,[N+4,N],True])
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:
Unlink retains links on the removed intrusive node.

Unlink one selected node from a finite doubly linked deque with sentinel S. Nodes are keyed by identity; return forward IDs, backward IDs, removed node links, size, sentinel endpoint links and reciprocal-link validity. Every input ID is unique.

split: open-access


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

N = 1
observations = []
def solve(x):
    ids, victim = x
    nodes = {'S': ['S','S']}
    for i, value in enumerate(ids):
        nodes[value] = [ids[i-1] if i else 'S', ids[i+1] if i+1 < len(ids) else 'S']
    if ids:
        nodes['S'] = [ids[-1],ids[0]]
    size = len(ids)
    left, right = nodes[victim]
    nodes[left][1] = right
    nodes[right][0] = left
    nodes[victim] = [None,None]
    size -= 2
    forward = []
    current = nodes['S'][1]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        forward.append(current)
        current = nodes[current][1]
    backward = []
    current = nodes['S'][0]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        backward.append(current)
        current = nodes[current][0]
    valid = all(nodes[nodes[v][0]][1] == v and nodes[nodes[v][1]][0] == v for v in forward if nodes[v][0] is not None and nodes[v][1] is not None)
    return [forward,backward,nodes[victim],size,nodes['S'],valid]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('middle unlink', solve([[N,N+1,N+2],N+1]), [[N,N+2],[N+2,N],[None,None],2,[N+2,N],True])
check('head unlink', solve([[N,N+1,N+2],N]), [[N+1,N+2],[N+2,N+1],[None,None],2,[N+2,N+1],True])
check('tail unlink', solve([[N,N+1,N+2],N+2]), [[N,N+1],[N+1,N],[None,None],2,[N+1,N],True])
check('only node', solve([[N],N]), [[],[],[None,None],0,["S","S"],True])
check('pair head', solve([[N,N+1],N]), [[N+1],[N+1],[None,None],1,[N+1,N+1],True])
check('long middle', solve([[N,N+1,N+2,N+3,N+4],N+2]), [[N,N+1,N+3,N+4],[N+4,N+3,N+1,N],[None,None],4,[N+4,N],True])
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(x):
    ids, victim = x
    nodes = {'S': ['S','S']}
    for i, value in enumerate(ids):
        nodes[value] = [ids[i-1] if i else 'S', ids[i+1] if i+1 < len(ids) else 'S']
    if ids:
        nodes['S'] = [ids[-1],ids[0]]
    size = len(ids)
    left, right = nodes[victim]
    nodes[left][1] = right
    nodes[right][0] = left
    nodes[victim] = [None,None]
    size -= 1 if size == 1 else 2
    forward = []
    current = nodes['S'][1]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        forward.append(current)
        current = nodes[current][1]
    backward = []
    current = nodes['S'][0]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        backward.append(current)
        current = nodes[current][0]
    valid = all(nodes[nodes[v][0]][1] == v and nodes[nodes[v][1]][0] == v for v in forward if nodes[v][0] is not None and nodes[v][1] is not None)
    return [forward,backward,nodes[victim],size,nodes['S'],valid]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('middle unlink', solve([[N,N+1,N+2],N+1]), [[N,N+2],[N+2,N],[None,None],2,[N+2,N],True])
check('head unlink', solve([[N,N+1,N+2],N]), [[N+1,N+2],[N+2,N+1],[None,None],2,[N+2,N+1],True])
check('tail unlink', solve([[N,N+1,N+2],N+2]), [[N,N+1],[N+1,N],[None,None],2,[N+1,N],True])
check('only node', solve([[N],N]), [[],[],[None,None],0,["S","S"],True])
check('pair head', solve([[N,N+1],N]), [[N+1],[N+1],[None,None],1,[N+1,N+1],True])
check('long middle', solve([[N,N+1,N+2,N+3,N+4],N+2]), [[N,N+1,N+3,N+4],[N+4,N+3,N+1,N],[None,None],4,[N+4,N],True])
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:
Unlink decrements size by both incident edges.

Unlink one selected node from a finite doubly linked deque with sentinel S. Nodes are keyed by identity; return forward IDs, backward IDs, removed node links, size, sentinel endpoint links and reciprocal-link validity. Every input ID is unique.

split: open-access


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

N = 1
observations = []
def solve(x):
    ids, victim = x
    nodes = {'S': ['S','S']}
    for i, value in enumerate(ids):
        nodes[value] = [ids[i-1] if i else 'S', ids[i+1] if i+1 < len(ids) else 'S']
    if ids:
        nodes['S'] = [ids[-1],ids[0]]
    size = len(ids)
    left, right = nodes[victim]
    nodes[left][1] = right
    nodes[right][0] = left
    nodes[victim] = [None,None]
    size -= 1
    forward = []
    current = nodes['S'][1]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        forward.append(current)
        current = nodes[current][1]
    backward = []
    current = nodes['S'][1]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        backward.append(current)
        current = nodes[current][0]
    valid = all(nodes[nodes[v][0]][1] == v and nodes[nodes[v][1]][0] == v for v in forward if nodes[v][0] is not None and nodes[v][1] is not None)
    return [forward,backward,nodes[victim],size,nodes['S'],valid]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('middle unlink', solve([[N,N+1,N+2],N+1]), [[N,N+2],[N+2,N],[None,None],2,[N+2,N],True])
check('head unlink', solve([[N,N+1,N+2],N]), [[N+1,N+2],[N+2,N+1],[None,None],2,[N+2,N+1],True])
check('tail unlink', solve([[N,N+1,N+2],N+2]), [[N,N+1],[N+1,N],[None,None],2,[N+1,N],True])
check('only node', solve([[N],N]), [[],[],[None,None],0,["S","S"],True])
check('pair head', solve([[N,N+1],N]), [[N+1],[N+1],[None,None],1,[N+1,N+1],True])
check('long middle', solve([[N,N+1,N+2,N+3,N+4],N+2]), [[N,N+1,N+3,N+4],[N+4,N+3,N+1,N],[None,None],4,[N+4,N],True])
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(x):
    ids, victim = x
    nodes = {'S': ['S','S']}
    for i, value in enumerate(ids):
        nodes[value] = [ids[i-1] if i else 'S', ids[i+1] if i+1 < len(ids) else 'S']
    if ids:
        nodes['S'] = [ids[-1],ids[0]]
    size = len(ids)
    left, right = nodes[victim]
    nodes[left][1] = right
    nodes[right][0] = left
    nodes[victim] = [None,None]
    size -= 1
    forward = []
    current = nodes['S'][1]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        forward.append(current)
        current = nodes[current][1]
    backward = []
    current = nodes['S'][0] if size <= 1 else nodes['S'][1]
    for _ in range(len(ids)+1):
        if current == 'S' or current is None: break
        backward.append(current)
        current = nodes[current][0]
    valid = all(nodes[nodes[v][0]][1] == v and nodes[nodes[v][1]][0] == v for v in forward if nodes[v][0] is not None and nodes[v][1] is not None)
    return [forward,backward,nodes[victim],size,nodes['S'],valid]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('middle unlink', solve([[N,N+1,N+2],N+1]), [[N,N+2],[N+2,N],[None,None],2,[N+2,N],True])
check('head unlink', solve([[N,N+1,N+2],N]), [[N+1,N+2],[N+2,N+1],[None,None],2,[N+2,N+1],True])
check('tail unlink', solve([[N,N+1,N+2],N+2]), [[N,N+1],[N+1,N],[None,None],2,[N+1,N],True])
check('only node', solve([[N],N]), [[],[],[None,None],0,["S","S"],True])
check('pair head', solve([[N,N+1],N]), [[N+1],[N+1],[None,None],1,[N+1,N+1],True])
check('long middle', solve([[N,N+1,N+2,N+3,N+4],N+2]), [[N,N+1,N+3,N+4],[N+4,N+3,N+1,N],[None,None],4,[N+4,N],True])
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:
Reverse traversal starts from the sentinel next link.

Unlink one selected node from a finite doubly linked deque with sentinel S. Nodes are keyed by identity; return forward IDs, backward IDs, removed node links, size, sentinel endpoint links and reciprocal-link validity. Every input ID is unique.

split: open-access


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

N = 1
observations = []
def solve(x):
    items, at, cursors = x
    remaining = items[:at] + items[at+2:]
    updated = []
    for position in cursors:
        if position is None:
            next_position = None
        elif position < at:
            next_position = position
        elif position == at:
            next_position = at if at < len(remaining) else None
        else:
            next_position = position - 1
        updated.append(next_position)
    observed = [remaining[p] if p is not None and 0 <= p < len(remaining) else None for p in updated]
    return [remaining,updated,observed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('interior cursors', solve([[N,N+1,N+2,N+3],1,[0,1,2,3,None]]), [[N,N+2,N+3],[0,1,1,2,None],[N,N+2,N+2,N+3,None]])
check('erased last cursor', solve([[N,N+1],1,[0,1,None]]), [[N],[0,None,None],[N,None,None]])
check('all point at head', solve([[N,N+1,N+2],0,[0,0,2]]), [[N+1,N+2],[0,0,1],[N+1,N+1,N+2]])
check('single node erased', solve([[N],0,[0,None]]), [[],[None,None],[None,None]])
check('no cursors', solve([[N,N+1],0,[]]), [[N+1],[],[]])
check('unaffected cursors', solve([[N,N+1,N+2,N+3],3,[0,1,2]]), [[N,N+1,N+2],[0,1,2],[N,N+1,N+2]])
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(x):
    items, at, cursors = x
    remaining = items[:at] + items[at+1:] if at == 0 else items[:at] + items[at+2:]
    updated = []
    for position in cursors:
        if position is None:
            next_position = None
        elif position < at:
            next_position = position
        elif position == at:
            next_position = at if at < len(remaining) else None
        else:
            next_position = position - 1
        updated.append(next_position)
    observed = [remaining[p] if p is not None and 0 <= p < len(remaining) else None for p in updated]
    return [remaining,updated,observed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('interior cursors', solve([[N,N+1,N+2,N+3],1,[0,1,2,3,None]]), [[N,N+2,N+3],[0,1,1,2,None],[N,N+2,N+2,N+3,None]])
check('erased last cursor', solve([[N,N+1],1,[0,1,None]]), [[N],[0,None,None],[N,None,None]])
check('all point at head', solve([[N,N+1,N+2],0,[0,0,2]]), [[N+1,N+2],[0,0,1],[N+1,N+1,N+2]])
check('single node erased', solve([[N],0,[0,None]]), [[],[None,None],[None,None]])
check('no cursors', solve([[N,N+1],0,[]]), [[N+1],[],[]])
check('unaffected cursors', solve([[N,N+1,N+2,N+3],3,[0,1,2]]), [[N,N+1,N+2],[0,1,2],[N,N+1,N+2]])
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:
Cursor erase drops the successor along with its target.

Erase a selected position while updating independent stable cursors. A cursor at the erased element moves to its successor, or end; later cursors shift left, earlier cursors stay. Return values, cursor positions, and cursor-observed values; None denotes end.

split: open-access


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

N = 1
observations = []
def solve(x):
    items, at, cursors = x
    remaining = items[:at] + items[at+1:]
    updated = []
    for position in cursors:
        if position is None:
            next_position = 0
        elif position < at:
            next_position = position
        elif position == at:
            next_position = at if at < len(remaining) else None
        else:
            next_position = position - 1
        updated.append(next_position)
    observed = [remaining[p] if p is not None and 0 <= p < len(remaining) else None for p in updated]
    return [remaining,updated,observed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('interior cursors', solve([[N,N+1,N+2,N+3],1,[0,1,2,3,None]]), [[N,N+2,N+3],[0,1,1,2,None],[N,N+2,N+2,N+3,None]])
check('erased last cursor', solve([[N,N+1],1,[0,1,None]]), [[N],[0,None,None],[N,None,None]])
check('all point at head', solve([[N,N+1,N+2],0,[0,0,2]]), [[N+1,N+2],[0,0,1],[N+1,N+1,N+2]])
check('single node erased', solve([[N],0,[0,None]]), [[],[None,None],[None,None]])
check('no cursors', solve([[N,N+1],0,[]]), [[N+1],[],[]])
check('unaffected cursors', solve([[N,N+1,N+2,N+3],3,[0,1,2]]), [[N,N+1,N+2],[0,1,2],[N,N+1,N+2]])
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(x):
    items, at, cursors = x
    remaining = items[:at] + items[at+1:]
    updated = []
    for position in cursors:
        if position is None:
            next_position = None if not remaining else 0
        elif position < at:
            next_position = position
        elif position == at:
            next_position = at if at < len(remaining) else None
        else:
            next_position = position - 1
        updated.append(next_position)
    observed = [remaining[p] if p is not None and 0 <= p < len(remaining) else None for p in updated]
    return [remaining,updated,observed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('interior cursors', solve([[N,N+1,N+2,N+3],1,[0,1,2,3,None]]), [[N,N+2,N+3],[0,1,1,2,None],[N,N+2,N+2,N+3,None]])
check('erased last cursor', solve([[N,N+1],1,[0,1,None]]), [[N],[0,None,None],[N,None,None]])
check('all point at head', solve([[N,N+1,N+2],0,[0,0,2]]), [[N+1,N+2],[0,0,1],[N+1,N+1,N+2]])
check('single node erased', solve([[N],0,[0,None]]), [[],[None,None],[None,None]])
check('no cursors', solve([[N,N+1],0,[]]), [[N+1],[],[]])
check('unaffected cursors', solve([[N,N+1,N+2,N+3],3,[0,1,2]]), [[N,N+1,N+2],[0,1,2],[N,N+1,N+2]])
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:
End cursor is rebound to the first element after erase.

Erase a selected position while updating independent stable cursors. A cursor at the erased element moves to its successor, or end; later cursors shift left, earlier cursors stay. Return values, cursor positions, and cursor-observed values; None denotes end.

split: open-access


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

N = 1
observations = []
def solve(x):
    items, at, cursors = x
    remaining = items[:at] + items[at+1:]
    updated = []
    for position in cursors:
        if position is None:
            next_position = None
        elif position < at:
            next_position = position - 1
        elif position == at:
            next_position = at if at < len(remaining) else None
        else:
            next_position = position - 1
        updated.append(next_position)
    observed = [remaining[p] if p is not None and 0 <= p < len(remaining) else None for p in updated]
    return [remaining,updated,observed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('interior cursors', solve([[N,N+1,N+2,N+3],1,[0,1,2,3,None]]), [[N,N+2,N+3],[0,1,1,2,None],[N,N+2,N+2,N+3,None]])
check('erased last cursor', solve([[N,N+1],1,[0,1,None]]), [[N],[0,None,None],[N,None,None]])
check('all point at head', solve([[N,N+1,N+2],0,[0,0,2]]), [[N+1,N+2],[0,0,1],[N+1,N+1,N+2]])
check('single node erased', solve([[N],0,[0,None]]), [[],[None,None],[None,None]])
check('no cursors', solve([[N,N+1],0,[]]), [[N+1],[],[]])
check('unaffected cursors', solve([[N,N+1,N+2,N+3],3,[0,1,2]]), [[N,N+1,N+2],[0,1,2],[N,N+1,N+2]])
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(x):
    items, at, cursors = x
    remaining = items[:at] + items[at+1:]
    updated = []
    for position in cursors:
        if position is None:
            next_position = None
        elif position < at:
            next_position = position if position == 0 else position - 1
        elif position == at:
            next_position = at if at < len(remaining) else None
        else:
            next_position = position - 1
        updated.append(next_position)
    observed = [remaining[p] if p is not None and 0 <= p < len(remaining) else None for p in updated]
    return [remaining,updated,observed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('interior cursors', solve([[N,N+1,N+2,N+3],1,[0,1,2,3,None]]), [[N,N+2,N+3],[0,1,1,2,None],[N,N+2,N+2,N+3,None]])
check('erased last cursor', solve([[N,N+1],1,[0,1,None]]), [[N],[0,None,None],[N,None,None]])
check('all point at head', solve([[N,N+1,N+2],0,[0,0,2]]), [[N+1,N+2],[0,0,1],[N+1,N+1,N+2]])
check('single node erased', solve([[N],0,[0,None]]), [[],[None,None],[None,None]])
check('no cursors', solve([[N,N+1],0,[]]), [[N+1],[],[]])
check('unaffected cursors', solve([[N,N+1,N+2,N+3],3,[0,1,2]]), [[N,N+1,N+2],[0,1,2],[N,N+1,N+2]])
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:
Erase shifts cursors that precede the erased position.

Erase a selected position while updating independent stable cursors. A cursor at the erased element moves to its successor, or end; later cursors shift left, earlier cursors stay. Return values, cursor positions, and cursor-observed values; None denotes end.

split: open-access


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

N = 1
observations = []
def solve(x):
    items, at, cursors = x
    remaining = items[:at] + items[at+1:]
    updated = []
    for position in cursors:
        if position is None:
            next_position = None
        elif position < at:
            next_position = position
        elif position == at:
            next_position = None
        else:
            next_position = position - 1
        updated.append(next_position)
    observed = [remaining[p] if p is not None and 0 <= p < len(remaining) else None for p in updated]
    return [remaining,updated,observed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('interior cursors', solve([[N,N+1,N+2,N+3],1,[0,1,2,3,None]]), [[N,N+2,N+3],[0,1,1,2,None],[N,N+2,N+2,N+3,None]])
check('erased last cursor', solve([[N,N+1],1,[0,1,None]]), [[N],[0,None,None],[N,None,None]])
check('all point at head', solve([[N,N+1,N+2],0,[0,0,2]]), [[N+1,N+2],[0,0,1],[N+1,N+1,N+2]])
check('single node erased', solve([[N],0,[0,None]]), [[],[None,None],[None,None]])
check('no cursors', solve([[N,N+1],0,[]]), [[N+1],[],[]])
check('unaffected cursors', solve([[N,N+1,N+2,N+3],3,[0,1,2]]), [[N,N+1,N+2],[0,1,2],[N,N+1,N+2]])
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(x):
    items, at, cursors = x
    remaining = items[:at] + items[at+1:]
    updated = []
    for position in cursors:
        if position is None:
            next_position = None
        elif position < at:
            next_position = position
        elif position == at:
            next_position = at if at == 0 and remaining else None
        else:
            next_position = position - 1
        updated.append(next_position)
    observed = [remaining[p] if p is not None and 0 <= p < len(remaining) else None for p in updated]
    return [remaining,updated,observed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('interior cursors', solve([[N,N+1,N+2,N+3],1,[0,1,2,3,None]]), [[N,N+2,N+3],[0,1,1,2,None],[N,N+2,N+2,N+3,None]])
check('erased last cursor', solve([[N,N+1],1,[0,1,None]]), [[N],[0,None,None],[N,None,None]])
check('all point at head', solve([[N,N+1,N+2],0,[0,0,2]]), [[N+1,N+2],[0,0,1],[N+1,N+1,N+2]])
check('single node erased', solve([[N],0,[0,None]]), [[],[None,None],[None,None]])
check('no cursors', solve([[N,N+1],0,[]]), [[N+1],[],[]])
check('unaffected cursors', solve([[N,N+1,N+2,N+3],3,[0,1,2]]), [[N,N+1,N+2],[0,1,2],[N,N+1,N+2]])
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:
Cursor on an erased interior node becomes end.

Erase a selected position while updating independent stable cursors. A cursor at the erased element moves to its successor, or end; later cursors shift left, earlier cursors stay. Return values, cursor positions, and cursor-observed values; None denotes end.

split: open-access


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

N = 1
observations = []
def solve(x):
    items, at, cursors = x
    remaining = items[:at] + items[at+1:]
    updated = []
    for position in cursors:
        if position is None:
            next_position = None
        elif position < at:
            next_position = position
        elif position == at:
            next_position = at if at < len(remaining) else None
        else:
            next_position = position
        updated.append(next_position)
    observed = [remaining[p] if p is not None and 0 <= p < len(remaining) else None for p in updated]
    return [remaining,updated,observed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('interior cursors', solve([[N,N+1,N+2,N+3],1,[0,1,2,3,None]]), [[N,N+2,N+3],[0,1,1,2,None],[N,N+2,N+2,N+3,None]])
check('erased last cursor', solve([[N,N+1],1,[0,1,None]]), [[N],[0,None,None],[N,None,None]])
check('all point at head', solve([[N,N+1,N+2],0,[0,0,2]]), [[N+1,N+2],[0,0,1],[N+1,N+1,N+2]])
check('single node erased', solve([[N],0,[0,None]]), [[],[None,None],[None,None]])
check('no cursors', solve([[N,N+1],0,[]]), [[N+1],[],[]])
check('unaffected cursors', solve([[N,N+1,N+2,N+3],3,[0,1,2]]), [[N,N+1,N+2],[0,1,2],[N,N+1,N+2]])
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(x):
    items, at, cursors = x
    remaining = items[:at] + items[at+1:]
    updated = []
    for position in cursors:
        if position is None:
            next_position = None
        elif position < at:
            next_position = position
        elif position == at:
            next_position = at if at < len(remaining) else None
        else:
            next_position = position - 1 if position == at + 1 else position
        updated.append(next_position)
    observed = [remaining[p] if p is not None and 0 <= p < len(remaining) else None for p in updated]
    return [remaining,updated,observed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('interior cursors', solve([[N,N+1,N+2,N+3],1,[0,1,2,3,None]]), [[N,N+2,N+3],[0,1,1,2,None],[N,N+2,N+2,N+3,None]])
check('erased last cursor', solve([[N,N+1],1,[0,1,None]]), [[N],[0,None,None],[N,None,None]])
check('all point at head', solve([[N,N+1,N+2],0,[0,0,2]]), [[N+1,N+2],[0,0,1],[N+1,N+1,N+2]])
check('single node erased', solve([[N],0,[0,None]]), [[],[None,None],[None,None]])
check('no cursors', solve([[N,N+1],0,[]]), [[N+1],[],[]])
check('unaffected cursors', solve([[N,N+1,N+2,N+3],3,[0,1,2]]), [[N,N+1,N+2],[0,1,2],[N,N+1,N+2]])
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:
Cursor after an erased node retains its old index.

Erase a selected position while updating independent stable cursors. A cursor at the erased element moves to its successor, or end; later cursors shift left, earlier cursors stay. Return values, cursor positions, and cursor-observed values; None denotes end.

split: open-access