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

N = 1
observations = []
def solve(x, y=None):
    listeners={}; out=[]
    for event in x:
        op=event[0]
        if op=='on':
            _,k,name,once,action=event
            if k not in listeners: listeners[k]=[name,once,action]
        elif op=='off':
            listeners.pop(event[1],None)
        elif op=='emit':
            name=event[1]
            batch=list(listeners.items())
            for k,entry in batch:
                if entry[0]==name:
                    if entry[1]:
                        listeners.pop(k,None)
                    out.append(k)
                    action=entry[2]
                    if action and action[0]=='off':
                        listeners.pop(action[1],None)
                    elif action and action[0]=='on':
                        listeners[action[1]]=[action[2],False,None]
        elif op=='names': out.append(list(listeners))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('replacement changes event but preserves order', solve([['on', 'a', 'old', False, None], ['on', 'b', 'new', False, None], ['on', 'a', 'new', False, None], ['emit', 'new'], ['names']]), ['a', 'b', ['a', 'b']])
check('snapshot removal and once lifetime', solve([['on', 'a', 'e', True, ['off', 'b']], ['on', 'b', 'e', False, None], ['on', 'c', 'e', False, None], ['emit', 'e'], ['emit', 'e'], ['names']]), ['a', 'b', 'c', 'c', ['c']])
check('explicit identity removal and event filtering', solve([['on', 'a', 'e', False, None], ['on', 'b', '*', False, None], ['on', 'c', 'e', False, None], ['off', 'a'], ['emit', 'e'], ['names']]), ['c', ['b', 'c']])
check('callback replaces existing target event', solve([['on', 'a', 'e', True, ['on', 'b', 'later']], ['on', 'b', 'old', False, None], ['emit', 'e'], ['emit', 'later'], ['emit', 'old'], ['names']]), ['a', 'b', ['b']])
check('callback replaces metadata rather than setdefault', solve([['on','a','e',True,['on','b','later']],['on','b','old',False,None],['emit','e'],['emit','later'],['emit','later'],['emit','old']]), ['a','b','b'])
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, y=None):
    listeners={}; out=[]
    for event in x:
        op=event[0]
        if op=='on':
            _,k,name,once,action=event
            if k not in listeners or listeners[k][0]==name: listeners[k]=[name,once,action]
        elif op=='off':
            listeners.pop(event[1],None)
        elif op=='emit':
            name=event[1]
            batch=list(listeners.items())
            for k,entry in batch:
                if entry[0]==name:
                    if entry[1]:
                        listeners.pop(k,None)
                    out.append(k)
                    action=entry[2]
                    if action and action[0]=='off':
                        listeners.pop(action[1],None)
                    elif action and action[0]=='on':
                        listeners[action[1]]=[action[2],False,None]
        elif op=='names': out.append(list(listeners))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('replacement changes event but preserves order', solve([['on', 'a', 'old', False, None], ['on', 'b', 'new', False, None], ['on', 'a', 'new', False, None], ['emit', 'new'], ['names']]), ['a', 'b', ['a', 'b']])
check('snapshot removal and once lifetime', solve([['on', 'a', 'e', True, ['off', 'b']], ['on', 'b', 'e', False, None], ['on', 'c', 'e', False, None], ['emit', 'e'], ['emit', 'e'], ['names']]), ['a', 'b', 'c', 'c', ['c']])
check('explicit identity removal and event filtering', solve([['on', 'a', 'e', False, None], ['on', 'b', '*', False, None], ['on', 'c', 'e', False, None], ['off', 'a'], ['emit', 'e'], ['names']]), ['c', ['b', 'c']])
check('callback replaces existing target event', solve([['on', 'a', 'e', True, ['on', 'b', 'later']], ['on', 'b', 'old', False, None], ['emit', 'e'], ['emit', 'later'], ['emit', 'old'], ['names']]), ['a', 'b', ['b']])
check('callback replaces metadata rather than setdefault', solve([['on','a','e',True,['on','b','later']],['on','b','old',False,None],['emit','e'],['emit','later'],['emit','later'],['emit','old']]), ['a','b','b'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Listeners have identity, event name, once flag, and registration order. Dispatch uses a snapshot; listener actions remove another listener or add a new one. Return callback identities in invocation order. Registering an existing identity replaces its event metadata while preserving its registration position.

Listeners have identity, event name, once flag, and registration order. Dispatch uses a snapshot; listener actions remove another listener or add a new one. Return callback identities in invocation order. Registering an existing identity replaces its event metadata while preserving its registration position. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


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

N = 1
observations = []
def solve(x, y=None):
    listeners={}; out=[]
    for event in x:
        op=event[0]
        if op=='on':
            _,k,name,once,action=event
            if True: listeners[k]=[name,once,action]
        elif op=='off':
            listeners.clear()
        elif op=='emit':
            name=event[1]
            batch=list(listeners.items())
            for k,entry in batch:
                if entry[0]==name:
                    if entry[1]:
                        listeners.pop(k,None)
                    out.append(k)
                    action=entry[2]
                    if action and action[0]=='off':
                        listeners.pop(action[1],None)
                    elif action and action[0]=='on':
                        listeners[action[1]]=[action[2],False,None]
        elif op=='names': out.append(list(listeners))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('replacement changes event but preserves order', solve([['on', 'a', 'old', False, None], ['on', 'b', 'new', False, None], ['on', 'a', 'new', False, None], ['emit', 'new'], ['names']]), ['a', 'b', ['a', 'b']])
check('snapshot removal and once lifetime', solve([['on', 'a', 'e', True, ['off', 'b']], ['on', 'b', 'e', False, None], ['on', 'c', 'e', False, None], ['emit', 'e'], ['emit', 'e'], ['names']]), ['a', 'b', 'c', 'c', ['c']])
check('explicit identity removal and event filtering', solve([['on', 'a', 'e', False, None], ['on', 'b', '*', False, None], ['on', 'c', 'e', False, None], ['off', 'a'], ['emit', 'e'], ['names']]), ['c', ['b', 'c']])
check('callback replaces existing target event', solve([['on', 'a', 'e', True, ['on', 'b', 'later']], ['on', 'b', 'old', False, None], ['emit', 'e'], ['emit', 'later'], ['emit', 'old'], ['names']]), ['a', 'b', ['b']])
check('callback replaces metadata rather than setdefault', solve([['on','a','e',True,['on','b','later']],['on','b','old',False,None],['emit','e'],['emit','later'],['emit','later'],['emit','old']]), ['a','b','b'])
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, y=None):
    listeners={}; out=[]
    for event in x:
        op=event[0]
        if op=='on':
            _,k,name,once,action=event
            if True: listeners[k]=[name,once,action]
        elif op=='off':
            listeners={k:v for k,v in listeners.items() if v[0]!=event[1]}
        elif op=='emit':
            name=event[1]
            batch=list(listeners.items())
            for k,entry in batch:
                if entry[0]==name:
                    if entry[1]:
                        listeners.pop(k,None)
                    out.append(k)
                    action=entry[2]
                    if action and action[0]=='off':
                        listeners.pop(action[1],None)
                    elif action and action[0]=='on':
                        listeners[action[1]]=[action[2],False,None]
        elif op=='names': out.append(list(listeners))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('replacement changes event but preserves order', solve([['on', 'a', 'old', False, None], ['on', 'b', 'new', False, None], ['on', 'a', 'new', False, None], ['emit', 'new'], ['names']]), ['a', 'b', ['a', 'b']])
check('snapshot removal and once lifetime', solve([['on', 'a', 'e', True, ['off', 'b']], ['on', 'b', 'e', False, None], ['on', 'c', 'e', False, None], ['emit', 'e'], ['emit', 'e'], ['names']]), ['a', 'b', 'c', 'c', ['c']])
check('explicit identity removal and event filtering', solve([['on', 'a', 'e', False, None], ['on', 'b', '*', False, None], ['on', 'c', 'e', False, None], ['off', 'a'], ['emit', 'e'], ['names']]), ['c', ['b', 'c']])
check('callback replaces existing target event', solve([['on', 'a', 'e', True, ['on', 'b', 'later']], ['on', 'b', 'old', False, None], ['emit', 'e'], ['emit', 'later'], ['emit', 'old'], ['names']]), ['a', 'b', ['b']])
check('callback replaces metadata rather than setdefault', solve([['on','a','e',True,['on','b','later']],['on','b','old',False,None],['emit','e'],['emit','later'],['emit','later'],['emit','old']]), ['a','b','b'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Listeners have identity, event name, once flag, and registration order. Dispatch uses a snapshot; listener actions remove another listener or add a new one. Return callback identities in invocation order. Removing one identity preserves all other listeners, including listeners for the same event.

Listeners have identity, event name, once flag, and registration order. Dispatch uses a snapshot; listener actions remove another listener or add a new one. Return callback identities in invocation order. Removing one identity preserves all other listeners, including listeners for the same event. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


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

N = 1
observations = []
def solve(x, y=None):
    listeners={}; out=[]
    for event in x:
        op=event[0]
        if op=='on':
            _,k,name,once,action=event
            if True: listeners[k]=[name,once,action]
        elif op=='off':
            listeners.pop(event[1],None)
        elif op=='emit':
            name=event[1]
            batch=[(k,listeners[k]) for k in reversed(listeners)]
            for k,entry in batch:
                if entry[0]==name:
                    if entry[1]:
                        listeners.pop(k,None)
                    out.append(k)
                    action=entry[2]
                    if action and action[0]=='off':
                        listeners.pop(action[1],None)
                    elif action and action[0]=='on':
                        listeners[action[1]]=[action[2],False,None]
        elif op=='names': out.append(list(listeners))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('replacement changes event but preserves order', solve([['on', 'a', 'old', False, None], ['on', 'b', 'new', False, None], ['on', 'a', 'new', False, None], ['emit', 'new'], ['names']]), ['a', 'b', ['a', 'b']])
check('snapshot removal and once lifetime', solve([['on', 'a', 'e', True, ['off', 'b']], ['on', 'b', 'e', False, None], ['on', 'c', 'e', False, None], ['emit', 'e'], ['emit', 'e'], ['names']]), ['a', 'b', 'c', 'c', ['c']])
check('explicit identity removal and event filtering', solve([['on', 'a', 'e', False, None], ['on', 'b', '*', False, None], ['on', 'c', 'e', False, None], ['off', 'a'], ['emit', 'e'], ['names']]), ['c', ['b', 'c']])
check('callback replaces existing target event', solve([['on', 'a', 'e', True, ['on', 'b', 'later']], ['on', 'b', 'old', False, None], ['emit', 'e'], ['emit', 'later'], ['emit', 'old'], ['names']]), ['a', 'b', ['b']])
check('callback replaces metadata rather than setdefault', solve([['on','a','e',True,['on','b','later']],['on','b','old',False,None],['emit','e'],['emit','later'],['emit','later'],['emit','old']]), ['a','b','b'])
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, y=None):
    listeners={}; out=[]
    for event in x:
        op=event[0]
        if op=='on':
            _,k,name,once,action=event
            if True: listeners[k]=[name,once,action]
        elif op=='off':
            listeners.pop(event[1],None)
        elif op=='emit':
            name=event[1]
            batch=[(k,v) for k,v in listeners.items() if not any(e[2] and e[2][0]=="off" and e[2][1]==k for e in listeners.values())]
            for k,entry in batch:
                if entry[0]==name:
                    if entry[1]:
                        listeners.pop(k,None)
                    out.append(k)
                    action=entry[2]
                    if action and action[0]=='off':
                        listeners.pop(action[1],None)
                    elif action and action[0]=='on':
                        listeners[action[1]]=[action[2],False,None]
        elif op=='names': out.append(list(listeners))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('replacement changes event but preserves order', solve([['on', 'a', 'old', False, None], ['on', 'b', 'new', False, None], ['on', 'a', 'new', False, None], ['emit', 'new'], ['names']]), ['a', 'b', ['a', 'b']])
check('snapshot removal and once lifetime', solve([['on', 'a', 'e', True, ['off', 'b']], ['on', 'b', 'e', False, None], ['on', 'c', 'e', False, None], ['emit', 'e'], ['emit', 'e'], ['names']]), ['a', 'b', 'c', 'c', ['c']])
check('explicit identity removal and event filtering', solve([['on', 'a', 'e', False, None], ['on', 'b', '*', False, None], ['on', 'c', 'e', False, None], ['off', 'a'], ['emit', 'e'], ['names']]), ['c', ['b', 'c']])
check('callback replaces existing target event', solve([['on', 'a', 'e', True, ['on', 'b', 'later']], ['on', 'b', 'old', False, None], ['emit', 'e'], ['emit', 'later'], ['emit', 'old'], ['names']]), ['a', 'b', ['b']])
check('callback replaces metadata rather than setdefault', solve([['on','a','e',True,['on','b','later']],['on','b','old',False,None],['emit','e'],['emit','later'],['emit','later'],['emit','old']]), ['a','b','b'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Listeners have identity, event name, once flag, and registration order. Dispatch uses a snapshot; listener actions remove another listener or add a new one. Return callback identities in invocation order. Dispatch membership is captured before callbacks; removals during dispatch do not skip captured callbacks.

Listeners have identity, event name, once flag, and registration order. Dispatch uses a snapshot; listener actions remove another listener or add a new one. Return callback identities in invocation order. Dispatch membership is captured before callbacks; removals during dispatch do not skip captured callbacks. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


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

N = 1
observations = []
def solve(x, y=None):
    listeners={}; out=[]
    for event in x:
        op=event[0]
        if op=='on':
            _,k,name,once,action=event
            if True: listeners[k]=[name,once,action]
        elif op=='off':
            listeners.pop(event[1],None)
        elif op=='emit':
            name=event[1]
            batch=list(listeners.items())
            for k,entry in batch:
                if True:
                    if entry[1]:
                        listeners.pop(k,None)
                    out.append(k)
                    action=entry[2]
                    if action and action[0]=='off':
                        listeners.pop(action[1],None)
                    elif action and action[0]=='on':
                        listeners[action[1]]=[action[2],False,None]
        elif op=='names': out.append(list(listeners))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('replacement changes event but preserves order', solve([['on', 'a', 'old', False, None], ['on', 'b', 'new', False, None], ['on', 'a', 'new', False, None], ['emit', 'new'], ['names']]), ['a', 'b', ['a', 'b']])
check('snapshot removal and once lifetime', solve([['on', 'a', 'e', True, ['off', 'b']], ['on', 'b', 'e', False, None], ['on', 'c', 'e', False, None], ['emit', 'e'], ['emit', 'e'], ['names']]), ['a', 'b', 'c', 'c', ['c']])
check('explicit identity removal and event filtering', solve([['on', 'a', 'e', False, None], ['on', 'b', '*', False, None], ['on', 'c', 'e', False, None], ['off', 'a'], ['emit', 'e'], ['names']]), ['c', ['b', 'c']])
check('callback replaces existing target event', solve([['on', 'a', 'e', True, ['on', 'b', 'later']], ['on', 'b', 'old', False, None], ['emit', 'e'], ['emit', 'later'], ['emit', 'old'], ['names']]), ['a', 'b', ['b']])
check('callback replaces metadata rather than setdefault', solve([['on','a','e',True,['on','b','later']],['on','b','old',False,None],['emit','e'],['emit','later'],['emit','later'],['emit','old']]), ['a','b','b'])
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, y=None):
    listeners={}; out=[]
    for event in x:
        op=event[0]
        if op=='on':
            _,k,name,once,action=event
            if True: listeners[k]=[name,once,action]
        elif op=='off':
            listeners.pop(event[1],None)
        elif op=='emit':
            name=event[1]
            batch=list(listeners.items())
            for k,entry in batch:
                if entry[0]==name or entry[0]=="*":
                    if entry[1]:
                        listeners.pop(k,None)
                    out.append(k)
                    action=entry[2]
                    if action and action[0]=='off':
                        listeners.pop(action[1],None)
                    elif action and action[0]=='on':
                        listeners[action[1]]=[action[2],False,None]
        elif op=='names': out.append(list(listeners))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('replacement changes event but preserves order', solve([['on', 'a', 'old', False, None], ['on', 'b', 'new', False, None], ['on', 'a', 'new', False, None], ['emit', 'new'], ['names']]), ['a', 'b', ['a', 'b']])
check('snapshot removal and once lifetime', solve([['on', 'a', 'e', True, ['off', 'b']], ['on', 'b', 'e', False, None], ['on', 'c', 'e', False, None], ['emit', 'e'], ['emit', 'e'], ['names']]), ['a', 'b', 'c', 'c', ['c']])
check('explicit identity removal and event filtering', solve([['on', 'a', 'e', False, None], ['on', 'b', '*', False, None], ['on', 'c', 'e', False, None], ['off', 'a'], ['emit', 'e'], ['names']]), ['c', ['b', 'c']])
check('callback replaces existing target event', solve([['on', 'a', 'e', True, ['on', 'b', 'later']], ['on', 'b', 'old', False, None], ['emit', 'e'], ['emit', 'later'], ['emit', 'old'], ['names']]), ['a', 'b', ['b']])
check('callback replaces metadata rather than setdefault', solve([['on','a','e',True,['on','b','later']],['on','b','old',False,None],['emit','e'],['emit','later'],['emit','later'],['emit','old']]), ['a','b','b'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Listeners have identity, event name, once flag, and registration order. Dispatch uses a snapshot; listener actions remove another listener or add a new one. Return callback identities in invocation order. Only listeners registered for the emitted event run.

Listeners have identity, event name, once flag, and registration order. Dispatch uses a snapshot; listener actions remove another listener or add a new one. Return callback identities in invocation order. Only listeners registered for the emitted event run. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


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

N = 1
observations = []
def solve(x, y=None):
    listeners={}; out=[]
    for event in x:
        op=event[0]
        if op=='on':
            _,k,name,once,action=event
            if True: listeners[k]=[name,once,action]
        elif op=='off':
            listeners.pop(event[1],None)
        elif op=='emit':
            name=event[1]
            batch=list(listeners.items())
            for k,entry in batch:
                if entry[0]==name:
                    if entry[1]:
                        pass
                    out.append(k)
                    action=entry[2]
                    if action and action[0]=='off':
                        listeners.pop(action[1],None)
                    elif action and action[0]=='on':
                        listeners[action[1]]=[action[2],False,None]
        elif op=='names': out.append(list(listeners))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('replacement changes event but preserves order', solve([['on', 'a', 'old', False, None], ['on', 'b', 'new', False, None], ['on', 'a', 'new', False, None], ['emit', 'new'], ['names']]), ['a', 'b', ['a', 'b']])
check('snapshot removal and once lifetime', solve([['on', 'a', 'e', True, ['off', 'b']], ['on', 'b', 'e', False, None], ['on', 'c', 'e', False, None], ['emit', 'e'], ['emit', 'e'], ['names']]), ['a', 'b', 'c', 'c', ['c']])
check('explicit identity removal and event filtering', solve([['on', 'a', 'e', False, None], ['on', 'b', '*', False, None], ['on', 'c', 'e', False, None], ['off', 'a'], ['emit', 'e'], ['names']]), ['c', ['b', 'c']])
check('callback replaces existing target event', solve([['on', 'a', 'e', True, ['on', 'b', 'later']], ['on', 'b', 'old', False, None], ['emit', 'e'], ['emit', 'later'], ['emit', 'old'], ['names']]), ['a', 'b', ['b']])
check('callback replaces metadata rather than setdefault', solve([['on','a','e',True,['on','b','later']],['on','b','old',False,None],['emit','e'],['emit','later'],['emit','later'],['emit','old']]), ['a','b','b'])
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, y=None):
    listeners={}; out=[]
    for event in x:
        op=event[0]
        if op=='on':
            _,k,name,once,action=event
            if True: listeners[k]=[name,once,action]
        elif op=='off':
            listeners.pop(event[1],None)
        elif op=='emit':
            name=event[1]
            batch=list(listeners.items())
            for k,entry in batch:
                if entry[0]==name:
                    if entry[1]:
                        listeners={i:e for i,e in listeners.items() if e[0]!=entry[0]}
                    out.append(k)
                    action=entry[2]
                    if action and action[0]=='off':
                        listeners.pop(action[1],None)
                    elif action and action[0]=='on':
                        listeners[action[1]]=[action[2],False,None]
        elif op=='names': out.append(list(listeners))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('replacement changes event but preserves order', solve([['on', 'a', 'old', False, None], ['on', 'b', 'new', False, None], ['on', 'a', 'new', False, None], ['emit', 'new'], ['names']]), ['a', 'b', ['a', 'b']])
check('snapshot removal and once lifetime', solve([['on', 'a', 'e', True, ['off', 'b']], ['on', 'b', 'e', False, None], ['on', 'c', 'e', False, None], ['emit', 'e'], ['emit', 'e'], ['names']]), ['a', 'b', 'c', 'c', ['c']])
check('explicit identity removal and event filtering', solve([['on', 'a', 'e', False, None], ['on', 'b', '*', False, None], ['on', 'c', 'e', False, None], ['off', 'a'], ['emit', 'e'], ['names']]), ['c', ['b', 'c']])
check('callback replaces existing target event', solve([['on', 'a', 'e', True, ['on', 'b', 'later']], ['on', 'b', 'old', False, None], ['emit', 'e'], ['emit', 'later'], ['emit', 'old'], ['names']]), ['a', 'b', ['b']])
check('callback replaces metadata rather than setdefault', solve([['on','a','e',True,['on','b','later']],['on','b','old',False,None],['emit','e'],['emit','later'],['emit','later'],['emit','old']]), ['a','b','b'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Listeners have identity, event name, once flag, and registration order. Dispatch uses a snapshot; listener actions remove another listener or add a new one. Return callback identities in invocation order. A once listener is removed before callback actions; a callback may explicitly re-register that identity.

Listeners have identity, event name, once flag, and registration order. Dispatch uses a snapshot; listener actions remove another listener or add a new one. Return callback identities in invocation order. A once listener is removed before callback actions; a callback may explicitly re-register that identity. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


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

N = 1
observations = []
def solve(x, y=None):
    listeners={}; out=[]
    for event in x:
        op=event[0]
        if op=='on':
            _,k,name,once,action=event
            if True: listeners[k]=[name,once,action]
        elif op=='off':
            listeners.pop(event[1],None)
        elif op=='emit':
            name=event[1]
            batch=list(listeners.items())
            for k,entry in batch:
                if entry[0]==name:
                    if entry[1]:
                        listeners.pop(k,None)
                    out.append(k)
                    action=entry[2]
                    if action and action[0]=='off':
                        listeners.pop(action[1],None)
                    elif action and action[0]=='on':
                        listeners[action[1]]=[name,False,None]
        elif op=='names': out.append(list(listeners))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('replacement changes event but preserves order', solve([['on', 'a', 'old', False, None], ['on', 'b', 'new', False, None], ['on', 'a', 'new', False, None], ['emit', 'new'], ['names']]), ['a', 'b', ['a', 'b']])
check('snapshot removal and once lifetime', solve([['on', 'a', 'e', True, ['off', 'b']], ['on', 'b', 'e', False, None], ['on', 'c', 'e', False, None], ['emit', 'e'], ['emit', 'e'], ['names']]), ['a', 'b', 'c', 'c', ['c']])
check('explicit identity removal and event filtering', solve([['on', 'a', 'e', False, None], ['on', 'b', '*', False, None], ['on', 'c', 'e', False, None], ['off', 'a'], ['emit', 'e'], ['names']]), ['c', ['b', 'c']])
check('callback replaces existing target event', solve([['on', 'a', 'e', True, ['on', 'b', 'later']], ['on', 'b', 'old', False, None], ['emit', 'e'], ['emit', 'later'], ['emit', 'old'], ['names']]), ['a', 'b', ['b']])
check('callback replaces metadata rather than setdefault', solve([['on','a','e',True,['on','b','later']],['on','b','old',False,None],['emit','e'],['emit','later'],['emit','later'],['emit','old']]), ['a','b','b'])
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, y=None):
    listeners={}; out=[]
    for event in x:
        op=event[0]
        if op=='on':
            _,k,name,once,action=event
            if True: listeners[k]=[name,once,action]
        elif op=='off':
            listeners.pop(event[1],None)
        elif op=='emit':
            name=event[1]
            batch=list(listeners.items())
            for k,entry in batch:
                if entry[0]==name:
                    if entry[1]:
                        listeners.pop(k,None)
                    out.append(k)
                    action=entry[2]
                    if action and action[0]=='off':
                        listeners.pop(action[1],None)
                    elif action and action[0]=='on':
                        listeners.setdefault(action[1],[action[2],False,None])
        elif op=='names': out.append(list(listeners))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('replacement changes event but preserves order', solve([['on', 'a', 'old', False, None], ['on', 'b', 'new', False, None], ['on', 'a', 'new', False, None], ['emit', 'new'], ['names']]), ['a', 'b', ['a', 'b']])
check('snapshot removal and once lifetime', solve([['on', 'a', 'e', True, ['off', 'b']], ['on', 'b', 'e', False, None], ['on', 'c', 'e', False, None], ['emit', 'e'], ['emit', 'e'], ['names']]), ['a', 'b', 'c', 'c', ['c']])
check('explicit identity removal and event filtering', solve([['on', 'a', 'e', False, None], ['on', 'b', '*', False, None], ['on', 'c', 'e', False, None], ['off', 'a'], ['emit', 'e'], ['names']]), ['c', ['b', 'c']])
check('callback replaces existing target event', solve([['on', 'a', 'e', True, ['on', 'b', 'later']], ['on', 'b', 'old', False, None], ['emit', 'e'], ['emit', 'later'], ['emit', 'old'], ['names']]), ['a', 'b', ['b']])
check('callback replaces metadata rather than setdefault', solve([['on','a','e',True,['on','b','later']],['on','b','old',False,None],['emit','e'],['emit','later'],['emit','later'],['emit','old']]), ['a','b','b'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Listeners have identity, event name, once flag, and registration order. Dispatch uses a snapshot; listener actions remove another listener or add a new one. Return callback identities in invocation order. A listener installed by a callback starts participating on the next dispatch and uses the action-specified event name.

Listeners have identity, event name, once flag, and registration order. Dispatch uses a snapshot; listener actions remove another listener or add a new one. Return callback identities in invocation order. A listener installed by a callback starts participating on the next dispatch and uses the action-specified event name. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    g=iter(x); a=list(g)[:y]; return [a,list(g)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('bounded prefix', solve(['a', 'b', 'c'], 1), [['a'], ['b', 'c']])
check('zero consumes none', solve(['a'], 0), [[], ['a']])
check('exhaustion', solve(['a'], 3), [['a'], []])
check('empty', solve([], 1), [[], []])
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
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    g=iter(x); a=list(it.islice(g,y+1))[:y]; return [a,list(g)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('bounded prefix', solve(['a', 'b', 'c'], 1), [['a'], ['b', 'c']])
check('zero consumes none', solve(['a'], 0), [[], ['a']])
check('exhaustion', solve(['a'], 3), [['a'], []])
check('empty', solve([], 1), [[], []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Take at most n values from a one-pass iterator and return [taken,unconsumed tail]; taking zero consumes nothing.

Take at most n values from a one-pass iterator and return [taken,unconsumed tail]; taking zero consumes nothing. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    g=iter(x); a=[v for v in g if v!=y]; return [a,list(g)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('middle stop', solve(['a', 'stop', 'b'], 'stop'), [['a'], ['b']])
check('stop first', solve(['stop', 'a'], 'stop'), [[], ['a']])
check('no stop', solve(['a'], 'stop'), [['a'], []])
check('empty', solve([], 'stop'), [[], []])
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
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    i=x.index(y) if y in x else len(x); return [x[:i],x[i:]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('middle stop', solve(['a', 'stop', 'b'], 'stop'), [['a'], ['b']])
check('stop first', solve(['stop', 'a'], 'stop'), [[], ['a']])
check('no stop', solve(['a'], 'stop'), [['a'], []])
check('empty', solve([], 'stop'), [[], []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Consume the prefix before sentinel, consuming but excluding the first sentinel; return [prefix,remainder].

Consume the prefix before sentinel, consuming but excluding the first sentinel; return [prefix,remainder]. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [v for v in x if v!=y]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('later sentinel retained', solve(['s', 'a', 's', 'b'], 's'), ['a', 's', 'b'])
check('all dropped', solve(['s', 's'], 's'), [])
check('no initial sentinel', solve(['a', 's'], 's'), ['a', 's'])
check('empty', solve([], 's'), [])
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
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return list(it.takewhile(lambda v:v!=y,iter(x)))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('later sentinel retained', solve(['s', 'a', 's', 'b'], 's'), ['a', 's', 'b'])
check('all dropped', solve(['s', 's'], 's'), [])
check('no initial sentinel', solve(['a', 's'], 's'), ['a', 's'])
check('empty', solve([], 's'), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Drop an initial run of sentinel values; once a non-sentinel appears, retain the entire suffix including later sentinels.

Drop an initial run of sentinel values; once a non-sentinel appears, retain the entire suffix including later sentinels. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    g=iter(x); a=[next(g) for flag in y if flag]; return [a,list(g)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('short selectors consume next data', solve(['a', 'b', 'c'], [True]), [['a'], ['c']])
check('false selector still advances', solve(['a', 'b', 'c'], [False, True]), [['b'], []])
check('empty selectors consume first', solve(['a', 'b'], []), [[], ['b']])
check('empty data', solve([], [False]), [[], []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    n=min(len(x),len(y)); return [[x[i] for i in range(n) if y[i]],x[n:]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('short selectors consume next data', solve(['a', 'b', 'c'], [True]), [['a'], ['c']])
check('false selector still advances', solve(['a', 'b', 'c'], [False, True]), [['b'], []])
check('empty selectors consume first', solve(['a', 'b'], []), [[], ['b']])
check('empty data', solve([], [False]), [[], []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Use itertools compress semantics: consume one data item before discovering selectors are exhausted; return [selected,data remainder].

Use itertools compress semantics: consume one data item before discovering selectors are exhausted; return [selected,data remainder]. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return list(filter(lambda v:v==y,x))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sentinel removed', solve(['a', 's', 'b'], 's'), ['a', 'b'])
check('falsy retained', solve([None, 's', ''], 's'), [None, ''])
check('all removed', solve(['s', 's'], 's'), [])
check('empty', solve([], 's'), [])
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
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [v for v in x if v and v!=y]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('sentinel removed', solve(['a', 's', 'b'], 's'), ['a', 'b'])
check('falsy retained', solve([None, 's', ''], 's'), [None, ''])
check('all removed', solve(['s', 's'], 's'), [])
check('empty', solve([], 's'), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Retain values unequal to the sentinel, including other falsy values.

Retain values unequal to the sentinel, including other falsy values. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [v for group in reversed(x) for v in group]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered groups', solve([['a', 'b'], ['c']]), ['a', 'b', 'c'])
check('nested remains nested', solve([[['a'], 'b'], ['c']]), [['a'], 'b', 'c'])
check('empty groups', solve([[], ['a'], []]), ['a'])
check('empty outer', solve([]), [])
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
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [z for group in x for v in group for z in (v if isinstance(v,list) else [v])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered groups', solve([['a', 'b'], ['c']]), ['a', 'b', 'c'])
check('nested remains nested', solve([[['a'], 'b'], ['c']]), [['a'], 'b', 'c'])
check('empty groups', solve([[], ['a'], []]), ['a'])
check('empty outer', solve([]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Flatten exactly one iterable level in outer order, retaining empty and nested values at deeper levels.

Flatten exactly one iterable level in outer order, retaining empty and nested values at deeper levels. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [[k,[v for v in x if v==k]] for k in dict.fromkeys(x)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('separate equal runs', solve(['a', 'b', 'a']), [['a', ['a']], ['b', ['b']], ['a', ['a']]])
check('same run', solve(['a', 'a']), [['a', ['a', 'a']]])
check('empty', solve([]), [])
check('nonlexical runs', solve(['b', 'b', 'a']), [['b', ['b', 'b']], ['a', ['a']]])
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
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [[k,list(g)] for k,g in it.groupby(sorted(x))]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('separate equal runs', solve(['a', 'b', 'a']), [['a', ['a']], ['b', ['b']], ['a', ['a']]])
check('same run', solve(['a', 'a']), [['a', ['a', 'a']]])
check('empty', solve([]), [])
check('nonlexical runs', solve(['b', 'b', 'a']), [['b', ['b', 'b']], ['a', ['a']]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Group consecutive equal values into [key,group] pairs; separated equal runs remain separate.

Group consecutive equal values into [key,group] pairs; separated equal runs remain separate. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    groups=list(it.groupby(x)); return [[k,list(g)] for k,g in groups]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('two groups', solve(['a', 'a', 'b']), [['a', ['a', 'a']], ['b', ['b']]])
check('one group', solve(['a', 'a']), [['a', ['a', 'a']]])
check('empty', solve([]), [])
check('three runs', solve(['b', 'a', 'b']), [['b', ['b']], ['a', ['a']], ['b', ['b']]])
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
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    groups=list(it.groupby(x)); return [[k,[]] for k,g in groups]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('two groups', solve(['a', 'a', 'b']), [['a', ['a', 'a']], ['b', ['b']]])
check('one group', solve(['a', 'a']), [['a', ['a', 'a']]])
check('empty', solve([]), [])
check('three runs', solve(['b', 'a', 'b']), [['b', ['b']], ['a', ['a']], ['b', ['b']]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Materialize each group before advancing the outer group iterator, since group iterators share their source.

Materialize each group before advancing the outer group iterator, since group iterators share their source. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    a=b=iter(x); p=list(it.islice(a,y)); return [p,list(b),list(a)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('branch lag', solve(['a', 'b', 'c'], 1), [['a'], ['a', 'b', 'c'], ['b', 'c']])
check('zero prefix', solve(['a'], 0), [[], ['a'], ['a']])
check('first exhausts', solve(['a'], 5), [['a'], ['a'], []])
check('empty', solve([], 2), [[], [], []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    a,b=it.tee(iter(x)); p=list(it.islice(a,y)); return [p,list(it.islice(b,y,None)),list(a)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('branch lag', solve(['a', 'b', 'c'], 1), [['a'], ['a', 'b', 'c'], ['b', 'c']])
check('zero prefix', solve(['a'], 0), [[], ['a'], ['a']])
check('first exhausts', solve(['a'], 5), [['a'], ['a'], []])
check('empty', solve([], 2), [[], [], []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Advance the first tee branch n positions; the second still yields the entire original stream.

Advance the first tee branch n positions; the second still yields the entire original stream. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return (x*y)[:len(x)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cycles order', solve(['a', 'b'], 5), ['a', 'b', 'a', 'b', 'a'])
check('partial cycle', solve(['a', 'b', 'c'], 2), ['a', 'b'])
check('empty input', solve([], 3), [])
check('zero requested', solve(['a'], 0), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return (x[:1]*y)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cycles order', solve(['a', 'b'], 5), ['a', 'b', 'a', 'b', 'a'])
check('partial cycle', solve(['a', 'b', 'c'], 2), ['a', 'b'])
check('empty input', solve([], 3), [])
check('zero requested', solve(['a'], 0), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Emit n cyclic values from a finite input, or no values for empty input.

Emit n cyclic values from a finite input, or no values for empty input. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    r=[list(x) for _ in range(y)]
    if r: r[0].append("new")
    return r
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeated alias', solve(['a'], 2), [['a', 'new'], ['a', 'new']])
check('single alias', solve([], 1), [['new']])
check('zero repeats', solve(['a'], 0), [])
check('three aliases', solve([], 3), [['new'], ['new'], ['new']])
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
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    r=[list(x) for _ in range(y)]
    return r
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeated alias', solve(['a'], 2), [['a', 'new'], ['a', 'new']])
check('single alias', solve([], 1), [['new']])
check('zero repeats', solve(['a'], 0), [])
check('three aliases', solve([], 3), [['new'], ['new'], ['new']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Repeat one mutable list n times, mutate its first repeated reference, and report all repetitions; they alias the same object.

Repeat one mutable list n times, mutate its first repeated reference, and report all repetitions; they alias the same object. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [list(v) for v in it.product(*x)] if x else []
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero pools identity', solve([]), [[]])
check('empty pool annihilates', solve([['a'], []]), [])
check('two pools all pairs', solve([['a', 'b'], ['c']]), [['a', 'c'], ['b', 'c']])
check('one pool', solve([['a', 'b']]), [['a'], ['b']])
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
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [list(v) for v in zip(*x)] if x else [[]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero pools identity', solve([]), [[]])
check('empty pool annihilates', solve([['a'], []]), [])
check('two pools all pairs', solve([['a', 'b'], ['c']]), [['a', 'c'], ['b', 'c']])
check('one pool', solve([['a', 'b']]), [['a'], ['b']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Compute the Cartesian product of the supplied pools, yielding one empty tuple for zero pools.

Compute the Cartesian product of the supplied pools, yielding one empty tuple for zero pools. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [list(v) for v in it.permutations(dict.fromkeys(x),y)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('duplicate positions', solve(['a', 'a'], 2), [['a', 'a'], ['a', 'a']])
check('orderings', solve(['a', 'b'], 2), [['a', 'b'], ['b', 'a']])
check('zero length', solve(['a'], 0), [[]])
check('insufficient positions', solve(['a'], 2), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [list(v) for v in it.combinations(x,y)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('duplicate positions', solve(['a', 'a'], 2), [['a', 'a'], ['a', 'a']])
check('orderings', solve(['a', 'b'], 2), [['a', 'b'], ['b', 'a']])
check('zero length', solve(['a'], 0), [[]])
check('insufficient positions', solve(['a'], 2), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Return ordered length-r permutations of distinct input positions; equal values may produce equal output tuples.

Return ordered length-r permutations of distinct input positions; equal values may produce equal output tuples. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [list(v) for v in it.permutations(x,y)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('position duplicates', solve(['a', 'a', 'b'], 2), [['a', 'a'], ['a', 'b'], ['a', 'b']])
check('input order', solve(['b', 'a'], 2), [['b', 'a']])
check('zero choice', solve([], 0), [[]])
check('too many', solve(['a'], 2), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [list(v) for v in it.combinations(dict.fromkeys(x),y)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('position duplicates', solve(['a', 'a', 'b'], 2), [['a', 'a'], ['a', 'b'], ['a', 'b']])
check('input order', solve(['b', 'a'], 2), [['b', 'a']])
check('zero choice', solve([], 0), [[]])
check('too many', solve(['a'], 2), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Return length-r combinations of input positions, preserving input order within tuples and retaining duplicate-valued tuples.

Return length-r combinations of input positions, preserving input order within tuples and retaining duplicate-valued tuples. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [list(v) for v in it.combinations(x,y)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeat position', solve(['a', 'b'], 2), [['a', 'a'], ['a', 'b'], ['b', 'b']])
check('one position reused', solve(['a'], 3), [['a', 'a', 'a']])
check('zero choice', solve([], 0), [[]])
check('empty positive choice', solve([], 2), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [list(v) for v in it.product(x,repeat=y)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeat position', solve(['a', 'b'], 2), [['a', 'a'], ['a', 'b'], ['b', 'b']])
check('one position reused', solve(['a'], 3), [['a', 'a', 'a']])
check('zero choice', solve([], 0), [[]])
check('empty positive choice', solve([], 2), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Return length-r combinations with replacement, allowing the same input position repeatedly.

Return length-r combinations with replacement, allowing the same input position repeatedly. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [list(v) for v in zip(x,y)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('present None retained', solve([None], ['a', 'b']), [[None, 'a'], ['missing', 'b']])
check('empty left', solve([], ['a']), [['missing', 'a']])
check('empty both', solve([], []), [])
check('empty right', solve(['a'], []), [['a', 'missing']])
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
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [["missing" if v is None else v for v in row] for row in it.zip_longest(x,y)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('present None retained', solve([None], ['a', 'b']), [[None, 'a'], ['missing', 'b']])
check('empty left', solve([], ['a']), [['missing', 'a']])
check('empty both', solve([], []), [])
check('empty right', solve(['a'], []), [['a', 'missing']])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Zip to exhaustion of both inputs and fill missing positions with a distinct string marker; present None is retained.

Zip to exhaustion of both inputs and fill missing positions with a distinct string marker; present None is retained. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    calls=[]
    def f(v): calls.append(v); return [v]
    g=iter([f(v) for v in x]); before=list(calls); a=list(it.islice(g,y)); return [before,calls,a]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('partial consumption', solve(['a', 'b'], 1), [[], ['a'], [['a']]])
check('zero consumption', solve(['a'], 0), [[], [], []])
check('full consumption', solve(['a'], 3), [[], ['a'], [['a']]])
check('empty', solve([], 1), [[], [], []])
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
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    calls=[]
    def f(v): calls.append(v); return [v]
    g=map(f,x); before=list(calls); a=list(g)[:y]; return [before,calls,a]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('partial consumption', solve(['a', 'b'], 1), [[], ['a'], [['a']]])
check('zero consumption', solve(['a'], 0), [[], [], []])
check('full consumption', solve(['a'], 3), [[], ['a'], [['a']]])
check('empty', solve([], 1), [[], [], []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Constructing map must not invoke callbacks; taking n results invokes only those callbacks. Return [calls before,calls after,results].

Constructing map must not invoke callbacks; taking n results invokes only those callbacks. Return [calls before,calls after,results]. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    g=iter(x); a=list(filter(lambda v:v==y,g)); return [a[0] if a else "missing",list(g)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('scan through match', solve(['a', 's', 'b'], 's'), ['s', ['b']])
check('first matches', solve(['s', 'a'], 's'), ['s', ['a']])
check('no match exhausts', solve(['a', 'b'], 's'), ['missing', []])
check('empty', solve([], 's'), ['missing', []])
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
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    g=iter(x); a=next(g,"missing"); return [a if a==y else "missing",list(g)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('scan through match', solve(['a', 's', 'b'], 's'), ['s', ['b']])
check('first matches', solve(['s', 'a'], 's'), ['s', ['a']])
check('no match exhausts', solve(['a', 'b'], 's'), ['missing', []])
check('empty', solve([], 's'), ['missing', []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Take the first value equal to sentinel from a filtered iterator; return [match or missing,unconsumed source].

Take the first value equal to sentinel from a filtered iterator; return [match or missing,unconsumed source]. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    g=iter(x); a=any(list(g)); return [a,list(g)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('first true stops', solve([False, True, False]), [True, [False]])
check('initial true', solve([True, False]), [True, [False]])
check('all false', solve([False, False]), [False, []])
check('empty', solve([]), [False, []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    g=iter(x); a=bool(next(g,False)); return [a,list(g)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('first true stops', solve([False, True, False]), [True, [False]])
check('initial true', solve([True, False]), [True, [False]])
check('all false', solve([False, False]), [False, []])
check('empty', solve([]), [False, []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Apply any to a one-pass stream and return [truth result,unconsumed suffix].

Apply any to a one-pass stream and return [truth result,unconsumed suffix]. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    g=iter(x); a=all(list(g)); return [a,list(g)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('first false stops', solve([True, False, True]), [False, [True]])
check('initial false', solve([False, True]), [False, [True]])
check('all true', solve([True, True]), [True, []])
check('empty', solve([]), [True, []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    g=iter(x); a=bool(next(g,False)); return [a,list(g)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('first false stops', solve([True, False, True]), [False, [True]])
check('initial false', solve([False, True]), [False, [True]])
check('all true', solve([True, True]), [True, []])
check('empty', solve([]), [True, []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Apply all to a one-pass stream and return [truth result,unconsumed suffix]; the empty result is true.

Apply all to a one-pass stream and return [truth result,unconsumed suffix]; the empty result is true. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [[i,v] for i,v in enumerate(x[y:],y)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive start', solve(['a', 'b'], 3), [[3, 'a'], [4, 'b']])
check('negative start', solve(['a', 'b'], -2), [[-2, 'a'], [-1, 'b']])
check('zero start', solve(['a'], 0), [[0, 'a']])
check('empty', solve([], 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
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [[i,v] for i,v in enumerate(x)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('positive start', solve(['a', 'b'], 3), [[3, 'a'], [4, 'b']])
check('negative start', solve(['a', 'b'], -2), [[-2, 'a'], [-1, 'b']])
check('zero start', solve(['a'], 0), [[0, 'a']])
check('empty', solve([], 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:
The operation returns a result or retained state that violates this contract: Enumerate the entire stream starting at the supplied counter value; offset does not skip source values.

Enumerate the entire stream starting at the supplied counter value; offset does not skip source values. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    g=iter(x); a=[]
    while True:
        v=next(g,y)
        if v is y: break
        a.append(v)
    return [a,list(g)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('equal separately allocated lists stop', solve([[1],[2],[3]], [2]), [[[1]],[[3]]])
check('valid empty list remains', solve([[],[2],[3]], [2]), [[[]],[[3]]])
check('sentinel first', solve([[2],[3]], [2]), [[],[[3]]])
check('empty input', solve([], [2]), [[],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    g=iter(x); a=list(it.takewhile(bool,g)); return [a,list(g)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('equal separately allocated lists stop', solve([[1],[2],[3]], [2]), [[[1]],[[3]]])
check('valid empty list remains', solve([[],[2],[3]], [2]), [[[]],[[3]]])
check('sentinel first', solve([[2],[3]], [2]), [[],[[3]]])
check('empty input', solve([], [2]), [[],[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
An equal sentinel stored in another object fails to stop iteration.

Consume callable results until one compares equal to the sentinel. Equal but separately allocated lists terminate iteration; the sentinel is consumed, excluded from output, and later values remain unconsumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [y in x,list(x)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('middle match', solve(['a', 'b', 'c'], 'b'), [True, ['c']])
check('first match', solve(['a', 'b'], 'a'), [True, ['b']])
check('missing exhausts', solve(['a'], 'z'), [False, []])
check('empty', solve([], 'z'), [False, []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    g=iter(x); a=y in list(g); return [a,list(g)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('middle match', solve(['a', 'b', 'c'], 'b'), [True, ['c']])
check('first match', solve(['a', 'b'], 'a'), [True, ['b']])
check('missing exhausts', solve(['a'], 'z'), [False, []])
check('empty', solve([], 'z'), [False, []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Membership testing on a one-pass iterator consumes through the matched item and leaves only later items.

Membership testing on a one-pass iterator consumes through the matched item and leaves only later items. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [list(x),list(x)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('two values', solve(['a', 'b']), [['a', 'b'], []])
check('singleton', solve(['a']), [['a'], []])
check('empty', solve([]), [[], []])
check('duplicates', solve(['a', 'a']), [['a', 'a'], []])
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
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    g=iter(x); a=list(g); return [a,a]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('two values', solve(['a', 'b']), [['a', 'b'], []])
check('singleton', solve(['a']), [['a'], []])
check('empty', solve([]), [[], []])
check('duplicates', solve(['a', 'a']), [['a', 'a'], []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Materializing a one-pass iterator exhausts it; a second materialization is empty.

Materializing a one-pass iterator exhausts it; a second materialization is empty. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [x[y[0]:y[1]:y[2]],x[(y[0]+((max(0,y[1]-y[0])-1)//y[2])*y[2]+1) if y[1]>y[0] else y[0]:]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('stop beyond last yield', solve(['a', 'b', 'c', 'd', 'e'], [0, 4, 3]), [['a', 'd'], ['e']])
check('skipped final position consumed', solve(['a', 'b', 'c', 'd', 'e'], [0, 4, 2]), [['a', 'c'], ['e']])
check('empty slice consumes start', solve(['a', 'b', 'c'], [2, 2, 1]), [[], ['c']])
check('empty input', solve([], [0, 3, 2]), [[], []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools as it
from collections import deque
N = 1
observations = []
def solve(x, y=None):
    return [x[y[0]:y[1]:y[2]],x[y[0]:]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('stop beyond last yield', solve(['a', 'b', 'c', 'd', 'e'], [0, 4, 3]), [['a', 'd'], ['e']])
check('skipped final position consumed', solve(['a', 'b', 'c', 'd', 'e'], [0, 4, 2]), [['a', 'c'], ['e']])
check('empty slice consumes start', solve(['a', 'b', 'c'], [2, 2, 1]), [[], ['c']])
check('empty input', solve([], [0, 3, 2]), [[], []])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Exhausting islice(start,stop,step) consumes through stop regardless of the last yielded position; return [yielded,remaining].

Exhausting islice(start,stop,step) consumes through stop regardless of the last yielded position; return [yielded,remaining]. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    return list(map(list,(Counter(x)-Counter(y)).items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero and negative retained', solve({'a': 2, 'b': 1}, {'a': 2, 'b': 3, 'c': 1}), [['a', 0], ['b', -2], ['c', -1]])
check('empty left', solve({}, {'a': 1}), [['a', -1]])
check('empty right', solve({'a': 0}, {}), [['a', 0]])
check('both empty', solve({}, {}), [])
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
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    a=Counter(x); a.subtract(y); return [[k,v] for k,v in a.items() if v!=0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero and negative retained', solve({'a': 2, 'b': 1}, {'a': 2, 'b': 3, 'c': 1}), [['a', 0], ['b', -2], ['c', -1]])
check('empty left', solve({}, {'a': 1}), [['a', -1]])
check('empty right', solve({'a': 0}, {}), [['a', 0]])
check('both empty', solve({}, {}), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Subtract right counts from left counts and retain zero and negative entries in insertion order.

Subtract right counts from left counts and retain zero and negative entries in insertion order. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    a=Counter(x); a.update(y); return dict(a)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero removed', solve({'a': 1, 'b': 2}, {'a': -1, 'b': -4}), {})
check('positive retained', solve({'a': 2}, {'a': 1, 'b': 1}), {'a': 3, 'b': 1})
check('empty', solve({}, {}), {})
check('negative left removed', solve({'a': -1}, {'b': 2}), {'b': 2})
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    a=Counter(x); a.update(y); return {k:v for k,v in a.items() if v>=0}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero removed', solve({'a': 1, 'b': 2}, {'a': -1, 'b': -4}), {})
check('positive retained', solve({'a': 2}, {'a': 1, 'b': 1}), {'a': 3, 'b': 1})
check('empty', solve({}, {}), {})
check('negative left removed', solve({'a': -1}, {'b': 2}), {'b': 2})
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Add two counters and retain only strictly positive resulting counts.

Add two counters and retain only strictly positive resulting counts. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    a=Counter(x); a=dict(a); a.update(y); return a
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('existing count accumulates', solve({'a': 2}, {'a': 3}), {'a': 5})
check('zero retained', solve({'a': 2}, {'a': -2}), {'a': 0})
check('negative retained', solve({}, {'a': -1}), {'a': -1})
check('empty', solve({}, {}), {})
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
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    return dict(Counter(x)+Counter(y))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('existing count accumulates', solve({'a': 2}, {'a': 3}), {'a': 5})
check('zero retained', solve({'a': 2}, {'a': -2}), {'a': 0})
check('negative retained', solve({}, {'a': -1}), {'a': -1})
check('empty', solve({}, {}), {})
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Counter update adds supplied counts to existing counts, retaining zero and negative entries.

Counter update adds supplied counts to existing counts, retaining zero and negative entries. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    return [k for k,v in x.items() for _ in range(abs(v))]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('negative omitted and insertion retained', solve({'b': 2, 'a': 1, 'c': -2, 'd': 0}), ['b', 'b', 'a'])
check('zero only', solve({'a': 0}), [])
check('empty', solve({}), [])
check('positive singleton', solve({'a': 2}), ['a', 'a'])
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
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    return [k for k,v in sorted(x.items()) for _ in range(max(0,v))]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('negative omitted and insertion retained', solve({'b': 2, 'a': 1, 'c': -2, 'd': 0}), ['b', 'b', 'a'])
check('zero only', solve({'a': 0}), [])
check('empty', solve({}), [])
check('positive singleton', solve({'a': 2}), ['a', 'a'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Expand positive integer counts in key insertion order; zero and negative counts produce no elements.

Expand positive integer counts in key insertion order; zero and negative counts produce no elements. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    return [[k,v] for k,v in sorted(x.items(),key=lambda p:(-p[1],p[0]))[:y]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie insertion order', solve({'b': 2, 'a': 2, 'c': 3}, 3), [['c', 3], ['b', 2], ['a', 2]])
check('zero requested', solve({'a': 1}, 0), [])
check('negative count included', solve({'a': -1}, 2), [['a', -1]])
check('empty', solve({}, 2), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    return [[k,v] for k,v in list(x.items())[:y]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tie insertion order', solve({'b': 2, 'a': 2, 'c': 3}, 3), [['c', 3], ['b', 2], ['a', 2]])
check('zero requested', solve({'a': 1}, 0), [])
check('negative count included', solve({'a': -1}, 2), [['a', -1]])
check('empty', solve({}, 2), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Return at most n [key,count] pairs by descending count, breaking ties by first insertion order.

Return at most n [key,count] pairs by descending count, breaking ties by first insertion order. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    return dict(x)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mixed signs', solve({'a': 2, 'b': 0, 'c': -1}), {'a': 2})
check('zero', solve({'a': 0}), {})
check('negative', solve({'a': -2}), {})
check('empty', solve({}), {})
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
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    return {k:v for k,v in x.items() if v>=0}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mixed signs', solve({'a': 2, 'b': 0, 'c': -1}), {'a': 2})
check('zero', solve({'a': 0}), {})
check('negative', solve({'a': -2}), {})
check('empty', solve({}), {})
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The operation returns a result or retained state that violates this contract: Unary counter normalization retains strictly positive counts without changing them.

Unary counter normalization retains strictly positive counts without changing them. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

split: open-access