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

N = 1
observations = []
def solve(d):
    try:
        groups,low,high=d
        out=[]
        for ident,minimum,maximum,nulls,count in groups:
            if count>0 and nulls==count: continue
            if minimum is not None and minimum>high: continue
            if maximum is not None and maximum<low: continue
            out.append(ident)
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('inclusive low', solve([[[1, -1, 1, 0, 3]], 1, 3]), [1])
    check('inclusive high', solve([[[1, 3, 5, 0, 3]], 1, 3]), [1])
    check('missing minimum', solve([[[1, None, 3, 0, 3]], 1, 3]), [1])
    check('missing maximum', solve([[[1, 1, None, 0, 3]], 1, 3]), [1])
    check('null only', solve([[[1, None, None, 3, 3]], 1, 3]), [])
    check('empty group', solve([[[1, None, None, 0, 0]], 1, 3]), [])
    check('disjoint bounds', solve([[[1, -3, 0, 0, 3], [2, 4, 6, 0, 3]], 1, 3]), [])
elif N == 2:
    check('inclusive low', solve([[[1, 0, 2, 0, 3]], 2, 4]), [1])
    check('inclusive high', solve([[[1, 4, 6, 0, 3]], 2, 4]), [1])
    check('missing minimum', solve([[[1, None, 4, 0, 3]], 2, 4]), [1])
    check('missing maximum', solve([[[1, 2, None, 0, 3]], 2, 4]), [1])
    check('null only', solve([[[1, None, None, 3, 3]], 2, 4]), [])
    check('empty group', solve([[[1, None, None, 0, 0]], 2, 4]), [])
    check('disjoint bounds', solve([[[1, -2, 1, 0, 3], [2, 5, 7, 0, 3]], 2, 4]), [])
elif N == 3:
    check('inclusive low', solve([[[1, 1, 3, 0, 3]], 3, 5]), [1])
    check('inclusive high', solve([[[1, 5, 7, 0, 3]], 3, 5]), [1])
    check('missing minimum', solve([[[1, None, 5, 0, 3]], 3, 5]), [1])
    check('missing maximum', solve([[[1, 3, None, 0, 3]], 3, 5]), [1])
    check('null only', solve([[[1, None, None, 3, 3]], 3, 5]), [])
    check('empty group', solve([[[1, None, None, 0, 0]], 3, 5]), [])
    check('disjoint bounds', solve([[[1, -1, 2, 0, 3], [2, 6, 8, 0, 3]], 3, 5]), [])
elif N == 4:
    check('inclusive low', solve([[[1, 2, 4, 0, 3]], 4, 6]), [1])
    check('inclusive high', solve([[[1, 6, 8, 0, 3]], 4, 6]), [1])
    check('missing minimum', solve([[[1, None, 6, 0, 3]], 4, 6]), [1])
    check('missing maximum', solve([[[1, 4, None, 0, 3]], 4, 6]), [1])
    check('null only', solve([[[1, None, None, 3, 3]], 4, 6]), [])
    check('empty group', solve([[[1, None, None, 0, 0]], 4, 6]), [])
    check('disjoint bounds', solve([[[1, 0, 3, 0, 3], [2, 7, 9, 0, 3]], 4, 6]), [])
elif N == 5:
    check('inclusive low', solve([[[1, 3, 5, 0, 3]], 5, 7]), [1])
    check('inclusive high', solve([[[1, 7, 9, 0, 3]], 5, 7]), [1])
    check('missing minimum', solve([[[1, None, 7, 0, 3]], 5, 7]), [1])
    check('missing maximum', solve([[[1, 5, None, 0, 3]], 5, 7]), [1])
    check('null only', solve([[[1, None, None, 3, 3]], 5, 7]), [])
    check('empty group', solve([[[1, None, None, 0, 0]], 5, 7]), [])
    check('disjoint bounds', solve([[[1, 1, 4, 0, 3], [2, 8, 10, 0, 3]], 5, 7]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        groups,low,high=d
        out=[]
        for ident,minimum,maximum,nulls,count in groups:
            if count<0: continue
            if count>0 and nulls==count: continue
            if minimum is not None and minimum>high: continue
            if maximum is not None and maximum<low: continue
            out.append(ident)
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('inclusive low', solve([[[1, -1, 1, 0, 3]], 1, 3]), [1])
    check('inclusive high', solve([[[1, 3, 5, 0, 3]], 1, 3]), [1])
    check('missing minimum', solve([[[1, None, 3, 0, 3]], 1, 3]), [1])
    check('missing maximum', solve([[[1, 1, None, 0, 3]], 1, 3]), [1])
    check('null only', solve([[[1, None, None, 3, 3]], 1, 3]), [])
    check('empty group', solve([[[1, None, None, 0, 0]], 1, 3]), [])
    check('disjoint bounds', solve([[[1, -3, 0, 0, 3], [2, 4, 6, 0, 3]], 1, 3]), [])
elif N == 2:
    check('inclusive low', solve([[[1, 0, 2, 0, 3]], 2, 4]), [1])
    check('inclusive high', solve([[[1, 4, 6, 0, 3]], 2, 4]), [1])
    check('missing minimum', solve([[[1, None, 4, 0, 3]], 2, 4]), [1])
    check('missing maximum', solve([[[1, 2, None, 0, 3]], 2, 4]), [1])
    check('null only', solve([[[1, None, None, 3, 3]], 2, 4]), [])
    check('empty group', solve([[[1, None, None, 0, 0]], 2, 4]), [])
    check('disjoint bounds', solve([[[1, -2, 1, 0, 3], [2, 5, 7, 0, 3]], 2, 4]), [])
elif N == 3:
    check('inclusive low', solve([[[1, 1, 3, 0, 3]], 3, 5]), [1])
    check('inclusive high', solve([[[1, 5, 7, 0, 3]], 3, 5]), [1])
    check('missing minimum', solve([[[1, None, 5, 0, 3]], 3, 5]), [1])
    check('missing maximum', solve([[[1, 3, None, 0, 3]], 3, 5]), [1])
    check('null only', solve([[[1, None, None, 3, 3]], 3, 5]), [])
    check('empty group', solve([[[1, None, None, 0, 0]], 3, 5]), [])
    check('disjoint bounds', solve([[[1, -1, 2, 0, 3], [2, 6, 8, 0, 3]], 3, 5]), [])
elif N == 4:
    check('inclusive low', solve([[[1, 2, 4, 0, 3]], 4, 6]), [1])
    check('inclusive high', solve([[[1, 6, 8, 0, 3]], 4, 6]), [1])
    check('missing minimum', solve([[[1, None, 6, 0, 3]], 4, 6]), [1])
    check('missing maximum', solve([[[1, 4, None, 0, 3]], 4, 6]), [1])
    check('null only', solve([[[1, None, None, 3, 3]], 4, 6]), [])
    check('empty group', solve([[[1, None, None, 0, 0]], 4, 6]), [])
    check('disjoint bounds', solve([[[1, 0, 3, 0, 3], [2, 7, 9, 0, 3]], 4, 6]), [])
elif N == 5:
    check('inclusive low', solve([[[1, 3, 5, 0, 3]], 5, 7]), [1])
    check('inclusive high', solve([[[1, 7, 9, 0, 3]], 5, 7]), [1])
    check('missing minimum', solve([[[1, None, 7, 0, 3]], 5, 7]), [1])
    check('missing maximum', solve([[[1, 5, None, 0, 3]], 5, 7]), [1])
    check('null only', solve([[[1, None, None, 3, 3]], 5, 7]), [])
    check('empty group', solve([[[1, None, None, 0, 0]], 5, 7]), [])
    check('disjoint bounds', solve([[[1, 1, 4, 0, 3], [2, 8, 10, 0, 3]], 5, 7]), [])
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:
Row-group pruning reports physically empty groups as scan candidates.

Choose row groups that may satisfy an inclusive equality/range scan. Metadata [id,min,max,null_count,row_count] describes known integer values; unknown min/max cannot prove exclusion. Null-only and empty groups cannot satisfy a non-null range. Return candidate IDs without claiming every candidate contains a match.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        fragments,deletes=d
        tombstones=set(tuple(x) for x in deletes)
        out=[]
        for file,base,values in fragments:
            for local,value in enumerate(values):
                position=base+local
                if any(p==position for f,p in tombstones): continue
                out.append([file,position,value])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('file scope', solve([[['b', 0, [1]], ['a', 0, [2]]], [['a', 0]]]), [['b', 0, 1]])
    check('fragment origin', solve([[['a', 5, [1, 2]]], [['a', 5]]]), [['a', 6, 2]])
    check('physical holes', solve([[['a', 0, [1, 2, 3]]], [['a', 0], ['a', 2]]]), [['a', 1, 2]])
    check('repeated tombstone', solve([[['a', 0, [1]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 1]]], []]), [['a', 0, None], ['a', 1, 1]])
    check('fragment order', solve([[['b', 0, [1]], ['a', 0, [2]]], []]), [['b', 0, 1], ['a', 0, 2]])
    check('empty input', solve([[], []]), [])
elif N == 2:
    check('file scope', solve([[['b', 0, [2]], ['a', 0, [3]]], [['a', 0]]]), [['b', 0, 2]])
    check('fragment origin', solve([[['a', 5, [2, 3]]], [['a', 5]]]), [['a', 6, 3]])
    check('physical holes', solve([[['a', 0, [2, 3, 4]]], [['a', 0], ['a', 2]]]), [['a', 1, 3]])
    check('repeated tombstone', solve([[['a', 0, [2]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 2]]], []]), [['a', 0, None], ['a', 1, 2]])
    check('fragment order', solve([[['b', 0, [2]], ['a', 0, [3]]], []]), [['b', 0, 2], ['a', 0, 3]])
    check('empty input', solve([[], []]), [])
elif N == 3:
    check('file scope', solve([[['b', 0, [3]], ['a', 0, [4]]], [['a', 0]]]), [['b', 0, 3]])
    check('fragment origin', solve([[['a', 5, [3, 4]]], [['a', 5]]]), [['a', 6, 4]])
    check('physical holes', solve([[['a', 0, [3, 4, 5]]], [['a', 0], ['a', 2]]]), [['a', 1, 4]])
    check('repeated tombstone', solve([[['a', 0, [3]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 3]]], []]), [['a', 0, None], ['a', 1, 3]])
    check('fragment order', solve([[['b', 0, [3]], ['a', 0, [4]]], []]), [['b', 0, 3], ['a', 0, 4]])
    check('empty input', solve([[], []]), [])
elif N == 4:
    check('file scope', solve([[['b', 0, [4]], ['a', 0, [5]]], [['a', 0]]]), [['b', 0, 4]])
    check('fragment origin', solve([[['a', 5, [4, 5]]], [['a', 5]]]), [['a', 6, 5]])
    check('physical holes', solve([[['a', 0, [4, 5, 6]]], [['a', 0], ['a', 2]]]), [['a', 1, 5]])
    check('repeated tombstone', solve([[['a', 0, [4]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 4]]], []]), [['a', 0, None], ['a', 1, 4]])
    check('fragment order', solve([[['b', 0, [4]], ['a', 0, [5]]], []]), [['b', 0, 4], ['a', 0, 5]])
    check('empty input', solve([[], []]), [])
elif N == 5:
    check('file scope', solve([[['b', 0, [5]], ['a', 0, [6]]], [['a', 0]]]), [['b', 0, 5]])
    check('fragment origin', solve([[['a', 5, [5, 6]]], [['a', 5]]]), [['a', 6, 6]])
    check('physical holes', solve([[['a', 0, [5, 6, 7]]], [['a', 0], ['a', 2]]]), [['a', 1, 6]])
    check('repeated tombstone', solve([[['a', 0, [5]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 5]]], []]), [['a', 0, None], ['a', 1, 5]])
    check('fragment order', solve([[['b', 0, [5]], ['a', 0, [6]]], []]), [['b', 0, 5], ['a', 0, 6]])
    check('empty input', solve([[], []]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(d):
    try:
        fragments,deletes=d
        tombstones=set(tuple(x) for x in deletes)
        out=[]
        for file,base,values in fragments:
            for local,value in enumerate(values):
                position=base+local
                if any(f==file or p==position for f,p in tombstones): continue
                out.append([file,position,value])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('file scope', solve([[['b', 0, [1]], ['a', 0, [2]]], [['a', 0]]]), [['b', 0, 1]])
    check('fragment origin', solve([[['a', 5, [1, 2]]], [['a', 5]]]), [['a', 6, 2]])
    check('physical holes', solve([[['a', 0, [1, 2, 3]]], [['a', 0], ['a', 2]]]), [['a', 1, 2]])
    check('repeated tombstone', solve([[['a', 0, [1]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 1]]], []]), [['a', 0, None], ['a', 1, 1]])
    check('fragment order', solve([[['b', 0, [1]], ['a', 0, [2]]], []]), [['b', 0, 1], ['a', 0, 2]])
    check('empty input', solve([[], []]), [])
elif N == 2:
    check('file scope', solve([[['b', 0, [2]], ['a', 0, [3]]], [['a', 0]]]), [['b', 0, 2]])
    check('fragment origin', solve([[['a', 5, [2, 3]]], [['a', 5]]]), [['a', 6, 3]])
    check('physical holes', solve([[['a', 0, [2, 3, 4]]], [['a', 0], ['a', 2]]]), [['a', 1, 3]])
    check('repeated tombstone', solve([[['a', 0, [2]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 2]]], []]), [['a', 0, None], ['a', 1, 2]])
    check('fragment order', solve([[['b', 0, [2]], ['a', 0, [3]]], []]), [['b', 0, 2], ['a', 0, 3]])
    check('empty input', solve([[], []]), [])
elif N == 3:
    check('file scope', solve([[['b', 0, [3]], ['a', 0, [4]]], [['a', 0]]]), [['b', 0, 3]])
    check('fragment origin', solve([[['a', 5, [3, 4]]], [['a', 5]]]), [['a', 6, 4]])
    check('physical holes', solve([[['a', 0, [3, 4, 5]]], [['a', 0], ['a', 2]]]), [['a', 1, 4]])
    check('repeated tombstone', solve([[['a', 0, [3]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 3]]], []]), [['a', 0, None], ['a', 1, 3]])
    check('fragment order', solve([[['b', 0, [3]], ['a', 0, [4]]], []]), [['b', 0, 3], ['a', 0, 4]])
    check('empty input', solve([[], []]), [])
elif N == 4:
    check('file scope', solve([[['b', 0, [4]], ['a', 0, [5]]], [['a', 0]]]), [['b', 0, 4]])
    check('fragment origin', solve([[['a', 5, [4, 5]]], [['a', 5]]]), [['a', 6, 5]])
    check('physical holes', solve([[['a', 0, [4, 5, 6]]], [['a', 0], ['a', 2]]]), [['a', 1, 5]])
    check('repeated tombstone', solve([[['a', 0, [4]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 4]]], []]), [['a', 0, None], ['a', 1, 4]])
    check('fragment order', solve([[['b', 0, [4]], ['a', 0, [5]]], []]), [['b', 0, 4], ['a', 0, 5]])
    check('empty input', solve([[], []]), [])
elif N == 5:
    check('file scope', solve([[['b', 0, [5]], ['a', 0, [6]]], [['a', 0]]]), [['b', 0, 5]])
    check('fragment origin', solve([[['a', 5, [5, 6]]], [['a', 5]]]), [['a', 6, 6]])
    check('physical holes', solve([[['a', 0, [5, 6, 7]]], [['a', 0], ['a', 2]]]), [['a', 1, 6]])
    check('repeated tombstone', solve([[['a', 0, [5]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 5]]], []]), [['a', 0, None], ['a', 1, 5]])
    check('fragment order', solve([[['b', 0, [5]], ['a', 0, [6]]], []]), [['b', 0, 5], ['a', 0, 6]])
    check('empty input', solve([[], []]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Position deletes erase the same row ordinal in unrelated files.

Scan fragments [file-id,base-row-position,values] applying position-delete pairs [file-id,absolute-row-position]. Deletions are file-scoped and use physical positions before filtering. Return [file-id,absolute-position,value] for surviving rows, including null values.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        fragments,deletes=d
        tombstones=set(tuple(x) for x in deletes)
        out=[]
        for file,base,values in fragments:
            for local,value in enumerate(values):
                position=local
                if (file,position) in tombstones: continue
                out.append([file,position,value])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('file scope', solve([[['b', 0, [1]], ['a', 0, [2]]], [['a', 0]]]), [['b', 0, 1]])
    check('fragment origin', solve([[['a', 5, [1, 2]]], [['a', 5]]]), [['a', 6, 2]])
    check('physical holes', solve([[['a', 0, [1, 2, 3]]], [['a', 0], ['a', 2]]]), [['a', 1, 2]])
    check('repeated tombstone', solve([[['a', 0, [1]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 1]]], []]), [['a', 0, None], ['a', 1, 1]])
    check('fragment order', solve([[['b', 0, [1]], ['a', 0, [2]]], []]), [['b', 0, 1], ['a', 0, 2]])
    check('empty input', solve([[], []]), [])
elif N == 2:
    check('file scope', solve([[['b', 0, [2]], ['a', 0, [3]]], [['a', 0]]]), [['b', 0, 2]])
    check('fragment origin', solve([[['a', 5, [2, 3]]], [['a', 5]]]), [['a', 6, 3]])
    check('physical holes', solve([[['a', 0, [2, 3, 4]]], [['a', 0], ['a', 2]]]), [['a', 1, 3]])
    check('repeated tombstone', solve([[['a', 0, [2]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 2]]], []]), [['a', 0, None], ['a', 1, 2]])
    check('fragment order', solve([[['b', 0, [2]], ['a', 0, [3]]], []]), [['b', 0, 2], ['a', 0, 3]])
    check('empty input', solve([[], []]), [])
elif N == 3:
    check('file scope', solve([[['b', 0, [3]], ['a', 0, [4]]], [['a', 0]]]), [['b', 0, 3]])
    check('fragment origin', solve([[['a', 5, [3, 4]]], [['a', 5]]]), [['a', 6, 4]])
    check('physical holes', solve([[['a', 0, [3, 4, 5]]], [['a', 0], ['a', 2]]]), [['a', 1, 4]])
    check('repeated tombstone', solve([[['a', 0, [3]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 3]]], []]), [['a', 0, None], ['a', 1, 3]])
    check('fragment order', solve([[['b', 0, [3]], ['a', 0, [4]]], []]), [['b', 0, 3], ['a', 0, 4]])
    check('empty input', solve([[], []]), [])
elif N == 4:
    check('file scope', solve([[['b', 0, [4]], ['a', 0, [5]]], [['a', 0]]]), [['b', 0, 4]])
    check('fragment origin', solve([[['a', 5, [4, 5]]], [['a', 5]]]), [['a', 6, 5]])
    check('physical holes', solve([[['a', 0, [4, 5, 6]]], [['a', 0], ['a', 2]]]), [['a', 1, 5]])
    check('repeated tombstone', solve([[['a', 0, [4]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 4]]], []]), [['a', 0, None], ['a', 1, 4]])
    check('fragment order', solve([[['b', 0, [4]], ['a', 0, [5]]], []]), [['b', 0, 4], ['a', 0, 5]])
    check('empty input', solve([[], []]), [])
elif N == 5:
    check('file scope', solve([[['b', 0, [5]], ['a', 0, [6]]], [['a', 0]]]), [['b', 0, 5]])
    check('fragment origin', solve([[['a', 5, [5, 6]]], [['a', 5]]]), [['a', 6, 6]])
    check('physical holes', solve([[['a', 0, [5, 6, 7]]], [['a', 0], ['a', 2]]]), [['a', 1, 6]])
    check('repeated tombstone', solve([[['a', 0, [5]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 5]]], []]), [['a', 0, None], ['a', 1, 5]])
    check('fragment order', solve([[['b', 0, [5]], ['a', 0, [6]]], []]), [['b', 0, 5], ['a', 0, 6]])
    check('empty input', solve([[], []]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        fragments,deletes=d
        tombstones=set(tuple(x) for x in deletes)
        out=[]
        for file,base,values in fragments:
            for local,value in enumerate(values):
                position=base+len(out)
                if (file,position) in tombstones: continue
                out.append([file,position,value])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('file scope', solve([[['b', 0, [1]], ['a', 0, [2]]], [['a', 0]]]), [['b', 0, 1]])
    check('fragment origin', solve([[['a', 5, [1, 2]]], [['a', 5]]]), [['a', 6, 2]])
    check('physical holes', solve([[['a', 0, [1, 2, 3]]], [['a', 0], ['a', 2]]]), [['a', 1, 2]])
    check('repeated tombstone', solve([[['a', 0, [1]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 1]]], []]), [['a', 0, None], ['a', 1, 1]])
    check('fragment order', solve([[['b', 0, [1]], ['a', 0, [2]]], []]), [['b', 0, 1], ['a', 0, 2]])
    check('empty input', solve([[], []]), [])
elif N == 2:
    check('file scope', solve([[['b', 0, [2]], ['a', 0, [3]]], [['a', 0]]]), [['b', 0, 2]])
    check('fragment origin', solve([[['a', 5, [2, 3]]], [['a', 5]]]), [['a', 6, 3]])
    check('physical holes', solve([[['a', 0, [2, 3, 4]]], [['a', 0], ['a', 2]]]), [['a', 1, 3]])
    check('repeated tombstone', solve([[['a', 0, [2]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 2]]], []]), [['a', 0, None], ['a', 1, 2]])
    check('fragment order', solve([[['b', 0, [2]], ['a', 0, [3]]], []]), [['b', 0, 2], ['a', 0, 3]])
    check('empty input', solve([[], []]), [])
elif N == 3:
    check('file scope', solve([[['b', 0, [3]], ['a', 0, [4]]], [['a', 0]]]), [['b', 0, 3]])
    check('fragment origin', solve([[['a', 5, [3, 4]]], [['a', 5]]]), [['a', 6, 4]])
    check('physical holes', solve([[['a', 0, [3, 4, 5]]], [['a', 0], ['a', 2]]]), [['a', 1, 4]])
    check('repeated tombstone', solve([[['a', 0, [3]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 3]]], []]), [['a', 0, None], ['a', 1, 3]])
    check('fragment order', solve([[['b', 0, [3]], ['a', 0, [4]]], []]), [['b', 0, 3], ['a', 0, 4]])
    check('empty input', solve([[], []]), [])
elif N == 4:
    check('file scope', solve([[['b', 0, [4]], ['a', 0, [5]]], [['a', 0]]]), [['b', 0, 4]])
    check('fragment origin', solve([[['a', 5, [4, 5]]], [['a', 5]]]), [['a', 6, 5]])
    check('physical holes', solve([[['a', 0, [4, 5, 6]]], [['a', 0], ['a', 2]]]), [['a', 1, 5]])
    check('repeated tombstone', solve([[['a', 0, [4]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 4]]], []]), [['a', 0, None], ['a', 1, 4]])
    check('fragment order', solve([[['b', 0, [4]], ['a', 0, [5]]], []]), [['b', 0, 4], ['a', 0, 5]])
    check('empty input', solve([[], []]), [])
elif N == 5:
    check('file scope', solve([[['b', 0, [5]], ['a', 0, [6]]], [['a', 0]]]), [['b', 0, 5]])
    check('fragment origin', solve([[['a', 5, [5, 6]]], [['a', 5]]]), [['a', 6, 6]])
    check('physical holes', solve([[['a', 0, [5, 6, 7]]], [['a', 0], ['a', 2]]]), [['a', 1, 6]])
    check('repeated tombstone', solve([[['a', 0, [5]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 5]]], []]), [['a', 0, None], ['a', 1, 5]])
    check('fragment order', solve([[['b', 0, [5]], ['a', 0, [6]]], []]), [['b', 0, 5], ['a', 0, 6]])
    check('empty input', solve([[], []]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Position deletes use fragment-local row positions.

Scan fragments [file-id,base-row-position,values] applying position-delete pairs [file-id,absolute-row-position]. Deletions are file-scoped and use physical positions before filtering. Return [file-id,absolute-position,value] for surviving rows, including null values.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        fragments,deletes=d
        tombstones=set(tuple(x) for x in deletes)
        out=[]
        for file,base,values in fragments:
            for local,value in enumerate(values):
                position=base+sum(r[0]==file for r in out)
                if (file,position) in tombstones: continue
                out.append([file,position,value])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('file scope', solve([[['b', 0, [1]], ['a', 0, [2]]], [['a', 0]]]), [['b', 0, 1]])
    check('fragment origin', solve([[['a', 5, [1, 2]]], [['a', 5]]]), [['a', 6, 2]])
    check('physical holes', solve([[['a', 0, [1, 2, 3]]], [['a', 0], ['a', 2]]]), [['a', 1, 2]])
    check('repeated tombstone', solve([[['a', 0, [1]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 1]]], []]), [['a', 0, None], ['a', 1, 1]])
    check('fragment order', solve([[['b', 0, [1]], ['a', 0, [2]]], []]), [['b', 0, 1], ['a', 0, 2]])
    check('empty input', solve([[], []]), [])
elif N == 2:
    check('file scope', solve([[['b', 0, [2]], ['a', 0, [3]]], [['a', 0]]]), [['b', 0, 2]])
    check('fragment origin', solve([[['a', 5, [2, 3]]], [['a', 5]]]), [['a', 6, 3]])
    check('physical holes', solve([[['a', 0, [2, 3, 4]]], [['a', 0], ['a', 2]]]), [['a', 1, 3]])
    check('repeated tombstone', solve([[['a', 0, [2]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 2]]], []]), [['a', 0, None], ['a', 1, 2]])
    check('fragment order', solve([[['b', 0, [2]], ['a', 0, [3]]], []]), [['b', 0, 2], ['a', 0, 3]])
    check('empty input', solve([[], []]), [])
elif N == 3:
    check('file scope', solve([[['b', 0, [3]], ['a', 0, [4]]], [['a', 0]]]), [['b', 0, 3]])
    check('fragment origin', solve([[['a', 5, [3, 4]]], [['a', 5]]]), [['a', 6, 4]])
    check('physical holes', solve([[['a', 0, [3, 4, 5]]], [['a', 0], ['a', 2]]]), [['a', 1, 4]])
    check('repeated tombstone', solve([[['a', 0, [3]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 3]]], []]), [['a', 0, None], ['a', 1, 3]])
    check('fragment order', solve([[['b', 0, [3]], ['a', 0, [4]]], []]), [['b', 0, 3], ['a', 0, 4]])
    check('empty input', solve([[], []]), [])
elif N == 4:
    check('file scope', solve([[['b', 0, [4]], ['a', 0, [5]]], [['a', 0]]]), [['b', 0, 4]])
    check('fragment origin', solve([[['a', 5, [4, 5]]], [['a', 5]]]), [['a', 6, 5]])
    check('physical holes', solve([[['a', 0, [4, 5, 6]]], [['a', 0], ['a', 2]]]), [['a', 1, 5]])
    check('repeated tombstone', solve([[['a', 0, [4]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 4]]], []]), [['a', 0, None], ['a', 1, 4]])
    check('fragment order', solve([[['b', 0, [4]], ['a', 0, [5]]], []]), [['b', 0, 4], ['a', 0, 5]])
    check('empty input', solve([[], []]), [])
elif N == 5:
    check('file scope', solve([[['b', 0, [5]], ['a', 0, [6]]], [['a', 0]]]), [['b', 0, 5]])
    check('fragment origin', solve([[['a', 5, [5, 6]]], [['a', 5]]]), [['a', 6, 6]])
    check('physical holes', solve([[['a', 0, [5, 6, 7]]], [['a', 0], ['a', 2]]]), [['a', 1, 6]])
    check('repeated tombstone', solve([[['a', 0, [5]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 5]]], []]), [['a', 0, None], ['a', 1, 5]])
    check('fragment order', solve([[['b', 0, [5]], ['a', 0, [6]]], []]), [['b', 0, 5], ['a', 0, 6]])
    check('empty input', solve([[], []]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        fragments,deletes=d
        tombstones=set(tuple(x) for x in deletes)
        out=[]
        for file,base,values in fragments:
            for local,value in enumerate(values):
                position=base+len([r for r in out if r[0]==file and r[1]>=base])
                if (file,position) in tombstones: continue
                out.append([file,position,value])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('file scope', solve([[['b', 0, [1]], ['a', 0, [2]]], [['a', 0]]]), [['b', 0, 1]])
    check('fragment origin', solve([[['a', 5, [1, 2]]], [['a', 5]]]), [['a', 6, 2]])
    check('physical holes', solve([[['a', 0, [1, 2, 3]]], [['a', 0], ['a', 2]]]), [['a', 1, 2]])
    check('repeated tombstone', solve([[['a', 0, [1]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 1]]], []]), [['a', 0, None], ['a', 1, 1]])
    check('fragment order', solve([[['b', 0, [1]], ['a', 0, [2]]], []]), [['b', 0, 1], ['a', 0, 2]])
    check('empty input', solve([[], []]), [])
elif N == 2:
    check('file scope', solve([[['b', 0, [2]], ['a', 0, [3]]], [['a', 0]]]), [['b', 0, 2]])
    check('fragment origin', solve([[['a', 5, [2, 3]]], [['a', 5]]]), [['a', 6, 3]])
    check('physical holes', solve([[['a', 0, [2, 3, 4]]], [['a', 0], ['a', 2]]]), [['a', 1, 3]])
    check('repeated tombstone', solve([[['a', 0, [2]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 2]]], []]), [['a', 0, None], ['a', 1, 2]])
    check('fragment order', solve([[['b', 0, [2]], ['a', 0, [3]]], []]), [['b', 0, 2], ['a', 0, 3]])
    check('empty input', solve([[], []]), [])
elif N == 3:
    check('file scope', solve([[['b', 0, [3]], ['a', 0, [4]]], [['a', 0]]]), [['b', 0, 3]])
    check('fragment origin', solve([[['a', 5, [3, 4]]], [['a', 5]]]), [['a', 6, 4]])
    check('physical holes', solve([[['a', 0, [3, 4, 5]]], [['a', 0], ['a', 2]]]), [['a', 1, 4]])
    check('repeated tombstone', solve([[['a', 0, [3]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 3]]], []]), [['a', 0, None], ['a', 1, 3]])
    check('fragment order', solve([[['b', 0, [3]], ['a', 0, [4]]], []]), [['b', 0, 3], ['a', 0, 4]])
    check('empty input', solve([[], []]), [])
elif N == 4:
    check('file scope', solve([[['b', 0, [4]], ['a', 0, [5]]], [['a', 0]]]), [['b', 0, 4]])
    check('fragment origin', solve([[['a', 5, [4, 5]]], [['a', 5]]]), [['a', 6, 5]])
    check('physical holes', solve([[['a', 0, [4, 5, 6]]], [['a', 0], ['a', 2]]]), [['a', 1, 5]])
    check('repeated tombstone', solve([[['a', 0, [4]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 4]]], []]), [['a', 0, None], ['a', 1, 4]])
    check('fragment order', solve([[['b', 0, [4]], ['a', 0, [5]]], []]), [['b', 0, 4], ['a', 0, 5]])
    check('empty input', solve([[], []]), [])
elif N == 5:
    check('file scope', solve([[['b', 0, [5]], ['a', 0, [6]]], [['a', 0]]]), [['b', 0, 5]])
    check('fragment origin', solve([[['a', 5, [5, 6]]], [['a', 5]]]), [['a', 6, 6]])
    check('physical holes', solve([[['a', 0, [5, 6, 7]]], [['a', 0], ['a', 2]]]), [['a', 1, 6]])
    check('repeated tombstone', solve([[['a', 0, [5]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 5]]], []]), [['a', 0, None], ['a', 1, 5]])
    check('fragment order', solve([[['b', 0, [5]], ['a', 0, [6]]], []]), [['b', 0, 5], ['a', 0, 6]])
    check('empty input', solve([[], []]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Position deletes number rows after previous deletions.

Scan fragments [file-id,base-row-position,values] applying position-delete pairs [file-id,absolute-row-position]. Deletions are file-scoped and use physical positions before filtering. Return [file-id,absolute-position,value] for surviving rows, including null values.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        fragments,deletes=d
        tombstones={tuple(x) for x in deletes if deletes.count(x)%2}
        out=[]
        for file,base,values in fragments:
            for local,value in enumerate(values):
                position=base+local
                if (file,position) in tombstones: continue
                out.append([file,position,value])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('file scope', solve([[['b', 0, [1]], ['a', 0, [2]]], [['a', 0]]]), [['b', 0, 1]])
    check('fragment origin', solve([[['a', 5, [1, 2]]], [['a', 5]]]), [['a', 6, 2]])
    check('physical holes', solve([[['a', 0, [1, 2, 3]]], [['a', 0], ['a', 2]]]), [['a', 1, 2]])
    check('repeated tombstone', solve([[['a', 0, [1]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 1]]], []]), [['a', 0, None], ['a', 1, 1]])
    check('fragment order', solve([[['b', 0, [1]], ['a', 0, [2]]], []]), [['b', 0, 1], ['a', 0, 2]])
    check('empty input', solve([[], []]), [])
elif N == 2:
    check('file scope', solve([[['b', 0, [2]], ['a', 0, [3]]], [['a', 0]]]), [['b', 0, 2]])
    check('fragment origin', solve([[['a', 5, [2, 3]]], [['a', 5]]]), [['a', 6, 3]])
    check('physical holes', solve([[['a', 0, [2, 3, 4]]], [['a', 0], ['a', 2]]]), [['a', 1, 3]])
    check('repeated tombstone', solve([[['a', 0, [2]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 2]]], []]), [['a', 0, None], ['a', 1, 2]])
    check('fragment order', solve([[['b', 0, [2]], ['a', 0, [3]]], []]), [['b', 0, 2], ['a', 0, 3]])
    check('empty input', solve([[], []]), [])
elif N == 3:
    check('file scope', solve([[['b', 0, [3]], ['a', 0, [4]]], [['a', 0]]]), [['b', 0, 3]])
    check('fragment origin', solve([[['a', 5, [3, 4]]], [['a', 5]]]), [['a', 6, 4]])
    check('physical holes', solve([[['a', 0, [3, 4, 5]]], [['a', 0], ['a', 2]]]), [['a', 1, 4]])
    check('repeated tombstone', solve([[['a', 0, [3]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 3]]], []]), [['a', 0, None], ['a', 1, 3]])
    check('fragment order', solve([[['b', 0, [3]], ['a', 0, [4]]], []]), [['b', 0, 3], ['a', 0, 4]])
    check('empty input', solve([[], []]), [])
elif N == 4:
    check('file scope', solve([[['b', 0, [4]], ['a', 0, [5]]], [['a', 0]]]), [['b', 0, 4]])
    check('fragment origin', solve([[['a', 5, [4, 5]]], [['a', 5]]]), [['a', 6, 5]])
    check('physical holes', solve([[['a', 0, [4, 5, 6]]], [['a', 0], ['a', 2]]]), [['a', 1, 5]])
    check('repeated tombstone', solve([[['a', 0, [4]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 4]]], []]), [['a', 0, None], ['a', 1, 4]])
    check('fragment order', solve([[['b', 0, [4]], ['a', 0, [5]]], []]), [['b', 0, 4], ['a', 0, 5]])
    check('empty input', solve([[], []]), [])
elif N == 5:
    check('file scope', solve([[['b', 0, [5]], ['a', 0, [6]]], [['a', 0]]]), [['b', 0, 5]])
    check('fragment origin', solve([[['a', 5, [5, 6]]], [['a', 5]]]), [['a', 6, 6]])
    check('physical holes', solve([[['a', 0, [5, 6, 7]]], [['a', 0], ['a', 2]]]), [['a', 1, 6]])
    check('repeated tombstone', solve([[['a', 0, [5]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 5]]], []]), [['a', 0, None], ['a', 1, 5]])
    check('fragment order', solve([[['b', 0, [5]], ['a', 0, [6]]], []]), [['b', 0, 5], ['a', 0, 6]])
    check('empty input', solve([[], []]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        fragments,deletes=d
        tombstones={tuple(x) for x in deletes if deletes.count(x)==1}
        out=[]
        for file,base,values in fragments:
            for local,value in enumerate(values):
                position=base+local
                if (file,position) in tombstones: continue
                out.append([file,position,value])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('file scope', solve([[['b', 0, [1]], ['a', 0, [2]]], [['a', 0]]]), [['b', 0, 1]])
    check('fragment origin', solve([[['a', 5, [1, 2]]], [['a', 5]]]), [['a', 6, 2]])
    check('physical holes', solve([[['a', 0, [1, 2, 3]]], [['a', 0], ['a', 2]]]), [['a', 1, 2]])
    check('repeated tombstone', solve([[['a', 0, [1]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 1]]], []]), [['a', 0, None], ['a', 1, 1]])
    check('fragment order', solve([[['b', 0, [1]], ['a', 0, [2]]], []]), [['b', 0, 1], ['a', 0, 2]])
    check('empty input', solve([[], []]), [])
elif N == 2:
    check('file scope', solve([[['b', 0, [2]], ['a', 0, [3]]], [['a', 0]]]), [['b', 0, 2]])
    check('fragment origin', solve([[['a', 5, [2, 3]]], [['a', 5]]]), [['a', 6, 3]])
    check('physical holes', solve([[['a', 0, [2, 3, 4]]], [['a', 0], ['a', 2]]]), [['a', 1, 3]])
    check('repeated tombstone', solve([[['a', 0, [2]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 2]]], []]), [['a', 0, None], ['a', 1, 2]])
    check('fragment order', solve([[['b', 0, [2]], ['a', 0, [3]]], []]), [['b', 0, 2], ['a', 0, 3]])
    check('empty input', solve([[], []]), [])
elif N == 3:
    check('file scope', solve([[['b', 0, [3]], ['a', 0, [4]]], [['a', 0]]]), [['b', 0, 3]])
    check('fragment origin', solve([[['a', 5, [3, 4]]], [['a', 5]]]), [['a', 6, 4]])
    check('physical holes', solve([[['a', 0, [3, 4, 5]]], [['a', 0], ['a', 2]]]), [['a', 1, 4]])
    check('repeated tombstone', solve([[['a', 0, [3]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 3]]], []]), [['a', 0, None], ['a', 1, 3]])
    check('fragment order', solve([[['b', 0, [3]], ['a', 0, [4]]], []]), [['b', 0, 3], ['a', 0, 4]])
    check('empty input', solve([[], []]), [])
elif N == 4:
    check('file scope', solve([[['b', 0, [4]], ['a', 0, [5]]], [['a', 0]]]), [['b', 0, 4]])
    check('fragment origin', solve([[['a', 5, [4, 5]]], [['a', 5]]]), [['a', 6, 5]])
    check('physical holes', solve([[['a', 0, [4, 5, 6]]], [['a', 0], ['a', 2]]]), [['a', 1, 5]])
    check('repeated tombstone', solve([[['a', 0, [4]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 4]]], []]), [['a', 0, None], ['a', 1, 4]])
    check('fragment order', solve([[['b', 0, [4]], ['a', 0, [5]]], []]), [['b', 0, 4], ['a', 0, 5]])
    check('empty input', solve([[], []]), [])
elif N == 5:
    check('file scope', solve([[['b', 0, [5]], ['a', 0, [6]]], [['a', 0]]]), [['b', 0, 5]])
    check('fragment origin', solve([[['a', 5, [5, 6]]], [['a', 5]]]), [['a', 6, 6]])
    check('physical holes', solve([[['a', 0, [5, 6, 7]]], [['a', 0], ['a', 2]]]), [['a', 1, 6]])
    check('repeated tombstone', solve([[['a', 0, [5]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 5]]], []]), [['a', 0, None], ['a', 1, 5]])
    check('fragment order', solve([[['b', 0, [5]], ['a', 0, [6]]], []]), [['b', 0, 5], ['a', 0, 6]])
    check('empty input', solve([[], []]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A repeated position-delete entry cancels itself.

Scan fragments [file-id,base-row-position,values] applying position-delete pairs [file-id,absolute-row-position]. Deletions are file-scoped and use physical positions before filtering. Return [file-id,absolute-position,value] for surviving rows, including null values.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        fragments,deletes=d
        tombstones=set(tuple(x) for x in deletes)
        out=[]
        for file,base,values in fragments:
            for local,value in enumerate(values):
                position=base+local
                if (file,position) in tombstones: continue
                if value is not None: out.append([file,position,value])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('file scope', solve([[['b', 0, [1]], ['a', 0, [2]]], [['a', 0]]]), [['b', 0, 1]])
    check('fragment origin', solve([[['a', 5, [1, 2]]], [['a', 5]]]), [['a', 6, 2]])
    check('physical holes', solve([[['a', 0, [1, 2, 3]]], [['a', 0], ['a', 2]]]), [['a', 1, 2]])
    check('repeated tombstone', solve([[['a', 0, [1]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 1]]], []]), [['a', 0, None], ['a', 1, 1]])
    check('fragment order', solve([[['b', 0, [1]], ['a', 0, [2]]], []]), [['b', 0, 1], ['a', 0, 2]])
    check('empty input', solve([[], []]), [])
elif N == 2:
    check('file scope', solve([[['b', 0, [2]], ['a', 0, [3]]], [['a', 0]]]), [['b', 0, 2]])
    check('fragment origin', solve([[['a', 5, [2, 3]]], [['a', 5]]]), [['a', 6, 3]])
    check('physical holes', solve([[['a', 0, [2, 3, 4]]], [['a', 0], ['a', 2]]]), [['a', 1, 3]])
    check('repeated tombstone', solve([[['a', 0, [2]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 2]]], []]), [['a', 0, None], ['a', 1, 2]])
    check('fragment order', solve([[['b', 0, [2]], ['a', 0, [3]]], []]), [['b', 0, 2], ['a', 0, 3]])
    check('empty input', solve([[], []]), [])
elif N == 3:
    check('file scope', solve([[['b', 0, [3]], ['a', 0, [4]]], [['a', 0]]]), [['b', 0, 3]])
    check('fragment origin', solve([[['a', 5, [3, 4]]], [['a', 5]]]), [['a', 6, 4]])
    check('physical holes', solve([[['a', 0, [3, 4, 5]]], [['a', 0], ['a', 2]]]), [['a', 1, 4]])
    check('repeated tombstone', solve([[['a', 0, [3]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 3]]], []]), [['a', 0, None], ['a', 1, 3]])
    check('fragment order', solve([[['b', 0, [3]], ['a', 0, [4]]], []]), [['b', 0, 3], ['a', 0, 4]])
    check('empty input', solve([[], []]), [])
elif N == 4:
    check('file scope', solve([[['b', 0, [4]], ['a', 0, [5]]], [['a', 0]]]), [['b', 0, 4]])
    check('fragment origin', solve([[['a', 5, [4, 5]]], [['a', 5]]]), [['a', 6, 5]])
    check('physical holes', solve([[['a', 0, [4, 5, 6]]], [['a', 0], ['a', 2]]]), [['a', 1, 5]])
    check('repeated tombstone', solve([[['a', 0, [4]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 4]]], []]), [['a', 0, None], ['a', 1, 4]])
    check('fragment order', solve([[['b', 0, [4]], ['a', 0, [5]]], []]), [['b', 0, 4], ['a', 0, 5]])
    check('empty input', solve([[], []]), [])
elif N == 5:
    check('file scope', solve([[['b', 0, [5]], ['a', 0, [6]]], [['a', 0]]]), [['b', 0, 5]])
    check('fragment origin', solve([[['a', 5, [5, 6]]], [['a', 5]]]), [['a', 6, 6]])
    check('physical holes', solve([[['a', 0, [5, 6, 7]]], [['a', 0], ['a', 2]]]), [['a', 1, 6]])
    check('repeated tombstone', solve([[['a', 0, [5]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 5]]], []]), [['a', 0, None], ['a', 1, 5]])
    check('fragment order', solve([[['b', 0, [5]], ['a', 0, [6]]], []]), [['b', 0, 5], ['a', 0, 6]])
    check('empty input', solve([[], []]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        fragments,deletes=d
        tombstones=set(tuple(x) for x in deletes)
        out=[]
        for file,base,values in fragments:
            for local,value in enumerate(values):
                position=base+local
                if (file,position) in tombstones: continue
                out.append([file,position,0 if value is None else value])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('file scope', solve([[['b', 0, [1]], ['a', 0, [2]]], [['a', 0]]]), [['b', 0, 1]])
    check('fragment origin', solve([[['a', 5, [1, 2]]], [['a', 5]]]), [['a', 6, 2]])
    check('physical holes', solve([[['a', 0, [1, 2, 3]]], [['a', 0], ['a', 2]]]), [['a', 1, 2]])
    check('repeated tombstone', solve([[['a', 0, [1]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 1]]], []]), [['a', 0, None], ['a', 1, 1]])
    check('fragment order', solve([[['b', 0, [1]], ['a', 0, [2]]], []]), [['b', 0, 1], ['a', 0, 2]])
    check('empty input', solve([[], []]), [])
elif N == 2:
    check('file scope', solve([[['b', 0, [2]], ['a', 0, [3]]], [['a', 0]]]), [['b', 0, 2]])
    check('fragment origin', solve([[['a', 5, [2, 3]]], [['a', 5]]]), [['a', 6, 3]])
    check('physical holes', solve([[['a', 0, [2, 3, 4]]], [['a', 0], ['a', 2]]]), [['a', 1, 3]])
    check('repeated tombstone', solve([[['a', 0, [2]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 2]]], []]), [['a', 0, None], ['a', 1, 2]])
    check('fragment order', solve([[['b', 0, [2]], ['a', 0, [3]]], []]), [['b', 0, 2], ['a', 0, 3]])
    check('empty input', solve([[], []]), [])
elif N == 3:
    check('file scope', solve([[['b', 0, [3]], ['a', 0, [4]]], [['a', 0]]]), [['b', 0, 3]])
    check('fragment origin', solve([[['a', 5, [3, 4]]], [['a', 5]]]), [['a', 6, 4]])
    check('physical holes', solve([[['a', 0, [3, 4, 5]]], [['a', 0], ['a', 2]]]), [['a', 1, 4]])
    check('repeated tombstone', solve([[['a', 0, [3]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 3]]], []]), [['a', 0, None], ['a', 1, 3]])
    check('fragment order', solve([[['b', 0, [3]], ['a', 0, [4]]], []]), [['b', 0, 3], ['a', 0, 4]])
    check('empty input', solve([[], []]), [])
elif N == 4:
    check('file scope', solve([[['b', 0, [4]], ['a', 0, [5]]], [['a', 0]]]), [['b', 0, 4]])
    check('fragment origin', solve([[['a', 5, [4, 5]]], [['a', 5]]]), [['a', 6, 5]])
    check('physical holes', solve([[['a', 0, [4, 5, 6]]], [['a', 0], ['a', 2]]]), [['a', 1, 5]])
    check('repeated tombstone', solve([[['a', 0, [4]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 4]]], []]), [['a', 0, None], ['a', 1, 4]])
    check('fragment order', solve([[['b', 0, [4]], ['a', 0, [5]]], []]), [['b', 0, 4], ['a', 0, 5]])
    check('empty input', solve([[], []]), [])
elif N == 5:
    check('file scope', solve([[['b', 0, [5]], ['a', 0, [6]]], [['a', 0]]]), [['b', 0, 5]])
    check('fragment origin', solve([[['a', 5, [5, 6]]], [['a', 5]]]), [['a', 6, 6]])
    check('physical holes', solve([[['a', 0, [5, 6, 7]]], [['a', 0], ['a', 2]]]), [['a', 1, 6]])
    check('repeated tombstone', solve([[['a', 0, [5]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 5]]], []]), [['a', 0, None], ['a', 1, 5]])
    check('fragment order', solve([[['b', 0, [5]], ['a', 0, [6]]], []]), [['b', 0, 5], ['a', 0, 6]])
    check('empty input', solve([[], []]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A delete-vector scan also removes surviving null-valued rows.

Scan fragments [file-id,base-row-position,values] applying position-delete pairs [file-id,absolute-row-position]. Deletions are file-scoped and use physical positions before filtering. Return [file-id,absolute-position,value] for surviving rows, including null values.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        fragments,deletes=d
        tombstones=set(tuple(x) for x in deletes)
        out=[]
        for file,base,values in sorted(fragments):
            for local,value in enumerate(values):
                position=base+local
                if (file,position) in tombstones: continue
                out.append([file,position,value])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('file scope', solve([[['b', 0, [1]], ['a', 0, [2]]], [['a', 0]]]), [['b', 0, 1]])
    check('fragment origin', solve([[['a', 5, [1, 2]]], [['a', 5]]]), [['a', 6, 2]])
    check('physical holes', solve([[['a', 0, [1, 2, 3]]], [['a', 0], ['a', 2]]]), [['a', 1, 2]])
    check('repeated tombstone', solve([[['a', 0, [1]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 1]]], []]), [['a', 0, None], ['a', 1, 1]])
    check('fragment order', solve([[['b', 0, [1]], ['a', 0, [2]]], []]), [['b', 0, 1], ['a', 0, 2]])
    check('empty input', solve([[], []]), [])
elif N == 2:
    check('file scope', solve([[['b', 0, [2]], ['a', 0, [3]]], [['a', 0]]]), [['b', 0, 2]])
    check('fragment origin', solve([[['a', 5, [2, 3]]], [['a', 5]]]), [['a', 6, 3]])
    check('physical holes', solve([[['a', 0, [2, 3, 4]]], [['a', 0], ['a', 2]]]), [['a', 1, 3]])
    check('repeated tombstone', solve([[['a', 0, [2]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 2]]], []]), [['a', 0, None], ['a', 1, 2]])
    check('fragment order', solve([[['b', 0, [2]], ['a', 0, [3]]], []]), [['b', 0, 2], ['a', 0, 3]])
    check('empty input', solve([[], []]), [])
elif N == 3:
    check('file scope', solve([[['b', 0, [3]], ['a', 0, [4]]], [['a', 0]]]), [['b', 0, 3]])
    check('fragment origin', solve([[['a', 5, [3, 4]]], [['a', 5]]]), [['a', 6, 4]])
    check('physical holes', solve([[['a', 0, [3, 4, 5]]], [['a', 0], ['a', 2]]]), [['a', 1, 4]])
    check('repeated tombstone', solve([[['a', 0, [3]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 3]]], []]), [['a', 0, None], ['a', 1, 3]])
    check('fragment order', solve([[['b', 0, [3]], ['a', 0, [4]]], []]), [['b', 0, 3], ['a', 0, 4]])
    check('empty input', solve([[], []]), [])
elif N == 4:
    check('file scope', solve([[['b', 0, [4]], ['a', 0, [5]]], [['a', 0]]]), [['b', 0, 4]])
    check('fragment origin', solve([[['a', 5, [4, 5]]], [['a', 5]]]), [['a', 6, 5]])
    check('physical holes', solve([[['a', 0, [4, 5, 6]]], [['a', 0], ['a', 2]]]), [['a', 1, 5]])
    check('repeated tombstone', solve([[['a', 0, [4]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 4]]], []]), [['a', 0, None], ['a', 1, 4]])
    check('fragment order', solve([[['b', 0, [4]], ['a', 0, [5]]], []]), [['b', 0, 4], ['a', 0, 5]])
    check('empty input', solve([[], []]), [])
elif N == 5:
    check('file scope', solve([[['b', 0, [5]], ['a', 0, [6]]], [['a', 0]]]), [['b', 0, 5]])
    check('fragment origin', solve([[['a', 5, [5, 6]]], [['a', 5]]]), [['a', 6, 6]])
    check('physical holes', solve([[['a', 0, [5, 6, 7]]], [['a', 0], ['a', 2]]]), [['a', 1, 6]])
    check('repeated tombstone', solve([[['a', 0, [5]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 5]]], []]), [['a', 0, None], ['a', 1, 5]])
    check('fragment order', solve([[['b', 0, [5]], ['a', 0, [6]]], []]), [['b', 0, 5], ['a', 0, 6]])
    check('empty input', solve([[], []]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        fragments,deletes=d
        tombstones=set(tuple(x) for x in deletes)
        out=[]
        for file,base,values in reversed(fragments):
            for local,value in enumerate(values):
                position=base+local
                if (file,position) in tombstones: continue
                out.append([file,position,value])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('file scope', solve([[['b', 0, [1]], ['a', 0, [2]]], [['a', 0]]]), [['b', 0, 1]])
    check('fragment origin', solve([[['a', 5, [1, 2]]], [['a', 5]]]), [['a', 6, 2]])
    check('physical holes', solve([[['a', 0, [1, 2, 3]]], [['a', 0], ['a', 2]]]), [['a', 1, 2]])
    check('repeated tombstone', solve([[['a', 0, [1]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 1]]], []]), [['a', 0, None], ['a', 1, 1]])
    check('fragment order', solve([[['b', 0, [1]], ['a', 0, [2]]], []]), [['b', 0, 1], ['a', 0, 2]])
    check('empty input', solve([[], []]), [])
elif N == 2:
    check('file scope', solve([[['b', 0, [2]], ['a', 0, [3]]], [['a', 0]]]), [['b', 0, 2]])
    check('fragment origin', solve([[['a', 5, [2, 3]]], [['a', 5]]]), [['a', 6, 3]])
    check('physical holes', solve([[['a', 0, [2, 3, 4]]], [['a', 0], ['a', 2]]]), [['a', 1, 3]])
    check('repeated tombstone', solve([[['a', 0, [2]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 2]]], []]), [['a', 0, None], ['a', 1, 2]])
    check('fragment order', solve([[['b', 0, [2]], ['a', 0, [3]]], []]), [['b', 0, 2], ['a', 0, 3]])
    check('empty input', solve([[], []]), [])
elif N == 3:
    check('file scope', solve([[['b', 0, [3]], ['a', 0, [4]]], [['a', 0]]]), [['b', 0, 3]])
    check('fragment origin', solve([[['a', 5, [3, 4]]], [['a', 5]]]), [['a', 6, 4]])
    check('physical holes', solve([[['a', 0, [3, 4, 5]]], [['a', 0], ['a', 2]]]), [['a', 1, 4]])
    check('repeated tombstone', solve([[['a', 0, [3]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 3]]], []]), [['a', 0, None], ['a', 1, 3]])
    check('fragment order', solve([[['b', 0, [3]], ['a', 0, [4]]], []]), [['b', 0, 3], ['a', 0, 4]])
    check('empty input', solve([[], []]), [])
elif N == 4:
    check('file scope', solve([[['b', 0, [4]], ['a', 0, [5]]], [['a', 0]]]), [['b', 0, 4]])
    check('fragment origin', solve([[['a', 5, [4, 5]]], [['a', 5]]]), [['a', 6, 5]])
    check('physical holes', solve([[['a', 0, [4, 5, 6]]], [['a', 0], ['a', 2]]]), [['a', 1, 5]])
    check('repeated tombstone', solve([[['a', 0, [4]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 4]]], []]), [['a', 0, None], ['a', 1, 4]])
    check('fragment order', solve([[['b', 0, [4]], ['a', 0, [5]]], []]), [['b', 0, 4], ['a', 0, 5]])
    check('empty input', solve([[], []]), [])
elif N == 5:
    check('file scope', solve([[['b', 0, [5]], ['a', 0, [6]]], [['a', 0]]]), [['b', 0, 5]])
    check('fragment origin', solve([[['a', 5, [5, 6]]], [['a', 5]]]), [['a', 6, 6]])
    check('physical holes', solve([[['a', 0, [5, 6, 7]]], [['a', 0], ['a', 2]]]), [['a', 1, 6]])
    check('repeated tombstone', solve([[['a', 0, [5]]], [['a', 0], ['a', 0]]]), [])
    check('surviving null', solve([[['a', 0, [None, 5]]], []]), [['a', 0, None], ['a', 1, 5]])
    check('fragment order', solve([[['b', 0, [5]], ['a', 0, [6]]], []]), [['b', 0, 5], ['a', 0, 6]])
    check('empty input', solve([[], []]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Delete-vector scanning sorts fragments by physical filename.

Scan fragments [file-id,base-row-position,values] applying position-delete pairs [file-id,absolute-row-position]. Deletions are file-scoped and use physical positions before filtering. Return [file-id,absolute-position,value] for surviving rows, including null values.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        changes=d
        state={}; order=[]
        for ident,before,after in changes:
            if ident not in state:
                state[ident]=[before,after]; order.append(ident)
            else:
                state[ident]=[before,after]
        return [[ident,state[ident][0],state[ident][1]] for ident in order if state[ident][0]!=state[ident][1]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('two updates', solve([[10, 1, 2], [10, 2, 3]]), [[10, 1, 3]])
    check('insert delete', solve([[10, None, 1], [10, 1, None]]), [])
    check('change revert', solve([[10, 1, 2], [10, 2, 1]]), [])
    check('touch order', solve([[20, 1, 2], [10, 3, 4]]), [[20, 1, 2], [10, 3, 4]])
    check('delete', solve([[10, 1, None]]), [[10, 1, None]])
    check('insert', solve([[10, None, 1]]), [[10, None, 1]])
    check('no transaction', solve([]), [])
elif N == 2:
    check('two updates', solve([[10, 2, 3], [10, 3, 4]]), [[10, 2, 4]])
    check('insert delete', solve([[10, None, 2], [10, 2, None]]), [])
    check('change revert', solve([[10, 2, 3], [10, 3, 2]]), [])
    check('touch order', solve([[20, 2, 3], [10, 4, 5]]), [[20, 2, 3], [10, 4, 5]])
    check('delete', solve([[10, 2, None]]), [[10, 2, None]])
    check('insert', solve([[10, None, 2]]), [[10, None, 2]])
    check('no transaction', solve([]), [])
elif N == 3:
    check('two updates', solve([[10, 3, 4], [10, 4, 5]]), [[10, 3, 5]])
    check('insert delete', solve([[10, None, 3], [10, 3, None]]), [])
    check('change revert', solve([[10, 3, 4], [10, 4, 3]]), [])
    check('touch order', solve([[20, 3, 4], [10, 5, 6]]), [[20, 3, 4], [10, 5, 6]])
    check('delete', solve([[10, 3, None]]), [[10, 3, None]])
    check('insert', solve([[10, None, 3]]), [[10, None, 3]])
    check('no transaction', solve([]), [])
elif N == 4:
    check('two updates', solve([[10, 4, 5], [10, 5, 6]]), [[10, 4, 6]])
    check('insert delete', solve([[10, None, 4], [10, 4, None]]), [])
    check('change revert', solve([[10, 4, 5], [10, 5, 4]]), [])
    check('touch order', solve([[20, 4, 5], [10, 6, 7]]), [[20, 4, 5], [10, 6, 7]])
    check('delete', solve([[10, 4, None]]), [[10, 4, None]])
    check('insert', solve([[10, None, 4]]), [[10, None, 4]])
    check('no transaction', solve([]), [])
elif N == 5:
    check('two updates', solve([[10, 5, 6], [10, 6, 7]]), [[10, 5, 7]])
    check('insert delete', solve([[10, None, 5], [10, 5, None]]), [])
    check('change revert', solve([[10, 5, 6], [10, 6, 5]]), [])
    check('touch order', solve([[20, 5, 6], [10, 7, 8]]), [[20, 5, 6], [10, 7, 8]])
    check('delete', solve([[10, 5, None]]), [[10, 5, None]])
    check('insert', solve([[10, None, 5]]), [[10, None, 5]])
    check('no transaction', solve([]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        changes=d
        state={}; order=[]
        for ident,before,after in changes:
            if ident not in state:
                state[ident]=[before,after]; order.append(ident)
            else:
                state[ident][0]=before; state[ident][1]=after
        return [[ident,state[ident][0],state[ident][1]] for ident in order if state[ident][0]!=state[ident][1]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('two updates', solve([[10, 1, 2], [10, 2, 3]]), [[10, 1, 3]])
    check('insert delete', solve([[10, None, 1], [10, 1, None]]), [])
    check('change revert', solve([[10, 1, 2], [10, 2, 1]]), [])
    check('touch order', solve([[20, 1, 2], [10, 3, 4]]), [[20, 1, 2], [10, 3, 4]])
    check('delete', solve([[10, 1, None]]), [[10, 1, None]])
    check('insert', solve([[10, None, 1]]), [[10, None, 1]])
    check('no transaction', solve([]), [])
elif N == 2:
    check('two updates', solve([[10, 2, 3], [10, 3, 4]]), [[10, 2, 4]])
    check('insert delete', solve([[10, None, 2], [10, 2, None]]), [])
    check('change revert', solve([[10, 2, 3], [10, 3, 2]]), [])
    check('touch order', solve([[20, 2, 3], [10, 4, 5]]), [[20, 2, 3], [10, 4, 5]])
    check('delete', solve([[10, 2, None]]), [[10, 2, None]])
    check('insert', solve([[10, None, 2]]), [[10, None, 2]])
    check('no transaction', solve([]), [])
elif N == 3:
    check('two updates', solve([[10, 3, 4], [10, 4, 5]]), [[10, 3, 5]])
    check('insert delete', solve([[10, None, 3], [10, 3, None]]), [])
    check('change revert', solve([[10, 3, 4], [10, 4, 3]]), [])
    check('touch order', solve([[20, 3, 4], [10, 5, 6]]), [[20, 3, 4], [10, 5, 6]])
    check('delete', solve([[10, 3, None]]), [[10, 3, None]])
    check('insert', solve([[10, None, 3]]), [[10, None, 3]])
    check('no transaction', solve([]), [])
elif N == 4:
    check('two updates', solve([[10, 4, 5], [10, 5, 6]]), [[10, 4, 6]])
    check('insert delete', solve([[10, None, 4], [10, 4, None]]), [])
    check('change revert', solve([[10, 4, 5], [10, 5, 4]]), [])
    check('touch order', solve([[20, 4, 5], [10, 6, 7]]), [[20, 4, 5], [10, 6, 7]])
    check('delete', solve([[10, 4, None]]), [[10, 4, None]])
    check('insert', solve([[10, None, 4]]), [[10, None, 4]])
    check('no transaction', solve([]), [])
elif N == 5:
    check('two updates', solve([[10, 5, 6], [10, 6, 7]]), [[10, 5, 7]])
    check('insert delete', solve([[10, None, 5], [10, 5, None]]), [])
    check('change revert', solve([[10, 5, 6], [10, 6, 5]]), [])
    check('touch order', solve([[20, 5, 6], [10, 7, 8]]), [[20, 5, 6], [10, 7, 8]])
    check('delete', solve([[10, 5, None]]), [[10, 5, None]])
    check('insert', solve([[10, None, 5]]), [[10, None, 5]])
    check('no transaction', solve([]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Transaction coalescing replaces the original before-image on every update.

Coalesce an ordered transaction of [id,before,after] changes to one net before/after per identity. Keep the first before-image and last after-image, order identities by first touch, suppress equal net states including insert-then-delete, and retain None as absence.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        changes=d
        state={}; order=[]
        for ident,before,after in changes:
            if ident not in state:
                state[ident]=[before,after]; order.append(ident)
            else:
                pass
        return [[ident,state[ident][0],state[ident][1]] for ident in order if state[ident][0]!=state[ident][1]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('two updates', solve([[10, 1, 2], [10, 2, 3]]), [[10, 1, 3]])
    check('insert delete', solve([[10, None, 1], [10, 1, None]]), [])
    check('change revert', solve([[10, 1, 2], [10, 2, 1]]), [])
    check('touch order', solve([[20, 1, 2], [10, 3, 4]]), [[20, 1, 2], [10, 3, 4]])
    check('delete', solve([[10, 1, None]]), [[10, 1, None]])
    check('insert', solve([[10, None, 1]]), [[10, None, 1]])
    check('no transaction', solve([]), [])
elif N == 2:
    check('two updates', solve([[10, 2, 3], [10, 3, 4]]), [[10, 2, 4]])
    check('insert delete', solve([[10, None, 2], [10, 2, None]]), [])
    check('change revert', solve([[10, 2, 3], [10, 3, 2]]), [])
    check('touch order', solve([[20, 2, 3], [10, 4, 5]]), [[20, 2, 3], [10, 4, 5]])
    check('delete', solve([[10, 2, None]]), [[10, 2, None]])
    check('insert', solve([[10, None, 2]]), [[10, None, 2]])
    check('no transaction', solve([]), [])
elif N == 3:
    check('two updates', solve([[10, 3, 4], [10, 4, 5]]), [[10, 3, 5]])
    check('insert delete', solve([[10, None, 3], [10, 3, None]]), [])
    check('change revert', solve([[10, 3, 4], [10, 4, 3]]), [])
    check('touch order', solve([[20, 3, 4], [10, 5, 6]]), [[20, 3, 4], [10, 5, 6]])
    check('delete', solve([[10, 3, None]]), [[10, 3, None]])
    check('insert', solve([[10, None, 3]]), [[10, None, 3]])
    check('no transaction', solve([]), [])
elif N == 4:
    check('two updates', solve([[10, 4, 5], [10, 5, 6]]), [[10, 4, 6]])
    check('insert delete', solve([[10, None, 4], [10, 4, None]]), [])
    check('change revert', solve([[10, 4, 5], [10, 5, 4]]), [])
    check('touch order', solve([[20, 4, 5], [10, 6, 7]]), [[20, 4, 5], [10, 6, 7]])
    check('delete', solve([[10, 4, None]]), [[10, 4, None]])
    check('insert', solve([[10, None, 4]]), [[10, None, 4]])
    check('no transaction', solve([]), [])
elif N == 5:
    check('two updates', solve([[10, 5, 6], [10, 6, 7]]), [[10, 5, 7]])
    check('insert delete', solve([[10, None, 5], [10, 5, None]]), [])
    check('change revert', solve([[10, 5, 6], [10, 6, 5]]), [])
    check('touch order', solve([[20, 5, 6], [10, 7, 8]]), [[20, 5, 6], [10, 7, 8]])
    check('delete', solve([[10, 5, None]]), [[10, 5, None]])
    check('insert', solve([[10, None, 5]]), [[10, None, 5]])
    check('no transaction', solve([]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        changes=d
        state={}; order=[]
        for ident,before,after in changes:
            if ident not in state:
                state[ident]=[before,after]; order.append(ident)
            else:
                state[ident][1]=before
        return [[ident,state[ident][0],state[ident][1]] for ident in order if state[ident][0]!=state[ident][1]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('two updates', solve([[10, 1, 2], [10, 2, 3]]), [[10, 1, 3]])
    check('insert delete', solve([[10, None, 1], [10, 1, None]]), [])
    check('change revert', solve([[10, 1, 2], [10, 2, 1]]), [])
    check('touch order', solve([[20, 1, 2], [10, 3, 4]]), [[20, 1, 2], [10, 3, 4]])
    check('delete', solve([[10, 1, None]]), [[10, 1, None]])
    check('insert', solve([[10, None, 1]]), [[10, None, 1]])
    check('no transaction', solve([]), [])
elif N == 2:
    check('two updates', solve([[10, 2, 3], [10, 3, 4]]), [[10, 2, 4]])
    check('insert delete', solve([[10, None, 2], [10, 2, None]]), [])
    check('change revert', solve([[10, 2, 3], [10, 3, 2]]), [])
    check('touch order', solve([[20, 2, 3], [10, 4, 5]]), [[20, 2, 3], [10, 4, 5]])
    check('delete', solve([[10, 2, None]]), [[10, 2, None]])
    check('insert', solve([[10, None, 2]]), [[10, None, 2]])
    check('no transaction', solve([]), [])
elif N == 3:
    check('two updates', solve([[10, 3, 4], [10, 4, 5]]), [[10, 3, 5]])
    check('insert delete', solve([[10, None, 3], [10, 3, None]]), [])
    check('change revert', solve([[10, 3, 4], [10, 4, 3]]), [])
    check('touch order', solve([[20, 3, 4], [10, 5, 6]]), [[20, 3, 4], [10, 5, 6]])
    check('delete', solve([[10, 3, None]]), [[10, 3, None]])
    check('insert', solve([[10, None, 3]]), [[10, None, 3]])
    check('no transaction', solve([]), [])
elif N == 4:
    check('two updates', solve([[10, 4, 5], [10, 5, 6]]), [[10, 4, 6]])
    check('insert delete', solve([[10, None, 4], [10, 4, None]]), [])
    check('change revert', solve([[10, 4, 5], [10, 5, 4]]), [])
    check('touch order', solve([[20, 4, 5], [10, 6, 7]]), [[20, 4, 5], [10, 6, 7]])
    check('delete', solve([[10, 4, None]]), [[10, 4, None]])
    check('insert', solve([[10, None, 4]]), [[10, None, 4]])
    check('no transaction', solve([]), [])
elif N == 5:
    check('two updates', solve([[10, 5, 6], [10, 6, 7]]), [[10, 5, 7]])
    check('insert delete', solve([[10, None, 5], [10, 5, None]]), [])
    check('change revert', solve([[10, 5, 6], [10, 6, 5]]), [])
    check('touch order', solve([[20, 5, 6], [10, 7, 8]]), [[20, 5, 6], [10, 7, 8]])
    check('delete', solve([[10, 5, None]]), [[10, 5, None]])
    check('insert', solve([[10, None, 5]]), [[10, None, 5]])
    check('no transaction', solve([]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Transaction coalescing retains the first after-image.

Coalesce an ordered transaction of [id,before,after] changes to one net before/after per identity. Keep the first before-image and last after-image, order identities by first touch, suppress equal net states including insert-then-delete, and retain None as absence.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        changes=d
        state={}; order=[]
        for ident,before,after in changes:
            if ident not in state:
                state[ident]=[before,after]; order.append(ident)
            else:
                state[ident][1]=after
        return [[ident,state[ident][0],state[ident][1]] for ident in order if True]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('two updates', solve([[10, 1, 2], [10, 2, 3]]), [[10, 1, 3]])
    check('insert delete', solve([[10, None, 1], [10, 1, None]]), [])
    check('change revert', solve([[10, 1, 2], [10, 2, 1]]), [])
    check('touch order', solve([[20, 1, 2], [10, 3, 4]]), [[20, 1, 2], [10, 3, 4]])
    check('delete', solve([[10, 1, None]]), [[10, 1, None]])
    check('insert', solve([[10, None, 1]]), [[10, None, 1]])
    check('no transaction', solve([]), [])
elif N == 2:
    check('two updates', solve([[10, 2, 3], [10, 3, 4]]), [[10, 2, 4]])
    check('insert delete', solve([[10, None, 2], [10, 2, None]]), [])
    check('change revert', solve([[10, 2, 3], [10, 3, 2]]), [])
    check('touch order', solve([[20, 2, 3], [10, 4, 5]]), [[20, 2, 3], [10, 4, 5]])
    check('delete', solve([[10, 2, None]]), [[10, 2, None]])
    check('insert', solve([[10, None, 2]]), [[10, None, 2]])
    check('no transaction', solve([]), [])
elif N == 3:
    check('two updates', solve([[10, 3, 4], [10, 4, 5]]), [[10, 3, 5]])
    check('insert delete', solve([[10, None, 3], [10, 3, None]]), [])
    check('change revert', solve([[10, 3, 4], [10, 4, 3]]), [])
    check('touch order', solve([[20, 3, 4], [10, 5, 6]]), [[20, 3, 4], [10, 5, 6]])
    check('delete', solve([[10, 3, None]]), [[10, 3, None]])
    check('insert', solve([[10, None, 3]]), [[10, None, 3]])
    check('no transaction', solve([]), [])
elif N == 4:
    check('two updates', solve([[10, 4, 5], [10, 5, 6]]), [[10, 4, 6]])
    check('insert delete', solve([[10, None, 4], [10, 4, None]]), [])
    check('change revert', solve([[10, 4, 5], [10, 5, 4]]), [])
    check('touch order', solve([[20, 4, 5], [10, 6, 7]]), [[20, 4, 5], [10, 6, 7]])
    check('delete', solve([[10, 4, None]]), [[10, 4, None]])
    check('insert', solve([[10, None, 4]]), [[10, None, 4]])
    check('no transaction', solve([]), [])
elif N == 5:
    check('two updates', solve([[10, 5, 6], [10, 6, 7]]), [[10, 5, 7]])
    check('insert delete', solve([[10, None, 5], [10, 5, None]]), [])
    check('change revert', solve([[10, 5, 6], [10, 6, 5]]), [])
    check('touch order', solve([[20, 5, 6], [10, 7, 8]]), [[20, 5, 6], [10, 7, 8]])
    check('delete', solve([[10, 5, None]]), [[10, 5, None]])
    check('insert', solve([[10, None, 5]]), [[10, None, 5]])
    check('no transaction', solve([]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        changes=d
        state={}; order=[]
        for ident,before,after in changes:
            if ident not in state:
                state[ident]=[before,after]; order.append(ident)
            else:
                state[ident][1]=after
        return [[ident,state[ident][0],state[ident][1]] for ident in order if state[ident][0] is not None or state[ident][1] is not None]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('two updates', solve([[10, 1, 2], [10, 2, 3]]), [[10, 1, 3]])
    check('insert delete', solve([[10, None, 1], [10, 1, None]]), [])
    check('change revert', solve([[10, 1, 2], [10, 2, 1]]), [])
    check('touch order', solve([[20, 1, 2], [10, 3, 4]]), [[20, 1, 2], [10, 3, 4]])
    check('delete', solve([[10, 1, None]]), [[10, 1, None]])
    check('insert', solve([[10, None, 1]]), [[10, None, 1]])
    check('no transaction', solve([]), [])
elif N == 2:
    check('two updates', solve([[10, 2, 3], [10, 3, 4]]), [[10, 2, 4]])
    check('insert delete', solve([[10, None, 2], [10, 2, None]]), [])
    check('change revert', solve([[10, 2, 3], [10, 3, 2]]), [])
    check('touch order', solve([[20, 2, 3], [10, 4, 5]]), [[20, 2, 3], [10, 4, 5]])
    check('delete', solve([[10, 2, None]]), [[10, 2, None]])
    check('insert', solve([[10, None, 2]]), [[10, None, 2]])
    check('no transaction', solve([]), [])
elif N == 3:
    check('two updates', solve([[10, 3, 4], [10, 4, 5]]), [[10, 3, 5]])
    check('insert delete', solve([[10, None, 3], [10, 3, None]]), [])
    check('change revert', solve([[10, 3, 4], [10, 4, 3]]), [])
    check('touch order', solve([[20, 3, 4], [10, 5, 6]]), [[20, 3, 4], [10, 5, 6]])
    check('delete', solve([[10, 3, None]]), [[10, 3, None]])
    check('insert', solve([[10, None, 3]]), [[10, None, 3]])
    check('no transaction', solve([]), [])
elif N == 4:
    check('two updates', solve([[10, 4, 5], [10, 5, 6]]), [[10, 4, 6]])
    check('insert delete', solve([[10, None, 4], [10, 4, None]]), [])
    check('change revert', solve([[10, 4, 5], [10, 5, 4]]), [])
    check('touch order', solve([[20, 4, 5], [10, 6, 7]]), [[20, 4, 5], [10, 6, 7]])
    check('delete', solve([[10, 4, None]]), [[10, 4, None]])
    check('insert', solve([[10, None, 4]]), [[10, None, 4]])
    check('no transaction', solve([]), [])
elif N == 5:
    check('two updates', solve([[10, 5, 6], [10, 6, 7]]), [[10, 5, 7]])
    check('insert delete', solve([[10, None, 5], [10, 5, None]]), [])
    check('change revert', solve([[10, 5, 6], [10, 6, 5]]), [])
    check('touch order', solve([[20, 5, 6], [10, 7, 8]]), [[20, 5, 6], [10, 7, 8]])
    check('delete', solve([[10, 5, None]]), [[10, 5, None]])
    check('insert', solve([[10, None, 5]]), [[10, None, 5]])
    check('no transaction', solve([]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Transaction coalescing emits identities whose net state is unchanged.

Coalesce an ordered transaction of [id,before,after] changes to one net before/after per identity. Keep the first before-image and last after-image, order identities by first touch, suppress equal net states including insert-then-delete, and retain None as absence.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        changes=d
        state={}; order=[]
        for ident,before,after in changes:
            if ident not in state:
                state[ident]=[before,after]; order.append(ident)
            else:
                state[ident][1]=after
        return [[ident,state[ident][0],state[ident][1]] for ident in sorted(order) if state[ident][0]!=state[ident][1]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('two updates', solve([[10, 1, 2], [10, 2, 3]]), [[10, 1, 3]])
    check('insert delete', solve([[10, None, 1], [10, 1, None]]), [])
    check('change revert', solve([[10, 1, 2], [10, 2, 1]]), [])
    check('touch order', solve([[20, 1, 2], [10, 3, 4]]), [[20, 1, 2], [10, 3, 4]])
    check('delete', solve([[10, 1, None]]), [[10, 1, None]])
    check('insert', solve([[10, None, 1]]), [[10, None, 1]])
    check('no transaction', solve([]), [])
elif N == 2:
    check('two updates', solve([[10, 2, 3], [10, 3, 4]]), [[10, 2, 4]])
    check('insert delete', solve([[10, None, 2], [10, 2, None]]), [])
    check('change revert', solve([[10, 2, 3], [10, 3, 2]]), [])
    check('touch order', solve([[20, 2, 3], [10, 4, 5]]), [[20, 2, 3], [10, 4, 5]])
    check('delete', solve([[10, 2, None]]), [[10, 2, None]])
    check('insert', solve([[10, None, 2]]), [[10, None, 2]])
    check('no transaction', solve([]), [])
elif N == 3:
    check('two updates', solve([[10, 3, 4], [10, 4, 5]]), [[10, 3, 5]])
    check('insert delete', solve([[10, None, 3], [10, 3, None]]), [])
    check('change revert', solve([[10, 3, 4], [10, 4, 3]]), [])
    check('touch order', solve([[20, 3, 4], [10, 5, 6]]), [[20, 3, 4], [10, 5, 6]])
    check('delete', solve([[10, 3, None]]), [[10, 3, None]])
    check('insert', solve([[10, None, 3]]), [[10, None, 3]])
    check('no transaction', solve([]), [])
elif N == 4:
    check('two updates', solve([[10, 4, 5], [10, 5, 6]]), [[10, 4, 6]])
    check('insert delete', solve([[10, None, 4], [10, 4, None]]), [])
    check('change revert', solve([[10, 4, 5], [10, 5, 4]]), [])
    check('touch order', solve([[20, 4, 5], [10, 6, 7]]), [[20, 4, 5], [10, 6, 7]])
    check('delete', solve([[10, 4, None]]), [[10, 4, None]])
    check('insert', solve([[10, None, 4]]), [[10, None, 4]])
    check('no transaction', solve([]), [])
elif N == 5:
    check('two updates', solve([[10, 5, 6], [10, 6, 7]]), [[10, 5, 7]])
    check('insert delete', solve([[10, None, 5], [10, 5, None]]), [])
    check('change revert', solve([[10, 5, 6], [10, 6, 5]]), [])
    check('touch order', solve([[20, 5, 6], [10, 7, 8]]), [[20, 5, 6], [10, 7, 8]])
    check('delete', solve([[10, 5, None]]), [[10, 5, None]])
    check('insert', solve([[10, None, 5]]), [[10, None, 5]])
    check('no transaction', solve([]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        changes=d
        state={}; order=[]
        for ident,before,after in changes:
            if ident not in state:
                state[ident]=[before,after]; order.append(ident)
            else:
                state[ident][1]=after
        return [[ident,state[ident][0],state[ident][1]] for ident in reversed(order) if state[ident][0]!=state[ident][1]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('two updates', solve([[10, 1, 2], [10, 2, 3]]), [[10, 1, 3]])
    check('insert delete', solve([[10, None, 1], [10, 1, None]]), [])
    check('change revert', solve([[10, 1, 2], [10, 2, 1]]), [])
    check('touch order', solve([[20, 1, 2], [10, 3, 4]]), [[20, 1, 2], [10, 3, 4]])
    check('delete', solve([[10, 1, None]]), [[10, 1, None]])
    check('insert', solve([[10, None, 1]]), [[10, None, 1]])
    check('no transaction', solve([]), [])
elif N == 2:
    check('two updates', solve([[10, 2, 3], [10, 3, 4]]), [[10, 2, 4]])
    check('insert delete', solve([[10, None, 2], [10, 2, None]]), [])
    check('change revert', solve([[10, 2, 3], [10, 3, 2]]), [])
    check('touch order', solve([[20, 2, 3], [10, 4, 5]]), [[20, 2, 3], [10, 4, 5]])
    check('delete', solve([[10, 2, None]]), [[10, 2, None]])
    check('insert', solve([[10, None, 2]]), [[10, None, 2]])
    check('no transaction', solve([]), [])
elif N == 3:
    check('two updates', solve([[10, 3, 4], [10, 4, 5]]), [[10, 3, 5]])
    check('insert delete', solve([[10, None, 3], [10, 3, None]]), [])
    check('change revert', solve([[10, 3, 4], [10, 4, 3]]), [])
    check('touch order', solve([[20, 3, 4], [10, 5, 6]]), [[20, 3, 4], [10, 5, 6]])
    check('delete', solve([[10, 3, None]]), [[10, 3, None]])
    check('insert', solve([[10, None, 3]]), [[10, None, 3]])
    check('no transaction', solve([]), [])
elif N == 4:
    check('two updates', solve([[10, 4, 5], [10, 5, 6]]), [[10, 4, 6]])
    check('insert delete', solve([[10, None, 4], [10, 4, None]]), [])
    check('change revert', solve([[10, 4, 5], [10, 5, 4]]), [])
    check('touch order', solve([[20, 4, 5], [10, 6, 7]]), [[20, 4, 5], [10, 6, 7]])
    check('delete', solve([[10, 4, None]]), [[10, 4, None]])
    check('insert', solve([[10, None, 4]]), [[10, None, 4]])
    check('no transaction', solve([]), [])
elif N == 5:
    check('two updates', solve([[10, 5, 6], [10, 6, 7]]), [[10, 5, 7]])
    check('insert delete', solve([[10, None, 5], [10, 5, None]]), [])
    check('change revert', solve([[10, 5, 6], [10, 6, 5]]), [])
    check('touch order', solve([[20, 5, 6], [10, 7, 8]]), [[20, 5, 6], [10, 7, 8]])
    check('delete', solve([[10, 5, None]]), [[10, 5, None]])
    check('insert', solve([[10, None, 5]]), [[10, None, 5]])
    check('no transaction', solve([]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Transaction coalescing sorts IDs instead of preserving first-touch order.

Coalesce an ordered transaction of [id,before,after] changes to one net before/after per identity. Keep the first before-image and last after-image, order identities by first touch, suppress equal net states including insert-then-delete, and retain None as absence.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        changes=d
        state={}; order=[]
        for ident,before,after in changes:
            if ident not in state:
                state[ident]=[None,after]; order.append(ident)
            else:
                state[ident][1]=after
        return [[ident,state[ident][0],state[ident][1]] for ident in order if state[ident][0]!=state[ident][1]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('two updates', solve([[10, 1, 2], [10, 2, 3]]), [[10, 1, 3]])
    check('insert delete', solve([[10, None, 1], [10, 1, None]]), [])
    check('change revert', solve([[10, 1, 2], [10, 2, 1]]), [])
    check('touch order', solve([[20, 1, 2], [10, 3, 4]]), [[20, 1, 2], [10, 3, 4]])
    check('delete', solve([[10, 1, None]]), [[10, 1, None]])
    check('insert', solve([[10, None, 1]]), [[10, None, 1]])
    check('no transaction', solve([]), [])
elif N == 2:
    check('two updates', solve([[10, 2, 3], [10, 3, 4]]), [[10, 2, 4]])
    check('insert delete', solve([[10, None, 2], [10, 2, None]]), [])
    check('change revert', solve([[10, 2, 3], [10, 3, 2]]), [])
    check('touch order', solve([[20, 2, 3], [10, 4, 5]]), [[20, 2, 3], [10, 4, 5]])
    check('delete', solve([[10, 2, None]]), [[10, 2, None]])
    check('insert', solve([[10, None, 2]]), [[10, None, 2]])
    check('no transaction', solve([]), [])
elif N == 3:
    check('two updates', solve([[10, 3, 4], [10, 4, 5]]), [[10, 3, 5]])
    check('insert delete', solve([[10, None, 3], [10, 3, None]]), [])
    check('change revert', solve([[10, 3, 4], [10, 4, 3]]), [])
    check('touch order', solve([[20, 3, 4], [10, 5, 6]]), [[20, 3, 4], [10, 5, 6]])
    check('delete', solve([[10, 3, None]]), [[10, 3, None]])
    check('insert', solve([[10, None, 3]]), [[10, None, 3]])
    check('no transaction', solve([]), [])
elif N == 4:
    check('two updates', solve([[10, 4, 5], [10, 5, 6]]), [[10, 4, 6]])
    check('insert delete', solve([[10, None, 4], [10, 4, None]]), [])
    check('change revert', solve([[10, 4, 5], [10, 5, 4]]), [])
    check('touch order', solve([[20, 4, 5], [10, 6, 7]]), [[20, 4, 5], [10, 6, 7]])
    check('delete', solve([[10, 4, None]]), [[10, 4, None]])
    check('insert', solve([[10, None, 4]]), [[10, None, 4]])
    check('no transaction', solve([]), [])
elif N == 5:
    check('two updates', solve([[10, 5, 6], [10, 6, 7]]), [[10, 5, 7]])
    check('insert delete', solve([[10, None, 5], [10, 5, None]]), [])
    check('change revert', solve([[10, 5, 6], [10, 6, 5]]), [])
    check('touch order', solve([[20, 5, 6], [10, 7, 8]]), [[20, 5, 6], [10, 7, 8]])
    check('delete', solve([[10, 5, None]]), [[10, 5, None]])
    check('insert', solve([[10, None, 5]]), [[10, None, 5]])
    check('no transaction', solve([]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        changes=d
        state={}; order=[]
        for ident,before,after in changes:
            if ident not in state:
                state[ident]=[after,after]; order.append(ident)
            else:
                state[ident][1]=after
        return [[ident,state[ident][0],state[ident][1]] for ident in order if state[ident][0]!=state[ident][1]]
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('two updates', solve([[10, 1, 2], [10, 2, 3]]), [[10, 1, 3]])
    check('insert delete', solve([[10, None, 1], [10, 1, None]]), [])
    check('change revert', solve([[10, 1, 2], [10, 2, 1]]), [])
    check('touch order', solve([[20, 1, 2], [10, 3, 4]]), [[20, 1, 2], [10, 3, 4]])
    check('delete', solve([[10, 1, None]]), [[10, 1, None]])
    check('insert', solve([[10, None, 1]]), [[10, None, 1]])
    check('no transaction', solve([]), [])
elif N == 2:
    check('two updates', solve([[10, 2, 3], [10, 3, 4]]), [[10, 2, 4]])
    check('insert delete', solve([[10, None, 2], [10, 2, None]]), [])
    check('change revert', solve([[10, 2, 3], [10, 3, 2]]), [])
    check('touch order', solve([[20, 2, 3], [10, 4, 5]]), [[20, 2, 3], [10, 4, 5]])
    check('delete', solve([[10, 2, None]]), [[10, 2, None]])
    check('insert', solve([[10, None, 2]]), [[10, None, 2]])
    check('no transaction', solve([]), [])
elif N == 3:
    check('two updates', solve([[10, 3, 4], [10, 4, 5]]), [[10, 3, 5]])
    check('insert delete', solve([[10, None, 3], [10, 3, None]]), [])
    check('change revert', solve([[10, 3, 4], [10, 4, 3]]), [])
    check('touch order', solve([[20, 3, 4], [10, 5, 6]]), [[20, 3, 4], [10, 5, 6]])
    check('delete', solve([[10, 3, None]]), [[10, 3, None]])
    check('insert', solve([[10, None, 3]]), [[10, None, 3]])
    check('no transaction', solve([]), [])
elif N == 4:
    check('two updates', solve([[10, 4, 5], [10, 5, 6]]), [[10, 4, 6]])
    check('insert delete', solve([[10, None, 4], [10, 4, None]]), [])
    check('change revert', solve([[10, 4, 5], [10, 5, 4]]), [])
    check('touch order', solve([[20, 4, 5], [10, 6, 7]]), [[20, 4, 5], [10, 6, 7]])
    check('delete', solve([[10, 4, None]]), [[10, 4, None]])
    check('insert', solve([[10, None, 4]]), [[10, None, 4]])
    check('no transaction', solve([]), [])
elif N == 5:
    check('two updates', solve([[10, 5, 6], [10, 6, 7]]), [[10, 5, 7]])
    check('insert delete', solve([[10, None, 5], [10, 5, None]]), [])
    check('change revert', solve([[10, 5, 6], [10, 6, 5]]), [])
    check('touch order', solve([[20, 5, 6], [10, 7, 8]]), [[20, 5, 6], [10, 7, 8]])
    check('delete', solve([[10, 5, None]]), [[10, 5, None]])
    check('insert', solve([[10, None, 5]]), [[10, None, 5]])
    check('no transaction', solve([]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Transaction coalescing initializes each identity as an insertion.

Coalesce an ordered transaction of [id,before,after] changes to one net before/after per identity. Keep the first before-image and last after-image, order identities by first touch, suppress equal net states including insert-then-delete, and retain None as absence.

split: open-access