FA-87801 / Collision detection broadphase / Open access
Endpoint refresh swaps min and max coordinates · case 01
The endpoint array is corrupted every frame and spurious events fire.
ROOT CAUSE
Min endpoints receive maxx and max endpoints minx.
THE FAILURE
Min endpoints receive maxx and max endpoints minx.
Unsuccessful approach: Reading max y for max endpoints mixes axes.
Case contract
solve(prev, curr): incremental sweep-and-prune on x. Endpoints [x, 0=min/1=max, id] of prev are sorted, refreshed with curr coordinates and insertion-sorted by (x, kind). Each swap where a min passes left over a max begins a pair (if y overlaps in curr); a max passing left over a min ends a pair. Return [sorted begin pairs, sorted end pairs, swap count], pairs as [min,max].
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(prev, curr):
old = {b[0]: b for b in prev}
new = {b[0]: b for b in curr}
E = []
for i, b in old.items():
E.append([b[1], 0, i])
E.append([b[3], 1, i])
E.sort()
for e in E:
b = new[e[2]]
e[0] = b[1] if e[1] == 1 else b[3]
def yover(a, c):
return new[a][2] <= new[c][4] and new[c][2] <= new[a][4]
begins, ends = set(), set()
swaps = 0
for i in range(1, len(E)):
j = i
while j > 0 and (E[j - 1][0], E[j - 1][1]) > (E[j][0], E[j][1]):
e, f = E[j], E[j - 1]
E[j - 1], E[j] = e, f
swaps += 1
p = (min(e[2], f[2]), max(e[2], f[2]))
if e[1] == 0 and f[1] == 1:
if yover(e[2], f[2]):
begins.add(p)
elif e[1] == 1 and f[1] == 0:
ends.add(p)
j -= 1
return [sorted(list(p) for p in begins), sorted(list(p) for p in ends), swaps]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[[35, -4.0, 0.0, -3.0, 1.0], [4, -4.0, 0.0, -4.0, 3.0], [36, 5.0, -2.0, 5.0, 1.0], [25, 4.0, -1.0, 4.0, 1.0]], [[35, -7.0, -1.0, -6.0, 0.0], [4, -4.0, 0.0, -4.0, 3.0], [36, 7.0, -2.0, 7.0, 1.0], [25, 4.0, 0.0, 4.0, 2.0]]], [[], [[4, 35]], 3]], [[[[8, -3.0, 4.0, 0.0, 6.0], [15, 2.0, -2.0, 4.0, -2.0], [33, -1.0, 2.0, 0.0, 2.0], [10, 2.0, -3.0, 3.0, -1.0]], [[8, -1.0, 5.0, 2.0, 7.0], [15, -1.0, -2.0, 1.0, -2.0], [33, 0.0, 3.0, 1.0, 3.0], [10, -1.0, -4.0, 0.0, -2.0]]], [[], [], 10]], [[[[36, 4.0, -3.0, 4.0, -2.0], [30, 5.0, 1.0, 5.0, 1.0]], [[36, 4.0, -3.0, 4.0, -2.0], [30, 5.0, 1.0, 5.0, 1.0]]], [[], [], 0]], [[[[31, 2.0, 5.0, 4.0, 8.0], [26, -1.0, -3.0, -1.0, -3.0], [32, 0.0, 4.0, 1.0, 5.0], [20, -4.0, 3.0, -2.0, 5.0]], [[31, 2.0, 4.0, 4.0, 7.0], [26, -1.0, -2.0, -1.0, -2.0], [32, 4.0, 4.0, 5.0, 5.0], [20, -2.0, 3.0, 0.0, 5.0]]], [[[31, 32]], [], 5]], [[[[13, 2.0, -5.0, 2.0, -4.0], [6, 1.0, -3.0, 1.0, -3.0], [20, -5.0, 1.0, -5.0, 1.0]], [[13, 1.0, -5.0, 1.0, -4.0], [6, 1.0, -3.0, 1.0, -3.0], [20, -1.0, 2.0, -1.0, 2.0]]], [[], [], 1]], [[[[39, -3.0, -2.0, -1.0, -2.0], [32, -3.0, -1.0, -3.0, 0.0], [33, -2.0, -2.0, -1.0, 0.0], [24, -5.0, 1.0, -4.0, 1.0], [16, -4.0, 3.0, -1.0, 4.0], [12, -5.0, 1.0, -2.0, 4.0]], [[39, -2.0, -2.0, 0.0, -2.0], [32, -3.0, -1.0, -3.0, 0.0], [33, 2.0, -3.0, 3.0, -1.0], [24, -5.0, 0.0, -4.0, 0.0], [16, -2.0, 4.0, 1.0, 5.0], [12, -3.0, 2.0, 0.0, 5.0]]], [[], [[12, 24], [12, 33], [16, 24], [16, 32], [16, 33], [32, 39], [33, 39]], 11]], [[[[6, -4.0, 2.0, -1.0, 2.0], [23, -2.0, 5.0, -2.0, 8.0], [37, 3.0, 2.0, 4.0, 4.0]], [[6, -7.0, 1.0, -4.0, 1.0], [23, -2.0, 5.0, -2.0, 8.0], [37, 4.0, 2.0, 5.0, 4.0]]], [[], [[6, 23]], 2]], [[[[25, 2.0, 0.0, 5.0, 2.0], [26, -4.0, -3.0, -2.0, 0.0], [3, 4.0, 4.0, 6.0, 6.0], [30, 4.0, 0.0, 6.0, 2.0]], [[25, 3.0, 1.0, 6.0, 3.0], [26, -7.0, -4.0, -5.0, -1.0], [3, 4.0, 5.0, 6.0, 7.0], [30, 6.0, 0.0, 8.0, 2.0]]], [[], [], 0]]], [[[[[39, -4.0, -3.0, -1.0, -3.0], [20, -5.0, 4.0, -4.0, 4.0], [13, 1.0, -4.0, 2.0, -1.0], [25, -1.0, -2.0, 2.0, 0.0], [22, 4.0, 4.0, 6.0, 6.0]], [[39, -7.0, -3.0, -4.0, -3.0], [20, -5.0, 3.0, -4.0, 3.0], [13, 1.0, -4.0, 2.0, -1.0], [25, -2.0, -3.0, 1.0, -1.0], [22, 4.0, 4.0, 6.0, 6.0]]], [[], [[25, 39]], 3]], [[[[8, -2.0, -1.0, -2.0, 2.0], [15, -4.0, -3.0, -3.0, -3.0], [22, 2.0, -3.0, 3.0, -3.0]], [[8, -3.0, 0.0, -3.0, 3.0], [15, -5.0, -2.0, -4.0, -2.0], [22, -1.0, -3.0, 0.0, -3.0]]], [[], [], 0]], [[[[29, 2.0, -3.0, 5.0, -2.0], [17, -4.0, 3.0, -1.0, 3.0], [24, 3.0, 4.0, 3.0, 5.0], [3, 0.0, -3.0, 0.0, 0.0], [27, -5.0, 4.0, -2.0, 7.0], [2, -2.0, -4.0, -1.0, -4.0], [26, -1.0, -3.0, 2.0, -2.0]], [[29, 4.0, -4.0, 7.0, -3.0], [17, -2.0, 2.0, 1.0, 2.0], [24, 0.0, 3.0, 0.0, 4.0], [3, 0.0, -3.0, 0.0, 0.0], [27, -3.0, 4.0, 0.0, 7.0], [2, -5.0, -3.0, -4.0, -3.0], [26, 1.0, -2.0, 4.0, -1.0]]], [[[24, 27]], [[2, 17], [2, 26], [2, 27], [3, 26], [24, 26], [24, 29]], 21]], [[[[34, -5.0, 0.0, -4.0, 2.0], [15, -5.0, -2.0, -4.0, -2.0], [33, 2.0, 2.0, 5.0, 2.0], [20, 1.0, -1.0, 2.0, -1.0], [21, -5.0, 5.0, -4.0, 8.0], [2, -1.0, 1.0, 0.0, 1.0], [25, -1.0, -4.0, -1.0, -1.0]], [[34, -3.0, 1.0, -2.0, 3.0], [15, -5.0, -3.0, -4.0, -3.0], [33, 2.0, 3.0, 5.0, 3.0], [20, -2.0, 0.0, -1.0, 0.0], [21, -8.0, 5.0, -7.0, 8.0], [2, -4.0, 0.0, -3.0, 0.0], [25, -1.0, -5.0, -1.0, -2.0]]], [[], [[2, 25], [15, 21], [15, 34], [20, 33], [21, 34]], 15]], [[[[8, -4.0, 3.0, -1.0, 5.0], [29, -3.0, -3.0, -2.0, -1.0], [6, -5.0, -4.0, -2.0, -3.0], [23, -3.0, 5.0, -2.0, 8.0]], [[8, -3.0, 3.0, 0.0, 5.0], [29, -4.0, -2.0, -3.0, 0.0], [6, -8.0, -4.0, -5.0, -3.0], [23, 1.0, 5.0, 2.0, 8.0]]], [[], [[6, 8], [6, 23], [6, 29], [8, 23], [23, 29]], 9]], [[[[4, -4.0, 2.0, -3.0, 4.0], [2, 1.0, 1.0, 2.0, 2.0], [7, -3.0, -2.0, 0.0, -2.0], [1, 1.0, 0.0, 4.0, 2.0], [16, 5.0, 2.0, 6.0, 5.0], [17, 5.0, -1.0, 7.0, 0.0], [28, 5.0, 0.0, 8.0, 3.0]], [[4, -4.0, 1.0, -3.0, 3.0], [2, 1.0, 1.0, 2.0, 2.0], [7, -1.0, -3.0, 2.0, -3.0], [1, 2.0, 1.0, 5.0, 3.0], [16, 4.0, 2.0, 5.0, 5.0], [17, 2.0, 0.0, 4.0, 1.0], [28, 4.0, 0.0, 7.0, 3.0]]], [[[1, 16], [1, 17], [1, 28], [2, 17]], [[4, 7]], 12]], [[[[2, 3.0, 3.0, 5.0, 3.0], [7, -4.0, 2.0, -2.0, 5.0], [8, 5.0, 2.0, 8.0, 5.0], [11, 4.0, -4.0, 5.0, -2.0], [9, 5.0, -4.0, 7.0, -3.0], [17, -1.0, 2.0, 0.0, 5.0], [39, -3.0, 5.0, 0.0, 8.0]], [[2, 3.0, 2.0, 5.0, 2.0], [7, -7.0, 2.0, -5.0, 5.0], [8, 2.0, 1.0, 5.0, 4.0], [11, 5.0, -5.0, 6.0, -3.0], [9, 5.0, -4.0, 7.0, -3.0], [17, -1.0, 2.0, 0.0, 5.0], [39, -3.0, 5.0, 0.0, 8.0]]], [[], [[7, 39]], 5]], [[[[23, -4.0, 0.0, -1.0, 1.0], [13, -4.0, -2.0, -4.0, 1.0], [6, -2.0, -5.0, 0.0, -3.0], [8, 5.0, 2.0, 5.0, 3.0], [9, -5.0, 0.0, -4.0, 2.0]], [[23, -7.0, 0.0, -4.0, 1.0], [13, -5.0, -1.0, -5.0, 2.0], [6, 0.0, -5.0, 2.0, -3.0], [8, 5.0, 3.0, 5.0, 4.0], [9, -8.0, 1.0, -7.0, 3.0]]], [[], [[6, 23], [9, 13]], 3]]], [[[[[39, -4.0, 0.0, -1.0, 0.0], [28, 2.0, 2.0, 5.0, 3.0], [31, 4.0, 5.0, 5.0, 8.0], [16, 1.0, 4.0, 1.0, 6.0], [6, 0.0, -5.0, 2.0, -3.0], [10, -4.0, -3.0, -3.0, 0.0], [33, 4.0, -4.0, 4.0, -1.0]], [[39, -2.0, -1.0, 1.0, -1.0], [28, 4.0, 1.0, 7.0, 2.0], [31, 5.0, 5.0, 6.0, 8.0], [16, 5.0, 5.0, 5.0, 7.0], [6, -1.0, -5.0, 1.0, -3.0], [10, -4.0, -3.0, -3.0, 0.0], [33, 3.0, -4.0, 3.0, -1.0]]], [[[16, 31]], [[6, 16], [6, 28], [10, 39], [16, 33], [28, 33], [31, 33]], 17]], [[[[13, 3.0, 4.0, 4.0, 4.0], [31, 0.0, 2.0, 2.0, 5.0], [3, 0.0, 5.0, 2.0, 5.0], [15, -1.0, 3.0, -1.0, 5.0], [5, 0.0, -4.0, 3.0, -1.0], [29, 1.0, -1.0, 2.0, 2.0], [19, -2.0, -3.0, 0.0, 0.0], [39, 5.0, -4.0, 8.0, -3.0]], [[13, 0.0, 4.0, 1.0, 4.0], [31, 0.0, 2.0, 2.0, 5.0], [3, 0.0, 5.0, 2.0, 5.0], [15, -1.0, 3.0, -1.0, 5.0], [5, 0.0, -4.0, 3.0, -1.0], [29, 3.0, -1.0, 4.0, 2.0], [19, -3.0, -3.0, -1.0, 0.0], [39, 9.0, -3.0, 12.0, -2.0]]], [[[13, 31]], [[3, 19], [3, 29], [5, 19], [13, 29], [19, 31], [29, 31]], 16]], [[[[8, 0.0, 4.0, 3.0, 5.0], [35, 1.0, 4.0, 1.0, 4.0]], [[8, 0.0, 4.0, 3.0, 5.0], [35, 3.0, 3.0, 3.0, 3.0]]], [[], [], 0]], [[[[17, -5.0, 2.0, -5.0, 3.0], [36, 1.0, 5.0, 1.0, 8.0]], [[17, -6.0, 2.0, -6.0, 3.0], [36, 0.0, 4.0, 0.0, 7.0]]], [[], [], 0]], [[[[28, 5.0, 3.0, 6.0, 4.0], [26, -1.0, 3.0, -1.0, 4.0]], [[28, 4.0, 3.0, 5.0, 4.0], [26, -4.0, 3.0, -4.0, 4.0]]], [[], [], 0]], [[[[11, -1.0, 3.0, 2.0, 6.0], [4, -1.0, -1.0, -1.0, 1.0]], [[11, 1.0, 2.0, 4.0, 5.0], [4, -1.0, -1.0, -1.0, 1.0]]], [[], [[4, 11]], 1]], [[[[38, -3.0, -5.0, -3.0, -4.0], [10, 4.0, 1.0, 6.0, 3.0], [15, 1.0, 0.0, 3.0, 3.0], [23, -4.0, -2.0, -1.0, 0.0], [24, -1.0, 3.0, 2.0, 4.0], [14, 3.0, -4.0, 5.0, -3.0], [26, -2.0, 3.0, 1.0, 5.0], [20, -5.0, 4.0, -4.0, 5.0]], [[38, -6.0, -6.0, -6.0, -5.0], [10, 1.0, 0.0, 3.0, 2.0], [15, 1.0, 1.0, 3.0, 4.0], [23, 0.0, -2.0, 3.0, 0.0], [24, 0.0, 2.0, 3.0, 3.0], [14, 5.0, -5.0, 7.0, -4.0], [26, -2.0, 2.0, 1.0, 4.0], [20, -3.0, 5.0, -2.0, 6.0]]], [[[10, 15], [10, 23], [10, 24], [10, 26]], [[10, 14], [14, 15], [20, 23], [20, 38], [23, 38]], 19]], [[[[31, 4.0, 0.0, 6.0, 1.0], [25, 0.0, 5.0, 2.0, 6.0], [4, -1.0, 3.0, 0.0, 5.0], [23, -5.0, 5.0, -3.0, 7.0], [17, 2.0, 1.0, 3.0, 2.0], [3, -5.0, 3.0, -5.0, 6.0], [24, 3.0, -3.0, 6.0, -2.0], [28, 4.0, 5.0, 6.0, 5.0]], [[31, 5.0, 0.0, 7.0, 1.0], [25, 2.0, 5.0, 4.0, 6.0], [4, 0.0, 4.0, 1.0, 6.0], [23, -5.0, 4.0, -3.0, 6.0], [17, 4.0, 1.0, 5.0, 2.0], [3, -6.0, 3.0, -6.0, 6.0], [24, 3.0, -2.0, 6.0, -1.0], [28, 8.0, 5.0, 10.0, 5.0]]], [[[17, 31]], [[3, 23], [4, 25], [24, 28], [28, 31]], 9]]], [[[[[21, 2.0, 0.0, 4.0, 1.0], [38, -5.0, 0.0, -3.0, 2.0], [25, 2.0, -2.0, 5.0, 0.0], [1, 0.0, 2.0, 2.0, 4.0]], [[21, 1.0, -1.0, 3.0, 0.0], [38, -4.0, 0.0, -2.0, 2.0], [25, 2.0, -2.0, 5.0, 0.0], [1, 0.0, 2.0, 2.0, 4.0]]], [[], [], 0]], [[[[1, -3.0, 2.0, -1.0, 3.0], [19, -5.0, -5.0, -3.0, -3.0], [20, -1.0, 4.0, 2.0, 6.0], [21, -3.0, 1.0, 0.0, 3.0], [11, 2.0, 4.0, 2.0, 7.0], [5, 1.0, 4.0, 1.0, 6.0], [13, -1.0, 0.0, 1.0, 0.0], [27, 0.0, -5.0, 0.0, -4.0]], [[1, -3.0, 3.0, -1.0, 4.0], [19, -5.0, -5.0, -3.0, -3.0], [20, -1.0, 3.0, 2.0, 5.0], [21, -1.0, 0.0, 2.0, 2.0], [11, 4.0, 4.0, 4.0, 7.0], [5, 1.0, 4.0, 1.0, 6.0], [13, -2.0, 1.0, 0.0, 1.0], [27, -3.0, -5.0, -3.0, -4.0]]], [[[19, 27]], [[5, 13], [11, 20], [13, 27], [19, 21], [20, 27], [21, 27]], 19]], [[[[12, 5.0, 5.0, 5.0, 8.0], [14, -4.0, 5.0, -4.0, 6.0], [7, 4.0, -3.0, 7.0, 0.0], [6, -4.0, 5.0, -1.0, 7.0]], [[12, 5.0, 5.0, 5.0, 8.0], [14, -7.0, 5.0, -7.0, 6.0], [7, 1.0, -4.0, 4.0, -1.0], [6, -4.0, 4.0, -1.0, 6.0]]], [[], [[6, 14], [7, 12]], 4]], [[[[22, -4.0, -3.0, -4.0, -1.0], [21, -1.0, -1.0, 0.0, 2.0], [11, -3.0, 0.0, -3.0, 0.0], [37, 1.0, -4.0, 3.0, -2.0]], [[22, -7.0, -3.0, -7.0, -1.0], [21, -4.0, 0.0, -3.0, 3.0], [11, -6.0, -1.0, -6.0, -1.0], [37, 1.0, -3.0, 3.0, -1.0]]], [[], [], 0]], [[[[25, -2.0, 4.0, -1.0, 7.0], [11, 4.0, 2.0, 4.0, 2.0], [5, 2.0, -3.0, 4.0, -2.0], [14, -2.0, -1.0, 1.0, 1.0], [29, -4.0, 5.0, -3.0, 7.0], [39, -1.0, 5.0, -1.0, 6.0], [20, 5.0, -1.0, 7.0, 1.0], [16, 4.0, 5.0, 7.0, 6.0]], [[25, -3.0, 5.0, -2.0, 8.0], [11, 5.0, 2.0, 5.0, 2.0], [5, -1.0, -4.0, 1.0, -3.0], [14, -5.0, -1.0, -2.0, 1.0], [29, 0.0, 6.0, 1.0, 8.0], [39, -2.0, 5.0, -2.0, 6.0], [20, 2.0, -1.0, 4.0, 1.0], [16, 1.0, 5.0, 4.0, 6.0]]], [[[16, 29], [25, 29], [29, 39]], [[5, 11], [11, 16], [11, 20], [14, 29], [25, 29], [29, 39]], 23]], [[[[13, 3.0, 4.0, 6.0, 6.0], [3, -4.0, 4.0, -3.0, 7.0], [36, 4.0, 0.0, 4.0, 3.0], [21, 0.0, 5.0, 1.0, 8.0], [33, 3.0, 4.0, 5.0, 4.0]], [[13, 7.0, 3.0, 10.0, 5.0], [3, -7.0, 3.0, -6.0, 6.0], [36, 4.0, 0.0, 4.0, 3.0], [21, 1.0, 4.0, 2.0, 7.0], [33, 3.0, 5.0, 5.0, 5.0]]], [[], [[13, 33], [13, 36]], 4]], [[[[8, 5.0, 2.0, 6.0, 2.0], [5, -3.0, -5.0, -1.0, -4.0], [27, 0.0, 1.0, 1.0, 1.0], [16, 4.0, 2.0, 6.0, 3.0], [38, 5.0, -4.0, 8.0, -2.0], [19, -5.0, 2.0, -5.0, 5.0], [20, 1.0, 1.0, 3.0, 1.0], [31, 5.0, -1.0, 8.0, 2.0], [22, -2.0, -4.0, -2.0, -2.0]], [[8, 5.0, 3.0, 6.0, 3.0], [5, -3.0, -5.0, -1.0, -4.0], [27, 2.0, 2.0, 3.0, 2.0], [16, 1.0, 2.0, 3.0, 3.0], [38, 7.0, -3.0, 10.0, -1.0], [19, -5.0, 3.0, -5.0, 6.0], [20, 2.0, 1.0, 4.0, 1.0], [31, 9.0, 0.0, 12.0, 3.0], [22, 0.0, -3.0, 0.0, -1.0]]], [[[16, 27]], [[5, 22], [8, 16], [8, 31], [8, 38], [16, 31], [16, 38]], 15]], [[[[18, -3.0, 3.0, -1.0, 4.0], [34, 1.0, -4.0, 1.0, -2.0], [23, 4.0, -2.0, 7.0, 1.0]], [[18, -3.0, 3.0, -1.0, 4.0], [34, 3.0, -4.0, 3.0, -2.0], [23, 3.0, -2.0, 6.0, 1.0]]], [[[23, 34]], [], 1]]], [[[[[3, -4.0, -4.0, -4.0, -1.0], [17, 3.0, -5.0, 3.0, -3.0]], [[3, -2.0, -4.0, -2.0, -1.0], [17, 2.0, -5.0, 2.0, -3.0]]], [[], [], 0]], [[[[23, 1.0, 0.0, 2.0, 1.0], [30, 5.0, -2.0, 5.0, -1.0], [16, 3.0, 5.0, 6.0, 8.0], [2, -3.0, 2.0, 0.0, 2.0]], [[23, 0.0, 0.0, 1.0, 1.0], [30, 7.0, -2.0, 7.0, -1.0], [16, 5.0, 4.0, 8.0, 7.0], [2, -6.0, 3.0, -3.0, 3.0]]], [[], [], 0]], [[[[24, -5.0, 3.0, -4.0, 3.0], [16, -2.0, -2.0, -1.0, -2.0], [22, -1.0, 0.0, 2.0, 0.0], [9, 1.0, -2.0, 3.0, 1.0]], [[24, -5.0, 3.0, -4.0, 3.0], [16, -2.0, -3.0, -1.0, -3.0], [22, -2.0, 0.0, 1.0, 0.0], [9, -2.0, -2.0, 0.0, 1.0]]], [[], [], 2]], [[[[25, 2.0, 5.0, 4.0, 7.0], [4, 3.0, 5.0, 6.0, 5.0], [2, 1.0, -1.0, 3.0, 0.0], [21, -5.0, -4.0, -2.0, -4.0]], [[25, 1.0, 6.0, 3.0, 8.0], [4, 5.0, 4.0, 8.0, 4.0], [2, 5.0, -1.0, 7.0, 0.0], [21, -5.0, -4.0, -2.0, -4.0]]], [[], [[2, 25], [4, 25]], 4]], [[[[30, -5.0, -2.0, -2.0, 0.0], [13, -5.0, 4.0, -5.0, 4.0]], [[30, -6.0, -2.0, -3.0, 0.0], [13, -3.0, 5.0, -3.0, 5.0]]], [[], [], 1]], [[[[4, -4.0, -1.0, -3.0, -1.0], [20, 2.0, -1.0, 5.0, 2.0], [22, 1.0, 1.0, 1.0, 1.0], [8, 4.0, -5.0, 4.0, -5.0], [7, 3.0, 4.0, 5.0, 6.0], [9, -2.0, -2.0, -2.0, 1.0], [13, 4.0, 4.0, 7.0, 5.0], [24, 5.0, 3.0, 6.0, 4.0]], [[4, -3.0, -2.0, -2.0, -2.0], [20, 1.0, -1.0, 4.0, 2.0], [22, -2.0, 2.0, -2.0, 2.0], [8, 1.0, -6.0, 1.0, -6.0], [7, 3.0, 4.0, 5.0, 6.0], [9, -1.0, -2.0, -1.0, 1.0], [13, 8.0, 4.0, 11.0, 5.0], [24, 4.0, 4.0, 5.0, 5.0]]], [[], [[7, 8], [7, 13], [8, 13], [9, 22], [13, 20], [13, 24]], 13]], [[[[17, 3.0, 1.0, 3.0, 1.0], [9, -3.0, -2.0, 0.0, -1.0], [34, 2.0, 4.0, 4.0, 5.0], [32, 4.0, 5.0, 4.0, 6.0], [30, 5.0, 0.0, 7.0, 3.0], [31, -3.0, 2.0, -2.0, 5.0], [25, -4.0, 3.0, -3.0, 6.0], [26, -4.0, 4.0, -4.0, 7.0]], [[17, 3.0, 1.0, 3.0, 1.0], [9, -2.0, -2.0, 1.0, -1.0], [34, 6.0, 3.0, 8.0, 4.0], [32, 1.0, 5.0, 1.0, 6.0], [30, 2.0, 0.0, 4.0, 3.0], [31, -6.0, 3.0, -5.0, 6.0], [25, -4.0, 2.0, -3.0, 5.0], [26, -5.0, 5.0, -5.0, 8.0]]], [[[17, 30], [26, 31], [30, 34]], [[9, 25], [9, 31], [17, 32], [17, 34], [25, 26], [25, 31], [30, 34], [32, 34]], 25]], [[[[29, -5.0, 2.0, -2.0, 4.0], [24, 1.0, 4.0, 1.0, 6.0], [25, -4.0, 0.0, -2.0, 0.0], [16, 0.0, 1.0, 3.0, 2.0], [2, 4.0, -1.0, 7.0, 1.0], [6, 4.0, 3.0, 7.0, 3.0], [3, -1.0, 0.0, -1.0, 1.0], [27, -4.0, 3.0, -1.0, 6.0], [23, -2.0, -5.0, -2.0, -4.0]], [[29, -8.0, 1.0, -5.0, 3.0], [24, -2.0, 4.0, -2.0, 6.0], [25, -3.0, 1.0, -1.0, 1.0], [16, 1.0, 2.0, 4.0, 3.0], [2, 8.0, -1.0, 11.0, 1.0], [6, 4.0, 2.0, 7.0, 2.0], [3, 3.0, 0.0, 3.0, 1.0], [27, -7.0, 2.0, -4.0, 5.0], [23, -1.0, -4.0, -1.0, -3.0]]], [[[6, 16]], [[2, 6], [3, 24], [3, 27], [16, 24], [23, 24], [23, 27], [23, 29], [25, 27], [25, 29]], 29]]]]
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 | [[], [[4, 35], [35, 35]], 4] | [[], [[4, 35]], 3] | Failed |
| case 1 | [[], [[8, 8], [8, 10], [8, 15], [8, 33], [10, 10], [10, 15], [10, 33], [15, 15], [15, 33], [33, 33]], 19] | [[], [], 10] | Failed |
| case 2 | [[], [], 0] | [[], [], 0] | Passed |
| case 3 | [[[31, 32]], [[20, 20], [20, 26], [31, 31], [31, 32], [32, 32]], 9] | [[[31, 32]], [], 5] | Failed |
| case 4 | [[], [], 1] | [[], [], 1] | Passed |
| case 5 | [[], [[12, 12], [12, 16], [12, 24], [12, 32], [12, 33], [12, 39], [16, 16], [16, 24], [16, 32], [16, 33], [16, 39], [24, 24], [32, 39], [33, 33], [33, 39], [39, 39]], 24] | [[], [[12, 24], [12, 33], [16, 24], [16, 32], [16, 33], [32, 39], [33, 39]], 11] | Failed |
| case 6 | [[], [[6, 6], [6, 23], [37, 37]], 4] | [[], [[6, 23]], 2] | Failed |
| case 7 | [[], [[3, 3], [3, 25], [3, 30], [25, 25], [25, 30], [26, 26], [30, 30]], 8] | [[], [], 0] | Failed |
SHA-256 / aecf001415b7094d2ba64942954d2ad8e8cf7de3164e941494438b77c556bf36
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(prev, curr):
old = {b[0]: b for b in prev}
new = {b[0]: b for b in curr}
E = []
for i, b in old.items():
E.append([b[1], 0, i])
E.append([b[3], 1, i])
E.sort()
for e in E:
b = new[e[2]]
e[0] = b[1] if e[1] == 0 else b[4]
def yover(a, c):
return new[a][2] <= new[c][4] and new[c][2] <= new[a][4]
begins, ends = set(), set()
swaps = 0
for i in range(1, len(E)):
j = i
while j > 0 and (E[j - 1][0], E[j - 1][1]) > (E[j][0], E[j][1]):
e, f = E[j], E[j - 1]
E[j - 1], E[j] = e, f
swaps += 1
p = (min(e[2], f[2]), max(e[2], f[2]))
if e[1] == 0 and f[1] == 1:
if yover(e[2], f[2]):
begins.add(p)
elif e[1] == 1 and f[1] == 0:
ends.add(p)
j -= 1
return [sorted(list(p) for p in begins), sorted(list(p) for p in ends), swaps]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[[35, -4.0, 0.0, -3.0, 1.0], [4, -4.0, 0.0, -4.0, 3.0], [36, 5.0, -2.0, 5.0, 1.0], [25, 4.0, -1.0, 4.0, 1.0]], [[35, -7.0, -1.0, -6.0, 0.0], [4, -4.0, 0.0, -4.0, 3.0], [36, 7.0, -2.0, 7.0, 1.0], [25, 4.0, 0.0, 4.0, 2.0]]], [[], [[4, 35]], 3]], [[[[8, -3.0, 4.0, 0.0, 6.0], [15, 2.0, -2.0, 4.0, -2.0], [33, -1.0, 2.0, 0.0, 2.0], [10, 2.0, -3.0, 3.0, -1.0]], [[8, -1.0, 5.0, 2.0, 7.0], [15, -1.0, -2.0, 1.0, -2.0], [33, 0.0, 3.0, 1.0, 3.0], [10, -1.0, -4.0, 0.0, -2.0]]], [[], [], 10]], [[[[36, 4.0, -3.0, 4.0, -2.0], [30, 5.0, 1.0, 5.0, 1.0]], [[36, 4.0, -3.0, 4.0, -2.0], [30, 5.0, 1.0, 5.0, 1.0]]], [[], [], 0]], [[[[31, 2.0, 5.0, 4.0, 8.0], [26, -1.0, -3.0, -1.0, -3.0], [32, 0.0, 4.0, 1.0, 5.0], [20, -4.0, 3.0, -2.0, 5.0]], [[31, 2.0, 4.0, 4.0, 7.0], [26, -1.0, -2.0, -1.0, -2.0], [32, 4.0, 4.0, 5.0, 5.0], [20, -2.0, 3.0, 0.0, 5.0]]], [[[31, 32]], [], 5]], [[[[13, 2.0, -5.0, 2.0, -4.0], [6, 1.0, -3.0, 1.0, -3.0], [20, -5.0, 1.0, -5.0, 1.0]], [[13, 1.0, -5.0, 1.0, -4.0], [6, 1.0, -3.0, 1.0, -3.0], [20, -1.0, 2.0, -1.0, 2.0]]], [[], [], 1]], [[[[39, -3.0, -2.0, -1.0, -2.0], [32, -3.0, -1.0, -3.0, 0.0], [33, -2.0, -2.0, -1.0, 0.0], [24, -5.0, 1.0, -4.0, 1.0], [16, -4.0, 3.0, -1.0, 4.0], [12, -5.0, 1.0, -2.0, 4.0]], [[39, -2.0, -2.0, 0.0, -2.0], [32, -3.0, -1.0, -3.0, 0.0], [33, 2.0, -3.0, 3.0, -1.0], [24, -5.0, 0.0, -4.0, 0.0], [16, -2.0, 4.0, 1.0, 5.0], [12, -3.0, 2.0, 0.0, 5.0]]], [[], [[12, 24], [12, 33], [16, 24], [16, 32], [16, 33], [32, 39], [33, 39]], 11]], [[[[6, -4.0, 2.0, -1.0, 2.0], [23, -2.0, 5.0, -2.0, 8.0], [37, 3.0, 2.0, 4.0, 4.0]], [[6, -7.0, 1.0, -4.0, 1.0], [23, -2.0, 5.0, -2.0, 8.0], [37, 4.0, 2.0, 5.0, 4.0]]], [[], [[6, 23]], 2]], [[[[25, 2.0, 0.0, 5.0, 2.0], [26, -4.0, -3.0, -2.0, 0.0], [3, 4.0, 4.0, 6.0, 6.0], [30, 4.0, 0.0, 6.0, 2.0]], [[25, 3.0, 1.0, 6.0, 3.0], [26, -7.0, -4.0, -5.0, -1.0], [3, 4.0, 5.0, 6.0, 7.0], [30, 6.0, 0.0, 8.0, 2.0]]], [[], [], 0]]], [[[[[39, -4.0, -3.0, -1.0, -3.0], [20, -5.0, 4.0, -4.0, 4.0], [13, 1.0, -4.0, 2.0, -1.0], [25, -1.0, -2.0, 2.0, 0.0], [22, 4.0, 4.0, 6.0, 6.0]], [[39, -7.0, -3.0, -4.0, -3.0], [20, -5.0, 3.0, -4.0, 3.0], [13, 1.0, -4.0, 2.0, -1.0], [25, -2.0, -3.0, 1.0, -1.0], [22, 4.0, 4.0, 6.0, 6.0]]], [[], [[25, 39]], 3]], [[[[8, -2.0, -1.0, -2.0, 2.0], [15, -4.0, -3.0, -3.0, -3.0], [22, 2.0, -3.0, 3.0, -3.0]], [[8, -3.0, 0.0, -3.0, 3.0], [15, -5.0, -2.0, -4.0, -2.0], [22, -1.0, -3.0, 0.0, -3.0]]], [[], [], 0]], [[[[29, 2.0, -3.0, 5.0, -2.0], [17, -4.0, 3.0, -1.0, 3.0], [24, 3.0, 4.0, 3.0, 5.0], [3, 0.0, -3.0, 0.0, 0.0], [27, -5.0, 4.0, -2.0, 7.0], [2, -2.0, -4.0, -1.0, -4.0], [26, -1.0, -3.0, 2.0, -2.0]], [[29, 4.0, -4.0, 7.0, -3.0], [17, -2.0, 2.0, 1.0, 2.0], [24, 0.0, 3.0, 0.0, 4.0], [3, 0.0, -3.0, 0.0, 0.0], [27, -3.0, 4.0, 0.0, 7.0], [2, -5.0, -3.0, -4.0, -3.0], [26, 1.0, -2.0, 4.0, -1.0]]], [[[24, 27]], [[2, 17], [2, 26], [2, 27], [3, 26], [24, 26], [24, 29]], 21]], [[[[34, -5.0, 0.0, -4.0, 2.0], [15, -5.0, -2.0, -4.0, -2.0], [33, 2.0, 2.0, 5.0, 2.0], [20, 1.0, -1.0, 2.0, -1.0], [21, -5.0, 5.0, -4.0, 8.0], [2, -1.0, 1.0, 0.0, 1.0], [25, -1.0, -4.0, -1.0, -1.0]], [[34, -3.0, 1.0, -2.0, 3.0], [15, -5.0, -3.0, -4.0, -3.0], [33, 2.0, 3.0, 5.0, 3.0], [20, -2.0, 0.0, -1.0, 0.0], [21, -8.0, 5.0, -7.0, 8.0], [2, -4.0, 0.0, -3.0, 0.0], [25, -1.0, -5.0, -1.0, -2.0]]], [[], [[2, 25], [15, 21], [15, 34], [20, 33], [21, 34]], 15]], [[[[8, -4.0, 3.0, -1.0, 5.0], [29, -3.0, -3.0, -2.0, -1.0], [6, -5.0, -4.0, -2.0, -3.0], [23, -3.0, 5.0, -2.0, 8.0]], [[8, -3.0, 3.0, 0.0, 5.0], [29, -4.0, -2.0, -3.0, 0.0], [6, -8.0, -4.0, -5.0, -3.0], [23, 1.0, 5.0, 2.0, 8.0]]], [[], [[6, 8], [6, 23], [6, 29], [8, 23], [23, 29]], 9]], [[[[4, -4.0, 2.0, -3.0, 4.0], [2, 1.0, 1.0, 2.0, 2.0], [7, -3.0, -2.0, 0.0, -2.0], [1, 1.0, 0.0, 4.0, 2.0], [16, 5.0, 2.0, 6.0, 5.0], [17, 5.0, -1.0, 7.0, 0.0], [28, 5.0, 0.0, 8.0, 3.0]], [[4, -4.0, 1.0, -3.0, 3.0], [2, 1.0, 1.0, 2.0, 2.0], [7, -1.0, -3.0, 2.0, -3.0], [1, 2.0, 1.0, 5.0, 3.0], [16, 4.0, 2.0, 5.0, 5.0], [17, 2.0, 0.0, 4.0, 1.0], [28, 4.0, 0.0, 7.0, 3.0]]], [[[1, 16], [1, 17], [1, 28], [2, 17]], [[4, 7]], 12]], [[[[2, 3.0, 3.0, 5.0, 3.0], [7, -4.0, 2.0, -2.0, 5.0], [8, 5.0, 2.0, 8.0, 5.0], [11, 4.0, -4.0, 5.0, -2.0], [9, 5.0, -4.0, 7.0, -3.0], [17, -1.0, 2.0, 0.0, 5.0], [39, -3.0, 5.0, 0.0, 8.0]], [[2, 3.0, 2.0, 5.0, 2.0], [7, -7.0, 2.0, -5.0, 5.0], [8, 2.0, 1.0, 5.0, 4.0], [11, 5.0, -5.0, 6.0, -3.0], [9, 5.0, -4.0, 7.0, -3.0], [17, -1.0, 2.0, 0.0, 5.0], [39, -3.0, 5.0, 0.0, 8.0]]], [[], [[7, 39]], 5]], [[[[23, -4.0, 0.0, -1.0, 1.0], [13, -4.0, -2.0, -4.0, 1.0], [6, -2.0, -5.0, 0.0, -3.0], [8, 5.0, 2.0, 5.0, 3.0], [9, -5.0, 0.0, -4.0, 2.0]], [[23, -7.0, 0.0, -4.0, 1.0], [13, -5.0, -1.0, -5.0, 2.0], [6, 0.0, -5.0, 2.0, -3.0], [8, 5.0, 3.0, 5.0, 4.0], [9, -8.0, 1.0, -7.0, 3.0]]], [[], [[6, 23], [9, 13]], 3]]], [[[[[39, -4.0, 0.0, -1.0, 0.0], [28, 2.0, 2.0, 5.0, 3.0], [31, 4.0, 5.0, 5.0, 8.0], [16, 1.0, 4.0, 1.0, 6.0], [6, 0.0, -5.0, 2.0, -3.0], [10, -4.0, -3.0, -3.0, 0.0], [33, 4.0, -4.0, 4.0, -1.0]], [[39, -2.0, -1.0, 1.0, -1.0], [28, 4.0, 1.0, 7.0, 2.0], [31, 5.0, 5.0, 6.0, 8.0], [16, 5.0, 5.0, 5.0, 7.0], [6, -1.0, -5.0, 1.0, -3.0], [10, -4.0, -3.0, -3.0, 0.0], [33, 3.0, -4.0, 3.0, -1.0]]], [[[16, 31]], [[6, 16], [6, 28], [10, 39], [16, 33], [28, 33], [31, 33]], 17]], [[[[13, 3.0, 4.0, 4.0, 4.0], [31, 0.0, 2.0, 2.0, 5.0], [3, 0.0, 5.0, 2.0, 5.0], [15, -1.0, 3.0, -1.0, 5.0], [5, 0.0, -4.0, 3.0, -1.0], [29, 1.0, -1.0, 2.0, 2.0], [19, -2.0, -3.0, 0.0, 0.0], [39, 5.0, -4.0, 8.0, -3.0]], [[13, 0.0, 4.0, 1.0, 4.0], [31, 0.0, 2.0, 2.0, 5.0], [3, 0.0, 5.0, 2.0, 5.0], [15, -1.0, 3.0, -1.0, 5.0], [5, 0.0, -4.0, 3.0, -1.0], [29, 3.0, -1.0, 4.0, 2.0], [19, -3.0, -3.0, -1.0, 0.0], [39, 9.0, -3.0, 12.0, -2.0]]], [[[13, 31]], [[3, 19], [3, 29], [5, 19], [13, 29], [19, 31], [29, 31]], 16]], [[[[8, 0.0, 4.0, 3.0, 5.0], [35, 1.0, 4.0, 1.0, 4.0]], [[8, 0.0, 4.0, 3.0, 5.0], [35, 3.0, 3.0, 3.0, 3.0]]], [[], [], 0]], [[[[17, -5.0, 2.0, -5.0, 3.0], [36, 1.0, 5.0, 1.0, 8.0]], [[17, -6.0, 2.0, -6.0, 3.0], [36, 0.0, 4.0, 0.0, 7.0]]], [[], [], 0]], [[[[28, 5.0, 3.0, 6.0, 4.0], [26, -1.0, 3.0, -1.0, 4.0]], [[28, 4.0, 3.0, 5.0, 4.0], [26, -4.0, 3.0, -4.0, 4.0]]], [[], [], 0]], [[[[11, -1.0, 3.0, 2.0, 6.0], [4, -1.0, -1.0, -1.0, 1.0]], [[11, 1.0, 2.0, 4.0, 5.0], [4, -1.0, -1.0, -1.0, 1.0]]], [[], [[4, 11]], 1]], [[[[38, -3.0, -5.0, -3.0, -4.0], [10, 4.0, 1.0, 6.0, 3.0], [15, 1.0, 0.0, 3.0, 3.0], [23, -4.0, -2.0, -1.0, 0.0], [24, -1.0, 3.0, 2.0, 4.0], [14, 3.0, -4.0, 5.0, -3.0], [26, -2.0, 3.0, 1.0, 5.0], [20, -5.0, 4.0, -4.0, 5.0]], [[38, -6.0, -6.0, -6.0, -5.0], [10, 1.0, 0.0, 3.0, 2.0], [15, 1.0, 1.0, 3.0, 4.0], [23, 0.0, -2.0, 3.0, 0.0], [24, 0.0, 2.0, 3.0, 3.0], [14, 5.0, -5.0, 7.0, -4.0], [26, -2.0, 2.0, 1.0, 4.0], [20, -3.0, 5.0, -2.0, 6.0]]], [[[10, 15], [10, 23], [10, 24], [10, 26]], [[10, 14], [14, 15], [20, 23], [20, 38], [23, 38]], 19]], [[[[31, 4.0, 0.0, 6.0, 1.0], [25, 0.0, 5.0, 2.0, 6.0], [4, -1.0, 3.0, 0.0, 5.0], [23, -5.0, 5.0, -3.0, 7.0], [17, 2.0, 1.0, 3.0, 2.0], [3, -5.0, 3.0, -5.0, 6.0], [24, 3.0, -3.0, 6.0, -2.0], [28, 4.0, 5.0, 6.0, 5.0]], [[31, 5.0, 0.0, 7.0, 1.0], [25, 2.0, 5.0, 4.0, 6.0], [4, 0.0, 4.0, 1.0, 6.0], [23, -5.0, 4.0, -3.0, 6.0], [17, 4.0, 1.0, 5.0, 2.0], [3, -6.0, 3.0, -6.0, 6.0], [24, 3.0, -2.0, 6.0, -1.0], [28, 8.0, 5.0, 10.0, 5.0]]], [[[17, 31]], [[3, 23], [4, 25], [24, 28], [28, 31]], 9]]], [[[[[21, 2.0, 0.0, 4.0, 1.0], [38, -5.0, 0.0, -3.0, 2.0], [25, 2.0, -2.0, 5.0, 0.0], [1, 0.0, 2.0, 2.0, 4.0]], [[21, 1.0, -1.0, 3.0, 0.0], [38, -4.0, 0.0, -2.0, 2.0], [25, 2.0, -2.0, 5.0, 0.0], [1, 0.0, 2.0, 2.0, 4.0]]], [[], [], 0]], [[[[1, -3.0, 2.0, -1.0, 3.0], [19, -5.0, -5.0, -3.0, -3.0], [20, -1.0, 4.0, 2.0, 6.0], [21, -3.0, 1.0, 0.0, 3.0], [11, 2.0, 4.0, 2.0, 7.0], [5, 1.0, 4.0, 1.0, 6.0], [13, -1.0, 0.0, 1.0, 0.0], [27, 0.0, -5.0, 0.0, -4.0]], [[1, -3.0, 3.0, -1.0, 4.0], [19, -5.0, -5.0, -3.0, -3.0], [20, -1.0, 3.0, 2.0, 5.0], [21, -1.0, 0.0, 2.0, 2.0], [11, 4.0, 4.0, 4.0, 7.0], [5, 1.0, 4.0, 1.0, 6.0], [13, -2.0, 1.0, 0.0, 1.0], [27, -3.0, -5.0, -3.0, -4.0]]], [[[19, 27]], [[5, 13], [11, 20], [13, 27], [19, 21], [20, 27], [21, 27]], 19]], [[[[12, 5.0, 5.0, 5.0, 8.0], [14, -4.0, 5.0, -4.0, 6.0], [7, 4.0, -3.0, 7.0, 0.0], [6, -4.0, 5.0, -1.0, 7.0]], [[12, 5.0, 5.0, 5.0, 8.0], [14, -7.0, 5.0, -7.0, 6.0], [7, 1.0, -4.0, 4.0, -1.0], [6, -4.0, 4.0, -1.0, 6.0]]], [[], [[6, 14], [7, 12]], 4]], [[[[22, -4.0, -3.0, -4.0, -1.0], [21, -1.0, -1.0, 0.0, 2.0], [11, -3.0, 0.0, -3.0, 0.0], [37, 1.0, -4.0, 3.0, -2.0]], [[22, -7.0, -3.0, -7.0, -1.0], [21, -4.0, 0.0, -3.0, 3.0], [11, -6.0, -1.0, -6.0, -1.0], [37, 1.0, -3.0, 3.0, -1.0]]], [[], [], 0]], [[[[25, -2.0, 4.0, -1.0, 7.0], [11, 4.0, 2.0, 4.0, 2.0], [5, 2.0, -3.0, 4.0, -2.0], [14, -2.0, -1.0, 1.0, 1.0], [29, -4.0, 5.0, -3.0, 7.0], [39, -1.0, 5.0, -1.0, 6.0], [20, 5.0, -1.0, 7.0, 1.0], [16, 4.0, 5.0, 7.0, 6.0]], [[25, -3.0, 5.0, -2.0, 8.0], [11, 5.0, 2.0, 5.0, 2.0], [5, -1.0, -4.0, 1.0, -3.0], [14, -5.0, -1.0, -2.0, 1.0], [29, 0.0, 6.0, 1.0, 8.0], [39, -2.0, 5.0, -2.0, 6.0], [20, 2.0, -1.0, 4.0, 1.0], [16, 1.0, 5.0, 4.0, 6.0]]], [[[16, 29], [25, 29], [29, 39]], [[5, 11], [11, 16], [11, 20], [14, 29], [25, 29], [29, 39]], 23]], [[[[13, 3.0, 4.0, 6.0, 6.0], [3, -4.0, 4.0, -3.0, 7.0], [36, 4.0, 0.0, 4.0, 3.0], [21, 0.0, 5.0, 1.0, 8.0], [33, 3.0, 4.0, 5.0, 4.0]], [[13, 7.0, 3.0, 10.0, 5.0], [3, -7.0, 3.0, -6.0, 6.0], [36, 4.0, 0.0, 4.0, 3.0], [21, 1.0, 4.0, 2.0, 7.0], [33, 3.0, 5.0, 5.0, 5.0]]], [[], [[13, 33], [13, 36]], 4]], [[[[8, 5.0, 2.0, 6.0, 2.0], [5, -3.0, -5.0, -1.0, -4.0], [27, 0.0, 1.0, 1.0, 1.0], [16, 4.0, 2.0, 6.0, 3.0], [38, 5.0, -4.0, 8.0, -2.0], [19, -5.0, 2.0, -5.0, 5.0], [20, 1.0, 1.0, 3.0, 1.0], [31, 5.0, -1.0, 8.0, 2.0], [22, -2.0, -4.0, -2.0, -2.0]], [[8, 5.0, 3.0, 6.0, 3.0], [5, -3.0, -5.0, -1.0, -4.0], [27, 2.0, 2.0, 3.0, 2.0], [16, 1.0, 2.0, 3.0, 3.0], [38, 7.0, -3.0, 10.0, -1.0], [19, -5.0, 3.0, -5.0, 6.0], [20, 2.0, 1.0, 4.0, 1.0], [31, 9.0, 0.0, 12.0, 3.0], [22, 0.0, -3.0, 0.0, -1.0]]], [[[16, 27]], [[5, 22], [8, 16], [8, 31], [8, 38], [16, 31], [16, 38]], 15]], [[[[18, -3.0, 3.0, -1.0, 4.0], [34, 1.0, -4.0, 1.0, -2.0], [23, 4.0, -2.0, 7.0, 1.0]], [[18, -3.0, 3.0, -1.0, 4.0], [34, 3.0, -4.0, 3.0, -2.0], [23, 3.0, -2.0, 6.0, 1.0]]], [[[23, 34]], [], 1]]], [[[[[3, -4.0, -4.0, -4.0, -1.0], [17, 3.0, -5.0, 3.0, -3.0]], [[3, -2.0, -4.0, -2.0, -1.0], [17, 2.0, -5.0, 2.0, -3.0]]], [[], [], 0]], [[[[23, 1.0, 0.0, 2.0, 1.0], [30, 5.0, -2.0, 5.0, -1.0], [16, 3.0, 5.0, 6.0, 8.0], [2, -3.0, 2.0, 0.0, 2.0]], [[23, 0.0, 0.0, 1.0, 1.0], [30, 7.0, -2.0, 7.0, -1.0], [16, 5.0, 4.0, 8.0, 7.0], [2, -6.0, 3.0, -3.0, 3.0]]], [[], [], 0]], [[[[24, -5.0, 3.0, -4.0, 3.0], [16, -2.0, -2.0, -1.0, -2.0], [22, -1.0, 0.0, 2.0, 0.0], [9, 1.0, -2.0, 3.0, 1.0]], [[24, -5.0, 3.0, -4.0, 3.0], [16, -2.0, -3.0, -1.0, -3.0], [22, -2.0, 0.0, 1.0, 0.0], [9, -2.0, -2.0, 0.0, 1.0]]], [[], [], 2]], [[[[25, 2.0, 5.0, 4.0, 7.0], [4, 3.0, 5.0, 6.0, 5.0], [2, 1.0, -1.0, 3.0, 0.0], [21, -5.0, -4.0, -2.0, -4.0]], [[25, 1.0, 6.0, 3.0, 8.0], [4, 5.0, 4.0, 8.0, 4.0], [2, 5.0, -1.0, 7.0, 0.0], [21, -5.0, -4.0, -2.0, -4.0]]], [[], [[2, 25], [4, 25]], 4]], [[[[30, -5.0, -2.0, -2.0, 0.0], [13, -5.0, 4.0, -5.0, 4.0]], [[30, -6.0, -2.0, -3.0, 0.0], [13, -3.0, 5.0, -3.0, 5.0]]], [[], [], 1]], [[[[4, -4.0, -1.0, -3.0, -1.0], [20, 2.0, -1.0, 5.0, 2.0], [22, 1.0, 1.0, 1.0, 1.0], [8, 4.0, -5.0, 4.0, -5.0], [7, 3.0, 4.0, 5.0, 6.0], [9, -2.0, -2.0, -2.0, 1.0], [13, 4.0, 4.0, 7.0, 5.0], [24, 5.0, 3.0, 6.0, 4.0]], [[4, -3.0, -2.0, -2.0, -2.0], [20, 1.0, -1.0, 4.0, 2.0], [22, -2.0, 2.0, -2.0, 2.0], [8, 1.0, -6.0, 1.0, -6.0], [7, 3.0, 4.0, 5.0, 6.0], [9, -1.0, -2.0, -1.0, 1.0], [13, 8.0, 4.0, 11.0, 5.0], [24, 4.0, 4.0, 5.0, 5.0]]], [[], [[7, 8], [7, 13], [8, 13], [9, 22], [13, 20], [13, 24]], 13]], [[[[17, 3.0, 1.0, 3.0, 1.0], [9, -3.0, -2.0, 0.0, -1.0], [34, 2.0, 4.0, 4.0, 5.0], [32, 4.0, 5.0, 4.0, 6.0], [30, 5.0, 0.0, 7.0, 3.0], [31, -3.0, 2.0, -2.0, 5.0], [25, -4.0, 3.0, -3.0, 6.0], [26, -4.0, 4.0, -4.0, 7.0]], [[17, 3.0, 1.0, 3.0, 1.0], [9, -2.0, -2.0, 1.0, -1.0], [34, 6.0, 3.0, 8.0, 4.0], [32, 1.0, 5.0, 1.0, 6.0], [30, 2.0, 0.0, 4.0, 3.0], [31, -6.0, 3.0, -5.0, 6.0], [25, -4.0, 2.0, -3.0, 5.0], [26, -5.0, 5.0, -5.0, 8.0]]], [[[17, 30], [26, 31], [30, 34]], [[9, 25], [9, 31], [17, 32], [17, 34], [25, 26], [25, 31], [30, 34], [32, 34]], 25]], [[[[29, -5.0, 2.0, -2.0, 4.0], [24, 1.0, 4.0, 1.0, 6.0], [25, -4.0, 0.0, -2.0, 0.0], [16, 0.0, 1.0, 3.0, 2.0], [2, 4.0, -1.0, 7.0, 1.0], [6, 4.0, 3.0, 7.0, 3.0], [3, -1.0, 0.0, -1.0, 1.0], [27, -4.0, 3.0, -1.0, 6.0], [23, -2.0, -5.0, -2.0, -4.0]], [[29, -8.0, 1.0, -5.0, 3.0], [24, -2.0, 4.0, -2.0, 6.0], [25, -3.0, 1.0, -1.0, 1.0], [16, 1.0, 2.0, 4.0, 3.0], [2, 8.0, -1.0, 11.0, 1.0], [6, 4.0, 2.0, 7.0, 2.0], [3, 3.0, 0.0, 3.0, 1.0], [27, -7.0, 2.0, -4.0, 5.0], [23, -1.0, -4.0, -1.0, -3.0]]], [[[6, 16]], [[2, 6], [3, 24], [3, 27], [16, 24], [23, 24], [23, 27], [23, 29], [25, 27], [25, 29]], 29]]]]
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 | [[], [[25, 25], [25, 36], [36, 36]], 8] | [[], [[4, 35]], 3] | Failed |
| case 1 | [[], [[8, 10], [8, 15], [10, 10], [10, 15], [10, 33], [15, 15], [15, 33]], 19] | [[], [], 10] | Failed |
| case 2 | [[], [[30, 30], [30, 36], [36, 36]], 3] | [[], [], 0] | Failed |
| case 3 | [[[20, 31], [20, 32], [31, 32]], [[26, 26]], 7] | [[[31, 32]], [], 5] | Failed |
| case 4 | [[], [[6, 6], [6, 13], [6, 20], [13, 13], [13, 20]], 10] | [[], [], 1] | Failed |
| case 5 | [[[24, 32]], [[33, 33], [33, 39]], 15] | [[], [[12, 24], [12, 33], [16, 24], [16, 32], [16, 33], [32, 39], [33, 39]], 11] | Failed |
| case 6 | [[], [], 3] | [[], [[6, 23]], 2] | Failed |
| case 7 | [[], [[3, 25], [3, 30], [25, 30], [30, 30]], 7] | [[], [], 0] | Failed |
SHA-256 / 65a481a96546330153ec4327abcbc0fc505f8c541d832a437ce0635eb4da48a4
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗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:02.324884+00:00.
Case digest / dfea7855efe537c6535db78ec9e12f511d40e75a87f405e7d66110bde4d10bda