FAILURE MAP
← Case archive

FA-70501 / GIS polygon topology / Open access

Rook and queen polygon adjacency: neighbour scan range · case 01

Adjacency lists are one-sided: later polygons do not list earlier neighbours.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The scan starts at i+1, so each adjacency is recorded only on the lower-indexed polygon.

VERIFIED REPAIR

At the neighbour scan range step restore `for j in range(len(polys)): if i == j: continue`, leaving the rest of the model unchanged.

Unsuccessful approach: The full scan is back but queen mode lists every polygon as its own neighbour.

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:]) 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(i + 1, 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 #6', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'rook'], [[], []]), ('control #8', [[[[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[], []]), ('control #10', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[], []])], [('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 #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 #10', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[], []])], [('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 #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 #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 #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 #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 #6', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'rook'], [[], []]), ('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 #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 #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 #6', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'rook'], [[], []]), ('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 #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 #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'], [[], []])]]
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 fixtureActualExpectedOutcome
control #0[[1, 3], [], [], []][[1, 3], [0], [], [0]]Failed
control #1[[1, 3], [2, 3], [], []][[1, 3], [0, 2, 3], [1], [0, 1]]Failed
control #2[[1, 2], [3], [3], []][[1, 2], [0, 3], [0, 3], [1, 2]]Failed
control #3[[1, 2, 3], [2, 3], [3], []][[1, 2, 3], [0, 2, 3], [0, 1, 3], [0, 1, 2]]Failed
control #4[[1, 3], [4], [4], [4], []][[1, 3], [0, 4], [4], [0, 4], [1, 2, 3]]Failed
control #6[[], []][[], []]Passed
control #8[[], []][[], []]Passed
control #10[[], []][[], []]Passed

SHA-256 / d91d05241995e5cc5feb1a034fecf4ba1df33e86ce1c3ad3075af5ecda163f9b

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 != 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 and mode == 'rook':
                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 #6', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'rook'], [[], []]), ('control #8', [[[[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[], []]), ('control #10', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[], []])], [('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 #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 #10', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[], []])], [('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 #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 #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 #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 #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 #6', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'rook'], [[], []]), ('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 #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 #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 #6', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'rook'], [[], []]), ('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 #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 #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'], [[], []])]]
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 fixtureActualExpectedOutcome
control #0[[1, 3], [0], [], [0]][[1, 3], [0], [], [0]]Passed
control #1[[0, 1, 3], [0, 1, 2, 3], [1, 2], [0, 1, 3]][[1, 3], [0, 2, 3], [1], [0, 1]]Failed
control #2[[1, 2], [0, 3], [0, 3], [1, 2]][[1, 2], [0, 3], [0, 3], [1, 2]]Passed
control #3[[0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3]][[1, 2, 3], [0, 2, 3], [0, 1, 3], [0, 1, 2]]Failed
control #4[[1, 3], [0, 4], [4], [0, 4], [1, 2, 3]][[1, 3], [0, 4], [4], [0, 4], [1, 2, 3]]Passed
control #6[[], []][[], []]Passed
control #8[[], []][[], []]Passed
control #10[[], []][[], []]Passed

SHA-256 / 4a3302016db7377e27bc70b9f3235b23cd9477945be46281b39fb5dfc98aea36

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 #6', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'rook'], [[], []]), ('control #8', [[[[2, 0], [4, 0], [4, 2], [2, 2], [2, 0]], [[4, 2], [6, 2], [6, 4], [4, 4], [4, 2]]], 'rook'], [[], []]), ('control #10', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[], []])], [('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 #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 #10', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]], 'rook'], [[], []])], [('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 #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 #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 #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 #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 #6', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'rook'], [[], []]), ('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 #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 #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 #6', [[[[0, 0], [2, 0], [2, 2], [0, 2], [0, 0]], [[10, 10], [12, 10], [11, 12], [10, 10]]], 'rook'], [[], []]), ('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 #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 #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'], [[], []])]]
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 fixtureActualExpectedOutcome
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 #6[[], []][[], []]Passed
control #8[[], []][[], []]Passed
control #10[[], []][[], []]Passed

SHA-256 / 909a6875ec599c3b9dd10d5fe4a4c48f1e10295adaac5d754823d66d687f744a

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.285585+00:00.

Case digest / 636458abf6b2db8938a8d5681149b7ce9804db160a55bf31317ba1a32aa1b072