broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    out=[]
    for line in data:
        cells=line.split(',')
        if cells[0]=='P':
            if len(cells)!=3: return None
            if not cells[2].isascii() or not cells[2].isdecimal() or str(int(cells[2]))!=cells[2]: return None
            out.append({'kind':'person','name':cells[1],'age':int(cells[2])})
        elif cells[0]=='M':
            if len(cells)!=4: return None
            out.append({'kind':'message','from':cells[2],'to':cells[1],'text':cells[3]})
        else: return None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mixed', solve(_vary(['P,@,12', 'M,a,b,hello'])), _vary([{'kind': 'person', 'name': '@', 'age': 12}, {'kind': 'message', 'from': 'a', 'to': 'b', 'text': 'hello'}]))
check('empty text', solve(_vary(['M,a,b,'])), _vary([{'kind': 'message', 'from': 'a', 'to': 'b', 'text': ''}]))
check('zero age', solve(_vary(['P,@,0'])), _vary([{'kind': 'person', 'name': '@', 'age': 0}]))
check('bad tag', solve(_vary(['X,a,b'])), _vary(None))
check('wrong person', solve(_vary(['P,a,12,x'])), _vary(None))
check('wrong message', solve(_vary(['M,a,b'])), _vary(None))
check('leading zero', solve(_vary(['P,@,01'])), _vary(None))
check('empty', solve(_vary([])), _vary([]))
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
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    out=[]
    for line in data:
        cells=line.split(',')
        if cells[0]=='P':
            if len(cells)!=3: return None
            if not cells[2].isascii() or not cells[2].isdecimal() or str(int(cells[2]))!=cells[2]: return None
            out.append({'kind':'person','name':cells[1],'age':int(cells[2])})
        elif cells[0]=='M':
            if len(cells)!=4: return None
            out.append({'kind':'message','from':cells[1],'to':cells[1],'text':cells[3]})
        else: return None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mixed', solve(_vary(['P,@,12', 'M,a,b,hello'])), _vary([{'kind': 'person', 'name': '@', 'age': 12}, {'kind': 'message', 'from': 'a', 'to': 'b', 'text': 'hello'}]))
check('empty text', solve(_vary(['M,a,b,'])), _vary([{'kind': 'message', 'from': 'a', 'to': 'b', 'text': ''}]))
check('zero age', solve(_vary(['P,@,0'])), _vary([{'kind': 'person', 'name': '@', 'age': 0}]))
check('bad tag', solve(_vary(['X,a,b'])), _vary(None))
check('wrong person', solve(_vary(['P,a,12,x'])), _vary(None))
check('wrong message', solve(_vary(['M,a,b'])), _vary(None))
check('leading zero', solve(_vary(['P,@,01'])), _vary(None))
check('empty', solve(_vary([])), _vary([]))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Decode tagged comma rows. P,name,age represents a person with canonical unsigned ASCII integer age; M,from,to,text represents a message with text that may be empty. Unknown tags and wrong arities reject. Return tagged dictionaries in source order.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    out=[]
    for line in data:
        cells=line.split(',')
        if cells[0]=='P':
            if len(cells)!=3: return None
            if not cells[2].isascii() or not cells[2].isdecimal() or str(int(cells[2]))!=cells[2]: return None
            out.append({'kind':'person','name':cells[1],'age':int(cells[2])})
        elif cells[0]=='M':
            if len(cells)!=4: return None
            out.append({'kind':'message','from':cells[1],'to':cells[2],'text':cells[2]})
        else: return None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mixed', solve(_vary(['P,@,12', 'M,a,b,hello'])), _vary([{'kind': 'person', 'name': '@', 'age': 12}, {'kind': 'message', 'from': 'a', 'to': 'b', 'text': 'hello'}]))
check('empty text', solve(_vary(['M,a,b,'])), _vary([{'kind': 'message', 'from': 'a', 'to': 'b', 'text': ''}]))
check('zero age', solve(_vary(['P,@,0'])), _vary([{'kind': 'person', 'name': '@', 'age': 0}]))
check('bad tag', solve(_vary(['X,a,b'])), _vary(None))
check('wrong person', solve(_vary(['P,a,12,x'])), _vary(None))
check('wrong message', solve(_vary(['M,a,b'])), _vary(None))
check('leading zero', solve(_vary(['P,@,01'])), _vary(None))
check('empty', solve(_vary([])), _vary([]))
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
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    out=[]
    for line in data:
        cells=line.split(',')
        if cells[0]=='P':
            if len(cells)!=3: return None
            if not cells[2].isascii() or not cells[2].isdecimal() or str(int(cells[2]))!=cells[2]: return None
            out.append({'kind':'person','name':cells[1],'age':int(cells[2])})
        elif cells[0]=='M':
            if len(cells)!=4: return None
            out.append({'kind':'message','from':cells[1],'to':cells[2],'text':','.join(cells[1:])})
        else: return None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mixed', solve(_vary(['P,@,12', 'M,a,b,hello'])), _vary([{'kind': 'person', 'name': '@', 'age': 12}, {'kind': 'message', 'from': 'a', 'to': 'b', 'text': 'hello'}]))
check('empty text', solve(_vary(['M,a,b,'])), _vary([{'kind': 'message', 'from': 'a', 'to': 'b', 'text': ''}]))
check('zero age', solve(_vary(['P,@,0'])), _vary([{'kind': 'person', 'name': '@', 'age': 0}]))
check('bad tag', solve(_vary(['X,a,b'])), _vary(None))
check('wrong person', solve(_vary(['P,a,12,x'])), _vary(None))
check('wrong message', solve(_vary(['M,a,b'])), _vary(None))
check('leading zero', solve(_vary(['P,@,01'])), _vary(None))
check('empty', solve(_vary([])), _vary([]))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Decode tagged comma rows. P,name,age represents a person with canonical unsigned ASCII integer age; M,from,to,text represents a message with text that may be empty. Unknown tags and wrong arities reject. Return tagged dictionaries in source order.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    out=[]
    for line in data:
        cells=line.split(',')
        if cells[0]=='P':
            if len(cells)!=3: return None
            if not cells[2].isascii() or not cells[2].isdecimal() : return None
            out.append({'kind':'person','name':cells[1],'age':int(cells[2])})
        elif cells[0]=='M':
            if len(cells)!=4: return None
            out.append({'kind':'message','from':cells[1],'to':cells[2],'text':cells[3]})
        else: return None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mixed', solve(_vary(['P,@,12', 'M,a,b,hello'])), _vary([{'kind': 'person', 'name': '@', 'age': 12}, {'kind': 'message', 'from': 'a', 'to': 'b', 'text': 'hello'}]))
check('empty text', solve(_vary(['M,a,b,'])), _vary([{'kind': 'message', 'from': 'a', 'to': 'b', 'text': ''}]))
check('zero age', solve(_vary(['P,@,0'])), _vary([{'kind': 'person', 'name': '@', 'age': 0}]))
check('bad tag', solve(_vary(['X,a,b'])), _vary(None))
check('wrong person', solve(_vary(['P,a,12,x'])), _vary(None))
check('wrong message', solve(_vary(['M,a,b'])), _vary(None))
check('leading zero', solve(_vary(['P,@,01'])), _vary(None))
check('empty', solve(_vary([])), _vary([]))
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
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    out=[]
    for line in data:
        cells=line.split(',')
        if cells[0]=='P':
            if len(cells)!=3: return None
            if not cells[2].isascii() or not cells[2].isdecimal() or (cells[2].startswith('0') and len(cells[2])>2): return None
            out.append({'kind':'person','name':cells[1],'age':int(cells[2])})
        elif cells[0]=='M':
            if len(cells)!=4: return None
            out.append({'kind':'message','from':cells[1],'to':cells[2],'text':cells[3]})
        else: return None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mixed', solve(_vary(['P,@,12', 'M,a,b,hello'])), _vary([{'kind': 'person', 'name': '@', 'age': 12}, {'kind': 'message', 'from': 'a', 'to': 'b', 'text': 'hello'}]))
check('empty text', solve(_vary(['M,a,b,'])), _vary([{'kind': 'message', 'from': 'a', 'to': 'b', 'text': ''}]))
check('zero age', solve(_vary(['P,@,0'])), _vary([{'kind': 'person', 'name': '@', 'age': 0}]))
check('bad tag', solve(_vary(['X,a,b'])), _vary(None))
check('wrong person', solve(_vary(['P,a,12,x'])), _vary(None))
check('wrong message', solve(_vary(['M,a,b'])), _vary(None))
check('leading zero', solve(_vary(['P,@,01'])), _vary(None))
check('empty', solve(_vary([])), _vary([]))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Decode tagged comma rows. P,name,age represents a person with canonical unsigned ASCII integer age; M,from,to,text represents a message with text that may be empty. Unknown tags and wrong arities reject. Return tagged dictionaries in source order.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    out=[]
    for line in data:
        cells=line.split(',')
        if cells[0]=='P':
            if len(cells)!=3: return None
            if not cells[2].isascii() or not cells[2].isdecimal() or str(int(cells[2]))!=cells[2]: return None
            out.append({'name':cells[1],'age':int(cells[2])})
        elif cells[0]=='M':
            if len(cells)!=4: return None
            out.append({'kind':'message','from':cells[1],'to':cells[2],'text':cells[3]})
        else: return None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mixed', solve(_vary(['P,@,12', 'M,a,b,hello'])), _vary([{'kind': 'person', 'name': '@', 'age': 12}, {'kind': 'message', 'from': 'a', 'to': 'b', 'text': 'hello'}]))
check('empty text', solve(_vary(['M,a,b,'])), _vary([{'kind': 'message', 'from': 'a', 'to': 'b', 'text': ''}]))
check('zero age', solve(_vary(['P,@,0'])), _vary([{'kind': 'person', 'name': '@', 'age': 0}]))
check('bad tag', solve(_vary(['X,a,b'])), _vary(None))
check('wrong person', solve(_vary(['P,a,12,x'])), _vary(None))
check('wrong message', solve(_vary(['M,a,b'])), _vary(None))
check('leading zero', solve(_vary(['P,@,01'])), _vary(None))
check('empty', solve(_vary([])), _vary([]))
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
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    out=[]
    for line in data:
        cells=line.split(',')
        if cells[0]=='P':
            if len(cells)!=3: return None
            if not cells[2].isascii() or not cells[2].isdecimal() or str(int(cells[2]))!=cells[2]: return None
            out.append({'kind':'P','name':cells[1],'age':int(cells[2])})
        elif cells[0]=='M':
            if len(cells)!=4: return None
            out.append({'kind':'message','from':cells[1],'to':cells[2],'text':cells[3]})
        else: return None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mixed', solve(_vary(['P,@,12', 'M,a,b,hello'])), _vary([{'kind': 'person', 'name': '@', 'age': 12}, {'kind': 'message', 'from': 'a', 'to': 'b', 'text': 'hello'}]))
check('empty text', solve(_vary(['M,a,b,'])), _vary([{'kind': 'message', 'from': 'a', 'to': 'b', 'text': ''}]))
check('zero age', solve(_vary(['P,@,0'])), _vary([{'kind': 'person', 'name': '@', 'age': 0}]))
check('bad tag', solve(_vary(['X,a,b'])), _vary(None))
check('wrong person', solve(_vary(['P,a,12,x'])), _vary(None))
check('wrong message', solve(_vary(['M,a,b'])), _vary(None))
check('leading zero', solve(_vary(['P,@,01'])), _vary(None))
check('empty', solve(_vary([])), _vary([]))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Decode tagged comma rows. P,name,age represents a person with canonical unsigned ASCII integer age; M,from,to,text represents a message with text that may be empty. Unknown tags and wrong arities reject. Return tagged dictionaries in source order.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    fields=[]; start=0
    for position,ch in enumerate(data):
        if ch==',':
            fields.append([data[start:position],start,position])
            start=position
    fields.append([data[start:],start,len(data)])
    return fields
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('normal', solve(_vary('ab,c')), _vary([['ab', 0, 2], ['c', 3, 4]]))
check('empty edges', solve(_vary(',a,')), _vary([['', 0, 0], ['a', 1, 2], ['', 3, 3]]))
check('empty input', solve(_vary('')), _vary([['', 0, 0]]))
check('unicode', solve(_vary('é,😀')), _vary([['é', 0, 1], ['😀', 2, 3]]))
check('many empties', solve(_vary(',,')), _vary([['', 0, 0], ['', 1, 1], ['', 2, 2]]))
check('one', solve(_vary('abcd')), _vary([['abcd', 0, 4]]))
check('middle empty', solve(_vary('a,,b')), _vary([['a', 0, 1], ['', 2, 2], ['b', 3, 4]]))
check('variant source extent', solve(('x'*N)+',y'), [['x'*N,0,N],['y',N+1,N+2]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    fields=[]; start=0
    for position,ch in enumerate(data):
        if ch==',':
            fields.append([data[start:position],start,position])
            start=position+2
    fields.append([data[start:],start,len(data)])
    return fields
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('normal', solve(_vary('ab,c')), _vary([['ab', 0, 2], ['c', 3, 4]]))
check('empty edges', solve(_vary(',a,')), _vary([['', 0, 0], ['a', 1, 2], ['', 3, 3]]))
check('empty input', solve(_vary('')), _vary([['', 0, 0]]))
check('unicode', solve(_vary('é,😀')), _vary([['é', 0, 1], ['😀', 2, 3]]))
check('many empties', solve(_vary(',,')), _vary([['', 0, 0], ['', 1, 1], ['', 2, 2]]))
check('one', solve(_vary('abcd')), _vary([['abcd', 0, 4]]))
check('middle empty', solve(_vary('a,,b')), _vary([['a', 0, 1], ['', 2, 2], ['b', 3, 4]]))
check('variant source extent', solve(('x'*N)+',y'), [['x'*N,0,N],['y',N+1,N+2]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Split a simple unquoted comma record and return [value,start,end] for each field, using zero-based Unicode-code-point offsets and exclusive ends. Delimiters are outside field spans; empty fields have equal start/end positions. The input contains no record terminator.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    fields=[]; start=0
    for position,ch in enumerate(data):
        if ch==',':
            fields.append([data[start:position],start,position+1])
            start=position+1
    fields.append([data[start:],start,len(data)])
    return fields
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('normal', solve(_vary('ab,c')), _vary([['ab', 0, 2], ['c', 3, 4]]))
check('empty edges', solve(_vary(',a,')), _vary([['', 0, 0], ['a', 1, 2], ['', 3, 3]]))
check('empty input', solve(_vary('')), _vary([['', 0, 0]]))
check('unicode', solve(_vary('é,😀')), _vary([['é', 0, 1], ['😀', 2, 3]]))
check('many empties', solve(_vary(',,')), _vary([['', 0, 0], ['', 1, 1], ['', 2, 2]]))
check('one', solve(_vary('abcd')), _vary([['abcd', 0, 4]]))
check('middle empty', solve(_vary('a,,b')), _vary([['a', 0, 1], ['', 2, 2], ['b', 3, 4]]))
check('variant source extent', solve(('x'*N)+',y'), [['x'*N,0,N],['y',N+1,N+2]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    fields=[]; start=0
    for position,ch in enumerate(data):
        if ch==',':
            fields.append([data[start:position],start,max(start,position-1)])
            start=position+1
    fields.append([data[start:],start,len(data)])
    return fields
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('normal', solve(_vary('ab,c')), _vary([['ab', 0, 2], ['c', 3, 4]]))
check('empty edges', solve(_vary(',a,')), _vary([['', 0, 0], ['a', 1, 2], ['', 3, 3]]))
check('empty input', solve(_vary('')), _vary([['', 0, 0]]))
check('unicode', solve(_vary('é,😀')), _vary([['é', 0, 1], ['😀', 2, 3]]))
check('many empties', solve(_vary(',,')), _vary([['', 0, 0], ['', 1, 1], ['', 2, 2]]))
check('one', solve(_vary('abcd')), _vary([['abcd', 0, 4]]))
check('middle empty', solve(_vary('a,,b')), _vary([['a', 0, 1], ['', 2, 2], ['b', 3, 4]]))
check('variant source extent', solve(('x'*N)+',y'), [['x'*N,0,N],['y',N+1,N+2]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Split a simple unquoted comma record and return [value,start,end] for each field, using zero-based Unicode-code-point offsets and exclusive ends. Delimiters are outside field spans; empty fields have equal start/end positions. The input contains no record terminator.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    fields=[]; start=0
    for position,ch in enumerate(data):
        if ch==',':
            fields.append([data[start:position],start,position])
            start=position+1
    fields.append([data[start:],start,max(0,start-1)])
    return fields
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('normal', solve(_vary('ab,c')), _vary([['ab', 0, 2], ['c', 3, 4]]))
check('empty edges', solve(_vary(',a,')), _vary([['', 0, 0], ['a', 1, 2], ['', 3, 3]]))
check('empty input', solve(_vary('')), _vary([['', 0, 0]]))
check('unicode', solve(_vary('é,😀')), _vary([['é', 0, 1], ['😀', 2, 3]]))
check('many empties', solve(_vary(',,')), _vary([['', 0, 0], ['', 1, 1], ['', 2, 2]]))
check('one', solve(_vary('abcd')), _vary([['abcd', 0, 4]]))
check('middle empty', solve(_vary('a,,b')), _vary([['a', 0, 1], ['', 2, 2], ['b', 3, 4]]))
check('variant source extent', solve(('x'*N)+',y'), [['x'*N,0,N],['y',N+1,N+2]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    fields=[]; start=0
    for position,ch in enumerate(data):
        if ch==',':
            fields.append([data[start:position],start,position])
            start=position+1
    fields.append([data[start:],start,len(data)+1])
    return fields
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('normal', solve(_vary('ab,c')), _vary([['ab', 0, 2], ['c', 3, 4]]))
check('empty edges', solve(_vary(',a,')), _vary([['', 0, 0], ['a', 1, 2], ['', 3, 3]]))
check('empty input', solve(_vary('')), _vary([['', 0, 0]]))
check('unicode', solve(_vary('é,😀')), _vary([['é', 0, 1], ['😀', 2, 3]]))
check('many empties', solve(_vary(',,')), _vary([['', 0, 0], ['', 1, 1], ['', 2, 2]]))
check('one', solve(_vary('abcd')), _vary([['abcd', 0, 4]]))
check('middle empty', solve(_vary('a,,b')), _vary([['a', 0, 1], ['', 2, 2], ['b', 3, 4]]))
check('variant source extent', solve(('x'*N)+',y'), [['x'*N,0,N],['y',N+1,N+2]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Split a simple unquoted comma record and return [value,start,end] for each field, using zero-based Unicode-code-point offsets and exclusive ends. Delimiters are outside field spans; empty fields have equal start/end positions. The input contains no record terminator.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    fields=[]; start=0
    for position,ch in enumerate(data):
        if ch==',':
            fields.append([data,start,position])
            start=position+1
    fields.append([data[start:],start,len(data)])
    return fields
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('normal', solve(_vary('ab,c')), _vary([['ab', 0, 2], ['c', 3, 4]]))
check('empty edges', solve(_vary(',a,')), _vary([['', 0, 0], ['a', 1, 2], ['', 3, 3]]))
check('empty input', solve(_vary('')), _vary([['', 0, 0]]))
check('unicode', solve(_vary('é,😀')), _vary([['é', 0, 1], ['😀', 2, 3]]))
check('many empties', solve(_vary(',,')), _vary([['', 0, 0], ['', 1, 1], ['', 2, 2]]))
check('one', solve(_vary('abcd')), _vary([['abcd', 0, 4]]))
check('middle empty', solve(_vary('a,,b')), _vary([['a', 0, 1], ['', 2, 2], ['b', 3, 4]]))
check('variant source extent', solve(('x'*N)+',y'), [['x'*N,0,N],['y',N+1,N+2]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    fields=[]; start=0
    for position,ch in enumerate(data):
        if ch==',':
            fields.append([data[:position],start,position])
            start=position+1
    fields.append([data[start:],start,len(data)])
    return fields
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('normal', solve(_vary('ab,c')), _vary([['ab', 0, 2], ['c', 3, 4]]))
check('empty edges', solve(_vary(',a,')), _vary([['', 0, 0], ['a', 1, 2], ['', 3, 3]]))
check('empty input', solve(_vary('')), _vary([['', 0, 0]]))
check('unicode', solve(_vary('é,😀')), _vary([['é', 0, 1], ['😀', 2, 3]]))
check('many empties', solve(_vary(',,')), _vary([['', 0, 0], ['', 1, 1], ['', 2, 2]]))
check('one', solve(_vary('abcd')), _vary([['abcd', 0, 4]]))
check('middle empty', solve(_vary('a,,b')), _vary([['a', 0, 1], ['', 2, 2], ['b', 3, 4]]))
check('variant source extent', solve(('x'*N)+',y'), [['x'*N,0,N],['y',N+1,N+2]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Split a simple unquoted comma record and return [value,start,end] for each field, using zero-based Unicode-code-point offsets and exclusive ends. Delimiters are outside field spans; empty fields have equal start/end positions. The input contains no record terminator.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    fields=[]; start=0
    for position,ch in enumerate(data):
        if ch==',':
            fields.append([data[start:position],start,position])
            start=position+1
    if start<len(data): fields.append([data[start:],start,len(data)])
    return fields
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('normal', solve(_vary('ab,c')), _vary([['ab', 0, 2], ['c', 3, 4]]))
check('empty edges', solve(_vary(',a,')), _vary([['', 0, 0], ['a', 1, 2], ['', 3, 3]]))
check('empty input', solve(_vary('')), _vary([['', 0, 0]]))
check('unicode', solve(_vary('é,😀')), _vary([['é', 0, 1], ['😀', 2, 3]]))
check('many empties', solve(_vary(',,')), _vary([['', 0, 0], ['', 1, 1], ['', 2, 2]]))
check('one', solve(_vary('abcd')), _vary([['abcd', 0, 4]]))
check('middle empty', solve(_vary('a,,b')), _vary([['a', 0, 1], ['', 2, 2], ['b', 3, 4]]))
check('variant source extent', solve(('x'*N)+',y'), [['x'*N,0,N],['y',N+1,N+2]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    fields=[]; start=0
    for position,ch in enumerate(data):
        if ch==',':
            fields.append([data[start:position],start,position])
            start=position+1
    if data[start:]: fields.append([data[start:],start,len(data)])
    return fields
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('normal', solve(_vary('ab,c')), _vary([['ab', 0, 2], ['c', 3, 4]]))
check('empty edges', solve(_vary(',a,')), _vary([['', 0, 0], ['a', 1, 2], ['', 3, 3]]))
check('empty input', solve(_vary('')), _vary([['', 0, 0]]))
check('unicode', solve(_vary('é,😀')), _vary([['é', 0, 1], ['😀', 2, 3]]))
check('many empties', solve(_vary(',,')), _vary([['', 0, 0], ['', 1, 1], ['', 2, 2]]))
check('one', solve(_vary('abcd')), _vary([['abcd', 0, 4]]))
check('middle empty', solve(_vary('a,,b')), _vary([['a', 0, 1], ['', 2, 2], ['b', 3, 4]]))
check('variant source extent', solve(('x'*N)+',y'), [['x'*N,0,N],['y',N+1,N+2]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Split a simple unquoted comma record and return [value,start,end] for each field, using zero-based Unicode-code-point offsets and exclusive ends. Delimiters are outside field spans; empty fields have equal start/end positions. The input contains no record terminator.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    text=data['row']; starts=[0]+[i+1 for i,ch in enumerate(text) if ch==',']
    ends=[i for i,ch in enumerate(text) if ch==',']+[len(text)]
    seen=set(); patches=[]
    for index,value in data['edits']:
        if not 0<=index<len(starts) or index in seen: return None
        if any(ch in value for ch in ',\r\n'): return None
        seen.add(index); patches.append((starts[index],ends[index],value))
    for start,end,value in sorted(patches):
        text=text[:start]+value+text[end:]
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('vary lengths', solve(_vary({'row': 'a,bbb,c', 'edits': [[0, '@long'], [2, 'z']]})), _vary('@long,bbb,z'))
check('empty field', solve(_vary({'row': 'a,,b', 'edits': [[1, '@']]})), _vary('a,@,b'))
check('empty replacement', solve(_vary({'row': 'a,b,c', 'edits': [[1, '']]})), _vary('a,,c'))
check('duplicate index', solve(_vary({'row': 'a,b', 'edits': [[0, 'x'], [0, 'y']]})), _vary(None))
check('invalid replacement', solve(_vary({'row': 'a,b', 'edits': [[1, 'x,y']]})), _vary(None))
check('out of range', solve(_vary({'row': 'a,b', 'edits': [[2, 'x']]})), _vary(None))
check('preserve spaces', solve(_vary({'row': ' a , b ', 'edits': [[1, '@']]})), _vary(' a ,@'))
check('unicode', solve(_vary({'row': 'é,😀,x', 'edits': [[1, '@']]})), _vary('é,@,x'))
check('no edits', solve(_vary({'row': '@,x', 'edits': []})), _vary('@,x'))
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
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    text=data['row']; starts=[0]+[i+1 for i,ch in enumerate(text) if ch==',']
    ends=[i for i,ch in enumerate(text) if ch==',']+[len(text)]
    seen=set(); patches=[]
    for index,value in data['edits']:
        if not 0<=index<len(starts) or index in seen: return None
        if any(ch in value for ch in ',\r\n'): return None
        seen.add(index); patches.append((starts[index],ends[index],value))
    for start,end,value in patches:
        text=text[:start]+value+text[end:]
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('vary lengths', solve(_vary({'row': 'a,bbb,c', 'edits': [[0, '@long'], [2, 'z']]})), _vary('@long,bbb,z'))
check('empty field', solve(_vary({'row': 'a,,b', 'edits': [[1, '@']]})), _vary('a,@,b'))
check('empty replacement', solve(_vary({'row': 'a,b,c', 'edits': [[1, '']]})), _vary('a,,c'))
check('duplicate index', solve(_vary({'row': 'a,b', 'edits': [[0, 'x'], [0, 'y']]})), _vary(None))
check('invalid replacement', solve(_vary({'row': 'a,b', 'edits': [[1, 'x,y']]})), _vary(None))
check('out of range', solve(_vary({'row': 'a,b', 'edits': [[2, 'x']]})), _vary(None))
check('preserve spaces', solve(_vary({'row': ' a , b ', 'edits': [[1, '@']]})), _vary(' a ,@'))
check('unicode', solve(_vary({'row': 'é,😀,x', 'edits': [[1, '@']]})), _vary('é,@,x'))
check('no edits', solve(_vary({'row': '@,x', 'edits': []})), _vary('@,x'))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Apply cell text edits to an unquoted comma row without changing unedited spelling. Edits are [zero-based cell index,replacement text], unique indexes only; replacements cannot contain comma or newline. Compute all source spans before editing and apply from right to left. Out-of-range indexes reject.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    text=data['row']; starts=[0]+[i+1 for i,ch in enumerate(text) if ch==',']
    ends=[i for i,ch in enumerate(text) if ch==',']+[len(text)]
    seen=set(); patches=[]
    for index,value in data['edits']:
        if not 0<=index<len(starts) or index in seen: return None
        if any(ch in value for ch in ',\r\n'): return None
        seen.add(index); patches.append((starts[index],ends[index],value))
    for start,end,value in sorted(patches,reverse=True):
        text=text[:start]+value+text[end+1:]
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('vary lengths', solve(_vary({'row': 'a,bbb,c', 'edits': [[0, '@long'], [2, 'z']]})), _vary('@long,bbb,z'))
check('empty field', solve(_vary({'row': 'a,,b', 'edits': [[1, '@']]})), _vary('a,@,b'))
check('empty replacement', solve(_vary({'row': 'a,b,c', 'edits': [[1, '']]})), _vary('a,,c'))
check('duplicate index', solve(_vary({'row': 'a,b', 'edits': [[0, 'x'], [0, 'y']]})), _vary(None))
check('invalid replacement', solve(_vary({'row': 'a,b', 'edits': [[1, 'x,y']]})), _vary(None))
check('out of range', solve(_vary({'row': 'a,b', 'edits': [[2, 'x']]})), _vary(None))
check('preserve spaces', solve(_vary({'row': ' a , b ', 'edits': [[1, '@']]})), _vary(' a ,@'))
check('unicode', solve(_vary({'row': 'é,😀,x', 'edits': [[1, '@']]})), _vary('é,@,x'))
check('no edits', solve(_vary({'row': '@,x', 'edits': []})), _vary('@,x'))
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
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    text=data['row']; starts=[0]+[i+1 for i,ch in enumerate(text) if ch==',']
    ends=[i for i,ch in enumerate(text) if ch==',']+[len(text)]
    seen=set(); patches=[]
    for index,value in data['edits']:
        if not 0<=index<len(starts) or index in seen: return None
        if any(ch in value for ch in ',\r\n'): return None
        seen.add(index); patches.append((starts[index],ends[index],value))
    for start,end,value in sorted(patches,reverse=True):
        text=text[:start]+value+text[min(end+2,len(text)):]
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('vary lengths', solve(_vary({'row': 'a,bbb,c', 'edits': [[0, '@long'], [2, 'z']]})), _vary('@long,bbb,z'))
check('empty field', solve(_vary({'row': 'a,,b', 'edits': [[1, '@']]})), _vary('a,@,b'))
check('empty replacement', solve(_vary({'row': 'a,b,c', 'edits': [[1, '']]})), _vary('a,,c'))
check('duplicate index', solve(_vary({'row': 'a,b', 'edits': [[0, 'x'], [0, 'y']]})), _vary(None))
check('invalid replacement', solve(_vary({'row': 'a,b', 'edits': [[1, 'x,y']]})), _vary(None))
check('out of range', solve(_vary({'row': 'a,b', 'edits': [[2, 'x']]})), _vary(None))
check('preserve spaces', solve(_vary({'row': ' a , b ', 'edits': [[1, '@']]})), _vary(' a ,@'))
check('unicode', solve(_vary({'row': 'é,😀,x', 'edits': [[1, '@']]})), _vary('é,@,x'))
check('no edits', solve(_vary({'row': '@,x', 'edits': []})), _vary('@,x'))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Apply cell text edits to an unquoted comma row without changing unedited spelling. Edits are [zero-based cell index,replacement text], unique indexes only; replacements cannot contain comma or newline. Compute all source spans before editing and apply from right to left. Out-of-range indexes reject.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    text=data['row']; starts=[0]+[i+1 for i,ch in enumerate(text) if ch==',']
    ends=[i for i,ch in enumerate(text) if ch==',']+[len(text)]
    seen=set(); patches=[]
    for index,value in data['edits']:
        if not 0<=index<len(starts) or index in seen: return None
        if any(ch in value for ch in ',\r\n'): return None
        seen.add(index); patches.append((0,ends[index],value))
    for start,end,value in sorted(patches,reverse=True):
        text=text[:start]+value+text[end:]
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('vary lengths', solve(_vary({'row': 'a,bbb,c', 'edits': [[0, '@long'], [2, 'z']]})), _vary('@long,bbb,z'))
check('empty field', solve(_vary({'row': 'a,,b', 'edits': [[1, '@']]})), _vary('a,@,b'))
check('empty replacement', solve(_vary({'row': 'a,b,c', 'edits': [[1, '']]})), _vary('a,,c'))
check('duplicate index', solve(_vary({'row': 'a,b', 'edits': [[0, 'x'], [0, 'y']]})), _vary(None))
check('invalid replacement', solve(_vary({'row': 'a,b', 'edits': [[1, 'x,y']]})), _vary(None))
check('out of range', solve(_vary({'row': 'a,b', 'edits': [[2, 'x']]})), _vary(None))
check('preserve spaces', solve(_vary({'row': ' a , b ', 'edits': [[1, '@']]})), _vary(' a ,@'))
check('unicode', solve(_vary({'row': 'é,😀,x', 'edits': [[1, '@']]})), _vary('é,@,x'))
check('no edits', solve(_vary({'row': '@,x', 'edits': []})), _vary('@,x'))
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
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    text=data['row']; starts=[0]+[i+1 for i,ch in enumerate(text) if ch==',']
    ends=[i for i,ch in enumerate(text) if ch==',']+[len(text)]
    seen=set(); patches=[]
    for index,value in data['edits']:
        if not 0<=index<len(starts) or index in seen: return None
        if any(ch in value for ch in ',\r\n'): return None
        seen.add(index); patches.append((index,ends[index],value))
    for start,end,value in sorted(patches,reverse=True):
        text=text[:start]+value+text[end:]
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('vary lengths', solve(_vary({'row': 'a,bbb,c', 'edits': [[0, '@long'], [2, 'z']]})), _vary('@long,bbb,z'))
check('empty field', solve(_vary({'row': 'a,,b', 'edits': [[1, '@']]})), _vary('a,@,b'))
check('empty replacement', solve(_vary({'row': 'a,b,c', 'edits': [[1, '']]})), _vary('a,,c'))
check('duplicate index', solve(_vary({'row': 'a,b', 'edits': [[0, 'x'], [0, 'y']]})), _vary(None))
check('invalid replacement', solve(_vary({'row': 'a,b', 'edits': [[1, 'x,y']]})), _vary(None))
check('out of range', solve(_vary({'row': 'a,b', 'edits': [[2, 'x']]})), _vary(None))
check('preserve spaces', solve(_vary({'row': ' a , b ', 'edits': [[1, '@']]})), _vary(' a ,@'))
check('unicode', solve(_vary({'row': 'é,😀,x', 'edits': [[1, '@']]})), _vary('é,@,x'))
check('no edits', solve(_vary({'row': '@,x', 'edits': []})), _vary('@,x'))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Apply cell text edits to an unquoted comma row without changing unedited spelling. Edits are [zero-based cell index,replacement text], unique indexes only; replacements cannot contain comma or newline. Compute all source spans before editing and apply from right to left. Out-of-range indexes reject.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    text=data['row']; starts=[0]+[i+1 for i,ch in enumerate(text) if ch==',']
    ends=[i for i,ch in enumerate(text) if ch==',']+[len(text)]
    seen=set(); patches=[]
    for index,value in data['edits']:
        if not 0<=index<len(starts) or index in seen: return None
        if any(ch in value for ch in ',\r\n'): return None
        seen.add(index); patches.append((starts[index],ends[index],value))
    for start,end,value in sorted(patches,reverse=True):
        text=text[:start]+value+text[start:]
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('vary lengths', solve(_vary({'row': 'a,bbb,c', 'edits': [[0, '@long'], [2, 'z']]})), _vary('@long,bbb,z'))
check('empty field', solve(_vary({'row': 'a,,b', 'edits': [[1, '@']]})), _vary('a,@,b'))
check('empty replacement', solve(_vary({'row': 'a,b,c', 'edits': [[1, '']]})), _vary('a,,c'))
check('duplicate index', solve(_vary({'row': 'a,b', 'edits': [[0, 'x'], [0, 'y']]})), _vary(None))
check('invalid replacement', solve(_vary({'row': 'a,b', 'edits': [[1, 'x,y']]})), _vary(None))
check('out of range', solve(_vary({'row': 'a,b', 'edits': [[2, 'x']]})), _vary(None))
check('preserve spaces', solve(_vary({'row': ' a , b ', 'edits': [[1, '@']]})), _vary(' a ,@'))
check('unicode', solve(_vary({'row': 'é,😀,x', 'edits': [[1, '@']]})), _vary('é,@,x'))
check('no edits', solve(_vary({'row': '@,x', 'edits': []})), _vary('@,x'))
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
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    text=data['row']; starts=[0]+[i+1 for i,ch in enumerate(text) if ch==',']
    ends=[i for i,ch in enumerate(text) if ch==',']+[len(text)]
    seen=set(); patches=[]
    for index,value in data['edits']:
        if not 0<=index<len(starts) or index in seen: return None
        if any(ch in value for ch in ',\r\n'): return None
        seen.add(index); patches.append((starts[index],ends[index],value))
    for start,end,value in sorted(patches,reverse=True):
        text=text[:end]+value+text[end:]
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('vary lengths', solve(_vary({'row': 'a,bbb,c', 'edits': [[0, '@long'], [2, 'z']]})), _vary('@long,bbb,z'))
check('empty field', solve(_vary({'row': 'a,,b', 'edits': [[1, '@']]})), _vary('a,@,b'))
check('empty replacement', solve(_vary({'row': 'a,b,c', 'edits': [[1, '']]})), _vary('a,,c'))
check('duplicate index', solve(_vary({'row': 'a,b', 'edits': [[0, 'x'], [0, 'y']]})), _vary(None))
check('invalid replacement', solve(_vary({'row': 'a,b', 'edits': [[1, 'x,y']]})), _vary(None))
check('out of range', solve(_vary({'row': 'a,b', 'edits': [[2, 'x']]})), _vary(None))
check('preserve spaces', solve(_vary({'row': ' a , b ', 'edits': [[1, '@']]})), _vary(' a ,@'))
check('unicode', solve(_vary({'row': 'é,😀,x', 'edits': [[1, '@']]})), _vary('é,@,x'))
check('no edits', solve(_vary({'row': '@,x', 'edits': []})), _vary('@,x'))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Apply cell text edits to an unquoted comma row without changing unedited spelling. Edits are [zero-based cell index,replacement text], unique indexes only; replacements cannot contain comma or newline. Compute all source spans before editing and apply from right to left. Out-of-range indexes reject.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    text=data['row']; starts=[0]+[i+1 for i,ch in enumerate(text) if ch==',']
    ends=[i for i,ch in enumerate(text) if ch==',']+[len(text)]
    seen=set(); patches=[]
    for index,value in data['edits']:
        if not 0<=index<len(starts) : return None
        if any(ch in value for ch in ',\r\n'): return None
        seen.add(index); patches.append((starts[index],ends[index],value))
    for start,end,value in sorted(patches,reverse=True):
        text=text[:start]+value+text[end:]
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('vary lengths', solve(_vary({'row': 'a,bbb,c', 'edits': [[0, '@long'], [2, 'z']]})), _vary('@long,bbb,z'))
check('empty field', solve(_vary({'row': 'a,,b', 'edits': [[1, '@']]})), _vary('a,@,b'))
check('empty replacement', solve(_vary({'row': 'a,b,c', 'edits': [[1, '']]})), _vary('a,,c'))
check('duplicate index', solve(_vary({'row': 'a,b', 'edits': [[0, 'x'], [0, 'y']]})), _vary(None))
check('invalid replacement', solve(_vary({'row': 'a,b', 'edits': [[1, 'x,y']]})), _vary(None))
check('out of range', solve(_vary({'row': 'a,b', 'edits': [[2, 'x']]})), _vary(None))
check('preserve spaces', solve(_vary({'row': ' a , b ', 'edits': [[1, '@']]})), _vary(' a ,@'))
check('unicode', solve(_vary({'row': 'é,😀,x', 'edits': [[1, '@']]})), _vary('é,@,x'))
check('no edits', solve(_vary({'row': '@,x', 'edits': []})), _vary('@,x'))
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
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    text=data['row']; starts=[0]+[i+1 for i,ch in enumerate(text) if ch==',']
    ends=[i for i,ch in enumerate(text) if ch==',']+[len(text)]
    seen=set(); patches=[]
    for index,value in data['edits']:
        if not 0<=index<len(starts) or (index in seen and value==''): return None
        if any(ch in value for ch in ',\r\n'): return None
        seen.add(index); patches.append((starts[index],ends[index],value))
    for start,end,value in sorted(patches,reverse=True):
        text=text[:start]+value+text[end:]
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('vary lengths', solve(_vary({'row': 'a,bbb,c', 'edits': [[0, '@long'], [2, 'z']]})), _vary('@long,bbb,z'))
check('empty field', solve(_vary({'row': 'a,,b', 'edits': [[1, '@']]})), _vary('a,@,b'))
check('empty replacement', solve(_vary({'row': 'a,b,c', 'edits': [[1, '']]})), _vary('a,,c'))
check('duplicate index', solve(_vary({'row': 'a,b', 'edits': [[0, 'x'], [0, 'y']]})), _vary(None))
check('invalid replacement', solve(_vary({'row': 'a,b', 'edits': [[1, 'x,y']]})), _vary(None))
check('out of range', solve(_vary({'row': 'a,b', 'edits': [[2, 'x']]})), _vary(None))
check('preserve spaces', solve(_vary({'row': ' a , b ', 'edits': [[1, '@']]})), _vary(' a ,@'))
check('unicode', solve(_vary({'row': 'é,😀,x', 'edits': [[1, '@']]})), _vary('é,@,x'))
check('no edits', solve(_vary({'row': '@,x', 'edits': []})), _vary('@,x'))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Apply cell text edits to an unquoted comma row without changing unedited spelling. Edits are [zero-based cell index,replacement text], unique indexes only; replacements cannot contain comma or newline. Compute all source spans before editing and apply from right to left. Out-of-range indexes reject.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    rows=[]; carry=''
    for chunk in data:
        carry=chunk
        while '\n' in carry:
            record,carry=carry.split('\n',1)
            rows.append(record.split(','))
    if carry: rows.append(carry.split(','))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split cell', solve(_vary(['a,', '@', '\nx,y\n'])), _vary([['a', '@'], ['x', 'y']]))
check('several per chunk', solve(_vary(['a,b\n@,z\n'])), _vary([['a', 'b'], ['@', 'z']]))
check('empty chunks', solve(_vary(['', '@', '', '\n', ''])), _vary([['@']]))
check('partial final', solve(_vary(['a,b\n@'])), _vary([['a', 'b'], ['@']]))
check('empty rows', solve(_vary(['\n\n'])), _vary([[''], ['']]))
check('empty input', solve(_vary([])), _vary([]))
check('no newline', solve(_vary(['@'])), _vary([['@']]))
check('split delimiter', solve(_vary(['a', '\n', 'b'])), _vary([['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
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    rows=[]; carry=''
    for chunk in data:
        carry=chunk+carry
        while '\n' in carry:
            record,carry=carry.split('\n',1)
            rows.append(record.split(','))
    if carry: rows.append(carry.split(','))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split cell', solve(_vary(['a,', '@', '\nx,y\n'])), _vary([['a', '@'], ['x', 'y']]))
check('several per chunk', solve(_vary(['a,b\n@,z\n'])), _vary([['a', 'b'], ['@', 'z']]))
check('empty chunks', solve(_vary(['', '@', '', '\n', ''])), _vary([['@']]))
check('partial final', solve(_vary(['a,b\n@'])), _vary([['a', 'b'], ['@']]))
check('empty rows', solve(_vary(['\n\n'])), _vary([[''], ['']]))
check('empty input', solve(_vary([])), _vary([]))
check('no newline', solve(_vary(['@'])), _vary([['@']]))
check('split delimiter', solve(_vary(['a', '\n', 'b'])), _vary([['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:
A structured table violates the declared record or column contract.

Consume arbitrary text chunks of an unquoted LF-delimited table. Complete records emit immediately into an output list; carry partial records across chunks. EOF emits a nonempty remaining fragment, but not a phantom row after final LF. Empty complete physical records are retained. Return comma-split rows.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    rows=[]; carry=''
    for chunk in data:
        carry+=chunk
        if '\n' in carry:
            record,carry=carry.split('\n',1)
            rows.append(record.split(','))
    if carry: rows.append(carry.split(','))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split cell', solve(_vary(['a,', '@', '\nx,y\n'])), _vary([['a', '@'], ['x', 'y']]))
check('several per chunk', solve(_vary(['a,b\n@,z\n'])), _vary([['a', 'b'], ['@', 'z']]))
check('empty chunks', solve(_vary(['', '@', '', '\n', ''])), _vary([['@']]))
check('partial final', solve(_vary(['a,b\n@'])), _vary([['a', 'b'], ['@']]))
check('empty rows', solve(_vary(['\n\n'])), _vary([[''], ['']]))
check('empty input', solve(_vary([])), _vary([]))
check('no newline', solve(_vary(['@'])), _vary([['@']]))
check('split delimiter', solve(_vary(['a', '\n', 'b'])), _vary([['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
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    rows=[]; carry=''
    for chunk in data:
        carry+=chunk
        if carry.count('\n')==1:
            record,carry=carry.split('\n',1)
            rows.append(record.split(','))
    if carry: rows.append(carry.split(','))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split cell', solve(_vary(['a,', '@', '\nx,y\n'])), _vary([['a', '@'], ['x', 'y']]))
check('several per chunk', solve(_vary(['a,b\n@,z\n'])), _vary([['a', 'b'], ['@', 'z']]))
check('empty chunks', solve(_vary(['', '@', '', '\n', ''])), _vary([['@']]))
check('partial final', solve(_vary(['a,b\n@'])), _vary([['a', 'b'], ['@']]))
check('empty rows', solve(_vary(['\n\n'])), _vary([[''], ['']]))
check('empty input', solve(_vary([])), _vary([]))
check('no newline', solve(_vary(['@'])), _vary([['@']]))
check('split delimiter', solve(_vary(['a', '\n', 'b'])), _vary([['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:
A structured table violates the declared record or column contract.

Consume arbitrary text chunks of an unquoted LF-delimited table. Complete records emit immediately into an output list; carry partial records across chunks. EOF emits a nonempty remaining fragment, but not a phantom row after final LF. Empty complete physical records are retained. Return comma-split rows.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    rows=[]; carry=''
    for chunk in data:
        carry+=chunk
        while '\n' in carry:
            record,carry=carry.rsplit('\n',1)
            rows.append(record.split(','))
    if carry: rows.append(carry.split(','))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split cell', solve(_vary(['a,', '@', '\nx,y\n'])), _vary([['a', '@'], ['x', 'y']]))
check('several per chunk', solve(_vary(['a,b\n@,z\n'])), _vary([['a', 'b'], ['@', 'z']]))
check('empty chunks', solve(_vary(['', '@', '', '\n', ''])), _vary([['@']]))
check('partial final', solve(_vary(['a,b\n@'])), _vary([['a', 'b'], ['@']]))
check('empty rows', solve(_vary(['\n\n'])), _vary([[''], ['']]))
check('empty input', solve(_vary([])), _vary([]))
check('no newline', solve(_vary(['@'])), _vary([['@']]))
check('split delimiter', solve(_vary(['a', '\n', 'b'])), _vary([['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
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    rows=[]; carry=''
    for chunk in data:
        carry+=chunk
        while '\n' in carry:
            record,carry=carry.split('\n',1)[::-1]
            rows.append(record.split(','))
    if carry: rows.append(carry.split(','))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split cell', solve(_vary(['a,', '@', '\nx,y\n'])), _vary([['a', '@'], ['x', 'y']]))
check('several per chunk', solve(_vary(['a,b\n@,z\n'])), _vary([['a', 'b'], ['@', 'z']]))
check('empty chunks', solve(_vary(['', '@', '', '\n', ''])), _vary([['@']]))
check('partial final', solve(_vary(['a,b\n@'])), _vary([['a', 'b'], ['@']]))
check('empty rows', solve(_vary(['\n\n'])), _vary([[''], ['']]))
check('empty input', solve(_vary([])), _vary([]))
check('no newline', solve(_vary(['@'])), _vary([['@']]))
check('split delimiter', solve(_vary(['a', '\n', 'b'])), _vary([['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:
A structured table violates the declared record or column contract.

Consume arbitrary text chunks of an unquoted LF-delimited table. Complete records emit immediately into an output list; carry partial records across chunks. EOF emits a nonempty remaining fragment, but not a phantom row after final LF. Empty complete physical records are retained. Return comma-split rows.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    rows=[]; carry=''
    for chunk in data:
        carry+=chunk
        while '\n' in carry:
            record,carry=carry.split('\n',1)
            rows.append(record.split(','))
    if False: rows.append(carry.split(','))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split cell', solve(_vary(['a,', '@', '\nx,y\n'])), _vary([['a', '@'], ['x', 'y']]))
check('several per chunk', solve(_vary(['a,b\n@,z\n'])), _vary([['a', 'b'], ['@', 'z']]))
check('empty chunks', solve(_vary(['', '@', '', '\n', ''])), _vary([['@']]))
check('partial final', solve(_vary(['a,b\n@'])), _vary([['a', 'b'], ['@']]))
check('empty rows', solve(_vary(['\n\n'])), _vary([[''], ['']]))
check('empty input', solve(_vary([])), _vary([]))
check('no newline', solve(_vary(['@'])), _vary([['@']]))
check('split delimiter', solve(_vary(['a', '\n', 'b'])), _vary([['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
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    rows=[]; carry=''
    for chunk in data:
        carry+=chunk
        while '\n' in carry:
            record,carry=carry.split('\n',1)
            rows.append(record.split(','))
    if carry.endswith('\n'): rows.append(carry.split(','))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split cell', solve(_vary(['a,', '@', '\nx,y\n'])), _vary([['a', '@'], ['x', 'y']]))
check('several per chunk', solve(_vary(['a,b\n@,z\n'])), _vary([['a', 'b'], ['@', 'z']]))
check('empty chunks', solve(_vary(['', '@', '', '\n', ''])), _vary([['@']]))
check('partial final', solve(_vary(['a,b\n@'])), _vary([['a', 'b'], ['@']]))
check('empty rows', solve(_vary(['\n\n'])), _vary([[''], ['']]))
check('empty input', solve(_vary([])), _vary([]))
check('no newline', solve(_vary(['@'])), _vary([['@']]))
check('split delimiter', solve(_vary(['a', '\n', 'b'])), _vary([['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:
A structured table violates the declared record or column contract.

Consume arbitrary text chunks of an unquoted LF-delimited table. Complete records emit immediately into an output list; carry partial records across chunks. EOF emits a nonempty remaining fragment, but not a phantom row after final LF. Empty complete physical records are retained. Return comma-split rows.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    rows=[]; carry=''
    for chunk in data:
        carry+=chunk
        while '\n' in carry:
            record,carry=carry.split('\n',1)
            if record: rows.append(record.split(','))
    if carry: rows.append(carry.split(','))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split cell', solve(_vary(['a,', '@', '\nx,y\n'])), _vary([['a', '@'], ['x', 'y']]))
check('several per chunk', solve(_vary(['a,b\n@,z\n'])), _vary([['a', 'b'], ['@', 'z']]))
check('empty chunks', solve(_vary(['', '@', '', '\n', ''])), _vary([['@']]))
check('partial final', solve(_vary(['a,b\n@'])), _vary([['a', 'b'], ['@']]))
check('empty rows', solve(_vary(['\n\n'])), _vary([[''], ['']]))
check('empty input', solve(_vary([])), _vary([]))
check('no newline', solve(_vary(['@'])), _vary([['@']]))
check('split delimiter', solve(_vary(['a', '\n', 'b'])), _vary([['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
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    rows=[]; carry=''
    for chunk in data:
        carry+=chunk
        while '\n' in carry:
            record,carry=carry.split('\n',1)
            if record.strip(): rows.append(record.split(','))
    if carry: rows.append(carry.split(','))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split cell', solve(_vary(['a,', '@', '\nx,y\n'])), _vary([['a', '@'], ['x', 'y']]))
check('several per chunk', solve(_vary(['a,b\n@,z\n'])), _vary([['a', 'b'], ['@', 'z']]))
check('empty chunks', solve(_vary(['', '@', '', '\n', ''])), _vary([['@']]))
check('partial final', solve(_vary(['a,b\n@'])), _vary([['a', 'b'], ['@']]))
check('empty rows', solve(_vary(['\n\n'])), _vary([[''], ['']]))
check('empty input', solve(_vary([])), _vary([]))
check('no newline', solve(_vary(['@'])), _vary([['@']]))
check('split delimiter', solve(_vary(['a', '\n', 'b'])), _vary([['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:
A structured table violates the declared record or column contract.

Consume arbitrary text chunks of an unquoted LF-delimited table. Complete records emit immediately into an output list; carry partial records across chunks. EOF emits a nonempty remaining fragment, but not a phantom row after final LF. Empty complete physical records are retained. Return comma-split rows.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    import csv,io
    reader=csv.reader(io.StringIO(data,newline=''))
    out=[]; start=1
    for cells in reader:
        end=len(out)+1
        out.append([start,end,cells])
        start=end+1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('multiline', solve(_vary('a,"x\ny"\nz,@\n')), _vary([[1, 2, ['a', 'x\ny']], [3, 3, ['z', '@']]]))
check('blank middle', solve(_vary('a\n\nz\n')), _vary([[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]]))
check('plain', solve(_vary('@,x\n')), _vary([[1, 1, ['@', 'x']]]))
check('CRLF', solve(_vary('"a\r\nb",z\r\n')), _vary([[1, 2, ['a\r\nb', 'z']]]))
check('empty', solve(_vary('')), _vary([]))
check('unterminated final', solve(_vary('@')), _vary([[1, 1, ['@']]]))
check('two multiline', solve(_vary('"a\nb"\n"c\nd"')), _vary([[1, 2, ['a\nb']], [3, 4, ['c\nd']]]))
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
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    import csv,io
    reader=csv.reader(io.StringIO(data,newline=''))
    out=[]; start=1
    for cells in reader:
        end=start
        out.append([start,end,cells])
        start=end+1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('multiline', solve(_vary('a,"x\ny"\nz,@\n')), _vary([[1, 2, ['a', 'x\ny']], [3, 3, ['z', '@']]]))
check('blank middle', solve(_vary('a\n\nz\n')), _vary([[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]]))
check('plain', solve(_vary('@,x\n')), _vary([[1, 1, ['@', 'x']]]))
check('CRLF', solve(_vary('"a\r\nb",z\r\n')), _vary([[1, 2, ['a\r\nb', 'z']]]))
check('empty', solve(_vary('')), _vary([]))
check('unterminated final', solve(_vary('@')), _vary([[1, 1, ['@']]]))
check('two multiline', solve(_vary('"a\nb"\n"c\nd"')), _vary([[1, 2, ['a\nb']], [3, 4, ['c\nd']]]))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Parse bounded valid CSV text using Python csv.reader and report each logical row with inclusive one-based physical start/end line numbers. Quoted embedded newlines count as physical lines. Empty input gives no rows; blank physical lines are zero-cell rows. Return [start,end,cells].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    import csv,io
    reader=csv.reader(io.StringIO(data,newline=''))
    out=[]; start=1
    for cells in reader:
        end=reader.line_num
        out.append([start,end,cells])
        start=end
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('multiline', solve(_vary('a,"x\ny"\nz,@\n')), _vary([[1, 2, ['a', 'x\ny']], [3, 3, ['z', '@']]]))
check('blank middle', solve(_vary('a\n\nz\n')), _vary([[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]]))
check('plain', solve(_vary('@,x\n')), _vary([[1, 1, ['@', 'x']]]))
check('CRLF', solve(_vary('"a\r\nb",z\r\n')), _vary([[1, 2, ['a\r\nb', 'z']]]))
check('empty', solve(_vary('')), _vary([]))
check('unterminated final', solve(_vary('@')), _vary([[1, 1, ['@']]]))
check('two multiline', solve(_vary('"a\nb"\n"c\nd"')), _vary([[1, 2, ['a\nb']], [3, 4, ['c\nd']]]))
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
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    import csv,io
    reader=csv.reader(io.StringIO(data,newline=''))
    out=[]; start=1
    for cells in reader:
        end=reader.line_num
        out.append([start,end,cells])
        start+=1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('multiline', solve(_vary('a,"x\ny"\nz,@\n')), _vary([[1, 2, ['a', 'x\ny']], [3, 3, ['z', '@']]]))
check('blank middle', solve(_vary('a\n\nz\n')), _vary([[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]]))
check('plain', solve(_vary('@,x\n')), _vary([[1, 1, ['@', 'x']]]))
check('CRLF', solve(_vary('"a\r\nb",z\r\n')), _vary([[1, 2, ['a\r\nb', 'z']]]))
check('empty', solve(_vary('')), _vary([]))
check('unterminated final', solve(_vary('@')), _vary([[1, 1, ['@']]]))
check('two multiline', solve(_vary('"a\nb"\n"c\nd"')), _vary([[1, 2, ['a\nb']], [3, 4, ['c\nd']]]))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Parse bounded valid CSV text using Python csv.reader and report each logical row with inclusive one-based physical start/end line numbers. Quoted embedded newlines count as physical lines. Empty input gives no rows; blank physical lines are zero-cell rows. Return [start,end,cells].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    import csv,io
    reader=csv.reader(io.StringIO(data,newline=''))
    out=[]; start=0
    for cells in reader:
        end=reader.line_num
        out.append([start,end,cells])
        start=end+1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('multiline', solve(_vary('a,"x\ny"\nz,@\n')), _vary([[1, 2, ['a', 'x\ny']], [3, 3, ['z', '@']]]))
check('blank middle', solve(_vary('a\n\nz\n')), _vary([[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]]))
check('plain', solve(_vary('@,x\n')), _vary([[1, 1, ['@', 'x']]]))
check('CRLF', solve(_vary('"a\r\nb",z\r\n')), _vary([[1, 2, ['a\r\nb', 'z']]]))
check('empty', solve(_vary('')), _vary([]))
check('unterminated final', solve(_vary('@')), _vary([[1, 1, ['@']]]))
check('two multiline', solve(_vary('"a\nb"\n"c\nd"')), _vary([[1, 2, ['a\nb']], [3, 4, ['c\nd']]]))
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
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    import csv,io
    reader=csv.reader(io.StringIO(data,newline=''))
    out=[]; start=2
    for cells in reader:
        end=reader.line_num
        out.append([start,end,cells])
        start=end+1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('multiline', solve(_vary('a,"x\ny"\nz,@\n')), _vary([[1, 2, ['a', 'x\ny']], [3, 3, ['z', '@']]]))
check('blank middle', solve(_vary('a\n\nz\n')), _vary([[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]]))
check('plain', solve(_vary('@,x\n')), _vary([[1, 1, ['@', 'x']]]))
check('CRLF', solve(_vary('"a\r\nb",z\r\n')), _vary([[1, 2, ['a\r\nb', 'z']]]))
check('empty', solve(_vary('')), _vary([]))
check('unterminated final', solve(_vary('@')), _vary([[1, 1, ['@']]]))
check('two multiline', solve(_vary('"a\nb"\n"c\nd"')), _vary([[1, 2, ['a\nb']], [3, 4, ['c\nd']]]))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Parse bounded valid CSV text using Python csv.reader and report each logical row with inclusive one-based physical start/end line numbers. Quoted embedded newlines count as physical lines. Empty input gives no rows; blank physical lines are zero-cell rows. Return [start,end,cells].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    import csv,io
    reader=csv.reader(io.StringIO(data,newline=''))
    out=[]; start=1
    for cells in reader:
        end=reader.line_num
        out.append([end,start,cells])
        start=end+1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('multiline', solve(_vary('a,"x\ny"\nz,@\n')), _vary([[1, 2, ['a', 'x\ny']], [3, 3, ['z', '@']]]))
check('blank middle', solve(_vary('a\n\nz\n')), _vary([[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]]))
check('plain', solve(_vary('@,x\n')), _vary([[1, 1, ['@', 'x']]]))
check('CRLF', solve(_vary('"a\r\nb",z\r\n')), _vary([[1, 2, ['a\r\nb', 'z']]]))
check('empty', solve(_vary('')), _vary([]))
check('unterminated final', solve(_vary('@')), _vary([[1, 1, ['@']]]))
check('two multiline', solve(_vary('"a\nb"\n"c\nd"')), _vary([[1, 2, ['a\nb']], [3, 4, ['c\nd']]]))
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
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    import csv,io
    reader=csv.reader(io.StringIO(data,newline=''))
    out=[]; start=1
    for cells in reader:
        end=reader.line_num
        out.append([start,end-start,cells])
        start=end+1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('multiline', solve(_vary('a,"x\ny"\nz,@\n')), _vary([[1, 2, ['a', 'x\ny']], [3, 3, ['z', '@']]]))
check('blank middle', solve(_vary('a\n\nz\n')), _vary([[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]]))
check('plain', solve(_vary('@,x\n')), _vary([[1, 1, ['@', 'x']]]))
check('CRLF', solve(_vary('"a\r\nb",z\r\n')), _vary([[1, 2, ['a\r\nb', 'z']]]))
check('empty', solve(_vary('')), _vary([]))
check('unterminated final', solve(_vary('@')), _vary([[1, 1, ['@']]]))
check('two multiline', solve(_vary('"a\nb"\n"c\nd"')), _vary([[1, 2, ['a\nb']], [3, 4, ['c\nd']]]))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Parse bounded valid CSV text using Python csv.reader and report each logical row with inclusive one-based physical start/end line numbers. Quoted embedded newlines count as physical lines. Empty input gives no rows; blank physical lines are zero-cell rows. Return [start,end,cells].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    import csv,io
    reader=csv.reader(io.StringIO(data,newline=''))
    out=[]; start=1
    for cells in reader:
        end=reader.line_num
        if cells: out.append([start,end,cells])
        start=end+1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('multiline', solve(_vary('a,"x\ny"\nz,@\n')), _vary([[1, 2, ['a', 'x\ny']], [3, 3, ['z', '@']]]))
check('blank middle', solve(_vary('a\n\nz\n')), _vary([[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]]))
check('plain', solve(_vary('@,x\n')), _vary([[1, 1, ['@', 'x']]]))
check('CRLF', solve(_vary('"a\r\nb",z\r\n')), _vary([[1, 2, ['a\r\nb', 'z']]]))
check('empty', solve(_vary('')), _vary([]))
check('unterminated final', solve(_vary('@')), _vary([[1, 1, ['@']]]))
check('two multiline', solve(_vary('"a\nb"\n"c\nd"')), _vary([[1, 2, ['a\nb']], [3, 4, ['c\nd']]]))
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
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    import csv,io
    reader=csv.reader(io.StringIO(data,newline=''))
    out=[]; start=1
    for cells in reader:
        end=reader.line_num
        if any(cells): out.append([start,end,cells])
        start=end+1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('multiline', solve(_vary('a,"x\ny"\nz,@\n')), _vary([[1, 2, ['a', 'x\ny']], [3, 3, ['z', '@']]]))
check('blank middle', solve(_vary('a\n\nz\n')), _vary([[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]]))
check('plain', solve(_vary('@,x\n')), _vary([[1, 1, ['@', 'x']]]))
check('CRLF', solve(_vary('"a\r\nb",z\r\n')), _vary([[1, 2, ['a\r\nb', 'z']]]))
check('empty', solve(_vary('')), _vary([]))
check('unterminated final', solve(_vary('@')), _vary([[1, 1, ['@']]]))
check('two multiline', solve(_vary('"a\nb"\n"c\nd"')), _vary([[1, 2, ['a\nb']], [3, 4, ['c\nd']]]))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Parse bounded valid CSV text using Python csv.reader and report each logical row with inclusive one-based physical start/end line numbers. Quoted embedded newlines count as physical lines. Empty input gives no rows; blank physical lines are zero-cell rows. Return [start,end,cells].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    if not data or not data[0].isascii() or not data[0].isdecimal(): return None
    count=int(data[0])
    if count<1 or len(data)<count+1: return None
    levels=[line.split(',') for line in data[1:count] or data[1:2]]
    width=len(levels[0])
    if any(len(level)!=width for level in levels): return None
    header=['/'.join(level[i] for level in levels if level[i]) for i in range(width)]
    if any(not name for name in header) or len(set(header))!=width: return None
    rows=[line.split(',') for line in data[count+1:]]
    if any(len(row)!=width for row in rows): return None
    return {'header':header,'rows':rows}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('levels', solve(_vary(['2', 'group,group', 'a,b', '@,z'])), _vary({'header': ['group/a', 'group/b'], 'rows': [['@', 'z']]}))
check('empty components', solve(_vary(['2', 'group,', 'a,b', '@,z'])), _vary({'header': ['group/a', 'b'], 'rows': [['@', 'z']]}))
check('header only', solve(_vary(['1', '@'])), _vary({'header': ['@'], 'rows': []}))
check('bad count', solve(_vary(['0', 'a'])), _vary(None))
check('too few headers', solve(_vary(['2', 'a'])), _vary(None))
check('width mismatch', solve(_vary(['2', 'a,b', 'c'])), _vary(None))
check('duplicate', solve(_vary(['1', 'a,a'])), _vary(None))
check('empty final name', solve(_vary(['2', ',a', ',b'])), _vary(None))
check('body width', solve(_vary(['1', 'a,b', '@'])), _vary(None))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    if not data or not data[0].isascii() or not data[0].isdecimal(): return None
    count=int(data[0])
    if count<1 or len(data)<count+1: return None
    levels=[line.split(',') for line in data[1:2]]
    width=len(levels[0])
    if any(len(level)!=width for level in levels): return None
    header=['/'.join(level[i] for level in levels if level[i]) for i in range(width)]
    if any(not name for name in header) or len(set(header))!=width: return None
    rows=[line.split(',') for line in data[count+1:]]
    if any(len(row)!=width for row in rows): return None
    return {'header':header,'rows':rows}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('levels', solve(_vary(['2', 'group,group', 'a,b', '@,z'])), _vary({'header': ['group/a', 'group/b'], 'rows': [['@', 'z']]}))
check('empty components', solve(_vary(['2', 'group,', 'a,b', '@,z'])), _vary({'header': ['group/a', 'b'], 'rows': [['@', 'z']]}))
check('header only', solve(_vary(['1', '@'])), _vary({'header': ['@'], 'rows': []}))
check('bad count', solve(_vary(['0', 'a'])), _vary(None))
check('too few headers', solve(_vary(['2', 'a'])), _vary(None))
check('width mismatch', solve(_vary(['2', 'a,b', 'c'])), _vary(None))
check('duplicate', solve(_vary(['1', 'a,a'])), _vary(None))
check('empty final name', solve(_vary(['2', ',a', ',b'])), _vary(None))
check('body width', solve(_vary(['1', 'a,b', '@'])), _vary(None))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A structured table violates the declared record or column contract.

Decode a table with an integer preamble giving the number of following physical header rows. Each header row is comma cells; combine corresponding column labels with /, omitting empty components. At least one header row is required, widths must agree, final names must be nonempty and unique. Remaining rows are body and must match width. Return header and body.

split: open-access