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

N = 1
observations = []
def solve(d):
    try:
        left,right=d
        i=j=0; out=[]
        while i<len(left) and j<len(right):
            a=left[i][0]; b=right[j][0]
            if a<b: i+=1; continue
            if a>b: j+=1; continue
            ie=i+1
            while ie<len(left) and left[ie][0]==a: ie+=1
            je=j+1
            while False: je+=1
            for x in left[i:ie]:
                for y in right[j:je]: out.append([x[1],y[1]])
            i,j=ie,je
        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('duplicate runs', solve([[[1, 10], [1, 11]], [[1, 20], [1, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[1, 10], [2, 11]], [[2, 20]]]), [[11, 20]])
    check('right gap', solve([[[2, 10]], [[1, 20], [2, 21]]]), [[10, 21]])
    check('single match', solve([[[1, 10]], [[1, 20]]]), [[10, 20]])
    check('no overlap', solve([[[1, 10]], [[3, 20]]]), [])
    check('empty left', solve([[], [[1, 20]]]), [])
    check('empty right', solve([[[1, 10]], []]), [])
elif N == 2:
    check('duplicate runs', solve([[[2, 10], [2, 11]], [[2, 20], [2, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[2, 10], [3, 11]], [[3, 20]]]), [[11, 20]])
    check('right gap', solve([[[3, 10]], [[2, 20], [3, 21]]]), [[10, 21]])
    check('single match', solve([[[2, 10]], [[2, 20]]]), [[10, 20]])
    check('no overlap', solve([[[2, 10]], [[4, 20]]]), [])
    check('empty left', solve([[], [[2, 20]]]), [])
    check('empty right', solve([[[2, 10]], []]), [])
elif N == 3:
    check('duplicate runs', solve([[[3, 10], [3, 11]], [[3, 20], [3, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[3, 10], [4, 11]], [[4, 20]]]), [[11, 20]])
    check('right gap', solve([[[4, 10]], [[3, 20], [4, 21]]]), [[10, 21]])
    check('single match', solve([[[3, 10]], [[3, 20]]]), [[10, 20]])
    check('no overlap', solve([[[3, 10]], [[5, 20]]]), [])
    check('empty left', solve([[], [[3, 20]]]), [])
    check('empty right', solve([[[3, 10]], []]), [])
elif N == 4:
    check('duplicate runs', solve([[[4, 10], [4, 11]], [[4, 20], [4, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[4, 10], [5, 11]], [[5, 20]]]), [[11, 20]])
    check('right gap', solve([[[5, 10]], [[4, 20], [5, 21]]]), [[10, 21]])
    check('single match', solve([[[4, 10]], [[4, 20]]]), [[10, 20]])
    check('no overlap', solve([[[4, 10]], [[6, 20]]]), [])
    check('empty left', solve([[], [[4, 20]]]), [])
    check('empty right', solve([[[4, 10]], []]), [])
elif N == 5:
    check('duplicate runs', solve([[[5, 10], [5, 11]], [[5, 20], [5, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[5, 10], [6, 11]], [[6, 20]]]), [[11, 20]])
    check('right gap', solve([[[6, 10]], [[5, 20], [6, 21]]]), [[10, 21]])
    check('single match', solve([[[5, 10]], [[5, 20]]]), [[10, 20]])
    check('no overlap', solve([[[5, 10]], [[7, 20]]]), [])
    check('empty left', solve([[], [[5, 20]]]), [])
    check('empty right', solve([[[5, 10]], []]), [])
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:
        left,right=d
        i=j=0; out=[]
        while i<len(left) and j<len(right):
            a=left[i][0]; b=right[j][0]
            if a<b: i+=1; continue
            if a>b: j+=1; continue
            ie=i+1
            while ie<len(left) and left[ie][0]==a: ie+=1
            je=j+1
            while je<len(right) and right[je]==right[j]: je+=1
            for x in left[i:ie]:
                for y in right[j:je]: out.append([x[1],y[1]])
            i,j=ie,je
        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('duplicate runs', solve([[[1, 10], [1, 11]], [[1, 20], [1, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[1, 10], [2, 11]], [[2, 20]]]), [[11, 20]])
    check('right gap', solve([[[2, 10]], [[1, 20], [2, 21]]]), [[10, 21]])
    check('single match', solve([[[1, 10]], [[1, 20]]]), [[10, 20]])
    check('no overlap', solve([[[1, 10]], [[3, 20]]]), [])
    check('empty left', solve([[], [[1, 20]]]), [])
    check('empty right', solve([[[1, 10]], []]), [])
elif N == 2:
    check('duplicate runs', solve([[[2, 10], [2, 11]], [[2, 20], [2, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[2, 10], [3, 11]], [[3, 20]]]), [[11, 20]])
    check('right gap', solve([[[3, 10]], [[2, 20], [3, 21]]]), [[10, 21]])
    check('single match', solve([[[2, 10]], [[2, 20]]]), [[10, 20]])
    check('no overlap', solve([[[2, 10]], [[4, 20]]]), [])
    check('empty left', solve([[], [[2, 20]]]), [])
    check('empty right', solve([[[2, 10]], []]), [])
elif N == 3:
    check('duplicate runs', solve([[[3, 10], [3, 11]], [[3, 20], [3, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[3, 10], [4, 11]], [[4, 20]]]), [[11, 20]])
    check('right gap', solve([[[4, 10]], [[3, 20], [4, 21]]]), [[10, 21]])
    check('single match', solve([[[3, 10]], [[3, 20]]]), [[10, 20]])
    check('no overlap', solve([[[3, 10]], [[5, 20]]]), [])
    check('empty left', solve([[], [[3, 20]]]), [])
    check('empty right', solve([[[3, 10]], []]), [])
elif N == 4:
    check('duplicate runs', solve([[[4, 10], [4, 11]], [[4, 20], [4, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[4, 10], [5, 11]], [[5, 20]]]), [[11, 20]])
    check('right gap', solve([[[5, 10]], [[4, 20], [5, 21]]]), [[10, 21]])
    check('single match', solve([[[4, 10]], [[4, 20]]]), [[10, 20]])
    check('no overlap', solve([[[4, 10]], [[6, 20]]]), [])
    check('empty left', solve([[], [[4, 20]]]), [])
    check('empty right', solve([[[4, 10]], []]), [])
elif N == 5:
    check('duplicate runs', solve([[[5, 10], [5, 11]], [[5, 20], [5, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[5, 10], [6, 11]], [[6, 20]]]), [[11, 20]])
    check('right gap', solve([[[6, 10]], [[5, 20], [6, 21]]]), [[10, 21]])
    check('single match', solve([[[5, 10]], [[5, 20]]]), [[10, 20]])
    check('no overlap', solve([[[5, 10]], [[7, 20]]]), [])
    check('empty left', solve([[], [[5, 20]]]), [])
    check('empty right', solve([[[5, 10]], []]), [])
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:
Merge join matches only the first row of a repeated right key.

Join two key-sorted non-null relations [key,id] by matching equal-key runs. Emit the full left-major Cartesian product for each matching run. Advance the lower unmatched run and preserve physical order within equal-key runs.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        left,right=d
        i=j=0; out=[]
        while i<len(left) and j<len(right):
            a=left[i][0]; b=right[j][0]
            if a<b: j+=1; continue
            if a>b: j+=1; continue
            ie=i+1
            while ie<len(left) and left[ie][0]==a: ie+=1
            je=j+1
            while je<len(right) and right[je][0]==b: je+=1
            for x in left[i:ie]:
                for y in right[j:je]: out.append([x[1],y[1]])
            i,j=ie,je
        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('duplicate runs', solve([[[1, 10], [1, 11]], [[1, 20], [1, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[1, 10], [2, 11]], [[2, 20]]]), [[11, 20]])
    check('right gap', solve([[[2, 10]], [[1, 20], [2, 21]]]), [[10, 21]])
    check('single match', solve([[[1, 10]], [[1, 20]]]), [[10, 20]])
    check('no overlap', solve([[[1, 10]], [[3, 20]]]), [])
    check('empty left', solve([[], [[1, 20]]]), [])
    check('empty right', solve([[[1, 10]], []]), [])
elif N == 2:
    check('duplicate runs', solve([[[2, 10], [2, 11]], [[2, 20], [2, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[2, 10], [3, 11]], [[3, 20]]]), [[11, 20]])
    check('right gap', solve([[[3, 10]], [[2, 20], [3, 21]]]), [[10, 21]])
    check('single match', solve([[[2, 10]], [[2, 20]]]), [[10, 20]])
    check('no overlap', solve([[[2, 10]], [[4, 20]]]), [])
    check('empty left', solve([[], [[2, 20]]]), [])
    check('empty right', solve([[[2, 10]], []]), [])
elif N == 3:
    check('duplicate runs', solve([[[3, 10], [3, 11]], [[3, 20], [3, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[3, 10], [4, 11]], [[4, 20]]]), [[11, 20]])
    check('right gap', solve([[[4, 10]], [[3, 20], [4, 21]]]), [[10, 21]])
    check('single match', solve([[[3, 10]], [[3, 20]]]), [[10, 20]])
    check('no overlap', solve([[[3, 10]], [[5, 20]]]), [])
    check('empty left', solve([[], [[3, 20]]]), [])
    check('empty right', solve([[[3, 10]], []]), [])
elif N == 4:
    check('duplicate runs', solve([[[4, 10], [4, 11]], [[4, 20], [4, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[4, 10], [5, 11]], [[5, 20]]]), [[11, 20]])
    check('right gap', solve([[[5, 10]], [[4, 20], [5, 21]]]), [[10, 21]])
    check('single match', solve([[[4, 10]], [[4, 20]]]), [[10, 20]])
    check('no overlap', solve([[[4, 10]], [[6, 20]]]), [])
    check('empty left', solve([[], [[4, 20]]]), [])
    check('empty right', solve([[[4, 10]], []]), [])
elif N == 5:
    check('duplicate runs', solve([[[5, 10], [5, 11]], [[5, 20], [5, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[5, 10], [6, 11]], [[6, 20]]]), [[11, 20]])
    check('right gap', solve([[[6, 10]], [[5, 20], [6, 21]]]), [[10, 21]])
    check('single match', solve([[[5, 10]], [[5, 20]]]), [[10, 20]])
    check('no overlap', solve([[[5, 10]], [[7, 20]]]), [])
    check('empty left', solve([[], [[5, 20]]]), [])
    check('empty right', solve([[[5, 10]], []]), [])
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:
        left,right=d
        i=j=0; out=[]
        while i<len(left) and j<len(right):
            a=left[i][0]; b=right[j][0]
            if a<b: i+=1; j+=1; continue
            if a>b: j+=1; continue
            ie=i+1
            while ie<len(left) and left[ie][0]==a: ie+=1
            je=j+1
            while je<len(right) and right[je][0]==b: je+=1
            for x in left[i:ie]:
                for y in right[j:je]: out.append([x[1],y[1]])
            i,j=ie,je
        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('duplicate runs', solve([[[1, 10], [1, 11]], [[1, 20], [1, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[1, 10], [2, 11]], [[2, 20]]]), [[11, 20]])
    check('right gap', solve([[[2, 10]], [[1, 20], [2, 21]]]), [[10, 21]])
    check('single match', solve([[[1, 10]], [[1, 20]]]), [[10, 20]])
    check('no overlap', solve([[[1, 10]], [[3, 20]]]), [])
    check('empty left', solve([[], [[1, 20]]]), [])
    check('empty right', solve([[[1, 10]], []]), [])
elif N == 2:
    check('duplicate runs', solve([[[2, 10], [2, 11]], [[2, 20], [2, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[2, 10], [3, 11]], [[3, 20]]]), [[11, 20]])
    check('right gap', solve([[[3, 10]], [[2, 20], [3, 21]]]), [[10, 21]])
    check('single match', solve([[[2, 10]], [[2, 20]]]), [[10, 20]])
    check('no overlap', solve([[[2, 10]], [[4, 20]]]), [])
    check('empty left', solve([[], [[2, 20]]]), [])
    check('empty right', solve([[[2, 10]], []]), [])
elif N == 3:
    check('duplicate runs', solve([[[3, 10], [3, 11]], [[3, 20], [3, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[3, 10], [4, 11]], [[4, 20]]]), [[11, 20]])
    check('right gap', solve([[[4, 10]], [[3, 20], [4, 21]]]), [[10, 21]])
    check('single match', solve([[[3, 10]], [[3, 20]]]), [[10, 20]])
    check('no overlap', solve([[[3, 10]], [[5, 20]]]), [])
    check('empty left', solve([[], [[3, 20]]]), [])
    check('empty right', solve([[[3, 10]], []]), [])
elif N == 4:
    check('duplicate runs', solve([[[4, 10], [4, 11]], [[4, 20], [4, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[4, 10], [5, 11]], [[5, 20]]]), [[11, 20]])
    check('right gap', solve([[[5, 10]], [[4, 20], [5, 21]]]), [[10, 21]])
    check('single match', solve([[[4, 10]], [[4, 20]]]), [[10, 20]])
    check('no overlap', solve([[[4, 10]], [[6, 20]]]), [])
    check('empty left', solve([[], [[4, 20]]]), [])
    check('empty right', solve([[[4, 10]], []]), [])
elif N == 5:
    check('duplicate runs', solve([[[5, 10], [5, 11]], [[5, 20], [5, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[5, 10], [6, 11]], [[6, 20]]]), [[11, 20]])
    check('right gap', solve([[[6, 10]], [[5, 20], [6, 21]]]), [[10, 21]])
    check('single match', solve([[[5, 10]], [[5, 20]]]), [[10, 20]])
    check('no overlap', solve([[[5, 10]], [[7, 20]]]), [])
    check('empty left', solve([[], [[5, 20]]]), [])
    check('empty right', solve([[[5, 10]], []]), [])
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:
Merge join advances the right cursor when the left key is smaller.

Join two key-sorted non-null relations [key,id] by matching equal-key runs. Emit the full left-major Cartesian product for each matching run. Advance the lower unmatched run and preserve physical order within equal-key runs.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        left,right=d
        i=j=0; out=[]
        while i<len(left) and j<len(right):
            a=left[i][0]; b=right[j][0]
            if a<b: i+=1; continue
            if a>b: i+=1; continue
            ie=i+1
            while ie<len(left) and left[ie][0]==a: ie+=1
            je=j+1
            while je<len(right) and right[je][0]==b: je+=1
            for x in left[i:ie]:
                for y in right[j:je]: out.append([x[1],y[1]])
            i,j=ie,je
        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('duplicate runs', solve([[[1, 10], [1, 11]], [[1, 20], [1, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[1, 10], [2, 11]], [[2, 20]]]), [[11, 20]])
    check('right gap', solve([[[2, 10]], [[1, 20], [2, 21]]]), [[10, 21]])
    check('single match', solve([[[1, 10]], [[1, 20]]]), [[10, 20]])
    check('no overlap', solve([[[1, 10]], [[3, 20]]]), [])
    check('empty left', solve([[], [[1, 20]]]), [])
    check('empty right', solve([[[1, 10]], []]), [])
elif N == 2:
    check('duplicate runs', solve([[[2, 10], [2, 11]], [[2, 20], [2, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[2, 10], [3, 11]], [[3, 20]]]), [[11, 20]])
    check('right gap', solve([[[3, 10]], [[2, 20], [3, 21]]]), [[10, 21]])
    check('single match', solve([[[2, 10]], [[2, 20]]]), [[10, 20]])
    check('no overlap', solve([[[2, 10]], [[4, 20]]]), [])
    check('empty left', solve([[], [[2, 20]]]), [])
    check('empty right', solve([[[2, 10]], []]), [])
elif N == 3:
    check('duplicate runs', solve([[[3, 10], [3, 11]], [[3, 20], [3, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[3, 10], [4, 11]], [[4, 20]]]), [[11, 20]])
    check('right gap', solve([[[4, 10]], [[3, 20], [4, 21]]]), [[10, 21]])
    check('single match', solve([[[3, 10]], [[3, 20]]]), [[10, 20]])
    check('no overlap', solve([[[3, 10]], [[5, 20]]]), [])
    check('empty left', solve([[], [[3, 20]]]), [])
    check('empty right', solve([[[3, 10]], []]), [])
elif N == 4:
    check('duplicate runs', solve([[[4, 10], [4, 11]], [[4, 20], [4, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[4, 10], [5, 11]], [[5, 20]]]), [[11, 20]])
    check('right gap', solve([[[5, 10]], [[4, 20], [5, 21]]]), [[10, 21]])
    check('single match', solve([[[4, 10]], [[4, 20]]]), [[10, 20]])
    check('no overlap', solve([[[4, 10]], [[6, 20]]]), [])
    check('empty left', solve([[], [[4, 20]]]), [])
    check('empty right', solve([[[4, 10]], []]), [])
elif N == 5:
    check('duplicate runs', solve([[[5, 10], [5, 11]], [[5, 20], [5, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[5, 10], [6, 11]], [[6, 20]]]), [[11, 20]])
    check('right gap', solve([[[6, 10]], [[5, 20], [6, 21]]]), [[10, 21]])
    check('single match', solve([[[5, 10]], [[5, 20]]]), [[10, 20]])
    check('no overlap', solve([[[5, 10]], [[7, 20]]]), [])
    check('empty left', solve([[], [[5, 20]]]), [])
    check('empty right', solve([[[5, 10]], []]), [])
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:
        left,right=d
        i=j=0; out=[]
        while i<len(left) and j<len(right):
            a=left[i][0]; b=right[j][0]
            if a<b: i+=1; continue
            if a>b: i+=1; j+=1; continue
            ie=i+1
            while ie<len(left) and left[ie][0]==a: ie+=1
            je=j+1
            while je<len(right) and right[je][0]==b: je+=1
            for x in left[i:ie]:
                for y in right[j:je]: out.append([x[1],y[1]])
            i,j=ie,je
        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('duplicate runs', solve([[[1, 10], [1, 11]], [[1, 20], [1, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[1, 10], [2, 11]], [[2, 20]]]), [[11, 20]])
    check('right gap', solve([[[2, 10]], [[1, 20], [2, 21]]]), [[10, 21]])
    check('single match', solve([[[1, 10]], [[1, 20]]]), [[10, 20]])
    check('no overlap', solve([[[1, 10]], [[3, 20]]]), [])
    check('empty left', solve([[], [[1, 20]]]), [])
    check('empty right', solve([[[1, 10]], []]), [])
elif N == 2:
    check('duplicate runs', solve([[[2, 10], [2, 11]], [[2, 20], [2, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[2, 10], [3, 11]], [[3, 20]]]), [[11, 20]])
    check('right gap', solve([[[3, 10]], [[2, 20], [3, 21]]]), [[10, 21]])
    check('single match', solve([[[2, 10]], [[2, 20]]]), [[10, 20]])
    check('no overlap', solve([[[2, 10]], [[4, 20]]]), [])
    check('empty left', solve([[], [[2, 20]]]), [])
    check('empty right', solve([[[2, 10]], []]), [])
elif N == 3:
    check('duplicate runs', solve([[[3, 10], [3, 11]], [[3, 20], [3, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[3, 10], [4, 11]], [[4, 20]]]), [[11, 20]])
    check('right gap', solve([[[4, 10]], [[3, 20], [4, 21]]]), [[10, 21]])
    check('single match', solve([[[3, 10]], [[3, 20]]]), [[10, 20]])
    check('no overlap', solve([[[3, 10]], [[5, 20]]]), [])
    check('empty left', solve([[], [[3, 20]]]), [])
    check('empty right', solve([[[3, 10]], []]), [])
elif N == 4:
    check('duplicate runs', solve([[[4, 10], [4, 11]], [[4, 20], [4, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[4, 10], [5, 11]], [[5, 20]]]), [[11, 20]])
    check('right gap', solve([[[5, 10]], [[4, 20], [5, 21]]]), [[10, 21]])
    check('single match', solve([[[4, 10]], [[4, 20]]]), [[10, 20]])
    check('no overlap', solve([[[4, 10]], [[6, 20]]]), [])
    check('empty left', solve([[], [[4, 20]]]), [])
    check('empty right', solve([[[4, 10]], []]), [])
elif N == 5:
    check('duplicate runs', solve([[[5, 10], [5, 11]], [[5, 20], [5, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[5, 10], [6, 11]], [[6, 20]]]), [[11, 20]])
    check('right gap', solve([[[6, 10]], [[5, 20], [6, 21]]]), [[10, 21]])
    check('single match', solve([[[5, 10]], [[5, 20]]]), [[10, 20]])
    check('no overlap', solve([[[5, 10]], [[7, 20]]]), [])
    check('empty left', solve([[], [[5, 20]]]), [])
    check('empty right', solve([[[5, 10]], []]), [])
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:
Merge join advances the left cursor when the right key is smaller.

Join two key-sorted non-null relations [key,id] by matching equal-key runs. Emit the full left-major Cartesian product for each matching run. Advance the lower unmatched run and preserve physical order within equal-key runs.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        left,right=d
        i=j=0; out=[]
        while i<len(left) and j<len(right):
            a=left[i][0]; b=right[j][0]
            if a<b: i+=1; continue
            if a>b: j+=1; continue
            ie=i+1
            while ie<len(left) and left[ie][0]==a: ie+=1
            je=j+1
            while je<len(right) and right[je][0]==b: je+=1
            for x in left[i:ie]:
                for y in right[j:j+1]: out.append([x[1],y[1]])
            i,j=ie,je
        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('duplicate runs', solve([[[1, 10], [1, 11]], [[1, 20], [1, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[1, 10], [2, 11]], [[2, 20]]]), [[11, 20]])
    check('right gap', solve([[[2, 10]], [[1, 20], [2, 21]]]), [[10, 21]])
    check('single match', solve([[[1, 10]], [[1, 20]]]), [[10, 20]])
    check('no overlap', solve([[[1, 10]], [[3, 20]]]), [])
    check('empty left', solve([[], [[1, 20]]]), [])
    check('empty right', solve([[[1, 10]], []]), [])
elif N == 2:
    check('duplicate runs', solve([[[2, 10], [2, 11]], [[2, 20], [2, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[2, 10], [3, 11]], [[3, 20]]]), [[11, 20]])
    check('right gap', solve([[[3, 10]], [[2, 20], [3, 21]]]), [[10, 21]])
    check('single match', solve([[[2, 10]], [[2, 20]]]), [[10, 20]])
    check('no overlap', solve([[[2, 10]], [[4, 20]]]), [])
    check('empty left', solve([[], [[2, 20]]]), [])
    check('empty right', solve([[[2, 10]], []]), [])
elif N == 3:
    check('duplicate runs', solve([[[3, 10], [3, 11]], [[3, 20], [3, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[3, 10], [4, 11]], [[4, 20]]]), [[11, 20]])
    check('right gap', solve([[[4, 10]], [[3, 20], [4, 21]]]), [[10, 21]])
    check('single match', solve([[[3, 10]], [[3, 20]]]), [[10, 20]])
    check('no overlap', solve([[[3, 10]], [[5, 20]]]), [])
    check('empty left', solve([[], [[3, 20]]]), [])
    check('empty right', solve([[[3, 10]], []]), [])
elif N == 4:
    check('duplicate runs', solve([[[4, 10], [4, 11]], [[4, 20], [4, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[4, 10], [5, 11]], [[5, 20]]]), [[11, 20]])
    check('right gap', solve([[[5, 10]], [[4, 20], [5, 21]]]), [[10, 21]])
    check('single match', solve([[[4, 10]], [[4, 20]]]), [[10, 20]])
    check('no overlap', solve([[[4, 10]], [[6, 20]]]), [])
    check('empty left', solve([[], [[4, 20]]]), [])
    check('empty right', solve([[[4, 10]], []]), [])
elif N == 5:
    check('duplicate runs', solve([[[5, 10], [5, 11]], [[5, 20], [5, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[5, 10], [6, 11]], [[6, 20]]]), [[11, 20]])
    check('right gap', solve([[[6, 10]], [[5, 20], [6, 21]]]), [[10, 21]])
    check('single match', solve([[[5, 10]], [[5, 20]]]), [[10, 20]])
    check('no overlap', solve([[[5, 10]], [[7, 20]]]), [])
    check('empty left', solve([[], [[5, 20]]]), [])
    check('empty right', solve([[[5, 10]], []]), [])
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:
        left,right=d
        i=j=0; out=[]
        while i<len(left) and j<len(right):
            a=left[i][0]; b=right[j][0]
            if a<b: i+=1; continue
            if a>b: j+=1; continue
            ie=i+1
            while ie<len(left) and left[ie][0]==a: ie+=1
            je=j+1
            while je<len(right) and right[je][0]==b: je+=1
            for x in left[i:ie]:
                for y in right[je-1:je]: out.append([x[1],y[1]])
            i,j=ie,je
        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('duplicate runs', solve([[[1, 10], [1, 11]], [[1, 20], [1, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[1, 10], [2, 11]], [[2, 20]]]), [[11, 20]])
    check('right gap', solve([[[2, 10]], [[1, 20], [2, 21]]]), [[10, 21]])
    check('single match', solve([[[1, 10]], [[1, 20]]]), [[10, 20]])
    check('no overlap', solve([[[1, 10]], [[3, 20]]]), [])
    check('empty left', solve([[], [[1, 20]]]), [])
    check('empty right', solve([[[1, 10]], []]), [])
elif N == 2:
    check('duplicate runs', solve([[[2, 10], [2, 11]], [[2, 20], [2, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[2, 10], [3, 11]], [[3, 20]]]), [[11, 20]])
    check('right gap', solve([[[3, 10]], [[2, 20], [3, 21]]]), [[10, 21]])
    check('single match', solve([[[2, 10]], [[2, 20]]]), [[10, 20]])
    check('no overlap', solve([[[2, 10]], [[4, 20]]]), [])
    check('empty left', solve([[], [[2, 20]]]), [])
    check('empty right', solve([[[2, 10]], []]), [])
elif N == 3:
    check('duplicate runs', solve([[[3, 10], [3, 11]], [[3, 20], [3, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[3, 10], [4, 11]], [[4, 20]]]), [[11, 20]])
    check('right gap', solve([[[4, 10]], [[3, 20], [4, 21]]]), [[10, 21]])
    check('single match', solve([[[3, 10]], [[3, 20]]]), [[10, 20]])
    check('no overlap', solve([[[3, 10]], [[5, 20]]]), [])
    check('empty left', solve([[], [[3, 20]]]), [])
    check('empty right', solve([[[3, 10]], []]), [])
elif N == 4:
    check('duplicate runs', solve([[[4, 10], [4, 11]], [[4, 20], [4, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[4, 10], [5, 11]], [[5, 20]]]), [[11, 20]])
    check('right gap', solve([[[5, 10]], [[4, 20], [5, 21]]]), [[10, 21]])
    check('single match', solve([[[4, 10]], [[4, 20]]]), [[10, 20]])
    check('no overlap', solve([[[4, 10]], [[6, 20]]]), [])
    check('empty left', solve([[], [[4, 20]]]), [])
    check('empty right', solve([[[4, 10]], []]), [])
elif N == 5:
    check('duplicate runs', solve([[[5, 10], [5, 11]], [[5, 20], [5, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[5, 10], [6, 11]], [[6, 20]]]), [[11, 20]])
    check('right gap', solve([[[6, 10]], [[5, 20], [6, 21]]]), [[10, 21]])
    check('single match', solve([[[5, 10]], [[5, 20]]]), [[10, 20]])
    check('no overlap', solve([[[5, 10]], [[7, 20]]]), [])
    check('empty left', solve([[], [[5, 20]]]), [])
    check('empty right', solve([[[5, 10]], []]), [])
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:
Merge join reuses only one build row per equal-key run.

Join two key-sorted non-null relations [key,id] by matching equal-key runs. Emit the full left-major Cartesian product for each matching run. Advance the lower unmatched run and preserve physical order within equal-key runs.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        left,right=d
        i=j=0; out=[]
        while i<len(left) and j<len(right):
            a=left[i][0]; b=right[j][0]
            if a<b: i+=1; continue
            if a>b: j+=1; continue
            ie=i+1
            while ie<len(left) and left[ie][0]==a: ie+=1
            je=j+1
            while je<len(right) and right[je][0]==b: je+=1
            for x in reversed(left[i:ie]):
                for y in right[j:je]: out.append([x[1],y[1]])
            i,j=ie,je
        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('duplicate runs', solve([[[1, 10], [1, 11]], [[1, 20], [1, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[1, 10], [2, 11]], [[2, 20]]]), [[11, 20]])
    check('right gap', solve([[[2, 10]], [[1, 20], [2, 21]]]), [[10, 21]])
    check('single match', solve([[[1, 10]], [[1, 20]]]), [[10, 20]])
    check('no overlap', solve([[[1, 10]], [[3, 20]]]), [])
    check('empty left', solve([[], [[1, 20]]]), [])
    check('empty right', solve([[[1, 10]], []]), [])
elif N == 2:
    check('duplicate runs', solve([[[2, 10], [2, 11]], [[2, 20], [2, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[2, 10], [3, 11]], [[3, 20]]]), [[11, 20]])
    check('right gap', solve([[[3, 10]], [[2, 20], [3, 21]]]), [[10, 21]])
    check('single match', solve([[[2, 10]], [[2, 20]]]), [[10, 20]])
    check('no overlap', solve([[[2, 10]], [[4, 20]]]), [])
    check('empty left', solve([[], [[2, 20]]]), [])
    check('empty right', solve([[[2, 10]], []]), [])
elif N == 3:
    check('duplicate runs', solve([[[3, 10], [3, 11]], [[3, 20], [3, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[3, 10], [4, 11]], [[4, 20]]]), [[11, 20]])
    check('right gap', solve([[[4, 10]], [[3, 20], [4, 21]]]), [[10, 21]])
    check('single match', solve([[[3, 10]], [[3, 20]]]), [[10, 20]])
    check('no overlap', solve([[[3, 10]], [[5, 20]]]), [])
    check('empty left', solve([[], [[3, 20]]]), [])
    check('empty right', solve([[[3, 10]], []]), [])
elif N == 4:
    check('duplicate runs', solve([[[4, 10], [4, 11]], [[4, 20], [4, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[4, 10], [5, 11]], [[5, 20]]]), [[11, 20]])
    check('right gap', solve([[[5, 10]], [[4, 20], [5, 21]]]), [[10, 21]])
    check('single match', solve([[[4, 10]], [[4, 20]]]), [[10, 20]])
    check('no overlap', solve([[[4, 10]], [[6, 20]]]), [])
    check('empty left', solve([[], [[4, 20]]]), [])
    check('empty right', solve([[[4, 10]], []]), [])
elif N == 5:
    check('duplicate runs', solve([[[5, 10], [5, 11]], [[5, 20], [5, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[5, 10], [6, 11]], [[6, 20]]]), [[11, 20]])
    check('right gap', solve([[[6, 10]], [[5, 20], [6, 21]]]), [[10, 21]])
    check('single match', solve([[[5, 10]], [[5, 20]]]), [[10, 20]])
    check('no overlap', solve([[[5, 10]], [[7, 20]]]), [])
    check('empty left', solve([[], [[5, 20]]]), [])
    check('empty right', solve([[[5, 10]], []]), [])
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:
        left,right=d
        i=j=0; out=[]
        while i<len(left) and j<len(right):
            a=left[i][0]; b=right[j][0]
            if a<b: i+=1; continue
            if a>b: j+=1; continue
            ie=i+1
            while ie<len(left) and left[ie][0]==a: ie+=1
            je=j+1
            while je<len(right) and right[je][0]==b: je+=1
            for x in sorted(left[i:ie],key=lambda r:-r[1]):
                for y in right[j:je]: out.append([x[1],y[1]])
            i,j=ie,je
        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('duplicate runs', solve([[[1, 10], [1, 11]], [[1, 20], [1, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[1, 10], [2, 11]], [[2, 20]]]), [[11, 20]])
    check('right gap', solve([[[2, 10]], [[1, 20], [2, 21]]]), [[10, 21]])
    check('single match', solve([[[1, 10]], [[1, 20]]]), [[10, 20]])
    check('no overlap', solve([[[1, 10]], [[3, 20]]]), [])
    check('empty left', solve([[], [[1, 20]]]), [])
    check('empty right', solve([[[1, 10]], []]), [])
elif N == 2:
    check('duplicate runs', solve([[[2, 10], [2, 11]], [[2, 20], [2, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[2, 10], [3, 11]], [[3, 20]]]), [[11, 20]])
    check('right gap', solve([[[3, 10]], [[2, 20], [3, 21]]]), [[10, 21]])
    check('single match', solve([[[2, 10]], [[2, 20]]]), [[10, 20]])
    check('no overlap', solve([[[2, 10]], [[4, 20]]]), [])
    check('empty left', solve([[], [[2, 20]]]), [])
    check('empty right', solve([[[2, 10]], []]), [])
elif N == 3:
    check('duplicate runs', solve([[[3, 10], [3, 11]], [[3, 20], [3, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[3, 10], [4, 11]], [[4, 20]]]), [[11, 20]])
    check('right gap', solve([[[4, 10]], [[3, 20], [4, 21]]]), [[10, 21]])
    check('single match', solve([[[3, 10]], [[3, 20]]]), [[10, 20]])
    check('no overlap', solve([[[3, 10]], [[5, 20]]]), [])
    check('empty left', solve([[], [[3, 20]]]), [])
    check('empty right', solve([[[3, 10]], []]), [])
elif N == 4:
    check('duplicate runs', solve([[[4, 10], [4, 11]], [[4, 20], [4, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[4, 10], [5, 11]], [[5, 20]]]), [[11, 20]])
    check('right gap', solve([[[5, 10]], [[4, 20], [5, 21]]]), [[10, 21]])
    check('single match', solve([[[4, 10]], [[4, 20]]]), [[10, 20]])
    check('no overlap', solve([[[4, 10]], [[6, 20]]]), [])
    check('empty left', solve([[], [[4, 20]]]), [])
    check('empty right', solve([[[4, 10]], []]), [])
elif N == 5:
    check('duplicate runs', solve([[[5, 10], [5, 11]], [[5, 20], [5, 21]]]), [[10, 20], [10, 21], [11, 20], [11, 21]])
    check('left gap', solve([[[5, 10], [6, 11]], [[6, 20]]]), [[11, 20]])
    check('right gap', solve([[[6, 10]], [[5, 20], [6, 21]]]), [[10, 21]])
    check('single match', solve([[[5, 10]], [[5, 20]]]), [[10, 20]])
    check('no overlap', solve([[[5, 10]], [[7, 20]]]), [])
    check('empty left', solve([[], [[5, 20]]]), [])
    check('empty right', solve([[[5, 10]], []]), [])
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:
Merge join reverses left-run order while emitting pairs.

Join two key-sorted non-null relations [key,id] by matching equal-key runs. Emit the full left-major Cartesian product for each matching run. Advance the lower unmatched run and preserve physical order within equal-key runs.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        left,right=d
        seen=set(); out=[]
        for ident,key,value in left:
            matched=False
            for pos,(other,k,v) in enumerate(right):
                if key is not None and k==key:
                    matched=True
                    seen.add(pos)
                    out.append([ident,other])
            if not matched: out.append([ident,None])
        for pos,(other,k,v) in enumerate(right):
            if pos not in seen: out.append([None,other])
        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('residual failure', solve([[[10, 'a', 2]], [[20, 'a', 1]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 1], [11, 'b', 1]], [[20, 'a', 2]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 1]], [[20, 'a', 1], [21, 'b', 1]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 1]], [[20, 'a', 1], [20, 'a', 1]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 1]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('residual failure', solve([[[10, 'a', 3]], [[20, 'a', 2]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 2], [11, 'b', 2]], [[20, 'a', 3]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 2]], [[20, 'a', 2], [21, 'b', 2]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 2]], [[20, 'a', 2], [20, 'a', 2]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 2]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('residual failure', solve([[[10, 'a', 4]], [[20, 'a', 3]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 3], [11, 'b', 3]], [[20, 'a', 4]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 3]], [[20, 'a', 3], [21, 'b', 3]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 3]], [[20, 'a', 3], [20, 'a', 3]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 3]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('residual failure', solve([[[10, 'a', 5]], [[20, 'a', 4]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 4], [11, 'b', 4]], [[20, 'a', 5]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 4]], [[20, 'a', 4], [21, 'b', 4]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 4]], [[20, 'a', 4], [20, 'a', 4]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 4]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('residual failure', solve([[[10, 'a', 6]], [[20, 'a', 5]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 5], [11, 'b', 5]], [[20, 'a', 6]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 5]], [[20, 'a', 5], [21, 'b', 5]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 5]], [[20, 'a', 5], [20, 'a', 5]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 5]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 5]], []]), [[10, None]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        left,right=d
        seen=set(); out=[]
        for ident,key,value in left:
            matched=False
            for pos,(other,k,v) in enumerate(right):
                if key is not None and k==key and v>=0:
                    matched=True
                    seen.add(pos)
                    out.append([ident,other])
            if not matched: out.append([ident,None])
        for pos,(other,k,v) in enumerate(right):
            if pos not in seen: out.append([None,other])
        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('residual failure', solve([[[10, 'a', 2]], [[20, 'a', 1]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 1], [11, 'b', 1]], [[20, 'a', 2]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 1]], [[20, 'a', 1], [21, 'b', 1]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 1]], [[20, 'a', 1], [20, 'a', 1]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 1]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('residual failure', solve([[[10, 'a', 3]], [[20, 'a', 2]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 2], [11, 'b', 2]], [[20, 'a', 3]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 2]], [[20, 'a', 2], [21, 'b', 2]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 2]], [[20, 'a', 2], [20, 'a', 2]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 2]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('residual failure', solve([[[10, 'a', 4]], [[20, 'a', 3]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 3], [11, 'b', 3]], [[20, 'a', 4]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 3]], [[20, 'a', 3], [21, 'b', 3]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 3]], [[20, 'a', 3], [20, 'a', 3]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 3]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('residual failure', solve([[[10, 'a', 5]], [[20, 'a', 4]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 4], [11, 'b', 4]], [[20, 'a', 5]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 4]], [[20, 'a', 4], [21, 'b', 4]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 4]], [[20, 'a', 4], [20, 'a', 4]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 4]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('residual failure', solve([[[10, 'a', 6]], [[20, 'a', 5]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 5], [11, 'b', 5]], [[20, 'a', 6]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 5]], [[20, 'a', 5], [21, 'b', 5]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 5]], [[20, 'a', 5], [20, 'a', 5]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 5]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 5]], []]), [[10, None]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Full outer join marks equal-key residual failures as matched.

Execute a full outer join of [id,key,value] rows with equality on non-null keys and right.value>=left.value. Track right matches by physical position; failed residuals do not mark a row matched. Emit left-major pairs, then unmatched right rows.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        left,right=d
        seen=set(); out=[]
        for ident,key,value in left:
            matched=False
            for pos,(other,k,v) in enumerate(right):
                if key is not None and k==key and v>=value:
                    matched=True
                    seen.add(other)
                    out.append([ident,other])
            if not matched: out.append([ident,None])
        for pos,(other,k,v) in enumerate(right):
            if pos not in seen: out.append([None,other])
        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('residual failure', solve([[[10, 'a', 2]], [[20, 'a', 1]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 1], [11, 'b', 1]], [[20, 'a', 2]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 1]], [[20, 'a', 1], [21, 'b', 1]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 1]], [[20, 'a', 1], [20, 'a', 1]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 1]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('residual failure', solve([[[10, 'a', 3]], [[20, 'a', 2]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 2], [11, 'b', 2]], [[20, 'a', 3]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 2]], [[20, 'a', 2], [21, 'b', 2]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 2]], [[20, 'a', 2], [20, 'a', 2]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 2]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('residual failure', solve([[[10, 'a', 4]], [[20, 'a', 3]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 3], [11, 'b', 3]], [[20, 'a', 4]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 3]], [[20, 'a', 3], [21, 'b', 3]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 3]], [[20, 'a', 3], [20, 'a', 3]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 3]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('residual failure', solve([[[10, 'a', 5]], [[20, 'a', 4]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 4], [11, 'b', 4]], [[20, 'a', 5]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 4]], [[20, 'a', 4], [21, 'b', 4]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 4]], [[20, 'a', 4], [20, 'a', 4]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 4]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('residual failure', solve([[[10, 'a', 6]], [[20, 'a', 5]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 5], [11, 'b', 5]], [[20, 'a', 6]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 5]], [[20, 'a', 5], [21, 'b', 5]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 5]], [[20, 'a', 5], [20, 'a', 5]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 5]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 5]], []]), [[10, None]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        left,right=d
        seen=set(); out=[]
        for ident,key,value in left:
            matched=False
            for pos,(other,k,v) in enumerate(right):
                if key is not None and k==key and v>=value:
                    matched=True
                    seen.add(k)
                    out.append([ident,other])
            if not matched: out.append([ident,None])
        for pos,(other,k,v) in enumerate(right):
            if pos not in seen: out.append([None,other])
        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('residual failure', solve([[[10, 'a', 2]], [[20, 'a', 1]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 1], [11, 'b', 1]], [[20, 'a', 2]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 1]], [[20, 'a', 1], [21, 'b', 1]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 1]], [[20, 'a', 1], [20, 'a', 1]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 1]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('residual failure', solve([[[10, 'a', 3]], [[20, 'a', 2]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 2], [11, 'b', 2]], [[20, 'a', 3]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 2]], [[20, 'a', 2], [21, 'b', 2]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 2]], [[20, 'a', 2], [20, 'a', 2]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 2]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('residual failure', solve([[[10, 'a', 4]], [[20, 'a', 3]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 3], [11, 'b', 3]], [[20, 'a', 4]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 3]], [[20, 'a', 3], [21, 'b', 3]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 3]], [[20, 'a', 3], [20, 'a', 3]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 3]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('residual failure', solve([[[10, 'a', 5]], [[20, 'a', 4]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 4], [11, 'b', 4]], [[20, 'a', 5]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 4]], [[20, 'a', 4], [21, 'b', 4]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 4]], [[20, 'a', 4], [20, 'a', 4]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 4]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('residual failure', solve([[[10, 'a', 6]], [[20, 'a', 5]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 5], [11, 'b', 5]], [[20, 'a', 6]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 5]], [[20, 'a', 5], [21, 'b', 5]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 5]], [[20, 'a', 5], [20, 'a', 5]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 5]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 5]], []]), [[10, None]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Full outer join stores right IDs but tests physical positions.

Execute a full outer join of [id,key,value] rows with equality on non-null keys and right.value>=left.value. Track right matches by physical position; failed residuals do not mark a row matched. Emit left-major pairs, then unmatched right rows.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        left,right=d
        seen=set(); out=[]
        for ident,key,value in left:
            matched=bool(seen)
            for pos,(other,k,v) in enumerate(right):
                if key is not None and k==key and v>=value:
                    matched=True
                    seen.add(pos)
                    out.append([ident,other])
            if not matched: out.append([ident,None])
        for pos,(other,k,v) in enumerate(right):
            if pos not in seen: out.append([None,other])
        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('residual failure', solve([[[10, 'a', 2]], [[20, 'a', 1]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 1], [11, 'b', 1]], [[20, 'a', 2]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 1]], [[20, 'a', 1], [21, 'b', 1]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 1]], [[20, 'a', 1], [20, 'a', 1]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 1]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('residual failure', solve([[[10, 'a', 3]], [[20, 'a', 2]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 2], [11, 'b', 2]], [[20, 'a', 3]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 2]], [[20, 'a', 2], [21, 'b', 2]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 2]], [[20, 'a', 2], [20, 'a', 2]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 2]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('residual failure', solve([[[10, 'a', 4]], [[20, 'a', 3]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 3], [11, 'b', 3]], [[20, 'a', 4]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 3]], [[20, 'a', 3], [21, 'b', 3]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 3]], [[20, 'a', 3], [20, 'a', 3]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 3]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('residual failure', solve([[[10, 'a', 5]], [[20, 'a', 4]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 4], [11, 'b', 4]], [[20, 'a', 5]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 4]], [[20, 'a', 4], [21, 'b', 4]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 4]], [[20, 'a', 4], [20, 'a', 4]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 4]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('residual failure', solve([[[10, 'a', 6]], [[20, 'a', 5]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 5], [11, 'b', 5]], [[20, 'a', 6]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 5]], [[20, 'a', 5], [21, 'b', 5]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 5]], [[20, 'a', 5], [20, 'a', 5]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 5]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 5]], []]), [[10, None]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        left,right=d
        seen=set(); out=[]
        for ident,key,value in left:
            matched=bool(out)
            for pos,(other,k,v) in enumerate(right):
                if key is not None and k==key and v>=value:
                    matched=True
                    seen.add(pos)
                    out.append([ident,other])
            if not matched: out.append([ident,None])
        for pos,(other,k,v) in enumerate(right):
            if pos not in seen: out.append([None,other])
        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('residual failure', solve([[[10, 'a', 2]], [[20, 'a', 1]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 1], [11, 'b', 1]], [[20, 'a', 2]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 1]], [[20, 'a', 1], [21, 'b', 1]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 1]], [[20, 'a', 1], [20, 'a', 1]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 1]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('residual failure', solve([[[10, 'a', 3]], [[20, 'a', 2]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 2], [11, 'b', 2]], [[20, 'a', 3]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 2]], [[20, 'a', 2], [21, 'b', 2]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 2]], [[20, 'a', 2], [20, 'a', 2]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 2]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('residual failure', solve([[[10, 'a', 4]], [[20, 'a', 3]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 3], [11, 'b', 3]], [[20, 'a', 4]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 3]], [[20, 'a', 3], [21, 'b', 3]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 3]], [[20, 'a', 3], [20, 'a', 3]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 3]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('residual failure', solve([[[10, 'a', 5]], [[20, 'a', 4]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 4], [11, 'b', 4]], [[20, 'a', 5]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 4]], [[20, 'a', 4], [21, 'b', 4]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 4]], [[20, 'a', 4], [20, 'a', 4]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 4]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('residual failure', solve([[[10, 'a', 6]], [[20, 'a', 5]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 5], [11, 'b', 5]], [[20, 'a', 6]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 5]], [[20, 'a', 5], [21, 'b', 5]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 5]], [[20, 'a', 5], [20, 'a', 5]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 5]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 5]], []]), [[10, None]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Full outer join carries a successful match into the next left row.

Execute a full outer join of [id,key,value] rows with equality on non-null keys and right.value>=left.value. Track right matches by physical position; failed residuals do not mark a row matched. Emit left-major pairs, then unmatched right rows.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        left,right=d
        seen=set(); out=[]
        for ident,key,value in left:
            matched=False
            for pos,(other,k,v) in enumerate(right):
                if key is not None and k==key and v>=value:
                    matched=True
                    seen.add(pos)
                    out.append([ident,other])
            if not matched: pass
        for pos,(other,k,v) in enumerate(right):
            if pos not in seen: out.append([None,other])
        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('residual failure', solve([[[10, 'a', 2]], [[20, 'a', 1]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 1], [11, 'b', 1]], [[20, 'a', 2]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 1]], [[20, 'a', 1], [21, 'b', 1]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 1]], [[20, 'a', 1], [20, 'a', 1]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 1]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('residual failure', solve([[[10, 'a', 3]], [[20, 'a', 2]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 2], [11, 'b', 2]], [[20, 'a', 3]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 2]], [[20, 'a', 2], [21, 'b', 2]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 2]], [[20, 'a', 2], [20, 'a', 2]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 2]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('residual failure', solve([[[10, 'a', 4]], [[20, 'a', 3]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 3], [11, 'b', 3]], [[20, 'a', 4]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 3]], [[20, 'a', 3], [21, 'b', 3]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 3]], [[20, 'a', 3], [20, 'a', 3]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 3]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('residual failure', solve([[[10, 'a', 5]], [[20, 'a', 4]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 4], [11, 'b', 4]], [[20, 'a', 5]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 4]], [[20, 'a', 4], [21, 'b', 4]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 4]], [[20, 'a', 4], [20, 'a', 4]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 4]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('residual failure', solve([[[10, 'a', 6]], [[20, 'a', 5]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 5], [11, 'b', 5]], [[20, 'a', 6]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 5]], [[20, 'a', 5], [21, 'b', 5]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 5]], [[20, 'a', 5], [20, 'a', 5]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 5]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 5]], []]), [[10, None]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        left,right=d
        seen=set(); out=[]
        for ident,key,value in left:
            matched=False
            for pos,(other,k,v) in enumerate(right):
                if key is not None and k==key and v>=value:
                    matched=True
                    seen.add(pos)
                    out.append([ident,other])
            if not matched: out.append([None,ident])
        for pos,(other,k,v) in enumerate(right):
            if pos not in seen: out.append([None,other])
        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('residual failure', solve([[[10, 'a', 2]], [[20, 'a', 1]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 1], [11, 'b', 1]], [[20, 'a', 2]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 1]], [[20, 'a', 1], [21, 'b', 1]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 1]], [[20, 'a', 1], [20, 'a', 1]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 1]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('residual failure', solve([[[10, 'a', 3]], [[20, 'a', 2]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 2], [11, 'b', 2]], [[20, 'a', 3]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 2]], [[20, 'a', 2], [21, 'b', 2]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 2]], [[20, 'a', 2], [20, 'a', 2]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 2]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('residual failure', solve([[[10, 'a', 4]], [[20, 'a', 3]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 3], [11, 'b', 3]], [[20, 'a', 4]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 3]], [[20, 'a', 3], [21, 'b', 3]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 3]], [[20, 'a', 3], [20, 'a', 3]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 3]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('residual failure', solve([[[10, 'a', 5]], [[20, 'a', 4]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 4], [11, 'b', 4]], [[20, 'a', 5]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 4]], [[20, 'a', 4], [21, 'b', 4]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 4]], [[20, 'a', 4], [20, 'a', 4]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 4]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('residual failure', solve([[[10, 'a', 6]], [[20, 'a', 5]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 5], [11, 'b', 5]], [[20, 'a', 6]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 5]], [[20, 'a', 5], [21, 'b', 5]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 5]], [[20, 'a', 5], [20, 'a', 5]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 5]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 5]], []]), [[10, None]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Full outer join omits unmatched left placeholders.

Execute a full outer join of [id,key,value] rows with equality on non-null keys and right.value>=left.value. Track right matches by physical position; failed residuals do not mark a row matched. Emit left-major pairs, then unmatched right rows.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        left,right=d
        seen=set(); out=[]
        for ident,key,value in left:
            matched=False
            for pos,(other,k,v) in enumerate(right):
                if key is not None and k==key and v>=value:
                    matched=True
                    seen.add(pos)
                    out.append([ident,other])
            if not matched: out.append([ident,None])
        for pos,(other,k,v) in enumerate(right):
            if True: out.append([None,other])
        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('residual failure', solve([[[10, 'a', 2]], [[20, 'a', 1]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 1], [11, 'b', 1]], [[20, 'a', 2]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 1]], [[20, 'a', 1], [21, 'b', 1]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 1]], [[20, 'a', 1], [20, 'a', 1]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 1]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('residual failure', solve([[[10, 'a', 3]], [[20, 'a', 2]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 2], [11, 'b', 2]], [[20, 'a', 3]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 2]], [[20, 'a', 2], [21, 'b', 2]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 2]], [[20, 'a', 2], [20, 'a', 2]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 2]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('residual failure', solve([[[10, 'a', 4]], [[20, 'a', 3]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 3], [11, 'b', 3]], [[20, 'a', 4]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 3]], [[20, 'a', 3], [21, 'b', 3]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 3]], [[20, 'a', 3], [20, 'a', 3]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 3]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('residual failure', solve([[[10, 'a', 5]], [[20, 'a', 4]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 4], [11, 'b', 4]], [[20, 'a', 5]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 4]], [[20, 'a', 4], [21, 'b', 4]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 4]], [[20, 'a', 4], [20, 'a', 4]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 4]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('residual failure', solve([[[10, 'a', 6]], [[20, 'a', 5]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 5], [11, 'b', 5]], [[20, 'a', 6]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 5]], [[20, 'a', 5], [21, 'b', 5]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 5]], [[20, 'a', 5], [20, 'a', 5]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 5]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 5]], []]), [[10, None]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        left,right=d
        seen=set(); out=[]
        for ident,key,value in left:
            matched=False
            for pos,(other,k,v) in enumerate(right):
                if key is not None and k==key and v>=value:
                    matched=True
                    seen.add(pos)
                    out.append([ident,other])
            if not matched: out.append([ident,None])
        for pos,(other,k,v) in enumerate(right):
            if pos in seen: out.append([None,other])
        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('residual failure', solve([[[10, 'a', 2]], [[20, 'a', 1]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 1], [11, 'b', 1]], [[20, 'a', 2]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 1]], [[20, 'a', 1], [21, 'b', 1]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 1]], [[20, 'a', 1], [20, 'a', 1]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 1]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('residual failure', solve([[[10, 'a', 3]], [[20, 'a', 2]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 2], [11, 'b', 2]], [[20, 'a', 3]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 2]], [[20, 'a', 2], [21, 'b', 2]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 2]], [[20, 'a', 2], [20, 'a', 2]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 2]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('residual failure', solve([[[10, 'a', 4]], [[20, 'a', 3]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 3], [11, 'b', 3]], [[20, 'a', 4]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 3]], [[20, 'a', 3], [21, 'b', 3]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 3]], [[20, 'a', 3], [20, 'a', 3]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 3]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('residual failure', solve([[[10, 'a', 5]], [[20, 'a', 4]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 4], [11, 'b', 4]], [[20, 'a', 5]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 4]], [[20, 'a', 4], [21, 'b', 4]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 4]], [[20, 'a', 4], [20, 'a', 4]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 4]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('residual failure', solve([[[10, 'a', 6]], [[20, 'a', 5]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 5], [11, 'b', 5]], [[20, 'a', 6]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 5]], [[20, 'a', 5], [21, 'b', 5]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 5]], [[20, 'a', 5], [20, 'a', 5]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 5]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 5]], []]), [[10, None]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Full outer join emits already matched right rows again.

Execute a full outer join of [id,key,value] rows with equality on non-null keys and right.value>=left.value. Track right matches by physical position; failed residuals do not mark a row matched. Emit left-major pairs, then unmatched right rows.

split: open-access


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

N = 1
observations = []
def solve(d):
    try:
        left,right=d
        seen=set(); out=[]
        for ident,key,value in left:
            matched=False
            for pos,(other,k,v) in enumerate(right):
                if k==key and v>=value:
                    matched=True
                    seen.add(pos)
                    out.append([ident,other])
            if not matched: out.append([ident,None])
        for pos,(other,k,v) in enumerate(right):
            if pos not in seen: out.append([None,other])
        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('residual failure', solve([[[10, 'a', 2]], [[20, 'a', 1]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 1], [11, 'b', 1]], [[20, 'a', 2]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 1]], [[20, 'a', 1], [21, 'b', 1]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 1]], [[20, 'a', 1], [20, 'a', 1]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 1]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('residual failure', solve([[[10, 'a', 3]], [[20, 'a', 2]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 2], [11, 'b', 2]], [[20, 'a', 3]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 2]], [[20, 'a', 2], [21, 'b', 2]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 2]], [[20, 'a', 2], [20, 'a', 2]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 2]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('residual failure', solve([[[10, 'a', 4]], [[20, 'a', 3]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 3], [11, 'b', 3]], [[20, 'a', 4]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 3]], [[20, 'a', 3], [21, 'b', 3]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 3]], [[20, 'a', 3], [20, 'a', 3]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 3]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('residual failure', solve([[[10, 'a', 5]], [[20, 'a', 4]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 4], [11, 'b', 4]], [[20, 'a', 5]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 4]], [[20, 'a', 4], [21, 'b', 4]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 4]], [[20, 'a', 4], [20, 'a', 4]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 4]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('residual failure', solve([[[10, 'a', 6]], [[20, 'a', 5]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 5], [11, 'b', 5]], [[20, 'a', 6]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 5]], [[20, 'a', 5], [21, 'b', 5]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 5]], [[20, 'a', 5], [20, 'a', 5]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 5]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 5]], []]), [[10, None]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    try:
        left,right=d
        seen=set(); out=[]
        for ident,key,value in left:
            matched=False
            for pos,(other,k,v) in enumerate(right):
                if (key is None or k==key) and v>=value:
                    matched=True
                    seen.add(pos)
                    out.append([ident,other])
            if not matched: out.append([ident,None])
        for pos,(other,k,v) in enumerate(right):
            if pos not in seen: out.append([None,other])
        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('residual failure', solve([[[10, 'a', 2]], [[20, 'a', 1]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 1], [11, 'b', 1]], [[20, 'a', 2]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 1]], [[20, None, 1]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 1]], [[20, 'a', 1], [21, 'b', 1]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 1]], [[20, 'a', 1], [20, 'a', 1]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 1]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 1]], []]), [[10, None]])
elif N == 2:
    check('residual failure', solve([[[10, 'a', 3]], [[20, 'a', 2]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 2], [11, 'b', 2]], [[20, 'a', 3]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 2]], [[20, None, 2]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 2]], [[20, 'a', 2], [21, 'b', 2]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 2]], [[20, 'a', 2], [20, 'a', 2]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 2]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 2]], []]), [[10, None]])
elif N == 3:
    check('residual failure', solve([[[10, 'a', 4]], [[20, 'a', 3]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 3], [11, 'b', 3]], [[20, 'a', 4]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 3]], [[20, None, 3]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 3]], [[20, 'a', 3], [21, 'b', 3]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 3]], [[20, 'a', 3], [20, 'a', 3]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 3]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 3]], []]), [[10, None]])
elif N == 4:
    check('residual failure', solve([[[10, 'a', 5]], [[20, 'a', 4]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 4], [11, 'b', 4]], [[20, 'a', 5]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 4]], [[20, None, 4]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 4]], [[20, 'a', 4], [21, 'b', 4]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 4]], [[20, 'a', 4], [20, 'a', 4]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 4]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 4]], []]), [[10, None]])
elif N == 5:
    check('residual failure', solve([[[10, 'a', 6]], [[20, 'a', 5]]]), [[10, None], [None, 20]])
    check('matched then unmatched', solve([[[10, 'a', 5], [11, 'b', 5]], [[20, 'a', 6]]]), [[10, 20], [11, None]])
    check('null keys', solve([[[10, None, 5]], [[20, None, 5]]]), [[10, None], [None, 20]])
    check('right unmatched', solve([[[10, 'a', 5]], [[20, 'a', 5], [21, 'b', 5]]]), [[10, 20], [None, 21]])
    check('right physical duplicates', solve([[[10, 'a', 5]], [[20, 'a', 5], [20, 'a', 5]]]), [[10, 20], [10, 20]])
    check('empty left', solve([[], [[20, 'a', 5]]]), [[None, 20]])
    check('empty right', solve([[[10, 'a', 5]], []]), [[10, None]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Full outer join treats missing keys as equal matches.

Execute a full outer join of [id,key,value] rows with equality on non-null keys and right.value>=left.value. Track right matches by physical position; failed residuals do not mark a row matched. Emit left-major pairs, then unmatched right rows.

split: open-access