FA-87781 / Collision detection broadphase / Open access
Second pass reports pairs as [b, a] · case 01
Consumers index the static set with a dynamic id.
ROOT CAUSE
Pass 2 appends [b id, a id].
VERIFIED REPAIR
Always report [a id, b id].
Unsuccessful approach: Sorting each pair by id breaks the set orientation.
Case contract
solve(A, B): bipartite box pruning (dynamic set A vs static set B), boxes [id,minx,miny,maxx,maxy], closed intervals. Sort both by (minx,id). Pass 1: for each a, B boxes with minx in [a.minx, a.maxx]; pass 2: for each b, A boxes with minx in (b.minx, b.maxx]; y overlap required. Return sorted [a id, b id] pairs.
Why this case matters
Broadphase stages decide which object pairs ever reach narrowphase; a wrong boundary, ordering or bookkeeping rule silently drops real contacts or floods the solver with false candidates.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(A, B):
As = sorted(A, key=lambda r: (r[1], r[0]))
Bs = sorted(B, key=lambda r: (r[1], r[0]))
def yover(p, q):
return p[2] <= q[4] and q[2] <= p[4]
pairs = []
j = 0
for a in As:
while j < len(Bs) and Bs[j][1] < a[1]:
j += 1
k = j
while k < len(Bs) and Bs[k][1] <= a[3]:
if yover(a, Bs[k]):
pairs.append([a[0], Bs[k][0]])
k += 1
j2 = 0
for b in Bs:
while j2 < len(As) and As[j2][1] <= b[1]:
j2 += 1
k = j2
while k < len(As) and As[k][1] <= b[3]:
if yover(As[k], b):
pairs.append([b[0], As[k][0]])
k += 1
pairs.sort()
return pairs
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[[23, -1.0, 2.0, 0.0, 2.0]], [[28, -1.0, -5.0, 3.0, -3.0], [5, 4.0, 3.0, 5.0, 4.0]]], []], [[[[29, -3.0, -4.0, -3.0, -1.0], [37, 5.0, 0.0, 5.0, 0.0], [14, -1.0, 2.0, 0.0, 3.0]], [[1, -3.0, -1.0, 3.0, -1.0], [20, 4.0, 0.0, 5.0, 3.0]]], [[29, 1], [37, 20]]], [[[[16, -3.0, 4.0, -3.0, 4.0], [21, 0.0, -2.0, 1.0, -2.0], [17, -3.0, -1.0, -2.0, 0.0]], [[11, -3.0, -2.0, 2.0, -2.0], [24, -5.0, 4.0, -3.0, 7.0], [5, -5.0, 0.0, -4.0, 2.0]]], [[16, 24], [21, 11]]], [[[[22, -5.0, -3.0, -2.0, 0.0], [19, 1.0, 3.0, 4.0, 5.0], [38, 0.0, 1.0, 0.0, 3.0], [33, 1.0, -4.0, 3.0, -3.0]], [[18, -1.0, 1.0, 2.0, 2.0], [27, -5.0, -1.0, -2.0, 0.0]]], [[22, 27], [38, 18]]], [[[[32, -2.0, 1.0, 1.0, 1.0], [4, 5.0, -2.0, 6.0, 1.0], [17, -3.0, -4.0, -1.0, -1.0]], [[28, 2.0, 4.0, 5.0, 7.0], [10, 5.0, 2.0, 8.0, 2.0], [6, -4.0, 0.0, -2.0, 1.0]]], [[32, 6]]], [[[[7, -5.0, 2.0, -2.0, 3.0]], [[22, 0.0, 5.0, 1.0, 8.0], [19, 0.0, 3.0, 3.0, 6.0]]], []], [[[[26, 1.0, 0.0, 4.0, 2.0]], [[12, -2.0, -1.0, -1.0, -1.0], [30, -4.0, 1.0, -2.0, 1.0], [6, -1.0, 1.0, 1.0, 1.0], [25, 5.0, -2.0, 5.0, 1.0]]], [[26, 6]]], [[[[14, 2.0, -5.0, 4.0, -4.0], [36, 4.0, -3.0, 6.0, -3.0], [5, 1.0, 3.0, 1.0, 6.0], [16, -3.0, 0.0, -1.0, 2.0]], [[34, 4.0, 1.0, 7.0, 4.0]]], []]], [[[[[2, 2.0, -1.0, 4.0, 0.0], [14, 3.0, -3.0, 3.0, -2.0]], [[5, -3.0, -2.0, -1.0, 0.0]]], []], [[[[9, 1.0, 5.0, 2.0, 7.0], [2, 2.0, 3.0, 5.0, 5.0], [18, -1.0, 1.0, 1.0, 2.0]], [[10, 5.0, -4.0, 7.0, -2.0], [7, -4.0, 2.0, -1.0, 4.0], [37, 4.0, 3.0, 5.0, 3.0], [23, 1.0, -2.0, 1.0, -2.0]]], [[2, 37], [18, 7]]], [[[[17, -2.0, -5.0, 1.0, -2.0], [23, 5.0, 3.0, 6.0, 5.0], [31, -3.0, -5.0, -1.0, -5.0]], [[7, -2.0, -1.0, 5.0, -1.0]]], []], [[[[5, -1.0, 1.0, 0.0, 4.0], [23, -5.0, -5.0, -3.0, -5.0]], [[17, -1.0, 1.0, -1.0, 1.0]]], [[5, 17]]], [[[[20, -4.0, -5.0, -4.0, -2.0], [9, 5.0, 2.0, 6.0, 5.0]], [[18, 2.0, 5.0, 4.0, 5.0], [5, 4.0, 3.0, 7.0, 5.0]]], [[9, 5]]], [[[[11, 0.0, -2.0, 0.0, 1.0], [17, -2.0, 3.0, 0.0, 3.0], [29, 2.0, -2.0, 4.0, -1.0]], [[1, 3.0, 1.0, 4.0, 4.0], [7, 4.0, 3.0, 7.0, 6.0], [28, -5.0, -1.0, -2.0, 2.0], [2, -4.0, 1.0, -2.0, 4.0]]], [[17, 2]]], [[[[3, -4.0, -2.0, -4.0, -2.0], [33, 5.0, -4.0, 7.0, -1.0], [1, -4.0, 2.0, -1.0, 2.0], [19, 4.0, 5.0, 6.0, 8.0]], [[7, 1.0, -2.0, 3.0, -1.0], [6, 1.0, 4.0, 4.0, 6.0]]], [[19, 6]]], [[[[21, -4.0, -2.0, -3.0, -1.0]], [[15, -2.0, -5.0, 0.0, -3.0], [2, -2.0, 3.0, 1.0, 3.0]]], []]], [[[[[27, 0.0, 3.0, 0.0, 6.0], [12, -4.0, 4.0, -3.0, 7.0], [8, -3.0, -1.0, -1.0, -1.0]], [[4, -1.0, -4.0, -1.0, -1.0], [16, -5.0, -4.0, -4.0, -3.0], [28, -4.0, 5.0, -2.0, 5.0], [5, -1.0, 4.0, 2.0, 5.0]]], [[8, 4], [12, 28], [27, 5]]], [[[[22, 0.0, 3.0, 0.0, 6.0], [10, 4.0, -1.0, 5.0, 0.0], [26, 5.0, 2.0, 8.0, 3.0], [2, 5.0, -3.0, 5.0, 0.0]], [[18, 0.0, -5.0, 5.0, -2.0]]], [[2, 18]]], [[[[14, -4.0, -3.0, -2.0, 0.0], [18, 0.0, -5.0, 2.0, -2.0], [37, 5.0, 5.0, 7.0, 5.0]], [[34, -4.0, -1.0, 5.0, 0.0], [4, -2.0, -2.0, 1.0, 1.0], [3, -2.0, 3.0, -2.0, 4.0], [11, 4.0, 5.0, 7.0, 6.0]]], [[14, 4], [14, 34], [18, 4], [37, 11]]], [[[[17, 1.0, 5.0, 2.0, 7.0]], [[19, 1.0, 4.0, 4.0, 4.0]]], []], [[[[30, 1.0, -2.0, 2.0, -2.0], [32, -1.0, -5.0, -1.0, -3.0], [28, -3.0, 5.0, 0.0, 5.0]], [[24, -4.0, 0.0, -2.0, 1.0], [22, -3.0, -3.0, 0.0, 0.0], [8, 4.0, -5.0, 6.0, -5.0], [31, 0.0, 5.0, 2.0, 8.0]]], [[28, 31], [32, 22]]], [[[[17, -1.0, -1.0, -1.0, -1.0], [19, 2.0, 0.0, 4.0, 2.0]], [[3, -3.0, 3.0, -3.0, 5.0], [24, -4.0, 2.0, -1.0, 3.0], [16, 0.0, -3.0, 2.0, 0.0], [28, 0.0, -4.0, 1.0, -4.0]]], [[19, 16]]], [[[[34, 3.0, 5.0, 4.0, 5.0], [13, -1.0, -5.0, 0.0, -4.0], [16, -2.0, 1.0, 1.0, 1.0]], [[10, 1.0, 0.0, 3.0, 1.0], [30, -1.0, -5.0, -1.0, -2.0]]], [[13, 30], [16, 10]]], [[[[26, -1.0, 1.0, 0.0, 1.0]], [[15, 1.0, -1.0, 2.0, -1.0], [10, 4.0, 5.0, 7.0, 6.0], [34, -5.0, -1.0, -4.0, -1.0]]], []]], [[[[[31, 2.0, 4.0, 2.0, 4.0], [7, -2.0, 2.0, 1.0, 4.0], [6, 3.0, 1.0, 5.0, 2.0], [35, 3.0, 2.0, 6.0, 4.0]], [[29, 5.0, -5.0, 7.0, -3.0], [1, 0.0, 0.0, 3.0, 2.0], [39, 0.0, -3.0, 3.0, -3.0], [2, 4.0, -1.0, 4.0, 1.0]]], [[6, 1], [6, 2], [7, 1], [35, 1]]], [[[[3, -3.0, -2.0, -1.0, 0.0]], [[7, 2.0, -5.0, 3.0, -3.0]]], []], [[[[16, -3.0, 4.0, 0.0, 4.0], [32, -1.0, -2.0, 2.0, 0.0]], [[29, -3.0, 0.0, 3.0, 0.0], [2, 2.0, -1.0, 2.0, 0.0], [13, 2.0, 4.0, 2.0, 6.0], [8, -1.0, -4.0, 1.0, -2.0]]], [[32, 2], [32, 8], [32, 29]]], [[[[14, 5.0, 3.0, 7.0, 4.0], [28, -4.0, 3.0, -1.0, 4.0], [26, 0.0, -5.0, 3.0, -4.0], [8, 5.0, 2.0, 8.0, 3.0]], [[1, 5.0, 1.0, 5.0, 3.0], [12, -2.0, 3.0, 1.0, 3.0]]], [[8, 1], [14, 1], [28, 12]]], [[[[26, 4.0, -5.0, 6.0, -3.0]], [[24, 4.0, -1.0, 4.0, 0.0]]], []], [[[[24, -5.0, -1.0, -2.0, 2.0], [38, -4.0, 2.0, -3.0, 4.0], [6, -3.0, 3.0, -2.0, 5.0]], [[19, -5.0, 5.0, -1.0, 5.0], [22, 4.0, 5.0, 4.0, 7.0], [30, 2.0, 4.0, 4.0, 5.0], [25, -3.0, 3.0, -1.0, 3.0]]], [[6, 19], [6, 25], [38, 25]]], [[[[36, 4.0, -3.0, 4.0, 0.0], [6, -3.0, 1.0, -3.0, 1.0], [37, -3.0, -3.0, -1.0, -2.0]], [[33, 3.0, -2.0, 4.0, -2.0], [18, -1.0, 5.0, -1.0, 7.0], [25, -3.0, -1.0, -1.0, 1.0], [2, -3.0, 5.0, 0.0, 6.0]]], [[6, 25], [36, 33]]], [[[[11, -2.0, -5.0, -1.0, -3.0], [39, 2.0, 3.0, 2.0, 3.0], [3, 4.0, -5.0, 4.0, -2.0]], [[20, 2.0, 3.0, 3.0, 4.0], [22, -3.0, -5.0, 0.0, -3.0]]], [[11, 22], [39, 20]]]], [[[[[22, 4.0, 4.0, 4.0, 5.0], [11, 1.0, -4.0, 3.0, -4.0], [6, -2.0, -5.0, -1.0, -5.0], [2, -3.0, 0.0, -1.0, 3.0]], [[17, 3.0, 4.0, 4.0, 7.0]]], [[22, 17]]], [[[[39, 5.0, 4.0, 7.0, 5.0], [16, -5.0, -3.0, -5.0, 0.0], [9, 2.0, -5.0, 5.0, -3.0]], [[21, 5.0, -4.0, 8.0, -4.0], [31, -3.0, -3.0, -2.0, 0.0], [8, 5.0, 2.0, 5.0, 3.0]]], [[9, 21]]], [[[[8, 5.0, 5.0, 5.0, 7.0], [24, 2.0, -5.0, 4.0, -2.0], [15, -4.0, -3.0, -3.0, 0.0], [35, -1.0, 3.0, -1.0, 5.0]], [[23, 5.0, 5.0, 5.0, 7.0], [11, 2.0, 0.0, 3.0, 1.0], [25, -2.0, 4.0, 1.0, 4.0]]], [[8, 23], [35, 25]]], [[[[23, -1.0, 3.0, 2.0, 6.0]], [[8, -1.0, 1.0, 0.0, 4.0], [10, -2.0, 4.0, 0.0, 6.0], [30, 4.0, 0.0, 6.0, 2.0]]], [[23, 8], [23, 10]]], [[[[12, 2.0, 3.0, 2.0, 6.0]], [[1, -4.0, 5.0, -4.0, 5.0], [11, 2.0, 2.0, 5.0, 5.0], [32, -5.0, -5.0, -2.0, -4.0]]], [[12, 11]]], [[[[36, 0.0, -4.0, 1.0, -4.0], [14, -3.0, 1.0, -1.0, 3.0]], [[8, 0.0, -3.0, 0.0, -1.0], [20, -5.0, 0.0, -3.0, 2.0], [22, 1.0, -2.0, 1.0, 1.0], [5, -4.0, 1.0, -1.0, 3.0]]], [[14, 5], [14, 20]]], [[[[18, -5.0, -3.0, -2.0, -2.0], [16, 1.0, 2.0, 3.0, 5.0]], [[26, -4.0, -3.0, -1.0, -2.0], [20, -5.0, 3.0, -4.0, 6.0], [19, -4.0, 2.0, -1.0, 2.0], [4, 1.0, -5.0, 1.0, -5.0]]], [[18, 26]]], [[[[6, -2.0, 3.0, -2.0, 3.0], [3, -2.0, 2.0, 0.0, 5.0], [1, -4.0, -1.0, -4.0, 1.0]], [[12, -4.0, 4.0, -2.0, 5.0]]], [[3, 12]]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("case %d" % i, solve(*args), expected)
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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| case 0 | [] | [] | Passed |
| case 1 | [[20, 37], [29, 1]] | [[29, 1], [37, 20]] | Failed |
| case 2 | [[11, 21], [24, 16]] | [[16, 24], [21, 11]] | Failed |
| case 3 | [[18, 38], [22, 27]] | [[22, 27], [38, 18]] | Failed |
| case 4 | [[6, 32]] | [[32, 6]] | Failed |
| case 5 | [] | [] | Passed |
| case 6 | [[6, 26]] | [[26, 6]] | Failed |
| case 7 | [] | [] | Passed |
SHA-256 / a89be9a80cb6572948c0a10ed7470f1448d079328cb8cec9f206a09a9fe553cc
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(A, B):
As = sorted(A, key=lambda r: (r[1], r[0]))
Bs = sorted(B, key=lambda r: (r[1], r[0]))
def yover(p, q):
return p[2] <= q[4] and q[2] <= p[4]
pairs = []
j = 0
for a in As:
while j < len(Bs) and Bs[j][1] < a[1]:
j += 1
k = j
while k < len(Bs) and Bs[k][1] <= a[3]:
if yover(a, Bs[k]):
pairs.append([a[0], Bs[k][0]])
k += 1
j2 = 0
for b in Bs:
while j2 < len(As) and As[j2][1] <= b[1]:
j2 += 1
k = j2
while k < len(As) and As[k][1] <= b[3]:
if yover(As[k], b):
pairs.append(sorted([As[k][0], b[0]]))
k += 1
pairs.sort()
return pairs
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[[23, -1.0, 2.0, 0.0, 2.0]], [[28, -1.0, -5.0, 3.0, -3.0], [5, 4.0, 3.0, 5.0, 4.0]]], []], [[[[29, -3.0, -4.0, -3.0, -1.0], [37, 5.0, 0.0, 5.0, 0.0], [14, -1.0, 2.0, 0.0, 3.0]], [[1, -3.0, -1.0, 3.0, -1.0], [20, 4.0, 0.0, 5.0, 3.0]]], [[29, 1], [37, 20]]], [[[[16, -3.0, 4.0, -3.0, 4.0], [21, 0.0, -2.0, 1.0, -2.0], [17, -3.0, -1.0, -2.0, 0.0]], [[11, -3.0, -2.0, 2.0, -2.0], [24, -5.0, 4.0, -3.0, 7.0], [5, -5.0, 0.0, -4.0, 2.0]]], [[16, 24], [21, 11]]], [[[[22, -5.0, -3.0, -2.0, 0.0], [19, 1.0, 3.0, 4.0, 5.0], [38, 0.0, 1.0, 0.0, 3.0], [33, 1.0, -4.0, 3.0, -3.0]], [[18, -1.0, 1.0, 2.0, 2.0], [27, -5.0, -1.0, -2.0, 0.0]]], [[22, 27], [38, 18]]], [[[[32, -2.0, 1.0, 1.0, 1.0], [4, 5.0, -2.0, 6.0, 1.0], [17, -3.0, -4.0, -1.0, -1.0]], [[28, 2.0, 4.0, 5.0, 7.0], [10, 5.0, 2.0, 8.0, 2.0], [6, -4.0, 0.0, -2.0, 1.0]]], [[32, 6]]], [[[[7, -5.0, 2.0, -2.0, 3.0]], [[22, 0.0, 5.0, 1.0, 8.0], [19, 0.0, 3.0, 3.0, 6.0]]], []], [[[[26, 1.0, 0.0, 4.0, 2.0]], [[12, -2.0, -1.0, -1.0, -1.0], [30, -4.0, 1.0, -2.0, 1.0], [6, -1.0, 1.0, 1.0, 1.0], [25, 5.0, -2.0, 5.0, 1.0]]], [[26, 6]]], [[[[14, 2.0, -5.0, 4.0, -4.0], [36, 4.0, -3.0, 6.0, -3.0], [5, 1.0, 3.0, 1.0, 6.0], [16, -3.0, 0.0, -1.0, 2.0]], [[34, 4.0, 1.0, 7.0, 4.0]]], []]], [[[[[2, 2.0, -1.0, 4.0, 0.0], [14, 3.0, -3.0, 3.0, -2.0]], [[5, -3.0, -2.0, -1.0, 0.0]]], []], [[[[9, 1.0, 5.0, 2.0, 7.0], [2, 2.0, 3.0, 5.0, 5.0], [18, -1.0, 1.0, 1.0, 2.0]], [[10, 5.0, -4.0, 7.0, -2.0], [7, -4.0, 2.0, -1.0, 4.0], [37, 4.0, 3.0, 5.0, 3.0], [23, 1.0, -2.0, 1.0, -2.0]]], [[2, 37], [18, 7]]], [[[[17, -2.0, -5.0, 1.0, -2.0], [23, 5.0, 3.0, 6.0, 5.0], [31, -3.0, -5.0, -1.0, -5.0]], [[7, -2.0, -1.0, 5.0, -1.0]]], []], [[[[5, -1.0, 1.0, 0.0, 4.0], [23, -5.0, -5.0, -3.0, -5.0]], [[17, -1.0, 1.0, -1.0, 1.0]]], [[5, 17]]], [[[[20, -4.0, -5.0, -4.0, -2.0], [9, 5.0, 2.0, 6.0, 5.0]], [[18, 2.0, 5.0, 4.0, 5.0], [5, 4.0, 3.0, 7.0, 5.0]]], [[9, 5]]], [[[[11, 0.0, -2.0, 0.0, 1.0], [17, -2.0, 3.0, 0.0, 3.0], [29, 2.0, -2.0, 4.0, -1.0]], [[1, 3.0, 1.0, 4.0, 4.0], [7, 4.0, 3.0, 7.0, 6.0], [28, -5.0, -1.0, -2.0, 2.0], [2, -4.0, 1.0, -2.0, 4.0]]], [[17, 2]]], [[[[3, -4.0, -2.0, -4.0, -2.0], [33, 5.0, -4.0, 7.0, -1.0], [1, -4.0, 2.0, -1.0, 2.0], [19, 4.0, 5.0, 6.0, 8.0]], [[7, 1.0, -2.0, 3.0, -1.0], [6, 1.0, 4.0, 4.0, 6.0]]], [[19, 6]]], [[[[21, -4.0, -2.0, -3.0, -1.0]], [[15, -2.0, -5.0, 0.0, -3.0], [2, -2.0, 3.0, 1.0, 3.0]]], []]], [[[[[27, 0.0, 3.0, 0.0, 6.0], [12, -4.0, 4.0, -3.0, 7.0], [8, -3.0, -1.0, -1.0, -1.0]], [[4, -1.0, -4.0, -1.0, -1.0], [16, -5.0, -4.0, -4.0, -3.0], [28, -4.0, 5.0, -2.0, 5.0], [5, -1.0, 4.0, 2.0, 5.0]]], [[8, 4], [12, 28], [27, 5]]], [[[[22, 0.0, 3.0, 0.0, 6.0], [10, 4.0, -1.0, 5.0, 0.0], [26, 5.0, 2.0, 8.0, 3.0], [2, 5.0, -3.0, 5.0, 0.0]], [[18, 0.0, -5.0, 5.0, -2.0]]], [[2, 18]]], [[[[14, -4.0, -3.0, -2.0, 0.0], [18, 0.0, -5.0, 2.0, -2.0], [37, 5.0, 5.0, 7.0, 5.0]], [[34, -4.0, -1.0, 5.0, 0.0], [4, -2.0, -2.0, 1.0, 1.0], [3, -2.0, 3.0, -2.0, 4.0], [11, 4.0, 5.0, 7.0, 6.0]]], [[14, 4], [14, 34], [18, 4], [37, 11]]], [[[[17, 1.0, 5.0, 2.0, 7.0]], [[19, 1.0, 4.0, 4.0, 4.0]]], []], [[[[30, 1.0, -2.0, 2.0, -2.0], [32, -1.0, -5.0, -1.0, -3.0], [28, -3.0, 5.0, 0.0, 5.0]], [[24, -4.0, 0.0, -2.0, 1.0], [22, -3.0, -3.0, 0.0, 0.0], [8, 4.0, -5.0, 6.0, -5.0], [31, 0.0, 5.0, 2.0, 8.0]]], [[28, 31], [32, 22]]], [[[[17, -1.0, -1.0, -1.0, -1.0], [19, 2.0, 0.0, 4.0, 2.0]], [[3, -3.0, 3.0, -3.0, 5.0], [24, -4.0, 2.0, -1.0, 3.0], [16, 0.0, -3.0, 2.0, 0.0], [28, 0.0, -4.0, 1.0, -4.0]]], [[19, 16]]], [[[[34, 3.0, 5.0, 4.0, 5.0], [13, -1.0, -5.0, 0.0, -4.0], [16, -2.0, 1.0, 1.0, 1.0]], [[10, 1.0, 0.0, 3.0, 1.0], [30, -1.0, -5.0, -1.0, -2.0]]], [[13, 30], [16, 10]]], [[[[26, -1.0, 1.0, 0.0, 1.0]], [[15, 1.0, -1.0, 2.0, -1.0], [10, 4.0, 5.0, 7.0, 6.0], [34, -5.0, -1.0, -4.0, -1.0]]], []]], [[[[[31, 2.0, 4.0, 2.0, 4.0], [7, -2.0, 2.0, 1.0, 4.0], [6, 3.0, 1.0, 5.0, 2.0], [35, 3.0, 2.0, 6.0, 4.0]], [[29, 5.0, -5.0, 7.0, -3.0], [1, 0.0, 0.0, 3.0, 2.0], [39, 0.0, -3.0, 3.0, -3.0], [2, 4.0, -1.0, 4.0, 1.0]]], [[6, 1], [6, 2], [7, 1], [35, 1]]], [[[[3, -3.0, -2.0, -1.0, 0.0]], [[7, 2.0, -5.0, 3.0, -3.0]]], []], [[[[16, -3.0, 4.0, 0.0, 4.0], [32, -1.0, -2.0, 2.0, 0.0]], [[29, -3.0, 0.0, 3.0, 0.0], [2, 2.0, -1.0, 2.0, 0.0], [13, 2.0, 4.0, 2.0, 6.0], [8, -1.0, -4.0, 1.0, -2.0]]], [[32, 2], [32, 8], [32, 29]]], [[[[14, 5.0, 3.0, 7.0, 4.0], [28, -4.0, 3.0, -1.0, 4.0], [26, 0.0, -5.0, 3.0, -4.0], [8, 5.0, 2.0, 8.0, 3.0]], [[1, 5.0, 1.0, 5.0, 3.0], [12, -2.0, 3.0, 1.0, 3.0]]], [[8, 1], [14, 1], [28, 12]]], [[[[26, 4.0, -5.0, 6.0, -3.0]], [[24, 4.0, -1.0, 4.0, 0.0]]], []], [[[[24, -5.0, -1.0, -2.0, 2.0], [38, -4.0, 2.0, -3.0, 4.0], [6, -3.0, 3.0, -2.0, 5.0]], [[19, -5.0, 5.0, -1.0, 5.0], [22, 4.0, 5.0, 4.0, 7.0], [30, 2.0, 4.0, 4.0, 5.0], [25, -3.0, 3.0, -1.0, 3.0]]], [[6, 19], [6, 25], [38, 25]]], [[[[36, 4.0, -3.0, 4.0, 0.0], [6, -3.0, 1.0, -3.0, 1.0], [37, -3.0, -3.0, -1.0, -2.0]], [[33, 3.0, -2.0, 4.0, -2.0], [18, -1.0, 5.0, -1.0, 7.0], [25, -3.0, -1.0, -1.0, 1.0], [2, -3.0, 5.0, 0.0, 6.0]]], [[6, 25], [36, 33]]], [[[[11, -2.0, -5.0, -1.0, -3.0], [39, 2.0, 3.0, 2.0, 3.0], [3, 4.0, -5.0, 4.0, -2.0]], [[20, 2.0, 3.0, 3.0, 4.0], [22, -3.0, -5.0, 0.0, -3.0]]], [[11, 22], [39, 20]]]], [[[[[22, 4.0, 4.0, 4.0, 5.0], [11, 1.0, -4.0, 3.0, -4.0], [6, -2.0, -5.0, -1.0, -5.0], [2, -3.0, 0.0, -1.0, 3.0]], [[17, 3.0, 4.0, 4.0, 7.0]]], [[22, 17]]], [[[[39, 5.0, 4.0, 7.0, 5.0], [16, -5.0, -3.0, -5.0, 0.0], [9, 2.0, -5.0, 5.0, -3.0]], [[21, 5.0, -4.0, 8.0, -4.0], [31, -3.0, -3.0, -2.0, 0.0], [8, 5.0, 2.0, 5.0, 3.0]]], [[9, 21]]], [[[[8, 5.0, 5.0, 5.0, 7.0], [24, 2.0, -5.0, 4.0, -2.0], [15, -4.0, -3.0, -3.0, 0.0], [35, -1.0, 3.0, -1.0, 5.0]], [[23, 5.0, 5.0, 5.0, 7.0], [11, 2.0, 0.0, 3.0, 1.0], [25, -2.0, 4.0, 1.0, 4.0]]], [[8, 23], [35, 25]]], [[[[23, -1.0, 3.0, 2.0, 6.0]], [[8, -1.0, 1.0, 0.0, 4.0], [10, -2.0, 4.0, 0.0, 6.0], [30, 4.0, 0.0, 6.0, 2.0]]], [[23, 8], [23, 10]]], [[[[12, 2.0, 3.0, 2.0, 6.0]], [[1, -4.0, 5.0, -4.0, 5.0], [11, 2.0, 2.0, 5.0, 5.0], [32, -5.0, -5.0, -2.0, -4.0]]], [[12, 11]]], [[[[36, 0.0, -4.0, 1.0, -4.0], [14, -3.0, 1.0, -1.0, 3.0]], [[8, 0.0, -3.0, 0.0, -1.0], [20, -5.0, 0.0, -3.0, 2.0], [22, 1.0, -2.0, 1.0, 1.0], [5, -4.0, 1.0, -1.0, 3.0]]], [[14, 5], [14, 20]]], [[[[18, -5.0, -3.0, -2.0, -2.0], [16, 1.0, 2.0, 3.0, 5.0]], [[26, -4.0, -3.0, -1.0, -2.0], [20, -5.0, 3.0, -4.0, 6.0], [19, -4.0, 2.0, -1.0, 2.0], [4, 1.0, -5.0, 1.0, -5.0]]], [[18, 26]]], [[[[6, -2.0, 3.0, -2.0, 3.0], [3, -2.0, 2.0, 0.0, 5.0], [1, -4.0, -1.0, -4.0, 1.0]], [[12, -4.0, 4.0, -2.0, 5.0]]], [[3, 12]]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("case %d" % i, solve(*args), expected)
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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| case 0 | [] | [] | Passed |
| case 1 | [[20, 37], [29, 1]] | [[29, 1], [37, 20]] | Failed |
| case 2 | [[11, 21], [16, 24]] | [[16, 24], [21, 11]] | Failed |
| case 3 | [[18, 38], [22, 27]] | [[22, 27], [38, 18]] | Failed |
| case 4 | [[6, 32]] | [[32, 6]] | Failed |
| case 5 | [] | [] | Passed |
| case 6 | [[6, 26]] | [[26, 6]] | Failed |
| case 7 | [] | [] | Passed |
SHA-256 / c0f54ee463412d2f170c5d70cee2178ef00293802564faafe36e6a719a0aa851
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(A, B):
As = sorted(A, key=lambda r: (r[1], r[0]))
Bs = sorted(B, key=lambda r: (r[1], r[0]))
def yover(p, q):
return p[2] <= q[4] and q[2] <= p[4]
pairs = []
j = 0
for a in As:
while j < len(Bs) and Bs[j][1] < a[1]:
j += 1
k = j
while k < len(Bs) and Bs[k][1] <= a[3]:
if yover(a, Bs[k]):
pairs.append([a[0], Bs[k][0]])
k += 1
j2 = 0
for b in Bs:
while j2 < len(As) and As[j2][1] <= b[1]:
j2 += 1
k = j2
while k < len(As) and As[k][1] <= b[3]:
if yover(As[k], b):
pairs.append([As[k][0], b[0]])
k += 1
pairs.sort()
return pairs
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[[23, -1.0, 2.0, 0.0, 2.0]], [[28, -1.0, -5.0, 3.0, -3.0], [5, 4.0, 3.0, 5.0, 4.0]]], []], [[[[29, -3.0, -4.0, -3.0, -1.0], [37, 5.0, 0.0, 5.0, 0.0], [14, -1.0, 2.0, 0.0, 3.0]], [[1, -3.0, -1.0, 3.0, -1.0], [20, 4.0, 0.0, 5.0, 3.0]]], [[29, 1], [37, 20]]], [[[[16, -3.0, 4.0, -3.0, 4.0], [21, 0.0, -2.0, 1.0, -2.0], [17, -3.0, -1.0, -2.0, 0.0]], [[11, -3.0, -2.0, 2.0, -2.0], [24, -5.0, 4.0, -3.0, 7.0], [5, -5.0, 0.0, -4.0, 2.0]]], [[16, 24], [21, 11]]], [[[[22, -5.0, -3.0, -2.0, 0.0], [19, 1.0, 3.0, 4.0, 5.0], [38, 0.0, 1.0, 0.0, 3.0], [33, 1.0, -4.0, 3.0, -3.0]], [[18, -1.0, 1.0, 2.0, 2.0], [27, -5.0, -1.0, -2.0, 0.0]]], [[22, 27], [38, 18]]], [[[[32, -2.0, 1.0, 1.0, 1.0], [4, 5.0, -2.0, 6.0, 1.0], [17, -3.0, -4.0, -1.0, -1.0]], [[28, 2.0, 4.0, 5.0, 7.0], [10, 5.0, 2.0, 8.0, 2.0], [6, -4.0, 0.0, -2.0, 1.0]]], [[32, 6]]], [[[[7, -5.0, 2.0, -2.0, 3.0]], [[22, 0.0, 5.0, 1.0, 8.0], [19, 0.0, 3.0, 3.0, 6.0]]], []], [[[[26, 1.0, 0.0, 4.0, 2.0]], [[12, -2.0, -1.0, -1.0, -1.0], [30, -4.0, 1.0, -2.0, 1.0], [6, -1.0, 1.0, 1.0, 1.0], [25, 5.0, -2.0, 5.0, 1.0]]], [[26, 6]]], [[[[14, 2.0, -5.0, 4.0, -4.0], [36, 4.0, -3.0, 6.0, -3.0], [5, 1.0, 3.0, 1.0, 6.0], [16, -3.0, 0.0, -1.0, 2.0]], [[34, 4.0, 1.0, 7.0, 4.0]]], []]], [[[[[2, 2.0, -1.0, 4.0, 0.0], [14, 3.0, -3.0, 3.0, -2.0]], [[5, -3.0, -2.0, -1.0, 0.0]]], []], [[[[9, 1.0, 5.0, 2.0, 7.0], [2, 2.0, 3.0, 5.0, 5.0], [18, -1.0, 1.0, 1.0, 2.0]], [[10, 5.0, -4.0, 7.0, -2.0], [7, -4.0, 2.0, -1.0, 4.0], [37, 4.0, 3.0, 5.0, 3.0], [23, 1.0, -2.0, 1.0, -2.0]]], [[2, 37], [18, 7]]], [[[[17, -2.0, -5.0, 1.0, -2.0], [23, 5.0, 3.0, 6.0, 5.0], [31, -3.0, -5.0, -1.0, -5.0]], [[7, -2.0, -1.0, 5.0, -1.0]]], []], [[[[5, -1.0, 1.0, 0.0, 4.0], [23, -5.0, -5.0, -3.0, -5.0]], [[17, -1.0, 1.0, -1.0, 1.0]]], [[5, 17]]], [[[[20, -4.0, -5.0, -4.0, -2.0], [9, 5.0, 2.0, 6.0, 5.0]], [[18, 2.0, 5.0, 4.0, 5.0], [5, 4.0, 3.0, 7.0, 5.0]]], [[9, 5]]], [[[[11, 0.0, -2.0, 0.0, 1.0], [17, -2.0, 3.0, 0.0, 3.0], [29, 2.0, -2.0, 4.0, -1.0]], [[1, 3.0, 1.0, 4.0, 4.0], [7, 4.0, 3.0, 7.0, 6.0], [28, -5.0, -1.0, -2.0, 2.0], [2, -4.0, 1.0, -2.0, 4.0]]], [[17, 2]]], [[[[3, -4.0, -2.0, -4.0, -2.0], [33, 5.0, -4.0, 7.0, -1.0], [1, -4.0, 2.0, -1.0, 2.0], [19, 4.0, 5.0, 6.0, 8.0]], [[7, 1.0, -2.0, 3.0, -1.0], [6, 1.0, 4.0, 4.0, 6.0]]], [[19, 6]]], [[[[21, -4.0, -2.0, -3.0, -1.0]], [[15, -2.0, -5.0, 0.0, -3.0], [2, -2.0, 3.0, 1.0, 3.0]]], []]], [[[[[27, 0.0, 3.0, 0.0, 6.0], [12, -4.0, 4.0, -3.0, 7.0], [8, -3.0, -1.0, -1.0, -1.0]], [[4, -1.0, -4.0, -1.0, -1.0], [16, -5.0, -4.0, -4.0, -3.0], [28, -4.0, 5.0, -2.0, 5.0], [5, -1.0, 4.0, 2.0, 5.0]]], [[8, 4], [12, 28], [27, 5]]], [[[[22, 0.0, 3.0, 0.0, 6.0], [10, 4.0, -1.0, 5.0, 0.0], [26, 5.0, 2.0, 8.0, 3.0], [2, 5.0, -3.0, 5.0, 0.0]], [[18, 0.0, -5.0, 5.0, -2.0]]], [[2, 18]]], [[[[14, -4.0, -3.0, -2.0, 0.0], [18, 0.0, -5.0, 2.0, -2.0], [37, 5.0, 5.0, 7.0, 5.0]], [[34, -4.0, -1.0, 5.0, 0.0], [4, -2.0, -2.0, 1.0, 1.0], [3, -2.0, 3.0, -2.0, 4.0], [11, 4.0, 5.0, 7.0, 6.0]]], [[14, 4], [14, 34], [18, 4], [37, 11]]], [[[[17, 1.0, 5.0, 2.0, 7.0]], [[19, 1.0, 4.0, 4.0, 4.0]]], []], [[[[30, 1.0, -2.0, 2.0, -2.0], [32, -1.0, -5.0, -1.0, -3.0], [28, -3.0, 5.0, 0.0, 5.0]], [[24, -4.0, 0.0, -2.0, 1.0], [22, -3.0, -3.0, 0.0, 0.0], [8, 4.0, -5.0, 6.0, -5.0], [31, 0.0, 5.0, 2.0, 8.0]]], [[28, 31], [32, 22]]], [[[[17, -1.0, -1.0, -1.0, -1.0], [19, 2.0, 0.0, 4.0, 2.0]], [[3, -3.0, 3.0, -3.0, 5.0], [24, -4.0, 2.0, -1.0, 3.0], [16, 0.0, -3.0, 2.0, 0.0], [28, 0.0, -4.0, 1.0, -4.0]]], [[19, 16]]], [[[[34, 3.0, 5.0, 4.0, 5.0], [13, -1.0, -5.0, 0.0, -4.0], [16, -2.0, 1.0, 1.0, 1.0]], [[10, 1.0, 0.0, 3.0, 1.0], [30, -1.0, -5.0, -1.0, -2.0]]], [[13, 30], [16, 10]]], [[[[26, -1.0, 1.0, 0.0, 1.0]], [[15, 1.0, -1.0, 2.0, -1.0], [10, 4.0, 5.0, 7.0, 6.0], [34, -5.0, -1.0, -4.0, -1.0]]], []]], [[[[[31, 2.0, 4.0, 2.0, 4.0], [7, -2.0, 2.0, 1.0, 4.0], [6, 3.0, 1.0, 5.0, 2.0], [35, 3.0, 2.0, 6.0, 4.0]], [[29, 5.0, -5.0, 7.0, -3.0], [1, 0.0, 0.0, 3.0, 2.0], [39, 0.0, -3.0, 3.0, -3.0], [2, 4.0, -1.0, 4.0, 1.0]]], [[6, 1], [6, 2], [7, 1], [35, 1]]], [[[[3, -3.0, -2.0, -1.0, 0.0]], [[7, 2.0, -5.0, 3.0, -3.0]]], []], [[[[16, -3.0, 4.0, 0.0, 4.0], [32, -1.0, -2.0, 2.0, 0.0]], [[29, -3.0, 0.0, 3.0, 0.0], [2, 2.0, -1.0, 2.0, 0.0], [13, 2.0, 4.0, 2.0, 6.0], [8, -1.0, -4.0, 1.0, -2.0]]], [[32, 2], [32, 8], [32, 29]]], [[[[14, 5.0, 3.0, 7.0, 4.0], [28, -4.0, 3.0, -1.0, 4.0], [26, 0.0, -5.0, 3.0, -4.0], [8, 5.0, 2.0, 8.0, 3.0]], [[1, 5.0, 1.0, 5.0, 3.0], [12, -2.0, 3.0, 1.0, 3.0]]], [[8, 1], [14, 1], [28, 12]]], [[[[26, 4.0, -5.0, 6.0, -3.0]], [[24, 4.0, -1.0, 4.0, 0.0]]], []], [[[[24, -5.0, -1.0, -2.0, 2.0], [38, -4.0, 2.0, -3.0, 4.0], [6, -3.0, 3.0, -2.0, 5.0]], [[19, -5.0, 5.0, -1.0, 5.0], [22, 4.0, 5.0, 4.0, 7.0], [30, 2.0, 4.0, 4.0, 5.0], [25, -3.0, 3.0, -1.0, 3.0]]], [[6, 19], [6, 25], [38, 25]]], [[[[36, 4.0, -3.0, 4.0, 0.0], [6, -3.0, 1.0, -3.0, 1.0], [37, -3.0, -3.0, -1.0, -2.0]], [[33, 3.0, -2.0, 4.0, -2.0], [18, -1.0, 5.0, -1.0, 7.0], [25, -3.0, -1.0, -1.0, 1.0], [2, -3.0, 5.0, 0.0, 6.0]]], [[6, 25], [36, 33]]], [[[[11, -2.0, -5.0, -1.0, -3.0], [39, 2.0, 3.0, 2.0, 3.0], [3, 4.0, -5.0, 4.0, -2.0]], [[20, 2.0, 3.0, 3.0, 4.0], [22, -3.0, -5.0, 0.0, -3.0]]], [[11, 22], [39, 20]]]], [[[[[22, 4.0, 4.0, 4.0, 5.0], [11, 1.0, -4.0, 3.0, -4.0], [6, -2.0, -5.0, -1.0, -5.0], [2, -3.0, 0.0, -1.0, 3.0]], [[17, 3.0, 4.0, 4.0, 7.0]]], [[22, 17]]], [[[[39, 5.0, 4.0, 7.0, 5.0], [16, -5.0, -3.0, -5.0, 0.0], [9, 2.0, -5.0, 5.0, -3.0]], [[21, 5.0, -4.0, 8.0, -4.0], [31, -3.0, -3.0, -2.0, 0.0], [8, 5.0, 2.0, 5.0, 3.0]]], [[9, 21]]], [[[[8, 5.0, 5.0, 5.0, 7.0], [24, 2.0, -5.0, 4.0, -2.0], [15, -4.0, -3.0, -3.0, 0.0], [35, -1.0, 3.0, -1.0, 5.0]], [[23, 5.0, 5.0, 5.0, 7.0], [11, 2.0, 0.0, 3.0, 1.0], [25, -2.0, 4.0, 1.0, 4.0]]], [[8, 23], [35, 25]]], [[[[23, -1.0, 3.0, 2.0, 6.0]], [[8, -1.0, 1.0, 0.0, 4.0], [10, -2.0, 4.0, 0.0, 6.0], [30, 4.0, 0.0, 6.0, 2.0]]], [[23, 8], [23, 10]]], [[[[12, 2.0, 3.0, 2.0, 6.0]], [[1, -4.0, 5.0, -4.0, 5.0], [11, 2.0, 2.0, 5.0, 5.0], [32, -5.0, -5.0, -2.0, -4.0]]], [[12, 11]]], [[[[36, 0.0, -4.0, 1.0, -4.0], [14, -3.0, 1.0, -1.0, 3.0]], [[8, 0.0, -3.0, 0.0, -1.0], [20, -5.0, 0.0, -3.0, 2.0], [22, 1.0, -2.0, 1.0, 1.0], [5, -4.0, 1.0, -1.0, 3.0]]], [[14, 5], [14, 20]]], [[[[18, -5.0, -3.0, -2.0, -2.0], [16, 1.0, 2.0, 3.0, 5.0]], [[26, -4.0, -3.0, -1.0, -2.0], [20, -5.0, 3.0, -4.0, 6.0], [19, -4.0, 2.0, -1.0, 2.0], [4, 1.0, -5.0, 1.0, -5.0]]], [[18, 26]]], [[[[6, -2.0, 3.0, -2.0, 3.0], [3, -2.0, 2.0, 0.0, 5.0], [1, -4.0, -1.0, -4.0, 1.0]], [[12, -4.0, 4.0, -2.0, 5.0]]], [[3, 12]]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("case %d" % i, solve(*args), expected)
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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| case 0 | [] | [] | Passed |
| case 1 | [[29, 1], [37, 20]] | [[29, 1], [37, 20]] | Passed |
| case 2 | [[16, 24], [21, 11]] | [[16, 24], [21, 11]] | Passed |
| case 3 | [[22, 27], [38, 18]] | [[22, 27], [38, 18]] | Passed |
| case 4 | [[32, 6]] | [[32, 6]] | Passed |
| case 5 | [] | [] | Passed |
| case 6 | [[26, 6]] | [[26, 6]] | Passed |
| case 7 | [] | [] | Passed |
SHA-256 / 72c85aeca7e9cd03330bc49f617f3d9d7f35430b41964b7a40da07a860d6e7d4
Verification & scope
A deterministic bounded teaching model with stipulated toy conventions; not a production physics engine or spatial index. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:51:01.946662+00:00.
Case digest / 9014b89681563c325d29bb14179b74a9089dd6cc109725f1810e44a96a335478