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

N = 1
observations = []
def solve(x):
    blocks, index = x
    ends = []
    total = 0
    for block in blocks:
        total = len(block)
        ends.append(total)
    b = next((i for i,end in enumerate(ends) if index < end), None)
    if b is None: return 'invalid directory'
    start = ends[b-1] if b else 0
    local = index - start
    value = blocks[b][local] if -len(blocks[b]) <= local < len(blocks[b]) else 'invalid offset'
    flat = [v for block in blocks for v in block]
    previous = flat[index-1] if index else None
    following = flat[index+1] if index+1 < total else None
    return [b,local,value,total,previous,following]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('second block first', solve([[[N,N+1],[N+2,N+3,N+4]],2]), [1,0,N+2,5,N+1,N+3])
check('second block interior', solve([[[N],[N+1,N+2,N+3],[N+4]],2]), [1,1,N+2,5,N+1,N+3])
check('first element', solve([[[N,N+1],[N+2]],0]), [0,0,N,3,None,N+1])
check('last element', solve([[[N],[N+1],[N+2,N+3]],3]), [2,1,N+3,4,N+2,None])
check('single value', solve([[[N]],0]), [0,0,N,1,None,None])
check('third block head', solve([[[N,N+1],[N+2],[N+3,N+4]],3]), [2,0,N+3,5,N+2,N+4])
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):
    blocks, index = x
    ends = []
    total = 0
    for block in blocks:
        total += len(block) if len(ends) < 1 else 0
        ends.append(total)
    b = next((i for i,end in enumerate(ends) if index < end), None)
    if b is None: return 'invalid directory'
    start = ends[b-1] if b else 0
    local = index - start
    value = blocks[b][local] if -len(blocks[b]) <= local < len(blocks[b]) else 'invalid offset'
    flat = [v for block in blocks for v in block]
    previous = flat[index-1] if index else None
    following = flat[index+1] if index+1 < total else None
    return [b,local,value,total,previous,following]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('second block first', solve([[[N,N+1],[N+2,N+3,N+4]],2]), [1,0,N+2,5,N+1,N+3])
check('second block interior', solve([[[N],[N+1,N+2,N+3],[N+4]],2]), [1,1,N+2,5,N+1,N+3])
check('first element', solve([[[N,N+1],[N+2]],0]), [0,0,N,3,None,N+1])
check('last element', solve([[[N],[N+1],[N+2,N+3]],3]), [2,1,N+3,4,N+2,None])
check('single value', solve([[[N]],0]), [0,0,N,1,None,None])
check('third block head', solve([[[N,N+1],[N+2],[N+3,N+4]],3]), [2,0,N+3,5,N+2,N+4])
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:
Deque directory uses each block length as an absolute end.

For nonempty, variable-size deque blocks, resolve a logical index into [block index, local offset, value, total size, predecessor value, successor value]. Null neighbors mark sequence endpoints. Directory is built from cumulative block lengths.

split: open-access


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

N = 1
observations = []
def solve(x):
    blocks, index = x
    ends = []
    total = 0
    for block in blocks:
        total += len(block)
        ends.append(total)
    b = next((i for i,end in enumerate(ends) if index < end), None)
    if b is None: return 'invalid directory'
    start = ends[b] if b else 0
    local = index - start
    value = blocks[b][local] if -len(blocks[b]) <= local < len(blocks[b]) else 'invalid offset'
    flat = [v for block in blocks for v in block]
    previous = flat[index-1] if index else None
    following = flat[index+1] if index+1 < total else None
    return [b,local,value,total,previous,following]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('second block first', solve([[[N,N+1],[N+2,N+3,N+4]],2]), [1,0,N+2,5,N+1,N+3])
check('second block interior', solve([[[N],[N+1,N+2,N+3],[N+4]],2]), [1,1,N+2,5,N+1,N+3])
check('first element', solve([[[N,N+1],[N+2]],0]), [0,0,N,3,None,N+1])
check('last element', solve([[[N],[N+1],[N+2,N+3]],3]), [2,1,N+3,4,N+2,None])
check('single value', solve([[[N]],0]), [0,0,N,1,None,None])
check('third block head', solve([[[N,N+1],[N+2],[N+3,N+4]],3]), [2,0,N+3,5,N+2,N+4])
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):
    blocks, index = x
    ends = []
    total = 0
    for block in blocks:
        total += len(block)
        ends.append(total)
    b = next((i for i,end in enumerate(ends) if index < end), None)
    if b is None: return 'invalid directory'
    start = ends[b-1] if b < 2 else ends[b]
    local = index - start
    value = blocks[b][local] if -len(blocks[b]) <= local < len(blocks[b]) else 'invalid offset'
    flat = [v for block in blocks for v in block]
    previous = flat[index-1] if index else None
    following = flat[index+1] if index+1 < total else None
    return [b,local,value,total,previous,following]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('second block first', solve([[[N,N+1],[N+2,N+3,N+4]],2]), [1,0,N+2,5,N+1,N+3])
check('second block interior', solve([[[N],[N+1,N+2,N+3],[N+4]],2]), [1,1,N+2,5,N+1,N+3])
check('first element', solve([[[N,N+1],[N+2]],0]), [0,0,N,3,None,N+1])
check('last element', solve([[[N],[N+1],[N+2,N+3]],3]), [2,1,N+3,4,N+2,None])
check('single value', solve([[[N]],0]), [0,0,N,1,None,None])
check('third block head', solve([[[N,N+1],[N+2],[N+3,N+4]],3]), [2,0,N+3,5,N+2,N+4])
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:
Directory subtracts the current block end from its logical index.

For nonempty, variable-size deque blocks, resolve a logical index into [block index, local offset, value, total size, predecessor value, successor value]. Null neighbors mark sequence endpoints. Directory is built from cumulative block lengths.

split: open-access


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

N = 1
observations = []
def solve(x):
    blocks, index = x
    ends = []
    total = 0
    for block in blocks:
        total += len(block)
        ends.append(total)
    b = next((i for i,end in enumerate(ends) if index < end), None)
    if b is None: return 'invalid directory'
    start = ends[b-1] if b else 0
    local = index % len(blocks[b])
    value = blocks[b][local] if -len(blocks[b]) <= local < len(blocks[b]) else 'invalid offset'
    flat = [v for block in blocks for v in block]
    previous = flat[index-1] if index else None
    following = flat[index+1] if index+1 < total else None
    return [b,local,value,total,previous,following]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('second block first', solve([[[N,N+1],[N+2,N+3,N+4]],2]), [1,0,N+2,5,N+1,N+3])
check('second block interior', solve([[[N],[N+1,N+2,N+3],[N+4]],2]), [1,1,N+2,5,N+1,N+3])
check('first element', solve([[[N,N+1],[N+2]],0]), [0,0,N,3,None,N+1])
check('last element', solve([[[N],[N+1],[N+2,N+3]],3]), [2,1,N+3,4,N+2,None])
check('single value', solve([[[N]],0]), [0,0,N,1,None,None])
check('third block head', solve([[[N,N+1],[N+2],[N+3,N+4]],3]), [2,0,N+3,5,N+2,N+4])
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):
    blocks, index = x
    ends = []
    total = 0
    for block in blocks:
        total += len(block)
        ends.append(total)
    b = next((i for i,end in enumerate(ends) if index < end), None)
    if b is None: return 'invalid directory'
    start = ends[b-1] if b else 0
    local = index - start if b == 0 else index % len(blocks[b])
    value = blocks[b][local] if -len(blocks[b]) <= local < len(blocks[b]) else 'invalid offset'
    flat = [v for block in blocks for v in block]
    previous = flat[index-1] if index else None
    following = flat[index+1] if index+1 < total else None
    return [b,local,value,total,previous,following]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('second block first', solve([[[N,N+1],[N+2,N+3,N+4]],2]), [1,0,N+2,5,N+1,N+3])
check('second block interior', solve([[[N],[N+1,N+2,N+3],[N+4]],2]), [1,1,N+2,5,N+1,N+3])
check('first element', solve([[[N,N+1],[N+2]],0]), [0,0,N,3,None,N+1])
check('last element', solve([[[N],[N+1],[N+2,N+3]],3]), [2,1,N+3,4,N+2,None])
check('single value', solve([[[N]],0]), [0,0,N,1,None,None])
check('third block head', solve([[[N,N+1],[N+2],[N+3,N+4]],3]), [2,0,N+3,5,N+2,N+4])
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:
Directory measures an index from the global origin.

For nonempty, variable-size deque blocks, resolve a logical index into [block index, local offset, value, total size, predecessor value, successor value]. Null neighbors mark sequence endpoints. Directory is built from cumulative block lengths.

split: open-access


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

N = 1
observations = []
def solve(x):
    blocks, index = x
    ends = []
    total = 0
    for block in blocks:
        total += len(block)
        ends.append(total)
    b = next((i for i,end in enumerate(ends) if index < end), None)
    if b is None: return 'invalid directory'
    start = ends[b-1] if b else 0
    local = index - start
    value = blocks[b][local] if -len(blocks[b]) <= local < len(blocks[b]) else 'invalid offset'
    flat = [v for block in blocks for v in block]
    previous = flat[index-1]
    following = flat[index+1] if index+1 < total else None
    return [b,local,value,total,previous,following]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('second block first', solve([[[N,N+1],[N+2,N+3,N+4]],2]), [1,0,N+2,5,N+1,N+3])
check('second block interior', solve([[[N],[N+1,N+2,N+3],[N+4]],2]), [1,1,N+2,5,N+1,N+3])
check('first element', solve([[[N,N+1],[N+2]],0]), [0,0,N,3,None,N+1])
check('last element', solve([[[N],[N+1],[N+2,N+3]],3]), [2,1,N+3,4,N+2,None])
check('single value', solve([[[N]],0]), [0,0,N,1,None,None])
check('third block head', solve([[[N,N+1],[N+2],[N+3,N+4]],3]), [2,0,N+3,5,N+2,N+4])
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):
    blocks, index = x
    ends = []
    total = 0
    for block in blocks:
        total += len(block)
        ends.append(total)
    b = next((i for i,end in enumerate(ends) if index < end), None)
    if b is None: return 'invalid directory'
    start = ends[b-1] if b else 0
    local = index - start
    value = blocks[b][local] if -len(blocks[b]) <= local < len(blocks[b]) else 'invalid offset'
    flat = [v for block in blocks for v in block]
    previous = flat[index-1] if len(flat)>1 else None
    following = flat[index+1] if index+1 < total else None
    return [b,local,value,total,previous,following]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('second block first', solve([[[N,N+1],[N+2,N+3,N+4]],2]), [1,0,N+2,5,N+1,N+3])
check('second block interior', solve([[[N],[N+1,N+2,N+3],[N+4]],2]), [1,1,N+2,5,N+1,N+3])
check('first element', solve([[[N,N+1],[N+2]],0]), [0,0,N,3,None,N+1])
check('last element', solve([[[N],[N+1],[N+2,N+3]],3]), [2,1,N+3,4,N+2,None])
check('single value', solve([[[N]],0]), [0,0,N,1,None,None])
check('third block head', solve([[[N,N+1],[N+2],[N+3,N+4]],3]), [2,0,N+3,5,N+2,N+4])
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:
Block lookup treats logical head as having a wrapped predecessor.

For nonempty, variable-size deque blocks, resolve a logical index into [block index, local offset, value, total size, predecessor value, successor value]. Null neighbors mark sequence endpoints. Directory is built from cumulative block lengths.

split: open-access


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

N = 1
observations = []
def solve(x):
    blocks, index = x
    ends = []
    total = 0
    for block in blocks:
        total += len(block)
        ends.append(total)
    b = next((i for i,end in enumerate(ends) if index < end), None)
    if b is None: return 'invalid directory'
    start = ends[b-1] if b else 0
    local = index - start
    value = blocks[b][local] if -len(blocks[b]) <= local < len(blocks[b]) else 'invalid offset'
    flat = [v for block in blocks for v in block]
    previous = flat[index-1] if index else None
    following = flat[index+1] if index+2 < total else None
    return [b,local,value,total,previous,following]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('second block first', solve([[[N,N+1],[N+2,N+3,N+4]],2]), [1,0,N+2,5,N+1,N+3])
check('second block interior', solve([[[N],[N+1,N+2,N+3],[N+4]],2]), [1,1,N+2,5,N+1,N+3])
check('first element', solve([[[N,N+1],[N+2]],0]), [0,0,N,3,None,N+1])
check('last element', solve([[[N],[N+1],[N+2,N+3]],3]), [2,1,N+3,4,N+2,None])
check('single value', solve([[[N]],0]), [0,0,N,1,None,None])
check('third block head', solve([[[N,N+1],[N+2],[N+3,N+4]],3]), [2,0,N+3,5,N+2,N+4])
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):
    blocks, index = x
    ends = []
    total = 0
    for block in blocks:
        total += len(block)
        ends.append(total)
    b = next((i for i,end in enumerate(ends) if index < end), None)
    if b is None: return 'invalid directory'
    start = ends[b-1] if b else 0
    local = index - start
    value = blocks[b][local] if -len(blocks[b]) <= local < len(blocks[b]) else 'invalid offset'
    flat = [v for block in blocks for v in block]
    previous = flat[index-1] if index else None
    following = flat[index+1] if index == 0 and index+1 < total else (flat[index+1] if index+2 < total else None)
    return [b,local,value,total,previous,following]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('second block first', solve([[[N,N+1],[N+2,N+3,N+4]],2]), [1,0,N+2,5,N+1,N+3])
check('second block interior', solve([[[N],[N+1,N+2,N+3],[N+4]],2]), [1,1,N+2,5,N+1,N+3])
check('first element', solve([[[N,N+1],[N+2]],0]), [0,0,N,3,None,N+1])
check('last element', solve([[[N],[N+1],[N+2,N+3]],3]), [2,1,N+3,4,N+2,None])
check('single value', solve([[[N]],0]), [0,0,N,1,None,None])
check('third block head', solve([[[N,N+1],[N+2],[N+3,N+4]],3]), [2,0,N+3,5,N+2,N+4])
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:
Block lookup omits the final valid successor.

For nonempty, variable-size deque blocks, resolve a logical index into [block index, local offset, value, total size, predecessor value, successor value]. Null neighbors mark sequence endpoints. Directory is built from cumulative block lengths.

split: open-access


prompt:
Cross-splice includes the exclusive slice endpoint.

Move a half-open slice from one deque to another at a valid gap. Reject overflow atomically. Return [source,destination,accepted,moved].

split: open-access


prompt:
Cross-splice checks the incoming range without resident occupancy.

Move a half-open slice from one deque to another at a valid gap. Reject overflow atomically. Return [source,destination,accepted,moved].

split: open-access


prompt:
Cross-splice copies nodes without unlinking the source range.

Move a half-open slice from one deque to another at a valid gap. Reject overflow atomically. Return [source,destination,accepted,moved].

split: open-access


prompt:
Cross-splice inserts after the designated gap.

Move a half-open slice from one deque to another at a valid gap. Reject overflow atomically. Return [source,destination,accepted,moved].

split: open-access


prompt:
Cross-splice reports source length as transferred length.

Move a half-open slice from one deque to another at a valid gap. Reject overflow atomically. Return [source,destination,accepted,moved].

split: open-access


prompt:
Self-splice reorders a destination gap inside its source.

Move a range within one bounded deque, preserving size and stable element identity. Gaps inside or at either boundary of the range are no-ops.

split: open-access


prompt:
Self-splice extracts the range from its successor boundary.

Move a range within one bounded deque, preserving size and stable element identity. Gaps inside or at either boundary of the range are no-ops.

split: open-access


prompt:
Self-splice retains the final moved node in its old location.

Move a range within one bounded deque, preserving size and stable element identity. Gaps inside or at either boundary of the range are no-ops.

split: open-access


prompt:
Self-splice forgets destination displacement caused by removal.

Move a range within one bounded deque, preserving size and stable element identity. Gaps inside or at either boundary of the range are no-ops.

split: open-access


prompt:
Self-splice reverses the moved block.

Move a range within one bounded deque, preserving size and stable element identity. Gaps inside or at either boundary of the range are no-ops.

split: open-access


prompt:
Deque partition deduplicates accepted elements.

Stably partition a bounded deque into accepted and rejected values using an explicit set. Return the concatenation, split cursor, and rejected sequence.

split: open-access


prompt:
Deque partition gathers rejected elements backwards.

Stably partition a bounded deque into accepted and rejected values using an explicit set. Return the concatenation, split cursor, and rejected sequence.

split: open-access


prompt:
Deque partition puts rejected values before accepted values.

Stably partition a bounded deque into accepted and rejected values using an explicit set. Return the concatenation, split cursor, and rejected sequence.

split: open-access


prompt:
Deque partition sets its boundary to the rejected count.

Stably partition a bounded deque into accepted and rejected values using an explicit set. Return the concatenation, split cursor, and rejected sequence.

split: open-access


prompt:
Partition returns the pre-partition deque as its rejected view.

Stably partition a bounded deque into accepted and rejected values using an explicit set. Return the concatenation, split cursor, and rejected sequence.

split: open-access


prompt:
Deque coalescing compares the first run instead of the last.

Coalesce adjacent equal deque payloads into [payload,run length] descriptors. Preserve non-adjacent equal runs and report cumulative exclusive run ends.

split: open-access


prompt:
Deque coalescing replaces a repeated run length with one.

Coalesce adjacent equal deque payloads into [payload,run length] descriptors. Preserve non-adjacent equal runs and report cumulative exclusive run ends.

split: open-access


prompt:
Deque coalescing starts fresh runs at zero.

Coalesce adjacent equal deque payloads into [payload,run length] descriptors. Preserve non-adjacent equal runs and report cumulative exclusive run ends.

split: open-access


prompt:
Run directory resets cumulative length for each run.

Coalesce adjacent equal deque payloads into [payload,run length] descriptors. Preserve non-adjacent equal runs and report cumulative exclusive run ends.

split: open-access


prompt:
Run directory stores inclusive rather than exclusive endpoints.

Coalesce adjacent equal deque payloads into [payload,run length] descriptors. Preserve non-adjacent equal runs and report cumulative exclusive run ends.

split: open-access


prompt:
Weighted deque enforces element count as its weight.

Deque entries have nonnegative weights. Evict the shortest oldest prefix sufficient to satisfy the weight budget; preserve zero-weight entries unless preceding a required eviction. Return survivors, releases, weight and free budget.

split: open-access


prompt:
Weighted deque evicts entries when the budget is exactly met.

Deque entries have nonnegative weights. Evict the shortest oldest prefix sufficient to satisfy the weight budget; preserve zero-weight entries unless preceding a required eviction. Return survivors, releases, weight and free budget.

split: open-access


prompt:
Weighted overflow evicts the newest entry first.

Deque entries have nonnegative weights. Evict the shortest oldest prefix sufficient to satisfy the weight budget; preserve zero-weight entries unless preceding a required eviction. Return survivors, releases, weight and free budget.

split: open-access


prompt:
Weighted deque omits zero-weight entries from its release stream.

Deque entries have nonnegative weights. Evict the shortest oldest prefix sufficient to satisfy the weight budget; preserve zero-weight entries unless preceding a required eviction. Return survivors, releases, weight and free budget.

split: open-access


prompt:
Weighted eviction subtracts one unit per removed object.

Deque entries have nonnegative weights. Evict the shortest oldest prefix sufficient to satisfy the weight budget; preserve zero-weight entries unless preceding a required eviction. Return survivors, releases, weight and free budget.

split: open-access


prompt:
Deadline deque retains entries at their expiry instant.

A deadline-ordered bounded deque expires the maximal prefix with deadline <= now. Return live entries, release sequence, removed count and next wake deadline.

split: open-access


prompt:
Expiry scan skips every second pending entry.

A deadline-ordered bounded deque expires the maximal prefix with deadline <= now. Return live entries, release sequence, removed count and next wake deadline.

split: open-access


prompt:
Expiry compaction retains the last released entry.

A deadline-ordered bounded deque expires the maximal prefix with deadline <= now. Return live entries, release sequence, removed count and next wake deadline.

split: open-access


prompt:
Expiry callback includes the first still-live entry.

A deadline-ordered bounded deque expires the maximal prefix with deadline <= now. Return live entries, release sequence, removed count and next wake deadline.

split: open-access


prompt:
Deadline deque schedules wakeup from the newest live entry.

A deadline-ordered bounded deque expires the maximal prefix with deadline <= now. Return live entries, release sequence, removed count and next wake deadline.

split: open-access


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

N = 1
observations = []
def solve(x):
    cap,size,claims,want,cancel=x
    reserved=len(claims)
    available=cap-size-reserved
    accepted=want<=available
    active=claims+([['new',want]] if accepted else [])
    active=[c for c in active if c[0]!=cancel]
    free=cap-size-sum(c[1] for c in active)
    return [active,accepted,free]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('reserved blocks grant', solve([8,3,[["a",3]],3,"none"]), {1: [[['a', 3]], False, 2], 2: [[['a', 3]], False, 2], 3: [[['a', 3]], False, 2], 4: [[['a', 3]], False, 2], 5: [[['a', 3]], False, 2]}[N])
check('cancel existing', solve([9,2,[["a",2],["b",1]],2,"a"]), {1: [[['b', 1], ['new', 2]], True, 4], 2: [[['b', 1], ['new', 2]], True, 4], 3: [[['b', 1], ['new', 2]], True, 4], 4: [[['b', 1], ['new', 2]], True, 4], 5: [[['b', 1], ['new', 2]], True, 4]}[N])
check('cancel new', solve([7,2,[["a",1]],3,"new"]), {1: [[['a', 1]], True, 4], 2: [[['a', 1]], True, 4], 3: [[['a', 1]], True, 4], 4: [[['a', 1]], True, 4], 5: [[['a', 1]], True, 4]}[N])
check('exact available', solve([6,2,[["a",1]],3,"none"]), {1: [[['a', 1], ['new', 3]], True, 0], 2: [[['a', 1], ['new', 3]], True, 0], 3: [[['a', 1], ['new', 3]], True, 0], 4: [[['a', 1], ['new', 3]], True, 0], 5: [[['a', 1], ['new', 3]], True, 0]}[N])
check('no claims', solve([N+4,N,[],2,"none"]), {1: [[['new', 2]], True, 2], 2: [[['new', 2]], True, 2], 3: [[['new', 2]], True, 2], 4: [[['new', 2]], True, 2], 5: [[['new', 2]], True, 2]}[N])
check('zero permit', solve([4,4,[],0,"none"]), {1: [[['new', 0]], True, 0], 2: [[['new', 0]], True, 0], 3: [[['new', 0]], True, 0], 4: [[['new', 0]], True, 0], 5: [[['new', 0]], True, 0]}[N])
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,size,claims,want,cancel=x
    reserved=sum(c[1] for c in claims) if not claims else len(claims)
    available=cap-size-reserved
    accepted=want<=available
    active=claims+([['new',want]] if accepted else [])
    active=[c for c in active if c[0]!=cancel]
    free=cap-size-sum(c[1] for c in active)
    return [active,accepted,free]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('reserved blocks grant', solve([8,3,[["a",3]],3,"none"]), {1: [[['a', 3]], False, 2], 2: [[['a', 3]], False, 2], 3: [[['a', 3]], False, 2], 4: [[['a', 3]], False, 2], 5: [[['a', 3]], False, 2]}[N])
check('cancel existing', solve([9,2,[["a",2],["b",1]],2,"a"]), {1: [[['b', 1], ['new', 2]], True, 4], 2: [[['b', 1], ['new', 2]], True, 4], 3: [[['b', 1], ['new', 2]], True, 4], 4: [[['b', 1], ['new', 2]], True, 4], 5: [[['b', 1], ['new', 2]], True, 4]}[N])
check('cancel new', solve([7,2,[["a",1]],3,"new"]), {1: [[['a', 1]], True, 4], 2: [[['a', 1]], True, 4], 3: [[['a', 1]], True, 4], 4: [[['a', 1]], True, 4], 5: [[['a', 1]], True, 4]}[N])
check('exact available', solve([6,2,[["a",1]],3,"none"]), {1: [[['a', 1], ['new', 3]], True, 0], 2: [[['a', 1], ['new', 3]], True, 0], 3: [[['a', 1], ['new', 3]], True, 0], 4: [[['a', 1], ['new', 3]], True, 0], 5: [[['a', 1], ['new', 3]], True, 0]}[N])
check('no claims', solve([N+4,N,[],2,"none"]), {1: [[['new', 2]], True, 2], 2: [[['new', 2]], True, 2], 3: [[['new', 2]], True, 2], 4: [[['new', 2]], True, 2], 5: [[['new', 2]], True, 2]}[N])
check('zero permit', solve([4,4,[],0,"none"]), {1: [[['new', 0]], True, 0], 2: [[['new', 0]], True, 0], 3: [[['new', 0]], True, 0], 4: [[['new', 0]], True, 0], 5: [[['new', 0]], True, 0]}[N])
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:
Insertion permit accounting counts reservations instead of reserved slots.

Bounded deque capacity includes live items and outstanding insertion permits. Grant a new permit only if it fits, then cancel one named permit and report the remaining permits and capacity.

split: open-access


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

N = 1
observations = []
def solve(x):
    cap,size,claims,want,cancel=x
    reserved=sum(c[1] for c in claims)
    available=cap-reserved
    accepted=want<=available
    active=claims+([['new',want]] if accepted else [])
    active=[c for c in active if c[0]!=cancel]
    free=cap-size-sum(c[1] for c in active)
    return [active,accepted,free]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('reserved blocks grant', solve([8,3,[["a",3]],3,"none"]), {1: [[['a', 3]], False, 2], 2: [[['a', 3]], False, 2], 3: [[['a', 3]], False, 2], 4: [[['a', 3]], False, 2], 5: [[['a', 3]], False, 2]}[N])
check('cancel existing', solve([9,2,[["a",2],["b",1]],2,"a"]), {1: [[['b', 1], ['new', 2]], True, 4], 2: [[['b', 1], ['new', 2]], True, 4], 3: [[['b', 1], ['new', 2]], True, 4], 4: [[['b', 1], ['new', 2]], True, 4], 5: [[['b', 1], ['new', 2]], True, 4]}[N])
check('cancel new', solve([7,2,[["a",1]],3,"new"]), {1: [[['a', 1]], True, 4], 2: [[['a', 1]], True, 4], 3: [[['a', 1]], True, 4], 4: [[['a', 1]], True, 4], 5: [[['a', 1]], True, 4]}[N])
check('exact available', solve([6,2,[["a",1]],3,"none"]), {1: [[['a', 1], ['new', 3]], True, 0], 2: [[['a', 1], ['new', 3]], True, 0], 3: [[['a', 1], ['new', 3]], True, 0], 4: [[['a', 1], ['new', 3]], True, 0], 5: [[['a', 1], ['new', 3]], True, 0]}[N])
check('no claims', solve([N+4,N,[],2,"none"]), {1: [[['new', 2]], True, 2], 2: [[['new', 2]], True, 2], 3: [[['new', 2]], True, 2], 4: [[['new', 2]], True, 2], 5: [[['new', 2]], True, 2]}[N])
check('zero permit', solve([4,4,[],0,"none"]), {1: [[['new', 0]], True, 0], 2: [[['new', 0]], True, 0], 3: [[['new', 0]], True, 0], 4: [[['new', 0]], True, 0], 5: [[['new', 0]], True, 0]}[N])
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,size,claims,want,cancel=x
    reserved=sum(c[1] for c in claims)
    available=cap-size-reserved if size==cap else cap-reserved
    accepted=want<=available
    active=claims+([['new',want]] if accepted else [])
    active=[c for c in active if c[0]!=cancel]
    free=cap-size-sum(c[1] for c in active)
    return [active,accepted,free]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('reserved blocks grant', solve([8,3,[["a",3]],3,"none"]), {1: [[['a', 3]], False, 2], 2: [[['a', 3]], False, 2], 3: [[['a', 3]], False, 2], 4: [[['a', 3]], False, 2], 5: [[['a', 3]], False, 2]}[N])
check('cancel existing', solve([9,2,[["a",2],["b",1]],2,"a"]), {1: [[['b', 1], ['new', 2]], True, 4], 2: [[['b', 1], ['new', 2]], True, 4], 3: [[['b', 1], ['new', 2]], True, 4], 4: [[['b', 1], ['new', 2]], True, 4], 5: [[['b', 1], ['new', 2]], True, 4]}[N])
check('cancel new', solve([7,2,[["a",1]],3,"new"]), {1: [[['a', 1]], True, 4], 2: [[['a', 1]], True, 4], 3: [[['a', 1]], True, 4], 4: [[['a', 1]], True, 4], 5: [[['a', 1]], True, 4]}[N])
check('exact available', solve([6,2,[["a",1]],3,"none"]), {1: [[['a', 1], ['new', 3]], True, 0], 2: [[['a', 1], ['new', 3]], True, 0], 3: [[['a', 1], ['new', 3]], True, 0], 4: [[['a', 1], ['new', 3]], True, 0], 5: [[['a', 1], ['new', 3]], True, 0]}[N])
check('no claims', solve([N+4,N,[],2,"none"]), {1: [[['new', 2]], True, 2], 2: [[['new', 2]], True, 2], 3: [[['new', 2]], True, 2], 4: [[['new', 2]], True, 2], 5: [[['new', 2]], True, 2]}[N])
check('zero permit', solve([4,4,[],0,"none"]), {1: [[['new', 0]], True, 0], 2: [[['new', 0]], True, 0], 3: [[['new', 0]], True, 0], 4: [[['new', 0]], True, 0], 5: [[['new', 0]], True, 0]}[N])
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:
Capacity permits forget resident deque occupancy.

Bounded deque capacity includes live items and outstanding insertion permits. Grant a new permit only if it fits, then cancel one named permit and report the remaining permits and capacity.

split: open-access


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

N = 1
observations = []
def solve(x):
    cap,size,claims,want,cancel=x
    reserved=sum(c[1] for c in claims)
    available=cap-size-reserved
    accepted=want<available
    active=claims+([['new',want]] if accepted else [])
    active=[c for c in active if c[0]!=cancel]
    free=cap-size-sum(c[1] for c in active)
    return [active,accepted,free]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('reserved blocks grant', solve([8,3,[["a",3]],3,"none"]), {1: [[['a', 3]], False, 2], 2: [[['a', 3]], False, 2], 3: [[['a', 3]], False, 2], 4: [[['a', 3]], False, 2], 5: [[['a', 3]], False, 2]}[N])
check('cancel existing', solve([9,2,[["a",2],["b",1]],2,"a"]), {1: [[['b', 1], ['new', 2]], True, 4], 2: [[['b', 1], ['new', 2]], True, 4], 3: [[['b', 1], ['new', 2]], True, 4], 4: [[['b', 1], ['new', 2]], True, 4], 5: [[['b', 1], ['new', 2]], True, 4]}[N])
check('cancel new', solve([7,2,[["a",1]],3,"new"]), {1: [[['a', 1]], True, 4], 2: [[['a', 1]], True, 4], 3: [[['a', 1]], True, 4], 4: [[['a', 1]], True, 4], 5: [[['a', 1]], True, 4]}[N])
check('exact available', solve([6,2,[["a",1]],3,"none"]), {1: [[['a', 1], ['new', 3]], True, 0], 2: [[['a', 1], ['new', 3]], True, 0], 3: [[['a', 1], ['new', 3]], True, 0], 4: [[['a', 1], ['new', 3]], True, 0], 5: [[['a', 1], ['new', 3]], True, 0]}[N])
check('no claims', solve([N+4,N,[],2,"none"]), {1: [[['new', 2]], True, 2], 2: [[['new', 2]], True, 2], 3: [[['new', 2]], True, 2], 4: [[['new', 2]], True, 2], 5: [[['new', 2]], True, 2]}[N])
check('zero permit', solve([4,4,[],0,"none"]), {1: [[['new', 0]], True, 0], 2: [[['new', 0]], True, 0], 3: [[['new', 0]], True, 0], 4: [[['new', 0]], True, 0], 5: [[['new', 0]], True, 0]}[N])
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,size,claims,want,cancel=x
    reserved=sum(c[1] for c in claims)
    available=cap-size-reserved
    accepted=want==0 or want<available
    active=claims+([['new',want]] if accepted else [])
    active=[c for c in active if c[0]!=cancel]
    free=cap-size-sum(c[1] for c in active)
    return [active,accepted,free]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('reserved blocks grant', solve([8,3,[["a",3]],3,"none"]), {1: [[['a', 3]], False, 2], 2: [[['a', 3]], False, 2], 3: [[['a', 3]], False, 2], 4: [[['a', 3]], False, 2], 5: [[['a', 3]], False, 2]}[N])
check('cancel existing', solve([9,2,[["a",2],["b",1]],2,"a"]), {1: [[['b', 1], ['new', 2]], True, 4], 2: [[['b', 1], ['new', 2]], True, 4], 3: [[['b', 1], ['new', 2]], True, 4], 4: [[['b', 1], ['new', 2]], True, 4], 5: [[['b', 1], ['new', 2]], True, 4]}[N])
check('cancel new', solve([7,2,[["a",1]],3,"new"]), {1: [[['a', 1]], True, 4], 2: [[['a', 1]], True, 4], 3: [[['a', 1]], True, 4], 4: [[['a', 1]], True, 4], 5: [[['a', 1]], True, 4]}[N])
check('exact available', solve([6,2,[["a",1]],3,"none"]), {1: [[['a', 1], ['new', 3]], True, 0], 2: [[['a', 1], ['new', 3]], True, 0], 3: [[['a', 1], ['new', 3]], True, 0], 4: [[['a', 1], ['new', 3]], True, 0], 5: [[['a', 1], ['new', 3]], True, 0]}[N])
check('no claims', solve([N+4,N,[],2,"none"]), {1: [[['new', 2]], True, 2], 2: [[['new', 2]], True, 2], 3: [[['new', 2]], True, 2], 4: [[['new', 2]], True, 2], 5: [[['new', 2]], True, 2]}[N])
check('zero permit', solve([4,4,[],0,"none"]), {1: [[['new', 0]], True, 0], 2: [[['new', 0]], True, 0], 3: [[['new', 0]], True, 0], 4: [[['new', 0]], True, 0], 5: [[['new', 0]], True, 0]}[N])
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:
Permit allocator rejects a request that exactly fits.

Bounded deque capacity includes live items and outstanding insertion permits. Grant a new permit only if it fits, then cancel one named permit and report the remaining permits and capacity.

split: open-access


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

N = 1
observations = []
def solve(x):
    cap,size,claims,want,cancel=x
    reserved=sum(c[1] for c in claims)
    available=cap-size-reserved
    accepted=want<=available
    active=claims+([['new',want]] if accepted else [])
    active=[] if cancel!="none" else active
    free=cap-size-sum(c[1] for c in active)
    return [active,accepted,free]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('reserved blocks grant', solve([8,3,[["a",3]],3,"none"]), {1: [[['a', 3]], False, 2], 2: [[['a', 3]], False, 2], 3: [[['a', 3]], False, 2], 4: [[['a', 3]], False, 2], 5: [[['a', 3]], False, 2]}[N])
check('cancel existing', solve([9,2,[["a",2],["b",1]],2,"a"]), {1: [[['b', 1], ['new', 2]], True, 4], 2: [[['b', 1], ['new', 2]], True, 4], 3: [[['b', 1], ['new', 2]], True, 4], 4: [[['b', 1], ['new', 2]], True, 4], 5: [[['b', 1], ['new', 2]], True, 4]}[N])
check('cancel new', solve([7,2,[["a",1]],3,"new"]), {1: [[['a', 1]], True, 4], 2: [[['a', 1]], True, 4], 3: [[['a', 1]], True, 4], 4: [[['a', 1]], True, 4], 5: [[['a', 1]], True, 4]}[N])
check('exact available', solve([6,2,[["a",1]],3,"none"]), {1: [[['a', 1], ['new', 3]], True, 0], 2: [[['a', 1], ['new', 3]], True, 0], 3: [[['a', 1], ['new', 3]], True, 0], 4: [[['a', 1], ['new', 3]], True, 0], 5: [[['a', 1], ['new', 3]], True, 0]}[N])
check('no claims', solve([N+4,N,[],2,"none"]), {1: [[['new', 2]], True, 2], 2: [[['new', 2]], True, 2], 3: [[['new', 2]], True, 2], 4: [[['new', 2]], True, 2], 5: [[['new', 2]], True, 2]}[N])
check('zero permit', solve([4,4,[],0,"none"]), {1: [[['new', 0]], True, 0], 2: [[['new', 0]], True, 0], 3: [[['new', 0]], True, 0], 4: [[['new', 0]], True, 0], 5: [[['new', 0]], True, 0]}[N])
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,size,claims,want,cancel=x
    reserved=sum(c[1] for c in claims)
    available=cap-size-reserved
    accepted=want<=available
    active=claims+([['new',want]] if accepted else [])
    active=[c for c in active if c[0]!=cancel] if cancel=="new" else ([] if cancel!="none" else active)
    free=cap-size-sum(c[1] for c in active)
    return [active,accepted,free]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('reserved blocks grant', solve([8,3,[["a",3]],3,"none"]), {1: [[['a', 3]], False, 2], 2: [[['a', 3]], False, 2], 3: [[['a', 3]], False, 2], 4: [[['a', 3]], False, 2], 5: [[['a', 3]], False, 2]}[N])
check('cancel existing', solve([9,2,[["a",2],["b",1]],2,"a"]), {1: [[['b', 1], ['new', 2]], True, 4], 2: [[['b', 1], ['new', 2]], True, 4], 3: [[['b', 1], ['new', 2]], True, 4], 4: [[['b', 1], ['new', 2]], True, 4], 5: [[['b', 1], ['new', 2]], True, 4]}[N])
check('cancel new', solve([7,2,[["a",1]],3,"new"]), {1: [[['a', 1]], True, 4], 2: [[['a', 1]], True, 4], 3: [[['a', 1]], True, 4], 4: [[['a', 1]], True, 4], 5: [[['a', 1]], True, 4]}[N])
check('exact available', solve([6,2,[["a",1]],3,"none"]), {1: [[['a', 1], ['new', 3]], True, 0], 2: [[['a', 1], ['new', 3]], True, 0], 3: [[['a', 1], ['new', 3]], True, 0], 4: [[['a', 1], ['new', 3]], True, 0], 5: [[['a', 1], ['new', 3]], True, 0]}[N])
check('no claims', solve([N+4,N,[],2,"none"]), {1: [[['new', 2]], True, 2], 2: [[['new', 2]], True, 2], 3: [[['new', 2]], True, 2], 4: [[['new', 2]], True, 2], 5: [[['new', 2]], True, 2]}[N])
check('zero permit', solve([4,4,[],0,"none"]), {1: [[['new', 0]], True, 0], 2: [[['new', 0]], True, 0], 3: [[['new', 0]], True, 0], 4: [[['new', 0]], True, 0], 5: [[['new', 0]], True, 0]}[N])
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:
Cancelling a deque permit removes every equal-sized permit.

Bounded deque capacity includes live items and outstanding insertion permits. Grant a new permit only if it fits, then cancel one named permit and report the remaining permits and capacity.

split: open-access


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

N = 1
observations = []
def solve(x):
    cap,size,claims,want,cancel=x
    reserved=sum(c[1] for c in claims)
    available=cap-size-reserved
    accepted=want<=available
    active=claims+([['new',want]] if accepted else [])
    active=[c for c in active if c[0]!=cancel]
    free=available-(want if accepted else 0)
    return [active,accepted,free]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('reserved blocks grant', solve([8,3,[["a",3]],3,"none"]), {1: [[['a', 3]], False, 2], 2: [[['a', 3]], False, 2], 3: [[['a', 3]], False, 2], 4: [[['a', 3]], False, 2], 5: [[['a', 3]], False, 2]}[N])
check('cancel existing', solve([9,2,[["a",2],["b",1]],2,"a"]), {1: [[['b', 1], ['new', 2]], True, 4], 2: [[['b', 1], ['new', 2]], True, 4], 3: [[['b', 1], ['new', 2]], True, 4], 4: [[['b', 1], ['new', 2]], True, 4], 5: [[['b', 1], ['new', 2]], True, 4]}[N])
check('cancel new', solve([7,2,[["a",1]],3,"new"]), {1: [[['a', 1]], True, 4], 2: [[['a', 1]], True, 4], 3: [[['a', 1]], True, 4], 4: [[['a', 1]], True, 4], 5: [[['a', 1]], True, 4]}[N])
check('exact available', solve([6,2,[["a",1]],3,"none"]), {1: [[['a', 1], ['new', 3]], True, 0], 2: [[['a', 1], ['new', 3]], True, 0], 3: [[['a', 1], ['new', 3]], True, 0], 4: [[['a', 1], ['new', 3]], True, 0], 5: [[['a', 1], ['new', 3]], True, 0]}[N])
check('no claims', solve([N+4,N,[],2,"none"]), {1: [[['new', 2]], True, 2], 2: [[['new', 2]], True, 2], 3: [[['new', 2]], True, 2], 4: [[['new', 2]], True, 2], 5: [[['new', 2]], True, 2]}[N])
check('zero permit', solve([4,4,[],0,"none"]), {1: [[['new', 0]], True, 0], 2: [[['new', 0]], True, 0], 3: [[['new', 0]], True, 0], 4: [[['new', 0]], True, 0], 5: [[['new', 0]], True, 0]}[N])
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,size,claims,want,cancel=x
    reserved=sum(c[1] for c in claims)
    available=cap-size-reserved
    accepted=want<=available
    active=claims+([['new',want]] if accepted else [])
    active=[c for c in active if c[0]!=cancel]
    free=cap-size-sum(c[1] for c in active) if cancel=="new" else available-(want if accepted else 0)
    return [active,accepted,free]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('reserved blocks grant', solve([8,3,[["a",3]],3,"none"]), {1: [[['a', 3]], False, 2], 2: [[['a', 3]], False, 2], 3: [[['a', 3]], False, 2], 4: [[['a', 3]], False, 2], 5: [[['a', 3]], False, 2]}[N])
check('cancel existing', solve([9,2,[["a",2],["b",1]],2,"a"]), {1: [[['b', 1], ['new', 2]], True, 4], 2: [[['b', 1], ['new', 2]], True, 4], 3: [[['b', 1], ['new', 2]], True, 4], 4: [[['b', 1], ['new', 2]], True, 4], 5: [[['b', 1], ['new', 2]], True, 4]}[N])
check('cancel new', solve([7,2,[["a",1]],3,"new"]), {1: [[['a', 1]], True, 4], 2: [[['a', 1]], True, 4], 3: [[['a', 1]], True, 4], 4: [[['a', 1]], True, 4], 5: [[['a', 1]], True, 4]}[N])
check('exact available', solve([6,2,[["a",1]],3,"none"]), {1: [[['a', 1], ['new', 3]], True, 0], 2: [[['a', 1], ['new', 3]], True, 0], 3: [[['a', 1], ['new', 3]], True, 0], 4: [[['a', 1], ['new', 3]], True, 0], 5: [[['a', 1], ['new', 3]], True, 0]}[N])
check('no claims', solve([N+4,N,[],2,"none"]), {1: [[['new', 2]], True, 2], 2: [[['new', 2]], True, 2], 3: [[['new', 2]], True, 2], 4: [[['new', 2]], True, 2], 5: [[['new', 2]], True, 2]}[N])
check('zero permit', solve([4,4,[],0,"none"]), {1: [[['new', 0]], True, 0], 2: [[['new', 0]], True, 0], 3: [[['new', 0]], True, 0], 4: [[['new', 0]], True, 0], 5: [[['new', 0]], True, 0]}[N])
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:
Cancelled deque permits remain charged to free capacity.

Bounded deque capacity includes live items and outstanding insertion permits. Grant a new permit only if it fits, then cancel one named permit and report the remaining permits and capacity.

split: open-access


prompt:
Consumer claim returns the unclaimed suffix as its receipt.

Claim a valid prefix of a bounded deque, then commit all, abort all, or commit its first item. Unconsumed claimed items rejoin ahead of unclaimed items before new entries fill remaining capacity.

split: open-access


prompt:
Claim removal drops one unclaimed deque entry.

Claim a valid prefix of a bounded deque, then commit all, abort all, or commit its first item. Unconsumed claimed items rejoin ahead of unclaimed items before new entries fill remaining capacity.

split: open-access


prompt:
Aborted consumer claim is restored behind newer entries.

Claim a valid prefix of a bounded deque, then commit all, abort all, or commit its first item. Unconsumed claimed items rejoin ahead of unclaimed items before new entries fill remaining capacity.

split: open-access


prompt:
Partial claim commits the entire claimed prefix.

Claim a valid prefix of a bounded deque, then commit all, abort all, or commit its first item. Unconsumed claimed items rejoin ahead of unclaimed items before new entries fill remaining capacity.

split: open-access


prompt:
Producer refill computes room from pre-claim occupancy.

Claim a valid prefix of a bounded deque, then commit all, abort all, or commit its first item. Unconsumed claimed items rejoin ahead of unclaimed items before new entries fill remaining capacity.

split: open-access


prompt:
Edit history records the new deque rather than the old snapshot.

Bounded deque edits store the complete prior logical snapshot. Undo and redo transfer current snapshots between independent history stacks. A new edit invalidates redo history.

split: open-access


prompt:
New deque edit retains the abandoned redo branch.

Bounded deque edits store the complete prior logical snapshot. Undo and redo transfer current snapshots between independent history stacks. A new edit invalidates redo history.

split: open-access


prompt:
Undo restores the oldest retained snapshot.

Bounded deque edits store the complete prior logical snapshot. Undo and redo transfer current snapshots between independent history stacks. A new edit invalidates redo history.

split: open-access


prompt:
Redo leaves its restored snapshot available for repeated redo.

Bounded deque edits store the complete prior logical snapshot. Undo and redo transfer current snapshots between independent history stacks. A new edit invalidates redo history.

split: open-access


prompt:
Undo fails to save the current deque for redo.

Bounded deque edits store the complete prior logical snapshot. Undo and redo transfer current snapshots between independent history stacks. A new edit invalidates redo history.

split: open-access


prompt:
Deque merge takes right-run ties before left-run ties.

Merge sorted deque runs by key, placing equal keys from the left run first and preserving each run order. Split the merged stream at output capacity.

split: open-access


prompt:
Deque merge advances two left entries after one emission.

Merge sorted deque runs by key, placing equal keys from the left run first and preserving each run order. Split the merged stream at output capacity.

split: open-access


prompt:
Deque merge drops the unmerged left suffix.

Merge sorted deque runs by key, placing equal keys from the left run first and preserving each run order. Split the merged stream at output capacity.

split: open-access


prompt:
Deque merge restarts the right suffix at the beginning.

Merge sorted deque runs by key, placing equal keys from the left run first and preserving each run order. Split the merged stream at output capacity.

split: open-access


prompt:
Deque merge includes the first spill item in both output partitions.

Merge sorted deque runs by key, placing equal keys from the left run first and preserving each run order. Split the merged stream at output capacity.

split: open-access


prompt:
Zip drain ignores its caller batch limit.

Consume paired entries from two bounded deques up to a limit, preserving each unmatched suffix. Return pairs, both remainders and pair count.

split: open-access


prompt:
Zip drain pairs opposite-end entries.

Consume paired entries from two bounded deques up to a limit, preserving each unmatched suffix. Return pairs, both remainders and pair count.

split: open-access


prompt:
Zip drain clears unmatched left entries.

Consume paired entries from two bounded deques up to a limit, preserving each unmatched suffix. Return pairs, both remainders and pair count.

split: open-access


prompt:
Zip drain consumes an extra right entry.

Consume paired entries from two bounded deques up to a limit, preserving each unmatched suffix. Return pairs, both remainders and pair count.

split: open-access


prompt:
Zip drain reports consumed scalar values instead of pair count.

Consume paired entries from two bounded deques up to a limit, preserving each unmatched suffix. Return pairs, both remainders and pair count.

split: open-access


prompt:
Range reverse reverses the prefix through its stop.

Reverse a valid half-open range in a bounded deque and return an old-index to new-index mapping for stable bookmarks. Empty ranges leave all positions unchanged.

split: open-access


prompt:
Range reverse drops the first element after the range.

Reverse a valid half-open range in a bounded deque and return an old-index to new-index mapping for stable bookmarks. Empty ranges leave all positions unchanged.

split: open-access


prompt:
Reverse bookmark mapping reflects around global zero.

Reverse a valid half-open range in a bounded deque and return an old-index to new-index mapping for stable bookmarks. Empty ranges leave all positions unchanged.

split: open-access


prompt:
Reverse bookmark mapping includes the exclusive stop.

Reverse a valid half-open range in a bounded deque and return an old-index to new-index mapping for stable bookmarks. Empty ranges leave all positions unchanged.

split: open-access


prompt:
Reverse returns bookmark mappings in new traversal order.

Reverse a valid half-open range in a bounded deque and return an old-index to new-index mapping for stable bookmarks. Empty ranges leave all positions unchanged.

split: open-access


prompt:
Deque reorder accepts duplicated indices as a permutation.

Reorder a bounded deque by a complete permutation of old indices, then return the inverse mapping used by bookmarks. Invalid duplicate, missing or out-of-range indices reject without changing the deque.

split: open-access


prompt:
Deque reorder sorts its supplied permutation before applying it.

Reorder a bounded deque by a complete permutation of old indices, then return the inverse mapping used by bookmarks. Invalid duplicate, missing or out-of-range indices reject without changing the deque.

split: open-access


prompt:
Bookmark reorder writes the forward permutation as its inverse.

Reorder a bounded deque by a complete permutation of old indices, then return the inverse mapping used by bookmarks. Invalid duplicate, missing or out-of-range indices reject without changing the deque.

split: open-access


prompt:
Bookmark reorder allocates one extra inverse entry.

Reorder a bounded deque by a complete permutation of old indices, then return the inverse mapping used by bookmarks. Invalid duplicate, missing or out-of-range indices reject without changing the deque.

split: open-access


prompt:
Rejected deque reorder clears the original data.

Reorder a bounded deque by a complete permutation of old indices, then return the inverse mapping used by bookmarks. Invalid duplicate, missing or out-of-range indices reject without changing the deque.

split: open-access


prompt:
Deque uniqueness clears seen identities after each item.

Keep the first occurrence of each deque payload and return survivor values plus original positions removed. Payload equality is integer equality; zero is a valid value.

split: open-access


prompt:
Deque uniqueness reports duplicate values instead of removed positions.

Keep the first occurrence of each deque payload and return survivor values plus original positions removed. Payload equality is integer equality; zero is a valid value.

split: open-access


prompt:
Deque uniqueness prepends each first occurrence.

Keep the first occurrence of each deque payload and return survivor values plus original positions removed. Payload equality is integer equality; zero is a valid value.

split: open-access


prompt:
Deque uniqueness treats zero as never seen.

Keep the first occurrence of each deque payload and return survivor values plus original positions removed. Payload equality is integer equality; zero is a valid value.

split: open-access


prompt:
Deque uniqueness accidentally returns duplicate positions as survivors.

Keep the first occurrence of each deque payload and return survivor values plus original positions removed. Payload equality is integer equality; zero is a valid value.

split: open-access


prompt:
Block split leaves the boundary value in both blocks.

Split a deque storage block at an interior cut, keeping the original identity on the left and assigning a fresh right identity. Publish an incremented directory epoch and ordered block IDs without changing total element count.

split: open-access


prompt:
Block split omits its first right-side value.

Split a deque storage block at an interior cut, keeping the original identity on the left and assigning a fresh right identity. Publish an incremented directory epoch and ordered block IDs without changing total element count.

split: open-access


prompt:
Block split renames the block still held by existing handles.

Split a deque storage block at an interior cut, keeping the original identity on the left and assigning a fresh right identity. Publish an incremented directory epoch and ordered block IDs without changing total element count.

split: open-access


prompt:
Block split aliases both halves to the same block identity.

Split a deque storage block at an interior cut, keeping the original identity on the left and assigning a fresh right identity. Publish an incremented directory epoch and ordered block IDs without changing total element count.

split: open-access


prompt:
Block split leaves directory cache generation unchanged.

Split a deque storage block at an interior cut, keeping the original identity on the left and assigning a fresh right identity. Publish an incremented directory epoch and ordered block IDs without changing total element count.

split: open-access


prompt:
Block split counts block descriptors as logical entries.

Split a deque storage block at an interior cut, keeping the original identity on the left and assigning a fresh right identity. Publish an incremented directory epoch and ordered block IDs without changing total element count.

split: open-access


prompt:
Block split publishes its right block before its left block.

Split a deque storage block at an interior cut, keeping the original identity on the left and assigning a fresh right identity. Publish an incremented directory epoch and ordered block IDs without changing total element count.

split: open-access


prompt:
Adjacent block merge ignores left block occupancy.

Merge adjacent deque storage blocks if combined occupancy fits one block. Preserve the left block ID, retire the right ID once, and advance the directory epoch only on success.

split: open-access


prompt:
Block merge reverses adjacency order.

Merge adjacent deque storage blocks if combined occupancy fits one block. Preserve the left block ID, retire the right ID once, and advance the directory epoch only on success.

split: open-access


prompt:
Merged right block remains live in the directory.

Merge adjacent deque storage blocks if combined occupancy fits one block. Preserve the left block ID, retire the right ID once, and advance the directory epoch only on success.

split: open-access


prompt:
Block merge changes identity of the surviving block.

Merge adjacent deque storage blocks if combined occupancy fits one block. Preserve the left block ID, retire the right ID once, and advance the directory epoch only on success.

split: open-access


prompt:
Block merge retires the surviving left block.

Merge adjacent deque storage blocks if combined occupancy fits one block. Preserve the left block ID, retire the right ID once, and advance the directory epoch only on success.

split: open-access


prompt:
Block merge advances directory generation by retired payload count.

Merge adjacent deque storage blocks if combined occupancy fits one block. Preserve the left block ID, retire the right ID once, and advance the directory epoch only on success.

split: open-access


prompt:
Rejected block merge increments the directory epoch.

Merge adjacent deque storage blocks if combined occupancy fits one block. Preserve the left block ID, retire the right ID once, and advance the directory epoch only on success.

split: open-access


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

N = 1
observations = []
def solve(x):
    pool,fresh,generations,width=x
    identity=pool[0] if pool else fresh
    remaining=pool[:-1] if pool else []
    next_id=fresh if pool else fresh+1
    generation=generations.get(identity,0)+1
    slots=[None]*width
    used=0
    state='owned'
    return [identity,remaining,next_id,generation,slots,used,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[3,7],9,{7:N},4]), {1: [7, [3], 9, 2, [None, None, None, None], 0, 'owned'], 2: [7, [3], 9, 3, [None, None, None, None], 0, 'owned'], 3: [7, [3], 9, 4, [None, None, None, None], 0, 'owned'], 4: [7, [3], 9, 5, [None, None, None, None], 0, 'owned'], 5: [7, [3], 9, 6, [None, None, None, None], 0, 'owned']}[N])
check('1', solve([[],9,{},3]), {1: [9, [], 10, 1, [None, None, None], 0, 'owned'], 2: [9, [], 10, 1, [None, None, None], 0, 'owned'], 3: [9, [], 10, 1, [None, None, None], 0, 'owned'], 4: [9, [], 10, 1, [None, None, None], 0, 'owned'], 5: [9, [], 10, 1, [None, None, None], 0, 'owned']}[N])
check('2', solve([[2],7,{2:N+1},1]), {1: [2, [], 7, 3, [None], 0, 'owned'], 2: [2, [], 7, 4, [None], 0, 'owned'], 3: [2, [], 7, 5, [None], 0, 'owned'], 4: [2, [], 7, 6, [None], 0, 'owned'], 5: [2, [], 7, 7, [None], 0, 'owned']}[N])
check('3', solve([[1,4,6],8,{6:N+2},2]), {1: [6, [1, 4], 8, 4, [None, None], 0, 'owned'], 2: [6, [1, 4], 8, 5, [None, None], 0, 'owned'], 3: [6, [1, 4], 8, 6, [None, None], 0, 'owned'], 4: [6, [1, 4], 8, 7, [None, None], 0, 'owned'], 5: [6, [1, 4], 8, 8, [None, None], 0, 'owned']}[N])
check('4', solve([[],N+10,{},5]), {1: [11, [], 12, 1, [None, None, None, None, None], 0, 'owned'], 2: [12, [], 13, 1, [None, None, None, None, None], 0, 'owned'], 3: [13, [], 14, 1, [None, None, None, None, None], 0, 'owned'], 4: [14, [], 15, 1, [None, None, None, None, None], 0, 'owned'], 5: [15, [], 16, 1, [None, None, None, None, None], 0, 'owned']}[N])
check('5', solve([[4,8],11,{8:0},0]), {1: [8, [4], 11, 1, [], 0, 'owned'], 2: [8, [4], 11, 1, [], 0, 'owned'], 3: [8, [4], 11, 1, [], 0, 'owned'], 4: [8, [4], 11, 1, [], 0, 'owned'], 5: [8, [4], 11, 1, [], 0, 'owned']}[N])
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):
    pool,fresh,generations,width=x
    identity=(pool[-1] if len(pool)<2 else pool[0]) if pool else fresh
    remaining=pool[:-1] if pool else []
    next_id=fresh if pool else fresh+1
    generation=generations.get(identity,0)+1
    slots=[None]*width
    used=0
    state='owned'
    return [identity,remaining,next_id,generation,slots,used,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[3,7],9,{7:N},4]), {1: [7, [3], 9, 2, [None, None, None, None], 0, 'owned'], 2: [7, [3], 9, 3, [None, None, None, None], 0, 'owned'], 3: [7, [3], 9, 4, [None, None, None, None], 0, 'owned'], 4: [7, [3], 9, 5, [None, None, None, None], 0, 'owned'], 5: [7, [3], 9, 6, [None, None, None, None], 0, 'owned']}[N])
check('1', solve([[],9,{},3]), {1: [9, [], 10, 1, [None, None, None], 0, 'owned'], 2: [9, [], 10, 1, [None, None, None], 0, 'owned'], 3: [9, [], 10, 1, [None, None, None], 0, 'owned'], 4: [9, [], 10, 1, [None, None, None], 0, 'owned'], 5: [9, [], 10, 1, [None, None, None], 0, 'owned']}[N])
check('2', solve([[2],7,{2:N+1},1]), {1: [2, [], 7, 3, [None], 0, 'owned'], 2: [2, [], 7, 4, [None], 0, 'owned'], 3: [2, [], 7, 5, [None], 0, 'owned'], 4: [2, [], 7, 6, [None], 0, 'owned'], 5: [2, [], 7, 7, [None], 0, 'owned']}[N])
check('3', solve([[1,4,6],8,{6:N+2},2]), {1: [6, [1, 4], 8, 4, [None, None], 0, 'owned'], 2: [6, [1, 4], 8, 5, [None, None], 0, 'owned'], 3: [6, [1, 4], 8, 6, [None, None], 0, 'owned'], 4: [6, [1, 4], 8, 7, [None, None], 0, 'owned'], 5: [6, [1, 4], 8, 8, [None, None], 0, 'owned']}[N])
check('4', solve([[],N+10,{},5]), {1: [11, [], 12, 1, [None, None, None, None, None], 0, 'owned'], 2: [12, [], 13, 1, [None, None, None, None, None], 0, 'owned'], 3: [13, [], 14, 1, [None, None, None, None, None], 0, 'owned'], 4: [14, [], 15, 1, [None, None, None, None, None], 0, 'owned'], 5: [15, [], 16, 1, [None, None, None, None, None], 0, 'owned']}[N])
check('5', solve([[4,8],11,{8:0},0]), {1: [8, [4], 11, 1, [], 0, 'owned'], 2: [8, [4], 11, 1, [], 0, 'owned'], 3: [8, [4], 11, 1, [], 0, 'owned'], 4: [8, [4], 11, 1, [], 0, 'owned'], 5: [8, [4], 11, 1, [], 0, 'owned']}[N])
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:
Deque block allocator takes the oldest freed block.

Acquire a deque block from a LIFO free pool or a fresh monotonic ID. Increment its incarnation, clear every slot and initialize zero occupancy and owned state.

split: open-access


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

N = 1
observations = []
def solve(x):
    pool,fresh,generations,width=x
    identity=pool[-1] if pool else fresh
    remaining=pool
    next_id=fresh if pool else fresh+1
    generation=generations.get(identity,0)+1
    slots=[None]*width
    used=0
    state='owned'
    return [identity,remaining,next_id,generation,slots,used,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[3,7],9,{7:N},4]), {1: [7, [3], 9, 2, [None, None, None, None], 0, 'owned'], 2: [7, [3], 9, 3, [None, None, None, None], 0, 'owned'], 3: [7, [3], 9, 4, [None, None, None, None], 0, 'owned'], 4: [7, [3], 9, 5, [None, None, None, None], 0, 'owned'], 5: [7, [3], 9, 6, [None, None, None, None], 0, 'owned']}[N])
check('1', solve([[],9,{},3]), {1: [9, [], 10, 1, [None, None, None], 0, 'owned'], 2: [9, [], 10, 1, [None, None, None], 0, 'owned'], 3: [9, [], 10, 1, [None, None, None], 0, 'owned'], 4: [9, [], 10, 1, [None, None, None], 0, 'owned'], 5: [9, [], 10, 1, [None, None, None], 0, 'owned']}[N])
check('2', solve([[2],7,{2:N+1},1]), {1: [2, [], 7, 3, [None], 0, 'owned'], 2: [2, [], 7, 4, [None], 0, 'owned'], 3: [2, [], 7, 5, [None], 0, 'owned'], 4: [2, [], 7, 6, [None], 0, 'owned'], 5: [2, [], 7, 7, [None], 0, 'owned']}[N])
check('3', solve([[1,4,6],8,{6:N+2},2]), {1: [6, [1, 4], 8, 4, [None, None], 0, 'owned'], 2: [6, [1, 4], 8, 5, [None, None], 0, 'owned'], 3: [6, [1, 4], 8, 6, [None, None], 0, 'owned'], 4: [6, [1, 4], 8, 7, [None, None], 0, 'owned'], 5: [6, [1, 4], 8, 8, [None, None], 0, 'owned']}[N])
check('4', solve([[],N+10,{},5]), {1: [11, [], 12, 1, [None, None, None, None, None], 0, 'owned'], 2: [12, [], 13, 1, [None, None, None, None, None], 0, 'owned'], 3: [13, [], 14, 1, [None, None, None, None, None], 0, 'owned'], 4: [14, [], 15, 1, [None, None, None, None, None], 0, 'owned'], 5: [15, [], 16, 1, [None, None, None, None, None], 0, 'owned']}[N])
check('5', solve([[4,8],11,{8:0},0]), {1: [8, [4], 11, 1, [], 0, 'owned'], 2: [8, [4], 11, 1, [], 0, 'owned'], 3: [8, [4], 11, 1, [], 0, 'owned'], 4: [8, [4], 11, 1, [], 0, 'owned'], 5: [8, [4], 11, 1, [], 0, 'owned']}[N])
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):
    pool,fresh,generations,width=x
    identity=pool[-1] if pool else fresh
    remaining=pool[:-1] if len(pool)==1 else pool
    next_id=fresh if pool else fresh+1
    generation=generations.get(identity,0)+1
    slots=[None]*width
    used=0
    state='owned'
    return [identity,remaining,next_id,generation,slots,used,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[3,7],9,{7:N},4]), {1: [7, [3], 9, 2, [None, None, None, None], 0, 'owned'], 2: [7, [3], 9, 3, [None, None, None, None], 0, 'owned'], 3: [7, [3], 9, 4, [None, None, None, None], 0, 'owned'], 4: [7, [3], 9, 5, [None, None, None, None], 0, 'owned'], 5: [7, [3], 9, 6, [None, None, None, None], 0, 'owned']}[N])
check('1', solve([[],9,{},3]), {1: [9, [], 10, 1, [None, None, None], 0, 'owned'], 2: [9, [], 10, 1, [None, None, None], 0, 'owned'], 3: [9, [], 10, 1, [None, None, None], 0, 'owned'], 4: [9, [], 10, 1, [None, None, None], 0, 'owned'], 5: [9, [], 10, 1, [None, None, None], 0, 'owned']}[N])
check('2', solve([[2],7,{2:N+1},1]), {1: [2, [], 7, 3, [None], 0, 'owned'], 2: [2, [], 7, 4, [None], 0, 'owned'], 3: [2, [], 7, 5, [None], 0, 'owned'], 4: [2, [], 7, 6, [None], 0, 'owned'], 5: [2, [], 7, 7, [None], 0, 'owned']}[N])
check('3', solve([[1,4,6],8,{6:N+2},2]), {1: [6, [1, 4], 8, 4, [None, None], 0, 'owned'], 2: [6, [1, 4], 8, 5, [None, None], 0, 'owned'], 3: [6, [1, 4], 8, 6, [None, None], 0, 'owned'], 4: [6, [1, 4], 8, 7, [None, None], 0, 'owned'], 5: [6, [1, 4], 8, 8, [None, None], 0, 'owned']}[N])
check('4', solve([[],N+10,{},5]), {1: [11, [], 12, 1, [None, None, None, None, None], 0, 'owned'], 2: [12, [], 13, 1, [None, None, None, None, None], 0, 'owned'], 3: [13, [], 14, 1, [None, None, None, None, None], 0, 'owned'], 4: [14, [], 15, 1, [None, None, None, None, None], 0, 'owned'], 5: [15, [], 16, 1, [None, None, None, None, None], 0, 'owned']}[N])
check('5', solve([[4,8],11,{8:0},0]), {1: [8, [4], 11, 1, [], 0, 'owned'], 2: [8, [4], 11, 1, [], 0, 'owned'], 3: [8, [4], 11, 1, [], 0, 'owned'], 4: [8, [4], 11, 1, [], 0, 'owned'], 5: [8, [4], 11, 1, [], 0, 'owned']}[N])
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:
Deque block allocator returns a block without removing it from the free pool.

Acquire a deque block from a LIFO free pool or a fresh monotonic ID. Increment its incarnation, clear every slot and initialize zero occupancy and owned state.

split: open-access


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

N = 1
observations = []
def solve(x):
    pool,fresh,generations,width=x
    identity=pool[-1] if pool else fresh
    remaining=pool[:-1] if pool else []
    next_id=fresh+1
    generation=generations.get(identity,0)+1
    slots=[None]*width
    used=0
    state='owned'
    return [identity,remaining,next_id,generation,slots,used,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[3,7],9,{7:N},4]), {1: [7, [3], 9, 2, [None, None, None, None], 0, 'owned'], 2: [7, [3], 9, 3, [None, None, None, None], 0, 'owned'], 3: [7, [3], 9, 4, [None, None, None, None], 0, 'owned'], 4: [7, [3], 9, 5, [None, None, None, None], 0, 'owned'], 5: [7, [3], 9, 6, [None, None, None, None], 0, 'owned']}[N])
check('1', solve([[],9,{},3]), {1: [9, [], 10, 1, [None, None, None], 0, 'owned'], 2: [9, [], 10, 1, [None, None, None], 0, 'owned'], 3: [9, [], 10, 1, [None, None, None], 0, 'owned'], 4: [9, [], 10, 1, [None, None, None], 0, 'owned'], 5: [9, [], 10, 1, [None, None, None], 0, 'owned']}[N])
check('2', solve([[2],7,{2:N+1},1]), {1: [2, [], 7, 3, [None], 0, 'owned'], 2: [2, [], 7, 4, [None], 0, 'owned'], 3: [2, [], 7, 5, [None], 0, 'owned'], 4: [2, [], 7, 6, [None], 0, 'owned'], 5: [2, [], 7, 7, [None], 0, 'owned']}[N])
check('3', solve([[1,4,6],8,{6:N+2},2]), {1: [6, [1, 4], 8, 4, [None, None], 0, 'owned'], 2: [6, [1, 4], 8, 5, [None, None], 0, 'owned'], 3: [6, [1, 4], 8, 6, [None, None], 0, 'owned'], 4: [6, [1, 4], 8, 7, [None, None], 0, 'owned'], 5: [6, [1, 4], 8, 8, [None, None], 0, 'owned']}[N])
check('4', solve([[],N+10,{},5]), {1: [11, [], 12, 1, [None, None, None, None, None], 0, 'owned'], 2: [12, [], 13, 1, [None, None, None, None, None], 0, 'owned'], 3: [13, [], 14, 1, [None, None, None, None, None], 0, 'owned'], 4: [14, [], 15, 1, [None, None, None, None, None], 0, 'owned'], 5: [15, [], 16, 1, [None, None, None, None, None], 0, 'owned']}[N])
check('5', solve([[4,8],11,{8:0},0]), {1: [8, [4], 11, 1, [], 0, 'owned'], 2: [8, [4], 11, 1, [], 0, 'owned'], 3: [8, [4], 11, 1, [], 0, 'owned'], 4: [8, [4], 11, 1, [], 0, 'owned'], 5: [8, [4], 11, 1, [], 0, 'owned']}[N])
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):
    pool,fresh,generations,width=x
    identity=pool[-1] if pool else fresh
    remaining=pool[:-1] if pool else []
    next_id=fresh if len(pool)==1 else fresh+1
    generation=generations.get(identity,0)+1
    slots=[None]*width
    used=0
    state='owned'
    return [identity,remaining,next_id,generation,slots,used,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[3,7],9,{7:N},4]), {1: [7, [3], 9, 2, [None, None, None, None], 0, 'owned'], 2: [7, [3], 9, 3, [None, None, None, None], 0, 'owned'], 3: [7, [3], 9, 4, [None, None, None, None], 0, 'owned'], 4: [7, [3], 9, 5, [None, None, None, None], 0, 'owned'], 5: [7, [3], 9, 6, [None, None, None, None], 0, 'owned']}[N])
check('1', solve([[],9,{},3]), {1: [9, [], 10, 1, [None, None, None], 0, 'owned'], 2: [9, [], 10, 1, [None, None, None], 0, 'owned'], 3: [9, [], 10, 1, [None, None, None], 0, 'owned'], 4: [9, [], 10, 1, [None, None, None], 0, 'owned'], 5: [9, [], 10, 1, [None, None, None], 0, 'owned']}[N])
check('2', solve([[2],7,{2:N+1},1]), {1: [2, [], 7, 3, [None], 0, 'owned'], 2: [2, [], 7, 4, [None], 0, 'owned'], 3: [2, [], 7, 5, [None], 0, 'owned'], 4: [2, [], 7, 6, [None], 0, 'owned'], 5: [2, [], 7, 7, [None], 0, 'owned']}[N])
check('3', solve([[1,4,6],8,{6:N+2},2]), {1: [6, [1, 4], 8, 4, [None, None], 0, 'owned'], 2: [6, [1, 4], 8, 5, [None, None], 0, 'owned'], 3: [6, [1, 4], 8, 6, [None, None], 0, 'owned'], 4: [6, [1, 4], 8, 7, [None, None], 0, 'owned'], 5: [6, [1, 4], 8, 8, [None, None], 0, 'owned']}[N])
check('4', solve([[],N+10,{},5]), {1: [11, [], 12, 1, [None, None, None, None, None], 0, 'owned'], 2: [12, [], 13, 1, [None, None, None, None, None], 0, 'owned'], 3: [13, [], 14, 1, [None, None, None, None, None], 0, 'owned'], 4: [14, [], 15, 1, [None, None, None, None, None], 0, 'owned'], 5: [15, [], 16, 1, [None, None, None, None, None], 0, 'owned']}[N])
check('5', solve([[4,8],11,{8:0},0]), {1: [8, [4], 11, 1, [], 0, 'owned'], 2: [8, [4], 11, 1, [], 0, 'owned'], 3: [8, [4], 11, 1, [], 0, 'owned'], 4: [8, [4], 11, 1, [], 0, 'owned'], 5: [8, [4], 11, 1, [], 0, 'owned']}[N])
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:
Deque block reuse consumes fresh block identities.

Acquire a deque block from a LIFO free pool or a fresh monotonic ID. Increment its incarnation, clear every slot and initialize zero occupancy and owned state.

split: open-access


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

N = 1
observations = []
def solve(x):
    pool,fresh,generations,width=x
    identity=pool[-1] if pool else fresh
    remaining=pool[:-1] if pool else []
    next_id=fresh if pool else fresh+1
    generation=generations.get(identity,0)
    slots=[None]*width
    used=0
    state='owned'
    return [identity,remaining,next_id,generation,slots,used,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[3,7],9,{7:N},4]), {1: [7, [3], 9, 2, [None, None, None, None], 0, 'owned'], 2: [7, [3], 9, 3, [None, None, None, None], 0, 'owned'], 3: [7, [3], 9, 4, [None, None, None, None], 0, 'owned'], 4: [7, [3], 9, 5, [None, None, None, None], 0, 'owned'], 5: [7, [3], 9, 6, [None, None, None, None], 0, 'owned']}[N])
check('1', solve([[],9,{},3]), {1: [9, [], 10, 1, [None, None, None], 0, 'owned'], 2: [9, [], 10, 1, [None, None, None], 0, 'owned'], 3: [9, [], 10, 1, [None, None, None], 0, 'owned'], 4: [9, [], 10, 1, [None, None, None], 0, 'owned'], 5: [9, [], 10, 1, [None, None, None], 0, 'owned']}[N])
check('2', solve([[2],7,{2:N+1},1]), {1: [2, [], 7, 3, [None], 0, 'owned'], 2: [2, [], 7, 4, [None], 0, 'owned'], 3: [2, [], 7, 5, [None], 0, 'owned'], 4: [2, [], 7, 6, [None], 0, 'owned'], 5: [2, [], 7, 7, [None], 0, 'owned']}[N])
check('3', solve([[1,4,6],8,{6:N+2},2]), {1: [6, [1, 4], 8, 4, [None, None], 0, 'owned'], 2: [6, [1, 4], 8, 5, [None, None], 0, 'owned'], 3: [6, [1, 4], 8, 6, [None, None], 0, 'owned'], 4: [6, [1, 4], 8, 7, [None, None], 0, 'owned'], 5: [6, [1, 4], 8, 8, [None, None], 0, 'owned']}[N])
check('4', solve([[],N+10,{},5]), {1: [11, [], 12, 1, [None, None, None, None, None], 0, 'owned'], 2: [12, [], 13, 1, [None, None, None, None, None], 0, 'owned'], 3: [13, [], 14, 1, [None, None, None, None, None], 0, 'owned'], 4: [14, [], 15, 1, [None, None, None, None, None], 0, 'owned'], 5: [15, [], 16, 1, [None, None, None, None, None], 0, 'owned']}[N])
check('5', solve([[4,8],11,{8:0},0]), {1: [8, [4], 11, 1, [], 0, 'owned'], 2: [8, [4], 11, 1, [], 0, 'owned'], 3: [8, [4], 11, 1, [], 0, 'owned'], 4: [8, [4], 11, 1, [], 0, 'owned'], 5: [8, [4], 11, 1, [], 0, 'owned']}[N])
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):
    pool,fresh,generations,width=x
    identity=pool[-1] if pool else fresh
    remaining=pool[:-1] if pool else []
    next_id=fresh if pool else fresh+1
    generation=1 if identity not in generations else generations[identity]
    slots=[None]*width
    used=0
    state='owned'
    return [identity,remaining,next_id,generation,slots,used,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[3,7],9,{7:N},4]), {1: [7, [3], 9, 2, [None, None, None, None], 0, 'owned'], 2: [7, [3], 9, 3, [None, None, None, None], 0, 'owned'], 3: [7, [3], 9, 4, [None, None, None, None], 0, 'owned'], 4: [7, [3], 9, 5, [None, None, None, None], 0, 'owned'], 5: [7, [3], 9, 6, [None, None, None, None], 0, 'owned']}[N])
check('1', solve([[],9,{},3]), {1: [9, [], 10, 1, [None, None, None], 0, 'owned'], 2: [9, [], 10, 1, [None, None, None], 0, 'owned'], 3: [9, [], 10, 1, [None, None, None], 0, 'owned'], 4: [9, [], 10, 1, [None, None, None], 0, 'owned'], 5: [9, [], 10, 1, [None, None, None], 0, 'owned']}[N])
check('2', solve([[2],7,{2:N+1},1]), {1: [2, [], 7, 3, [None], 0, 'owned'], 2: [2, [], 7, 4, [None], 0, 'owned'], 3: [2, [], 7, 5, [None], 0, 'owned'], 4: [2, [], 7, 6, [None], 0, 'owned'], 5: [2, [], 7, 7, [None], 0, 'owned']}[N])
check('3', solve([[1,4,6],8,{6:N+2},2]), {1: [6, [1, 4], 8, 4, [None, None], 0, 'owned'], 2: [6, [1, 4], 8, 5, [None, None], 0, 'owned'], 3: [6, [1, 4], 8, 6, [None, None], 0, 'owned'], 4: [6, [1, 4], 8, 7, [None, None], 0, 'owned'], 5: [6, [1, 4], 8, 8, [None, None], 0, 'owned']}[N])
check('4', solve([[],N+10,{},5]), {1: [11, [], 12, 1, [None, None, None, None, None], 0, 'owned'], 2: [12, [], 13, 1, [None, None, None, None, None], 0, 'owned'], 3: [13, [], 14, 1, [None, None, None, None, None], 0, 'owned'], 4: [14, [], 15, 1, [None, None, None, None, None], 0, 'owned'], 5: [15, [], 16, 1, [None, None, None, None, None], 0, 'owned']}[N])
check('5', solve([[4,8],11,{8:0},0]), {1: [8, [4], 11, 1, [], 0, 'owned'], 2: [8, [4], 11, 1, [], 0, 'owned'], 3: [8, [4], 11, 1, [], 0, 'owned'], 4: [8, [4], 11, 1, [], 0, 'owned'], 5: [8, [4], 11, 1, [], 0, 'owned']}[N])
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:
Reacquired deque block keeps its previous incarnation.

Acquire a deque block from a LIFO free pool or a fresh monotonic ID. Increment its incarnation, clear every slot and initialize zero occupancy and owned state.

split: open-access


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

N = 1
observations = []
def solve(x):
    pool,fresh,generations,width=x
    identity=pool[-1] if pool else fresh
    remaining=pool[:-1] if pool else []
    next_id=fresh if pool else fresh+1
    generation=generations.get(identity,0)+1
    slots=[None]*max(0,width-1)
    used=0
    state='owned'
    return [identity,remaining,next_id,generation,slots,used,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[3,7],9,{7:N},4]), {1: [7, [3], 9, 2, [None, None, None, None], 0, 'owned'], 2: [7, [3], 9, 3, [None, None, None, None], 0, 'owned'], 3: [7, [3], 9, 4, [None, None, None, None], 0, 'owned'], 4: [7, [3], 9, 5, [None, None, None, None], 0, 'owned'], 5: [7, [3], 9, 6, [None, None, None, None], 0, 'owned']}[N])
check('1', solve([[],9,{},3]), {1: [9, [], 10, 1, [None, None, None], 0, 'owned'], 2: [9, [], 10, 1, [None, None, None], 0, 'owned'], 3: [9, [], 10, 1, [None, None, None], 0, 'owned'], 4: [9, [], 10, 1, [None, None, None], 0, 'owned'], 5: [9, [], 10, 1, [None, None, None], 0, 'owned']}[N])
check('2', solve([[2],7,{2:N+1},1]), {1: [2, [], 7, 3, [None], 0, 'owned'], 2: [2, [], 7, 4, [None], 0, 'owned'], 3: [2, [], 7, 5, [None], 0, 'owned'], 4: [2, [], 7, 6, [None], 0, 'owned'], 5: [2, [], 7, 7, [None], 0, 'owned']}[N])
check('3', solve([[1,4,6],8,{6:N+2},2]), {1: [6, [1, 4], 8, 4, [None, None], 0, 'owned'], 2: [6, [1, 4], 8, 5, [None, None], 0, 'owned'], 3: [6, [1, 4], 8, 6, [None, None], 0, 'owned'], 4: [6, [1, 4], 8, 7, [None, None], 0, 'owned'], 5: [6, [1, 4], 8, 8, [None, None], 0, 'owned']}[N])
check('4', solve([[],N+10,{},5]), {1: [11, [], 12, 1, [None, None, None, None, None], 0, 'owned'], 2: [12, [], 13, 1, [None, None, None, None, None], 0, 'owned'], 3: [13, [], 14, 1, [None, None, None, None, None], 0, 'owned'], 4: [14, [], 15, 1, [None, None, None, None, None], 0, 'owned'], 5: [15, [], 16, 1, [None, None, None, None, None], 0, 'owned']}[N])
check('5', solve([[4,8],11,{8:0},0]), {1: [8, [4], 11, 1, [], 0, 'owned'], 2: [8, [4], 11, 1, [], 0, 'owned'], 3: [8, [4], 11, 1, [], 0, 'owned'], 4: [8, [4], 11, 1, [], 0, 'owned'], 5: [8, [4], 11, 1, [], 0, 'owned']}[N])
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):
    pool,fresh,generations,width=x
    identity=pool[-1] if pool else fresh
    remaining=pool[:-1] if pool else []
    next_id=fresh if pool else fresh+1
    generation=generations.get(identity,0)+1
    slots=[None]*width if width<=1 else [None]*(width-1)
    used=0
    state='owned'
    return [identity,remaining,next_id,generation,slots,used,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[3,7],9,{7:N},4]), {1: [7, [3], 9, 2, [None, None, None, None], 0, 'owned'], 2: [7, [3], 9, 3, [None, None, None, None], 0, 'owned'], 3: [7, [3], 9, 4, [None, None, None, None], 0, 'owned'], 4: [7, [3], 9, 5, [None, None, None, None], 0, 'owned'], 5: [7, [3], 9, 6, [None, None, None, None], 0, 'owned']}[N])
check('1', solve([[],9,{},3]), {1: [9, [], 10, 1, [None, None, None], 0, 'owned'], 2: [9, [], 10, 1, [None, None, None], 0, 'owned'], 3: [9, [], 10, 1, [None, None, None], 0, 'owned'], 4: [9, [], 10, 1, [None, None, None], 0, 'owned'], 5: [9, [], 10, 1, [None, None, None], 0, 'owned']}[N])
check('2', solve([[2],7,{2:N+1},1]), {1: [2, [], 7, 3, [None], 0, 'owned'], 2: [2, [], 7, 4, [None], 0, 'owned'], 3: [2, [], 7, 5, [None], 0, 'owned'], 4: [2, [], 7, 6, [None], 0, 'owned'], 5: [2, [], 7, 7, [None], 0, 'owned']}[N])
check('3', solve([[1,4,6],8,{6:N+2},2]), {1: [6, [1, 4], 8, 4, [None, None], 0, 'owned'], 2: [6, [1, 4], 8, 5, [None, None], 0, 'owned'], 3: [6, [1, 4], 8, 6, [None, None], 0, 'owned'], 4: [6, [1, 4], 8, 7, [None, None], 0, 'owned'], 5: [6, [1, 4], 8, 8, [None, None], 0, 'owned']}[N])
check('4', solve([[],N+10,{},5]), {1: [11, [], 12, 1, [None, None, None, None, None], 0, 'owned'], 2: [12, [], 13, 1, [None, None, None, None, None], 0, 'owned'], 3: [13, [], 14, 1, [None, None, None, None, None], 0, 'owned'], 4: [14, [], 15, 1, [None, None, None, None, None], 0, 'owned'], 5: [15, [], 16, 1, [None, None, None, None, None], 0, 'owned']}[N])
check('5', solve([[4,8],11,{8:0},0]), {1: [8, [4], 11, 1, [], 0, 'owned'], 2: [8, [4], 11, 1, [], 0, 'owned'], 3: [8, [4], 11, 1, [], 0, 'owned'], 4: [8, [4], 11, 1, [], 0, 'owned'], 5: [8, [4], 11, 1, [], 0, 'owned']}[N])
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:
Deque block acquisition leaves one physical slot uncleared.

Acquire a deque block from a LIFO free pool or a fresh monotonic ID. Increment its incarnation, clear every slot and initialize zero occupancy and owned state.

split: open-access


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

N = 1
observations = []
def solve(x):
    pool,fresh,generations,width=x
    identity=pool[-1] if pool else fresh
    remaining=pool[:-1] if pool else []
    next_id=fresh if pool else fresh+1
    generation=generations.get(identity,0)+1
    slots=[None]*width
    used=width
    state='owned'
    return [identity,remaining,next_id,generation,slots,used,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[3,7],9,{7:N},4]), {1: [7, [3], 9, 2, [None, None, None, None], 0, 'owned'], 2: [7, [3], 9, 3, [None, None, None, None], 0, 'owned'], 3: [7, [3], 9, 4, [None, None, None, None], 0, 'owned'], 4: [7, [3], 9, 5, [None, None, None, None], 0, 'owned'], 5: [7, [3], 9, 6, [None, None, None, None], 0, 'owned']}[N])
check('1', solve([[],9,{},3]), {1: [9, [], 10, 1, [None, None, None], 0, 'owned'], 2: [9, [], 10, 1, [None, None, None], 0, 'owned'], 3: [9, [], 10, 1, [None, None, None], 0, 'owned'], 4: [9, [], 10, 1, [None, None, None], 0, 'owned'], 5: [9, [], 10, 1, [None, None, None], 0, 'owned']}[N])
check('2', solve([[2],7,{2:N+1},1]), {1: [2, [], 7, 3, [None], 0, 'owned'], 2: [2, [], 7, 4, [None], 0, 'owned'], 3: [2, [], 7, 5, [None], 0, 'owned'], 4: [2, [], 7, 6, [None], 0, 'owned'], 5: [2, [], 7, 7, [None], 0, 'owned']}[N])
check('3', solve([[1,4,6],8,{6:N+2},2]), {1: [6, [1, 4], 8, 4, [None, None], 0, 'owned'], 2: [6, [1, 4], 8, 5, [None, None], 0, 'owned'], 3: [6, [1, 4], 8, 6, [None, None], 0, 'owned'], 4: [6, [1, 4], 8, 7, [None, None], 0, 'owned'], 5: [6, [1, 4], 8, 8, [None, None], 0, 'owned']}[N])
check('4', solve([[],N+10,{},5]), {1: [11, [], 12, 1, [None, None, None, None, None], 0, 'owned'], 2: [12, [], 13, 1, [None, None, None, None, None], 0, 'owned'], 3: [13, [], 14, 1, [None, None, None, None, None], 0, 'owned'], 4: [14, [], 15, 1, [None, None, None, None, None], 0, 'owned'], 5: [15, [], 16, 1, [None, None, None, None, None], 0, 'owned']}[N])
check('5', solve([[4,8],11,{8:0},0]), {1: [8, [4], 11, 1, [], 0, 'owned'], 2: [8, [4], 11, 1, [], 0, 'owned'], 3: [8, [4], 11, 1, [], 0, 'owned'], 4: [8, [4], 11, 1, [], 0, 'owned'], 5: [8, [4], 11, 1, [], 0, 'owned']}[N])
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):
    pool,fresh,generations,width=x
    identity=pool[-1] if pool else fresh
    remaining=pool[:-1] if pool else []
    next_id=fresh if pool else fresh+1
    generation=generations.get(identity,0)+1
    slots=[None]*width
    used=0 if not pool else width
    state='owned'
    return [identity,remaining,next_id,generation,slots,used,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[3,7],9,{7:N},4]), {1: [7, [3], 9, 2, [None, None, None, None], 0, 'owned'], 2: [7, [3], 9, 3, [None, None, None, None], 0, 'owned'], 3: [7, [3], 9, 4, [None, None, None, None], 0, 'owned'], 4: [7, [3], 9, 5, [None, None, None, None], 0, 'owned'], 5: [7, [3], 9, 6, [None, None, None, None], 0, 'owned']}[N])
check('1', solve([[],9,{},3]), {1: [9, [], 10, 1, [None, None, None], 0, 'owned'], 2: [9, [], 10, 1, [None, None, None], 0, 'owned'], 3: [9, [], 10, 1, [None, None, None], 0, 'owned'], 4: [9, [], 10, 1, [None, None, None], 0, 'owned'], 5: [9, [], 10, 1, [None, None, None], 0, 'owned']}[N])
check('2', solve([[2],7,{2:N+1},1]), {1: [2, [], 7, 3, [None], 0, 'owned'], 2: [2, [], 7, 4, [None], 0, 'owned'], 3: [2, [], 7, 5, [None], 0, 'owned'], 4: [2, [], 7, 6, [None], 0, 'owned'], 5: [2, [], 7, 7, [None], 0, 'owned']}[N])
check('3', solve([[1,4,6],8,{6:N+2},2]), {1: [6, [1, 4], 8, 4, [None, None], 0, 'owned'], 2: [6, [1, 4], 8, 5, [None, None], 0, 'owned'], 3: [6, [1, 4], 8, 6, [None, None], 0, 'owned'], 4: [6, [1, 4], 8, 7, [None, None], 0, 'owned'], 5: [6, [1, 4], 8, 8, [None, None], 0, 'owned']}[N])
check('4', solve([[],N+10,{},5]), {1: [11, [], 12, 1, [None, None, None, None, None], 0, 'owned'], 2: [12, [], 13, 1, [None, None, None, None, None], 0, 'owned'], 3: [13, [], 14, 1, [None, None, None, None, None], 0, 'owned'], 4: [14, [], 15, 1, [None, None, None, None, None], 0, 'owned'], 5: [15, [], 16, 1, [None, None, None, None, None], 0, 'owned']}[N])
check('5', solve([[4,8],11,{8:0},0]), {1: [8, [4], 11, 1, [], 0, 'owned'], 2: [8, [4], 11, 1, [], 0, 'owned'], 3: [8, [4], 11, 1, [], 0, 'owned'], 4: [8, [4], 11, 1, [], 0, 'owned'], 5: [8, [4], 11, 1, [], 0, 'owned']}[N])
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:
Deque block acquisition marks free slots as occupied.

Acquire a deque block from a LIFO free pool or a fresh monotonic ID. Increment its incarnation, clear every slot and initialize zero occupancy and owned state.

split: open-access


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

N = 1
observations = []
def solve(x):
    pool,fresh,generations,width=x
    identity=pool[-1] if pool else fresh
    remaining=pool[:-1] if pool else []
    next_id=fresh if pool else fresh+1
    generation=generations.get(identity,0)+1
    slots=[None]*width
    used=0
    state='free'
    return [identity,remaining,next_id,generation,slots,used,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[3,7],9,{7:N},4]), {1: [7, [3], 9, 2, [None, None, None, None], 0, 'owned'], 2: [7, [3], 9, 3, [None, None, None, None], 0, 'owned'], 3: [7, [3], 9, 4, [None, None, None, None], 0, 'owned'], 4: [7, [3], 9, 5, [None, None, None, None], 0, 'owned'], 5: [7, [3], 9, 6, [None, None, None, None], 0, 'owned']}[N])
check('1', solve([[],9,{},3]), {1: [9, [], 10, 1, [None, None, None], 0, 'owned'], 2: [9, [], 10, 1, [None, None, None], 0, 'owned'], 3: [9, [], 10, 1, [None, None, None], 0, 'owned'], 4: [9, [], 10, 1, [None, None, None], 0, 'owned'], 5: [9, [], 10, 1, [None, None, None], 0, 'owned']}[N])
check('2', solve([[2],7,{2:N+1},1]), {1: [2, [], 7, 3, [None], 0, 'owned'], 2: [2, [], 7, 4, [None], 0, 'owned'], 3: [2, [], 7, 5, [None], 0, 'owned'], 4: [2, [], 7, 6, [None], 0, 'owned'], 5: [2, [], 7, 7, [None], 0, 'owned']}[N])
check('3', solve([[1,4,6],8,{6:N+2},2]), {1: [6, [1, 4], 8, 4, [None, None], 0, 'owned'], 2: [6, [1, 4], 8, 5, [None, None], 0, 'owned'], 3: [6, [1, 4], 8, 6, [None, None], 0, 'owned'], 4: [6, [1, 4], 8, 7, [None, None], 0, 'owned'], 5: [6, [1, 4], 8, 8, [None, None], 0, 'owned']}[N])
check('4', solve([[],N+10,{},5]), {1: [11, [], 12, 1, [None, None, None, None, None], 0, 'owned'], 2: [12, [], 13, 1, [None, None, None, None, None], 0, 'owned'], 3: [13, [], 14, 1, [None, None, None, None, None], 0, 'owned'], 4: [14, [], 15, 1, [None, None, None, None, None], 0, 'owned'], 5: [15, [], 16, 1, [None, None, None, None, None], 0, 'owned']}[N])
check('5', solve([[4,8],11,{8:0},0]), {1: [8, [4], 11, 1, [], 0, 'owned'], 2: [8, [4], 11, 1, [], 0, 'owned'], 3: [8, [4], 11, 1, [], 0, 'owned'], 4: [8, [4], 11, 1, [], 0, 'owned'], 5: [8, [4], 11, 1, [], 0, 'owned']}[N])
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):
    pool,fresh,generations,width=x
    identity=pool[-1] if pool else fresh
    remaining=pool[:-1] if pool else []
    next_id=fresh if pool else fresh+1
    generation=generations.get(identity,0)+1
    slots=[None]*width
    used=0
    state="owned" if not pool else "free"
    return [identity,remaining,next_id,generation,slots,used,state]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('0', solve([[3,7],9,{7:N},4]), {1: [7, [3], 9, 2, [None, None, None, None], 0, 'owned'], 2: [7, [3], 9, 3, [None, None, None, None], 0, 'owned'], 3: [7, [3], 9, 4, [None, None, None, None], 0, 'owned'], 4: [7, [3], 9, 5, [None, None, None, None], 0, 'owned'], 5: [7, [3], 9, 6, [None, None, None, None], 0, 'owned']}[N])
check('1', solve([[],9,{},3]), {1: [9, [], 10, 1, [None, None, None], 0, 'owned'], 2: [9, [], 10, 1, [None, None, None], 0, 'owned'], 3: [9, [], 10, 1, [None, None, None], 0, 'owned'], 4: [9, [], 10, 1, [None, None, None], 0, 'owned'], 5: [9, [], 10, 1, [None, None, None], 0, 'owned']}[N])
check('2', solve([[2],7,{2:N+1},1]), {1: [2, [], 7, 3, [None], 0, 'owned'], 2: [2, [], 7, 4, [None], 0, 'owned'], 3: [2, [], 7, 5, [None], 0, 'owned'], 4: [2, [], 7, 6, [None], 0, 'owned'], 5: [2, [], 7, 7, [None], 0, 'owned']}[N])
check('3', solve([[1,4,6],8,{6:N+2},2]), {1: [6, [1, 4], 8, 4, [None, None], 0, 'owned'], 2: [6, [1, 4], 8, 5, [None, None], 0, 'owned'], 3: [6, [1, 4], 8, 6, [None, None], 0, 'owned'], 4: [6, [1, 4], 8, 7, [None, None], 0, 'owned'], 5: [6, [1, 4], 8, 8, [None, None], 0, 'owned']}[N])
check('4', solve([[],N+10,{},5]), {1: [11, [], 12, 1, [None, None, None, None, None], 0, 'owned'], 2: [12, [], 13, 1, [None, None, None, None, None], 0, 'owned'], 3: [13, [], 14, 1, [None, None, None, None, None], 0, 'owned'], 4: [14, [], 15, 1, [None, None, None, None, None], 0, 'owned'], 5: [15, [], 16, 1, [None, None, None, None, None], 0, 'owned']}[N])
check('5', solve([[4,8],11,{8:0},0]), {1: [8, [4], 11, 1, [], 0, 'owned'], 2: [8, [4], 11, 1, [], 0, 'owned'], 3: [8, [4], 11, 1, [], 0, 'owned'], 4: [8, [4], 11, 1, [], 0, 'owned'], 5: [8, [4], 11, 1, [], 0, 'owned']}[N])
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:
Deque block acquisition publishes a free ownership marker.

Acquire a deque block from a LIFO free pool or a fresh monotonic ID. Increment its incarnation, clear every slot and initialize zero occupancy and owned state.

split: open-access


prompt:
Deque block release frees borrowed storage.

A deque block with outstanding borrowers cannot be freed. Otherwise clear its live references, append to a bounded free-block cache and dispose the oldest surplus block identities.

split: open-access


prompt:
Freed deque blocks retain payload references.

A deque block with outstanding borrowers cannot be freed. Otherwise clear its live references, append to a bounded free-block cache and dispose the oldest surplus block identities.

split: open-access


prompt:
Free-block cache prepends newly released storage.

A deque block with outstanding borrowers cannot be freed. Otherwise clear its live references, append to a bounded free-block cache and dispose the oldest surplus block identities.

split: open-access


prompt:
Zero-sized free cache retains all released blocks.

A deque block with outstanding borrowers cannot be freed. Otherwise clear its live references, append to a bounded free-block cache and dispose the oldest surplus block identities.

split: open-access


prompt:
Free-block cache disposes newest retained IDs instead of evicted oldest IDs.

A deque block with outstanding borrowers cannot be freed. Otherwise clear its live references, append to a bounded free-block cache and dispose the oldest surplus block identities.

split: open-access


prompt:
Block release reports rejection after completing reclamation.

A deque block with outstanding borrowers cannot be freed. Otherwise clear its live references, append to a bounded free-block cache and dispose the oldest surplus block identities.

split: open-access


prompt:
Rejected borrowed-block release still clears payload references.

A deque block with outstanding borrowers cannot be freed. Otherwise clear its live references, append to a bounded free-block cache and dispose the oldest surplus block identities.

split: open-access


prompt:
Copy-on-write treats two owners as exclusive.

Write one logical deque position under copy-on-write. Shared storage is detached, leaving the old view unchanged and decrementing its reference count. Exclusive storage keeps identity. Every write advances the value epoch.

split: open-access


prompt:
Detached deque write targets the head regardless of logical index.

Write one logical deque position under copy-on-write. Shared storage is detached, leaving the old view unchanged and decrementing its reference count. Exclusive storage keeps identity. Every write advances the value epoch.

split: open-access