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+1]]
    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:]]
    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:count+1]]
    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+2:]]
    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


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+1]]
    width=len(levels[0])
    if any(len(level)!=width for level in levels): return None
    header=['/'.join(level[i] for level in reversed(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)

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):
    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+1]]
    width=len(levels[0])
    if any(len(level)!=width for level in levels): return None
    header=['/'.join(sorted(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


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+1]]
    width=len(levels[0])
    if any(len(level)!=width for level in levels): return None
    header=['/'.join(level[i] for level in levels) 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:count+1]]
    width=len(levels[0])
    if any(len(level)!=width for level in levels): return None
    header=['/'.join(level[i] if level[i] else '_' for level in levels) 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


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+1]]
    width=len(levels[0])
    if any(len(level)!=width for level in levels): return None
    header=['/'.join(level) for level in levels]
    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:count+1]]
    width=len(levels[0])
    if any(len(level)!=width for level in levels): return None
    header=['/'.join(level) for level in levels][: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


prompt:
The packet sync prefix is dropped before packed sample codes.

Pack unsigned codes fitting width 1..7 most-significant bit first after an explicit bit prefix; return octets, significant-bit count and zero tail padding count.

split: open-access


prompt:
Packed sample fields emit least-significant bit first.

Pack unsigned codes fitting width 1..7 most-significant bit first after an explicit bit prefix; return octets, significant-bit count and zero tail padding count.

split: open-access


prompt:
Already aligned packets receive a whole spurious padding octet.

Pack unsigned codes fitting width 1..7 most-significant bit first after an explicit bit prefix; return octets, significant-bit count and zero tail padding count.

split: open-access


prompt:
Tail pad bits are set, violating canonical zero padding.

Pack unsigned codes fitting width 1..7 most-significant bit first after an explicit bit prefix; return octets, significant-bit count and zero tail padding count.

split: open-access


prompt:
Wire octets reverse the bit significance of packed fields.

Pack unsigned codes fitting width 1..7 most-significant bit first after an explicit bit prefix; return octets, significant-bit count and zero tail padding count.

split: open-access


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

N = 1
observations = []
def solve(octets, width, count, prefix_bits):
    bits = [(byte >> (7-j)) & 1 for byte in octets for j in range(8)]
    bits = bits[prefix_bits//8:]
    available = len(bits)//width
    count = min(count,available)
    values=[]
    for i in range(count):
        values.append(sum(bits[i*width+j] << (width-1-j) for j in range(width)))
    consumed = prefix_bits+count*width
    return [values,consumed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([179, 144], 3, 3, 2)), [[6, 3, 4], 11])
check('oracle 2', solve(*([255], 2, 2, 0)), [[3, 3], 4])
check('oracle 3', solve(*([0], 1, 8, 0)), [[0, 0, 0, 0, 0, 0, 0, 0], 8])
check('oracle 4', solve(*([], 3, 0, 0)), [[], 0])
check('oracle 5', solve(*([160], 3, 1, 1)), [[2], 4])
check('oracle 6', solve(*([18, 52], 4, 2, 4)), [[2, 3], 12])
check('oracle 7', solve(*([255], 3, 5, 1)), [[7, 7], 7])
if N == 1: check('variant packet 1', solve(*[[179, 144, 179, 144], 3, 6, 2]), [[6, 3, 4, 4, 1, 3], 20])
if N == 2: check('variant packet 2', solve(*[[179, 144, 179, 144, 179, 144], 3, 9, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2], 29])
if N == 3: check('variant packet 3', solve(*[[179, 144, 179, 144, 179, 144, 179, 144], 3, 12, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4], 38])
if N == 4: check('variant packet 4', solve(*[[179, 144, 179, 144, 179, 144, 179, 144, 179, 144], 3, 15, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4, 7, 1, 0], 47])
if N == 5: check('variant packet 5', solve(*[[179, 144, 179, 144, 179, 144, 179, 144, 179, 144, 179, 144], 3, 18, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4, 7, 1, 0, 2, 6, 3], 56])
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:
Reader consumes the sync prefix as a sample field.

Read up to declared unsigned packed fields after a bit prefix; incomplete fields are ignored, and report cursor in bits from packet start.

split: open-access


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

N = 1
observations = []
def solve(octets, width, count, prefix_bits):
    bits = [(byte >> (7-j)) & 1 for byte in octets for j in range(8)]
    bits = bits[prefix_bits:]
    available = len(bits)//8
    count = min(count,available)
    values=[]
    for i in range(count):
        values.append(sum(bits[i*width+j] << (width-1-j) for j in range(width)))
    consumed = prefix_bits+count*width
    return [values,consumed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([179, 144], 3, 3, 2)), [[6, 3, 4], 11])
check('oracle 2', solve(*([255], 2, 2, 0)), [[3, 3], 4])
check('oracle 3', solve(*([0], 1, 8, 0)), [[0, 0, 0, 0, 0, 0, 0, 0], 8])
check('oracle 4', solve(*([], 3, 0, 0)), [[], 0])
check('oracle 5', solve(*([160], 3, 1, 1)), [[2], 4])
check('oracle 6', solve(*([18, 52], 4, 2, 4)), [[2, 3], 12])
check('oracle 7', solve(*([255], 3, 5, 1)), [[7, 7], 7])
if N == 1: check('variant packet 1', solve(*[[179, 144, 179, 144], 3, 6, 2]), [[6, 3, 4, 4, 1, 3], 20])
if N == 2: check('variant packet 2', solve(*[[179, 144, 179, 144, 179, 144], 3, 9, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2], 29])
if N == 3: check('variant packet 3', solve(*[[179, 144, 179, 144, 179, 144, 179, 144], 3, 12, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4], 38])
if N == 4: check('variant packet 4', solve(*[[179, 144, 179, 144, 179, 144, 179, 144, 179, 144], 3, 15, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4, 7, 1, 0], 47])
if N == 5: check('variant packet 5', solve(*[[179, 144, 179, 144, 179, 144, 179, 144, 179, 144, 179, 144], 3, 18, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4, 7, 1, 0, 2, 6, 3], 56])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(octets, width, count, prefix_bits):
    bits = [(byte >> (7-j)) & 1 for byte in octets for j in range(8)]
    bits = bits[prefix_bits:]
    available = max(0,len(bits)//width-1)
    count = min(count,available)
    values=[]
    for i in range(count):
        values.append(sum(bits[i*width+j] << (width-1-j) for j in range(width)))
    consumed = prefix_bits+count*width
    return [values,consumed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([179, 144], 3, 3, 2)), [[6, 3, 4], 11])
check('oracle 2', solve(*([255], 2, 2, 0)), [[3, 3], 4])
check('oracle 3', solve(*([0], 1, 8, 0)), [[0, 0, 0, 0, 0, 0, 0, 0], 8])
check('oracle 4', solve(*([], 3, 0, 0)), [[], 0])
check('oracle 5', solve(*([160], 3, 1, 1)), [[2], 4])
check('oracle 6', solve(*([18, 52], 4, 2, 4)), [[2, 3], 12])
check('oracle 7', solve(*([255], 3, 5, 1)), [[7, 7], 7])
if N == 1: check('variant packet 1', solve(*[[179, 144, 179, 144], 3, 6, 2]), [[6, 3, 4, 4, 1, 3], 20])
if N == 2: check('variant packet 2', solve(*[[179, 144, 179, 144, 179, 144], 3, 9, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2], 29])
if N == 3: check('variant packet 3', solve(*[[179, 144, 179, 144, 179, 144, 179, 144], 3, 12, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4], 38])
if N == 4: check('variant packet 4', solve(*[[179, 144, 179, 144, 179, 144, 179, 144, 179, 144], 3, 15, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4, 7, 1, 0], 47])
if N == 5: check('variant packet 5', solve(*[[179, 144, 179, 144, 179, 144, 179, 144, 179, 144, 179, 144], 3, 18, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4, 7, 1, 0, 2, 6, 3], 56])
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:
Available packed samples are counted as octets.

Read up to declared unsigned packed fields after a bit prefix; incomplete fields are ignored, and report cursor in bits from packet start.

split: open-access


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

N = 1
observations = []
def solve(octets, width, count, prefix_bits):
    bits = [(byte >> (7-j)) & 1 for byte in octets for j in range(8)]
    bits = bits[prefix_bits:]
    available = len(bits)//width
    count = available
    values=[]
    for i in range(count):
        values.append(sum(bits[i*width+j] << (width-1-j) for j in range(width)))
    consumed = prefix_bits+count*width
    return [values,consumed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([179, 144], 3, 3, 2)), [[6, 3, 4], 11])
check('oracle 2', solve(*([255], 2, 2, 0)), [[3, 3], 4])
check('oracle 3', solve(*([0], 1, 8, 0)), [[0, 0, 0, 0, 0, 0, 0, 0], 8])
check('oracle 4', solve(*([], 3, 0, 0)), [[], 0])
check('oracle 5', solve(*([160], 3, 1, 1)), [[2], 4])
check('oracle 6', solve(*([18, 52], 4, 2, 4)), [[2, 3], 12])
check('oracle 7', solve(*([255], 3, 5, 1)), [[7, 7], 7])
if N == 1: check('variant packet 1', solve(*[[179, 144, 179, 144], 3, 6, 2]), [[6, 3, 4, 4, 1, 3], 20])
if N == 2: check('variant packet 2', solve(*[[179, 144, 179, 144, 179, 144], 3, 9, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2], 29])
if N == 3: check('variant packet 3', solve(*[[179, 144, 179, 144, 179, 144, 179, 144], 3, 12, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4], 38])
if N == 4: check('variant packet 4', solve(*[[179, 144, 179, 144, 179, 144, 179, 144, 179, 144], 3, 15, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4, 7, 1, 0], 47])
if N == 5: check('variant packet 5', solve(*[[179, 144, 179, 144, 179, 144, 179, 144, 179, 144, 179, 144], 3, 18, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4, 7, 1, 0, 2, 6, 3], 56])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(octets, width, count, prefix_bits):
    bits = [(byte >> (7-j)) & 1 for byte in octets for j in range(8)]
    bits = bits[prefix_bits:]
    available = len(bits)//width
    count = min(1,count,available)
    values=[]
    for i in range(count):
        values.append(sum(bits[i*width+j] << (width-1-j) for j in range(width)))
    consumed = prefix_bits+count*width
    return [values,consumed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([179, 144], 3, 3, 2)), [[6, 3, 4], 11])
check('oracle 2', solve(*([255], 2, 2, 0)), [[3, 3], 4])
check('oracle 3', solve(*([0], 1, 8, 0)), [[0, 0, 0, 0, 0, 0, 0, 0], 8])
check('oracle 4', solve(*([], 3, 0, 0)), [[], 0])
check('oracle 5', solve(*([160], 3, 1, 1)), [[2], 4])
check('oracle 6', solve(*([18, 52], 4, 2, 4)), [[2, 3], 12])
check('oracle 7', solve(*([255], 3, 5, 1)), [[7, 7], 7])
if N == 1: check('variant packet 1', solve(*[[179, 144, 179, 144], 3, 6, 2]), [[6, 3, 4, 4, 1, 3], 20])
if N == 2: check('variant packet 2', solve(*[[179, 144, 179, 144, 179, 144], 3, 9, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2], 29])
if N == 3: check('variant packet 3', solve(*[[179, 144, 179, 144, 179, 144, 179, 144], 3, 12, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4], 38])
if N == 4: check('variant packet 4', solve(*[[179, 144, 179, 144, 179, 144, 179, 144, 179, 144], 3, 15, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4, 7, 1, 0], 47])
if N == 5: check('variant packet 5', solve(*[[179, 144, 179, 144, 179, 144, 179, 144, 179, 144, 179, 144], 3, 18, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4, 7, 1, 0, 2, 6, 3], 56])
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:
Tail padding is decoded as additional samples beyond declared count.

Read up to declared unsigned packed fields after a bit prefix; incomplete fields are ignored, and report cursor in bits from packet start.

split: open-access


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

N = 1
observations = []
def solve(octets, width, count, prefix_bits):
    bits = [(byte >> (7-j)) & 1 for byte in octets for j in range(8)]
    bits = bits[prefix_bits:]
    available = len(bits)//width
    count = min(count,available)
    values=[]
    for i in range(count):
        values.append(sum(bits[i+j] << (width-1-j) for j in range(width)))
    consumed = prefix_bits+count*width
    return [values,consumed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([179, 144], 3, 3, 2)), [[6, 3, 4], 11])
check('oracle 2', solve(*([255], 2, 2, 0)), [[3, 3], 4])
check('oracle 3', solve(*([0], 1, 8, 0)), [[0, 0, 0, 0, 0, 0, 0, 0], 8])
check('oracle 4', solve(*([], 3, 0, 0)), [[], 0])
check('oracle 5', solve(*([160], 3, 1, 1)), [[2], 4])
check('oracle 6', solve(*([18, 52], 4, 2, 4)), [[2, 3], 12])
check('oracle 7', solve(*([255], 3, 5, 1)), [[7, 7], 7])
if N == 1: check('variant packet 1', solve(*[[179, 144, 179, 144], 3, 6, 2]), [[6, 3, 4, 4, 1, 3], 20])
if N == 2: check('variant packet 2', solve(*[[179, 144, 179, 144, 179, 144], 3, 9, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2], 29])
if N == 3: check('variant packet 3', solve(*[[179, 144, 179, 144, 179, 144, 179, 144], 3, 12, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4], 38])
if N == 4: check('variant packet 4', solve(*[[179, 144, 179, 144, 179, 144, 179, 144, 179, 144], 3, 15, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4, 7, 1, 0], 47])
if N == 5: check('variant packet 5', solve(*[[179, 144, 179, 144, 179, 144, 179, 144, 179, 144, 179, 144], 3, 18, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4, 7, 1, 0, 2, 6, 3], 56])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(octets, width, count, prefix_bits):
    bits = [(byte >> (7-j)) & 1 for byte in octets for j in range(8)]
    bits = bits[prefix_bits:]
    available = len(bits)//width
    count = min(count,available)
    values=[]
    for i in range(count):
        values.append(sum(bits[j] << (width-1-j) for j in range(width)))
    consumed = prefix_bits+count*width
    return [values,consumed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([179, 144], 3, 3, 2)), [[6, 3, 4], 11])
check('oracle 2', solve(*([255], 2, 2, 0)), [[3, 3], 4])
check('oracle 3', solve(*([0], 1, 8, 0)), [[0, 0, 0, 0, 0, 0, 0, 0], 8])
check('oracle 4', solve(*([], 3, 0, 0)), [[], 0])
check('oracle 5', solve(*([160], 3, 1, 1)), [[2], 4])
check('oracle 6', solve(*([18, 52], 4, 2, 4)), [[2, 3], 12])
check('oracle 7', solve(*([255], 3, 5, 1)), [[7, 7], 7])
if N == 1: check('variant packet 1', solve(*[[179, 144, 179, 144], 3, 6, 2]), [[6, 3, 4, 4, 1, 3], 20])
if N == 2: check('variant packet 2', solve(*[[179, 144, 179, 144, 179, 144], 3, 9, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2], 29])
if N == 3: check('variant packet 3', solve(*[[179, 144, 179, 144, 179, 144, 179, 144], 3, 12, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4], 38])
if N == 4: check('variant packet 4', solve(*[[179, 144, 179, 144, 179, 144, 179, 144, 179, 144], 3, 15, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4, 7, 1, 0], 47])
if N == 5: check('variant packet 5', solve(*[[179, 144, 179, 144, 179, 144, 179, 144, 179, 144, 179, 144], 3, 18, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4, 7, 1, 0, 2, 6, 3], 56])
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:
Field starts advance one bit instead of the code width.

Read up to declared unsigned packed fields after a bit prefix; incomplete fields are ignored, and report cursor in bits from packet start.

split: open-access


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

N = 1
observations = []
def solve(octets, width, count, prefix_bits):
    bits = [(byte >> (7-j)) & 1 for byte in octets for j in range(8)]
    bits = bits[prefix_bits:]
    available = len(bits)//width
    count = min(count,available)
    values=[]
    for i in range(count):
        values.append(sum(bits[i*width+j] << (width-1-j) for j in range(width)))
    consumed = prefix_bits+len(octets)*8
    return [values,consumed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([179, 144], 3, 3, 2)), [[6, 3, 4], 11])
check('oracle 2', solve(*([255], 2, 2, 0)), [[3, 3], 4])
check('oracle 3', solve(*([0], 1, 8, 0)), [[0, 0, 0, 0, 0, 0, 0, 0], 8])
check('oracle 4', solve(*([], 3, 0, 0)), [[], 0])
check('oracle 5', solve(*([160], 3, 1, 1)), [[2], 4])
check('oracle 6', solve(*([18, 52], 4, 2, 4)), [[2, 3], 12])
check('oracle 7', solve(*([255], 3, 5, 1)), [[7, 7], 7])
if N == 1: check('variant packet 1', solve(*[[179, 144, 179, 144], 3, 6, 2]), [[6, 3, 4, 4, 1, 3], 20])
if N == 2: check('variant packet 2', solve(*[[179, 144, 179, 144, 179, 144], 3, 9, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2], 29])
if N == 3: check('variant packet 3', solve(*[[179, 144, 179, 144, 179, 144, 179, 144], 3, 12, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4], 38])
if N == 4: check('variant packet 4', solve(*[[179, 144, 179, 144, 179, 144, 179, 144, 179, 144], 3, 15, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4, 7, 1, 0], 47])
if N == 5: check('variant packet 5', solve(*[[179, 144, 179, 144, 179, 144, 179, 144, 179, 144, 179, 144], 3, 18, 2]), [[6, 3, 4, 4, 1, 3, 1, 6, 2, 0, 5, 4, 7, 1, 0, 2, 6, 3], 56])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Cursor excludes consumed sync prefix.

Read up to declared unsigned packed fields after a bit prefix; incomplete fields are ignored, and report cursor in bits from packet start.

split: open-access


prompt:
Left justified sample bits are interpreted as right justified.

Extract a signed valid-bit field left justified in an unsigned container; ignore bits above the container and separately return low unused pad bits. valid<container.

split: open-access


prompt:
Bits above the declared container leak into the valid field.

Extract a signed valid-bit field left justified in an unsigned container; ignore bits above the container and separately return low unused pad bits. valid<container.

split: open-access


prompt:
The container sign position is tested after valid-bit extraction.

Extract a signed valid-bit field left justified in an unsigned container; ignore bits above the container and separately return low unused pad bits. valid<container.

split: open-access


prompt:
The extracted field is sign-corrected using container modulus.

Extract a signed valid-bit field left justified in an unsigned container; ignore bits above the container and separately return low unused pad bits. valid<container.

split: open-access


prompt:
Padding inspection includes signal bits.

Extract a signed valid-bit field left justified in an unsigned container; ignore bits above the container and separately return low unused pad bits. valid<container.

split: open-access


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

N = 1
observations = []
def solve(codes, width, preserve_negative_zero):
    mask=(1<<width)-1
    sign=1<<(width-1)
    values=[]
    negative_zero=[]
    for raw in codes:
        code=raw
        magnitude=(~code)&mask if code&sign else code
        value=-magnitude if code&sign else magnitude
        values.append(value)
        negative_zero.append(bool(preserve_negative_zero and code==mask))
    return [values,negative_zero]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, 7, 8, 14, 15], 4, True)), [[0, 1, 7, -7, -1, 0], [False, False, False, False, False, True]])
check('oracle 2', solve(*([15, 0, 8], 4, False)), [[0, 0, -7], [False, False, False]])
check('oracle 3', solve(*([31, 16, 17], 4, True)), [[0, 0, 1], [True, False, False]])
check('oracle 4', solve(*([], 4, True)), [[], []])
check('oracle 5', solve(*([0, 3, 4, 6, 7], 3, True)), [[0, 3, -3, -1, 0], [False, False, False, False, True]])
check('oracle 6', solve(*([255, 128, 254, 127], 8, False)), [[0, -127, -1, 127], [False, False, False, False]])
check('oracle 7', solve(*([255], 8, True)), [[0], [True]])
if N == 1: check('variant packet 1', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 2: check('variant packet 2', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 3: check('variant packet 3', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 4: check('variant packet 4', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 5: check('variant packet 5', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(codes, width, preserve_negative_zero):
    mask=(1<<width)-1
    sign=1<<(width-1)
    values=[]
    negative_zero=[]
    for raw in codes:
        code=raw&(sign-1)
        magnitude=(~code)&mask if code&sign else code
        value=-magnitude if code&sign else magnitude
        values.append(value)
        negative_zero.append(bool(preserve_negative_zero and code==mask))
    return [values,negative_zero]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, 7, 8, 14, 15], 4, True)), [[0, 1, 7, -7, -1, 0], [False, False, False, False, False, True]])
check('oracle 2', solve(*([15, 0, 8], 4, False)), [[0, 0, -7], [False, False, False]])
check('oracle 3', solve(*([31, 16, 17], 4, True)), [[0, 0, 1], [True, False, False]])
check('oracle 4', solve(*([], 4, True)), [[], []])
check('oracle 5', solve(*([0, 3, 4, 6, 7], 3, True)), [[0, 3, -3, -1, 0], [False, False, False, False, True]])
check('oracle 6', solve(*([255, 128, 254, 127], 8, False)), [[0, -127, -1, 127], [False, False, False, False]])
check('oracle 7', solve(*([255], 8, True)), [[0], [True]])
if N == 1: check('variant packet 1', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 2: check('variant packet 2', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 3: check('variant packet 3', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 4: check('variant packet 4', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 5: check('variant packet 5', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Storage bits outside the PCM field participate in zero-code detection.

Decode bounded ones-complement PCM fields; optionally preserve a per-sample negative-zero sideband while numeric zero stays JSON integer zero.

split: open-access


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

N = 1
observations = []
def solve(codes, width, preserve_negative_zero):
    mask=(1<<width)-1
    sign=1<<(width-1)
    values=[]
    negative_zero=[]
    for raw in codes:
        code=raw&mask
        magnitude=code-(1<<width) if code&sign else code
        value=-magnitude if code&sign else magnitude
        values.append(value)
        negative_zero.append(bool(preserve_negative_zero and code==mask))
    return [values,negative_zero]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, 7, 8, 14, 15], 4, True)), [[0, 1, 7, -7, -1, 0], [False, False, False, False, False, True]])
check('oracle 2', solve(*([15, 0, 8], 4, False)), [[0, 0, -7], [False, False, False]])
check('oracle 3', solve(*([31, 16, 17], 4, True)), [[0, 0, 1], [True, False, False]])
check('oracle 4', solve(*([], 4, True)), [[], []])
check('oracle 5', solve(*([0, 3, 4, 6, 7], 3, True)), [[0, 3, -3, -1, 0], [False, False, False, False, True]])
check('oracle 6', solve(*([255, 128, 254, 127], 8, False)), [[0, -127, -1, 127], [False, False, False, False]])
check('oracle 7', solve(*([255], 8, True)), [[0], [True]])
if N == 1: check('variant packet 1', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 2: check('variant packet 2', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 3: check('variant packet 3', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 4: check('variant packet 4', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 5: check('variant packet 5', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(codes, width, preserve_negative_zero):
    mask=(1<<width)-1
    sign=1<<(width-1)
    values=[]
    negative_zero=[]
    for raw in codes:
        code=raw&mask
        magnitude=(~code)&(sign-1)+1 if code&sign else code
        value=-magnitude if code&sign else magnitude
        values.append(value)
        negative_zero.append(bool(preserve_negative_zero and code==mask))
    return [values,negative_zero]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, 7, 8, 14, 15], 4, True)), [[0, 1, 7, -7, -1, 0], [False, False, False, False, False, True]])
check('oracle 2', solve(*([15, 0, 8], 4, False)), [[0, 0, -7], [False, False, False]])
check('oracle 3', solve(*([31, 16, 17], 4, True)), [[0, 0, 1], [True, False, False]])
check('oracle 4', solve(*([], 4, True)), [[], []])
check('oracle 5', solve(*([0, 3, 4, 6, 7], 3, True)), [[0, 3, -3, -1, 0], [False, False, False, False, True]])
check('oracle 6', solve(*([255, 128, 254, 127], 8, False)), [[0, -127, -1, 127], [False, False, False, False]])
check('oracle 7', solve(*([255], 8, True)), [[0], [True]])
if N == 1: check('variant packet 1', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 2: check('variant packet 2', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 3: check('variant packet 3', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 4: check('variant packet 4', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 5: check('variant packet 5', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A ones-complement field is decoded with a twos-complement magnitude rule.

Decode bounded ones-complement PCM fields; optionally preserve a per-sample negative-zero sideband while numeric zero stays JSON integer zero.

split: open-access


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

N = 1
observations = []
def solve(codes, width, preserve_negative_zero):
    mask=(1<<width)-1
    sign=1<<(width-1)
    values=[]
    negative_zero=[]
    for raw in codes:
        code=raw&mask
        magnitude=(~code)&mask if code&sign else code+1
        value=-magnitude if code&sign else magnitude
        values.append(value)
        negative_zero.append(bool(preserve_negative_zero and code==mask))
    return [values,negative_zero]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, 7, 8, 14, 15], 4, True)), [[0, 1, 7, -7, -1, 0], [False, False, False, False, False, True]])
check('oracle 2', solve(*([15, 0, 8], 4, False)), [[0, 0, -7], [False, False, False]])
check('oracle 3', solve(*([31, 16, 17], 4, True)), [[0, 0, 1], [True, False, False]])
check('oracle 4', solve(*([], 4, True)), [[], []])
check('oracle 5', solve(*([0, 3, 4, 6, 7], 3, True)), [[0, 3, -3, -1, 0], [False, False, False, False, True]])
check('oracle 6', solve(*([255, 128, 254, 127], 8, False)), [[0, -127, -1, 127], [False, False, False, False]])
check('oracle 7', solve(*([255], 8, True)), [[0], [True]])
if N == 1: check('variant packet 1', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 2: check('variant packet 2', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 3: check('variant packet 3', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 4: check('variant packet 4', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 5: check('variant packet 5', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(codes, width, preserve_negative_zero):
    mask=(1<<width)-1
    sign=1<<(width-1)
    values=[]
    negative_zero=[]
    for raw in codes:
        code=raw&mask
        magnitude=(~code)&mask if code&sign else max(0,code-1)
        value=-magnitude if code&sign else magnitude
        values.append(value)
        negative_zero.append(bool(preserve_negative_zero and code==mask))
    return [values,negative_zero]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, 7, 8, 14, 15], 4, True)), [[0, 1, 7, -7, -1, 0], [False, False, False, False, False, True]])
check('oracle 2', solve(*([15, 0, 8], 4, False)), [[0, 0, -7], [False, False, False]])
check('oracle 3', solve(*([31, 16, 17], 4, True)), [[0, 0, 1], [True, False, False]])
check('oracle 4', solve(*([], 4, True)), [[], []])
check('oracle 5', solve(*([0, 3, 4, 6, 7], 3, True)), [[0, 3, -3, -1, 0], [False, False, False, False, True]])
check('oracle 6', solve(*([255, 128, 254, 127], 8, False)), [[0, -127, -1, 127], [False, False, False, False]])
check('oracle 7', solve(*([255], 8, True)), [[0], [True]])
if N == 1: check('variant packet 1', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 2: check('variant packet 2', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 3: check('variant packet 3', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 4: check('variant packet 4', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 5: check('variant packet 5', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Positive codes are biased despite the direct positive mapping.

Decode bounded ones-complement PCM fields; optionally preserve a per-sample negative-zero sideband while numeric zero stays JSON integer zero.

split: open-access


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

N = 1
observations = []
def solve(codes, width, preserve_negative_zero):
    mask=(1<<width)-1
    sign=1<<(width-1)
    values=[]
    negative_zero=[]
    for raw in codes:
        code=raw&mask
        magnitude=(~code)&mask if code&sign else code
        value=-magnitude if code&sign else magnitude
        values.append(value)
        negative_zero.append(bool(preserve_negative_zero and code==sign))
    return [values,negative_zero]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, 7, 8, 14, 15], 4, True)), [[0, 1, 7, -7, -1, 0], [False, False, False, False, False, True]])
check('oracle 2', solve(*([15, 0, 8], 4, False)), [[0, 0, -7], [False, False, False]])
check('oracle 3', solve(*([31, 16, 17], 4, True)), [[0, 0, 1], [True, False, False]])
check('oracle 4', solve(*([], 4, True)), [[], []])
check('oracle 5', solve(*([0, 3, 4, 6, 7], 3, True)), [[0, 3, -3, -1, 0], [False, False, False, False, True]])
check('oracle 6', solve(*([255, 128, 254, 127], 8, False)), [[0, -127, -1, 127], [False, False, False, False]])
check('oracle 7', solve(*([255], 8, True)), [[0], [True]])
if N == 1: check('variant packet 1', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 2: check('variant packet 2', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 3: check('variant packet 3', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 4: check('variant packet 4', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 5: check('variant packet 5', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(codes, width, preserve_negative_zero):
    mask=(1<<width)-1
    sign=1<<(width-1)
    values=[]
    negative_zero=[]
    for raw in codes:
        code=raw&mask
        magnitude=(~code)&mask if code&sign else code
        value=-magnitude if code&sign else magnitude
        values.append(value)
        negative_zero.append(bool(preserve_negative_zero and code==0))
    return [values,negative_zero]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, 7, 8, 14, 15], 4, True)), [[0, 1, 7, -7, -1, 0], [False, False, False, False, False, True]])
check('oracle 2', solve(*([15, 0, 8], 4, False)), [[0, 0, -7], [False, False, False]])
check('oracle 3', solve(*([31, 16, 17], 4, True)), [[0, 0, 1], [True, False, False]])
check('oracle 4', solve(*([], 4, True)), [[], []])
check('oracle 5', solve(*([0, 3, 4, 6, 7], 3, True)), [[0, 3, -3, -1, 0], [False, False, False, False, True]])
check('oracle 6', solve(*([255, 128, 254, 127], 8, False)), [[0, -127, -1, 127], [False, False, False, False]])
check('oracle 7', solve(*([255], 8, True)), [[0], [True]])
if N == 1: check('variant packet 1', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 2: check('variant packet 2', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 3: check('variant packet 3', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 4: check('variant packet 4', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 5: check('variant packet 5', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Negative zero is confused with the largest negative code.

Decode bounded ones-complement PCM fields; optionally preserve a per-sample negative-zero sideband while numeric zero stays JSON integer zero.

split: open-access


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

N = 1
observations = []
def solve(codes, width, preserve_negative_zero):
    mask=(1<<width)-1
    sign=1<<(width-1)
    values=[]
    negative_zero=[]
    for raw in codes:
        code=raw&mask
        magnitude=(~code)&mask if code&sign else code
        value=-magnitude if code&sign else magnitude
        values.append(value)
        negative_zero.append(bool(code==mask))
    return [values,negative_zero]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, 7, 8, 14, 15], 4, True)), [[0, 1, 7, -7, -1, 0], [False, False, False, False, False, True]])
check('oracle 2', solve(*([15, 0, 8], 4, False)), [[0, 0, -7], [False, False, False]])
check('oracle 3', solve(*([31, 16, 17], 4, True)), [[0, 0, 1], [True, False, False]])
check('oracle 4', solve(*([], 4, True)), [[], []])
check('oracle 5', solve(*([0, 3, 4, 6, 7], 3, True)), [[0, 3, -3, -1, 0], [False, False, False, False, True]])
check('oracle 6', solve(*([255, 128, 254, 127], 8, False)), [[0, -127, -1, 127], [False, False, False, False]])
check('oracle 7', solve(*([255], 8, True)), [[0], [True]])
if N == 1: check('variant packet 1', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 2: check('variant packet 2', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 3: check('variant packet 3', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 4: check('variant packet 4', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 5: check('variant packet 5', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(codes, width, preserve_negative_zero):
    mask=(1<<width)-1
    sign=1<<(width-1)
    values=[]
    negative_zero=[]
    for raw in codes:
        code=raw&mask
        magnitude=(~code)&mask if code&sign else code
        value=-magnitude if code&sign else magnitude
        values.append(value)
        negative_zero.append(bool(preserve_negative_zero or code==mask))
    return [values,negative_zero]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, 7, 8, 14, 15], 4, True)), [[0, 1, 7, -7, -1, 0], [False, False, False, False, False, True]])
check('oracle 2', solve(*([15, 0, 8], 4, False)), [[0, 0, -7], [False, False, False]])
check('oracle 3', solve(*([31, 16, 17], 4, True)), [[0, 0, 1], [True, False, False]])
check('oracle 4', solve(*([], 4, True)), [[], []])
check('oracle 5', solve(*([0, 3, 4, 6, 7], 3, True)), [[0, 3, -3, -1, 0], [False, False, False, False, True]])
check('oracle 6', solve(*([255, 128, 254, 127], 8, False)), [[0, -127, -1, 127], [False, False, False, False]])
check('oracle 7', solve(*([255], 8, True)), [[0], [True]])
if N == 1: check('variant packet 1', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 2: check('variant packet 2', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 3: check('variant packet 3', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 4: check('variant packet 4', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
if N == 5: check('variant packet 5', solve(*[[0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15, 0, 1, 7, 8, 14, 15], 4, True]), [[0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0, 0, 1, 7, -7, -1, 0], [False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A caller-requested zero canonicalization policy is ignored.

Decode bounded ones-complement PCM fields; optionally preserve a per-sample negative-zero sideband while numeric zero stays JSON integer zero.

split: open-access


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

N = 1
observations = []
def solve(codes, width, invert_sign):
    mask=(1<<(width-1))-1
    sign=1<<(width-1)
    values=[]
    zeros=[]
    for code in codes:
        magnitude=code
        negative=bool(code&sign)^invert_sign
        values.append(-magnitude if negative else magnitude)
        zeros.append(bool(negative and magnitude==0))
    return [values,zeros]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, 7, 8, 9, 15], 4, False)), [[0, 1, 7, 0, -1, -7], [False, False, False, True, False, False]])
check('oracle 2', solve(*([0, 8, 1, 9], 4, True)), [[0, 0, -1, 1], [True, False, False, False]])
check('oracle 3', solve(*([], 4, False)), [[], []])
check('oracle 4', solve(*([0, 3, 4, 7], 3, False)), [[0, 3, 0, -3], [False, False, True, False]])
check('oracle 5', solve(*([0, 128, 255, 127], 8, False)), [[0, 0, -127, 127], [False, True, False, False]])
check('oracle 6', solve(*([1, 2, 3], 4, True)), [[-1, -2, -3], [False, False, False]])
check('oracle 7', solve(*([0, 4], 3, True)), [[0, 0], [True, False]])
if N == 1: check('variant packet 1', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 2: check('variant packet 2', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 3: check('variant packet 3', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 4: check('variant packet 4', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 5: check('variant packet 5', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(codes, width, invert_sign):
    mask=(1<<(width-1))-1
    sign=1<<(width-1)
    values=[]
    zeros=[]
    for code in codes:
        magnitude=code>>1
        negative=bool(code&sign)^invert_sign
        values.append(-magnitude if negative else magnitude)
        zeros.append(bool(negative and magnitude==0))
    return [values,zeros]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, 7, 8, 9, 15], 4, False)), [[0, 1, 7, 0, -1, -7], [False, False, False, True, False, False]])
check('oracle 2', solve(*([0, 8, 1, 9], 4, True)), [[0, 0, -1, 1], [True, False, False, False]])
check('oracle 3', solve(*([], 4, False)), [[], []])
check('oracle 4', solve(*([0, 3, 4, 7], 3, False)), [[0, 3, 0, -3], [False, False, True, False]])
check('oracle 5', solve(*([0, 128, 255, 127], 8, False)), [[0, 0, -127, 127], [False, True, False, False]])
check('oracle 6', solve(*([1, 2, 3], 4, True)), [[-1, -2, -3], [False, False, False]])
check('oracle 7', solve(*([0, 4], 3, True)), [[0, 0], [True, False]])
if N == 1: check('variant packet 1', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 2: check('variant packet 2', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 3: check('variant packet 3', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 4: check('variant packet 4', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 5: check('variant packet 5', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Sign bit is included in magnitude.

Decode sign-magnitude PCM with configurable physical sign-bit polarity and preserve numerical negative zero as a Boolean sideband.

split: open-access


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

N = 1
observations = []
def solve(codes, width, invert_sign):
    mask=(1<<(width-1))-1
    sign=1<<(width-1)
    values=[]
    zeros=[]
    for code in codes:
        magnitude=code&mask
        negative=bool(code&sign)
        values.append(-magnitude if negative else magnitude)
        zeros.append(bool(negative and magnitude==0))
    return [values,zeros]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, 7, 8, 9, 15], 4, False)), [[0, 1, 7, 0, -1, -7], [False, False, False, True, False, False]])
check('oracle 2', solve(*([0, 8, 1, 9], 4, True)), [[0, 0, -1, 1], [True, False, False, False]])
check('oracle 3', solve(*([], 4, False)), [[], []])
check('oracle 4', solve(*([0, 3, 4, 7], 3, False)), [[0, 3, 0, -3], [False, False, True, False]])
check('oracle 5', solve(*([0, 128, 255, 127], 8, False)), [[0, 0, -127, 127], [False, True, False, False]])
check('oracle 6', solve(*([1, 2, 3], 4, True)), [[-1, -2, -3], [False, False, False]])
check('oracle 7', solve(*([0, 4], 3, True)), [[0, 0], [True, False]])
if N == 1: check('variant packet 1', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 2: check('variant packet 2', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 3: check('variant packet 3', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 4: check('variant packet 4', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 5: check('variant packet 5', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(codes, width, invert_sign):
    mask=(1<<(width-1))-1
    sign=1<<(width-1)
    values=[]
    zeros=[]
    for code in codes:
        magnitude=code&mask
        negative=bool(code&sign) or invert_sign
        values.append(-magnitude if negative else magnitude)
        zeros.append(bool(negative and magnitude==0))
    return [values,zeros]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, 7, 8, 9, 15], 4, False)), [[0, 1, 7, 0, -1, -7], [False, False, False, True, False, False]])
check('oracle 2', solve(*([0, 8, 1, 9], 4, True)), [[0, 0, -1, 1], [True, False, False, False]])
check('oracle 3', solve(*([], 4, False)), [[], []])
check('oracle 4', solve(*([0, 3, 4, 7], 3, False)), [[0, 3, 0, -3], [False, False, True, False]])
check('oracle 5', solve(*([0, 128, 255, 127], 8, False)), [[0, 0, -127, 127], [False, True, False, False]])
check('oracle 6', solve(*([1, 2, 3], 4, True)), [[-1, -2, -3], [False, False, False]])
check('oracle 7', solve(*([0, 4], 3, True)), [[0, 0], [True, False]])
if N == 1: check('variant packet 1', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 2: check('variant packet 2', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 3: check('variant packet 3', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 4: check('variant packet 4', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 5: check('variant packet 5', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Configured sign polarity is ignored for a sign-magnitude stream.

Decode sign-magnitude PCM with configurable physical sign-bit polarity and preserve numerical negative zero as a Boolean sideband.

split: open-access


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

N = 1
observations = []
def solve(codes, width, invert_sign):
    mask=(1<<(width-1))-1
    sign=1<<(width-1)
    values=[]
    zeros=[]
    for code in codes:
        magnitude=code&mask
        negative=bool(code&sign)^invert_sign
        values.append(magnitude-(1<<width) if negative else magnitude)
        zeros.append(bool(negative and magnitude==0))
    return [values,zeros]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, 7, 8, 9, 15], 4, False)), [[0, 1, 7, 0, -1, -7], [False, False, False, True, False, False]])
check('oracle 2', solve(*([0, 8, 1, 9], 4, True)), [[0, 0, -1, 1], [True, False, False, False]])
check('oracle 3', solve(*([], 4, False)), [[], []])
check('oracle 4', solve(*([0, 3, 4, 7], 3, False)), [[0, 3, 0, -3], [False, False, True, False]])
check('oracle 5', solve(*([0, 128, 255, 127], 8, False)), [[0, 0, -127, 127], [False, True, False, False]])
check('oracle 6', solve(*([1, 2, 3], 4, True)), [[-1, -2, -3], [False, False, False]])
check('oracle 7', solve(*([0, 4], 3, True)), [[0, 0], [True, False]])
if N == 1: check('variant packet 1', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 2: check('variant packet 2', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 3: check('variant packet 3', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 4: check('variant packet 4', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 5: check('variant packet 5', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(codes, width, invert_sign):
    mask=(1<<(width-1))-1
    sign=1<<(width-1)
    values=[]
    zeros=[]
    for code in codes:
        magnitude=code&mask
        negative=bool(code&sign)^invert_sign
        values.append(-magnitude-1 if negative else magnitude)
        zeros.append(bool(negative and magnitude==0))
    return [values,zeros]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, 7, 8, 9, 15], 4, False)), [[0, 1, 7, 0, -1, -7], [False, False, False, True, False, False]])
check('oracle 2', solve(*([0, 8, 1, 9], 4, True)), [[0, 0, -1, 1], [True, False, False, False]])
check('oracle 3', solve(*([], 4, False)), [[], []])
check('oracle 4', solve(*([0, 3, 4, 7], 3, False)), [[0, 3, 0, -3], [False, False, True, False]])
check('oracle 5', solve(*([0, 128, 255, 127], 8, False)), [[0, 0, -127, 127], [False, True, False, False]])
check('oracle 6', solve(*([1, 2, 3], 4, True)), [[-1, -2, -3], [False, False, False]])
check('oracle 7', solve(*([0, 4], 3, True)), [[0, 0], [True, False]])
if N == 1: check('variant packet 1', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 2: check('variant packet 2', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 3: check('variant packet 3', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 4: check('variant packet 4', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
if N == 5: check('variant packet 5', solve(*[[0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15, 0, 1, 7, 8, 9, 15], 4, False]), [[0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7, 0, 1, 7, 0, -1, -7], [False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, False]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Sign-magnitude negatives are decoded as complement negatives.

Decode sign-magnitude PCM with configurable physical sign-bit polarity and preserve numerical negative zero as a Boolean sideband.

split: open-access