FA-70511 / GIS polygon topology / Open access
Rook and queen polygon adjacency: degenerate edge filter · case 01
Polygons with a repeated corner vertex become rook neighbours of anything sharing that corner.
ROOT CAUSE
Zero-length edges from repeated vertices are kept, and two such point-edges at a shared corner match.
VERIFIED REPAIR
At the degenerate edge filter step restore `for a, b in zip(r, r[1:]) if a != b}`, leaving the rest of the model unchanged.
Unsuccessful approach: Filtering on differing x coordinates also discards every vertical edge.
Case contract
Input [polygons, mode] where each polygon is a closed ring of integer vertices on a noded coverage (shared borders use identical vertices). Rook neighbours share at least one non-degenerate edge irrespective of direction; queen neighbours share at least one vertex. Return, for each polygon index, the ascending list of neighbour indexes (never itself).
Why this case matters
Spatial weights for regional statistics, district contiguity checks and map colouring all start from adjacency.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
polys, mode = x
def edges(r):
return {tuple(sorted([tuple(a), tuple(b)])) for a, b in zip(r, r[1:])}
def verts(r):
return {tuple(p) for p in r}
E = [edges(p) for p in polys]
V = [verts(p) for p in polys]
out = []
for i in range(len(polys)):
nb = []
for j in range(len(polys)):
if i == j:
continue
if mode == 'rook':
ok = bool(E[i] & E[j])
else:
ok = bool(V[i] & V[j])
if ok:
nb.append(j)
out.append(nb)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control #0', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]]], 'rook'], [[1, 3], [0], [], [0]]), ('control #1', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]]], 'queen'], [[1, 3], [0, 2, 3], [1], [0, 1]]), ('control #2', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[1, 2], [0, 3], [0, 3], [1, 2]]), ('control #3', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'queen'], [[1, 2, 3], [0, 2, 3], [0, 1, 3], [0, 1, 2]]), ('control #4', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[1, 3], [0, 4], [4], [0, 4], [1, 2, 3]]), ('control #5', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'queen'], [[1, 3, 4], [0, 2, 3, 4], [1, 4], [0, 1, 4], [0, 1, 2, 3]]), ('control #6', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'rook'], [[], []]), ('control #16', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[1], [0], []])], [('control #2', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[1, 2], [0, 3], [0, 3], [1, 2]]), ('control #4', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[1, 3], [0, 4], [4], [0, 4], [1, 2, 3]]), ('control #5', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'queen'], [[1, 3, 4], [0, 2, 3, 4], [1, 4], [0, 1, 4], [0, 1, 2, 3]]), ('control #6', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'rook'], [[], []]), ('control #7', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'queen'], [[], []]), ('control #8', [[[[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[], []]), ('control #9', [[[[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0]]), ('control #18', [[[[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[], []])], [('control #4', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[1, 3], [0, 4], [4], [0, 4], [1, 2, 3]]), ('control #7', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'queen'], [[], []]), ('control #8', [[[[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[], []]), ('control #9', [[[[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0]]), ('control #10', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[], []]), ('control #11', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'queen'], [[1], [0]]), ('control #12', [[[[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[1], [0, 2], [1]]), ('control #16', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[1], [0], []])], [('control #9', [[[[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0]]), ('control #10', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[], []]), ('control #11', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'queen'], [[1], [0]]), ('control #12', [[[[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[1], [0, 2], [1]]), ('control #13', [[[[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0, 2], [1]]), ('control #14', [[[[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]]], 'rook'], [[1], [0]]), ('control #15', [[[[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]]], 'queen'], [[1], [0]]), ('control #18', [[[[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[], []])], [('control #12', [[[[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[1], [0, 2], [1]]), ('control #13', [[[[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0, 2], [1]]), ('control #14', [[[[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]]], 'rook'], [[1], [0]]), ('control #15', [[[[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]]], 'queen'], [[1], [0]]), ('control #16', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[1], [0], []]), ('control #17', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0, 2], [1]]), ('control #18', [[[[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[], []]), ('control #19', [[[[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0]])]]
for label, args, expected in fixtures[N-1]:
check(label, 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 |
|---|---|---|---|
| control #0 | [[1, 3], [0], [], [0]] | [[1, 3], [0], [], [0]] | Passed |
| control #1 | [[1, 3], [0, 2, 3], [1], [0, 1]] | [[1, 3], [0, 2, 3], [1], [0, 1]] | Passed |
| control #2 | [[1, 2], [0, 3], [0, 3], [1, 2]] | [[1, 2], [0, 3], [0, 3], [1, 2]] | Passed |
| control #3 | [[1, 2, 3], [0, 2, 3], [0, 1, 3], [0, 1, 2]] | [[1, 2, 3], [0, 2, 3], [0, 1, 3], [0, 1, 2]] | Passed |
| control #4 | [[1, 3], [0, 4], [4], [0, 4], [1, 2, 3]] | [[1, 3], [0, 4], [4], [0, 4], [1, 2, 3]] | Passed |
| control #5 | [[1, 3, 4], [0, 2, 3, 4], [1, 4], [0, 1, 4], [0, 1, 2, 3]] | [[1, 3, 4], [0, 2, 3, 4], [1, 4], [0, 1, 4], [0, 1, 2, 3]] | Passed |
| control #6 | [[], []] | [[], []] | Passed |
| control #16 | [[1], [0, 2], [1]] | [[1], [0], []] | Failed |
SHA-256 / 249159aedf51bdb04f345fee9cb9e75d921384d093120a51b2f5e8844201592c
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
polys, mode = x
def edges(r):
return {tuple(sorted([tuple(a), tuple(b)])) for a, b in zip(r, r[1:]) if a[0] != b[0]}
def verts(r):
return {tuple(p) for p in r}
E = [edges(p) for p in polys]
V = [verts(p) for p in polys]
out = []
for i in range(len(polys)):
nb = []
for j in range(len(polys)):
if i == j:
continue
if mode == 'rook':
ok = bool(E[i] & E[j])
else:
ok = bool(V[i] & V[j])
if ok:
nb.append(j)
out.append(nb)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control #0', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]]], 'rook'], [[1, 3], [0], [], [0]]), ('control #1', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]]], 'queen'], [[1, 3], [0, 2, 3], [1], [0, 1]]), ('control #2', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[1, 2], [0, 3], [0, 3], [1, 2]]), ('control #3', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'queen'], [[1, 2, 3], [0, 2, 3], [0, 1, 3], [0, 1, 2]]), ('control #4', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[1, 3], [0, 4], [4], [0, 4], [1, 2, 3]]), ('control #5', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'queen'], [[1, 3, 4], [0, 2, 3, 4], [1, 4], [0, 1, 4], [0, 1, 2, 3]]), ('control #6', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'rook'], [[], []]), ('control #16', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[1], [0], []])], [('control #2', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[1, 2], [0, 3], [0, 3], [1, 2]]), ('control #4', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[1, 3], [0, 4], [4], [0, 4], [1, 2, 3]]), ('control #5', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'queen'], [[1, 3, 4], [0, 2, 3, 4], [1, 4], [0, 1, 4], [0, 1, 2, 3]]), ('control #6', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'rook'], [[], []]), ('control #7', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'queen'], [[], []]), ('control #8', [[[[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[], []]), ('control #9', [[[[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0]]), ('control #18', [[[[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[], []])], [('control #4', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[1, 3], [0, 4], [4], [0, 4], [1, 2, 3]]), ('control #7', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'queen'], [[], []]), ('control #8', [[[[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[], []]), ('control #9', [[[[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0]]), ('control #10', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[], []]), ('control #11', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'queen'], [[1], [0]]), ('control #12', [[[[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[1], [0, 2], [1]]), ('control #16', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[1], [0], []])], [('control #9', [[[[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0]]), ('control #10', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[], []]), ('control #11', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'queen'], [[1], [0]]), ('control #12', [[[[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[1], [0, 2], [1]]), ('control #13', [[[[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0, 2], [1]]), ('control #14', [[[[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]]], 'rook'], [[1], [0]]), ('control #15', [[[[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]]], 'queen'], [[1], [0]]), ('control #18', [[[[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[], []])], [('control #12', [[[[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[1], [0, 2], [1]]), ('control #13', [[[[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0, 2], [1]]), ('control #14', [[[[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]]], 'rook'], [[1], [0]]), ('control #15', [[[[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]]], 'queen'], [[1], [0]]), ('control #16', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[1], [0], []]), ('control #17', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0, 2], [1]]), ('control #18', [[[[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[], []]), ('control #19', [[[[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0]])]]
for label, args, expected in fixtures[N-1]:
check(label, 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 |
|---|---|---|---|
| control #0 | [[3], [], [], [0]] | [[1, 3], [0], [], [0]] | Failed |
| control #1 | [[1, 3], [0, 2, 3], [1], [0, 1]] | [[1, 3], [0, 2, 3], [1], [0, 1]] | Passed |
| control #2 | [[2], [3], [0], [1]] | [[1, 2], [0, 3], [0, 3], [1, 2]] | Failed |
| control #3 | [[1, 2, 3], [0, 2, 3], [0, 1, 3], [0, 1, 2]] | [[1, 2, 3], [0, 2, 3], [0, 1, 3], [0, 1, 2]] | Passed |
| control #4 | [[3], [4], [], [0], [1]] | [[1, 3], [0, 4], [4], [0, 4], [1, 2, 3]] | Failed |
| control #5 | [[1, 3, 4], [0, 2, 3, 4], [1, 4], [0, 1, 4], [0, 1, 2, 3]] | [[1, 3, 4], [0, 2, 3, 4], [1, 4], [0, 1, 4], [0, 1, 2, 3]] | Passed |
| control #6 | [[], []] | [[], []] | Passed |
| control #16 | [[], [], []] | [[1], [0], []] | Failed |
SHA-256 / 19906d55a1c6ee46fc19dc7f4d74e943a56e4106e959780706a55b1822faef99
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
polys, mode = x
def edges(r):
return {tuple(sorted([tuple(a), tuple(b)])) for a, b in zip(r, r[1:]) if a != b}
def verts(r):
return {tuple(p) for p in r}
E = [edges(p) for p in polys]
V = [verts(p) for p in polys]
out = []
for i in range(len(polys)):
nb = []
for j in range(len(polys)):
if i == j:
continue
if mode == 'rook':
ok = bool(E[i] & E[j])
else:
ok = bool(V[i] & V[j])
if ok:
nb.append(j)
out.append(nb)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control #0', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]]], 'rook'], [[1, 3], [0], [], [0]]), ('control #1', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]]], 'queen'], [[1, 3], [0, 2, 3], [1], [0, 1]]), ('control #2', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[1, 2], [0, 3], [0, 3], [1, 2]]), ('control #3', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'queen'], [[1, 2, 3], [0, 2, 3], [0, 1, 3], [0, 1, 2]]), ('control #4', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[1, 3], [0, 4], [4], [0, 4], [1, 2, 3]]), ('control #5', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'queen'], [[1, 3, 4], [0, 2, 3, 4], [1, 4], [0, 1, 4], [0, 1, 2, 3]]), ('control #6', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'rook'], [[], []]), ('control #16', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[1], [0], []])], [('control #2', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[1, 2], [0, 3], [0, 3], [1, 2]]), ('control #4', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[1, 3], [0, 4], [4], [0, 4], [1, 2, 3]]), ('control #5', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'queen'], [[1, 3, 4], [0, 2, 3, 4], [1, 4], [0, 1, 4], [0, 1, 2, 3]]), ('control #6', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'rook'], [[], []]), ('control #7', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'queen'], [[], []]), ('control #8', [[[[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[], []]), ('control #9', [[[[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0]]), ('control #18', [[[[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[], []])], [('control #4', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]], [[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[1, 3], [0, 4], [4], [0, 4], [1, 2, 3]]), ('control #7', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'queen'], [[], []]), ('control #8', [[[[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[], []]), ('control #9', [[[[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0]]), ('control #10', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[], []]), ('control #11', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'queen'], [[1], [0]]), ('control #12', [[[[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[1], [0, 2], [1]]), ('control #16', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[1], [0], []])], [('control #9', [[[[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0]]), ('control #10', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[], []]), ('control #11', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'queen'], [[1], [0]]), ('control #12', [[[[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[1], [0, 2], [1]]), ('control #13', [[[[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0, 2], [1]]), ('control #14', [[[[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]]], 'rook'], [[1], [0]]), ('control #15', [[[[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]]], 'queen'], [[1], [0]]), ('control #18', [[[[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[], []])], [('control #12', [[[[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[1], [0, 2], [1]]), ('control #13', [[[[0, 2], [2, 2], [2, 4], [0, 4], [0, 2]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0, 2], [1]]), ('control #14', [[[[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]]], 'rook'], [[1], [0]]), ('control #15', [[[[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]], [[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]]], 'queen'], [[1], [0]]), ('control #16', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[1], [0], []]), ('control #17', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0, 2], [1]]), ('control #18', [[[[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[], []]), ('control #19', [[[[2, 0], [4, 0], [4, 2], [4, 2], [2, 2], [2, 0]], [[4, 2], [4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'queen'], [[1], [0]])]]
for label, args, expected in fixtures[N-1]:
check(label, 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 |
|---|---|---|---|
| control #0 | [[1, 3], [0], [], [0]] | [[1, 3], [0], [], [0]] | Passed |
| control #1 | [[1, 3], [0, 2, 3], [1], [0, 1]] | [[1, 3], [0, 2, 3], [1], [0, 1]] | Passed |
| control #2 | [[1, 2], [0, 3], [0, 3], [1, 2]] | [[1, 2], [0, 3], [0, 3], [1, 2]] | Passed |
| control #3 | [[1, 2, 3], [0, 2, 3], [0, 1, 3], [0, 1, 2]] | [[1, 2, 3], [0, 2, 3], [0, 1, 3], [0, 1, 2]] | Passed |
| control #4 | [[1, 3], [0, 4], [4], [0, 4], [1, 2, 3]] | [[1, 3], [0, 4], [4], [0, 4], [1, 2, 3]] | Passed |
| control #5 | [[1, 3, 4], [0, 2, 3, 4], [1, 4], [0, 1, 4], [0, 1, 2, 3]] | [[1, 3, 4], [0, 2, 3, 4], [1, 4], [0, 1, 4], [0, 1, 2, 3]] | Passed |
| control #6 | [[], []] | [[], []] | Passed |
| control #16 | [[1], [0], []] | [[1], [0], []] | Passed |
SHA-256 / 39114ce31479e65c2200f57ef392cca0e8276c818e1cec3417b345b1f1583a48
Verification & scope
Stipulated deterministic toy contract on a bounded input domain; results are rounded as stated and no conformance with any published standard or library is claimed. 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:48:21.327527+00:00.
Case digest / 879e7053a66b01007d0b1e59f9181f74a3b48a1e0f46acc65053fe153fb6c70d