FA-70836 / GIS polygon topology / Open access
Missing node (T-junction) detection in a coverage: report ordering · case 01
Report order depends on polygon traversal order.
ROOT CAUSE
Reports are returned in discovery order.
VERIFIED REPAIR
At the report ordering step restore `return sorted(out)`, leaving the rest of the model unchanged.
Unsuccessful approach: Sorting by polygon index only leaves ties in discovery order.
Case contract
Input: polygons as closed integer rings forming a coverage. For each polygon i and each distinct vertex v (closing duplicate excluded), and each other polygon j, report [i, v, j] when v lies exactly on an edge of j (zero cross product, inside the closed segment box) but is not one of that edge endpoints. Return the reports sorted.
Why this case matters
Coverage cleaning requires shared boundaries to have identical vertices; T-junctions cause gaps after simplification and must be noded first.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
polys = x
out = []
for i, P in enumerate(polys):
for v in P[:-1]:
for j, Q in enumerate(polys):
if i == j:
continue
for a, b in zip(Q, Q[1:]):
if v == a or v == b:
continue
cross = (b[0] - a[0]) * (v[1] - a[1]) - (b[1] - a[1]) * (v[0] - a[0])
if cross == 0 and min(a[0], b[0]) <= v[0] <= max(a[0], b[0]) and min(a[1], b[1]) <= v[1] <= max(a[1], b[1]):
out.append([i, list(v), j])
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control #0', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]]], []), ('regression #1', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 2], [4, 0]]], [[1, [4, 2], 0]]), ('regression #2', [[[4, 0], [8, 0], [8, 4], [4, 4], [4, 2], [4, 0]], [[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]]], [[0, [4, 2], 1]]), ('regression #3', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]], [[0, 4], [4, 4], [4, 8], [0, 8], [0, 4]]], []), ('regression #4', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[2, 4], [6, 4], [6, 8], [2, 8], [2, 4]]], [[0, [4, 4], 1], [1, [2, 4], 0]]), ('regression #5', [[[8, 0], [12, 4], [8, 4], [8, 0]], [[10, 2], [14, 2], [14, 6], [10, 2]]], [[0, [12, 4], 1], [1, [10, 2], 0]]), ('regression #14', [[[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]]], [[1, [2, 4], 0], [1, [6, 4], 0]]), ('regression #15', [[[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]], [[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[0, 8], [8, 8], [8, 12], [0, 12], [0, 8]]], [[0, [2, 4], 1], [0, [2, 8], 2], [0, [6, 4], 1], [0, [6, 8], 2]])], [('regression #3', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]], [[0, 4], [4, 4], [4, 8], [0, 8], [0, 4]]], []), ('regression #4', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[2, 4], [6, 4], [6, 8], [2, 8], [2, 4]]], [[0, [4, 4], 1], [1, [2, 4], 0]]), ('regression #5', [[[8, 0], [12, 4], [8, 4], [8, 0]], [[10, 2], [14, 2], [14, 6], [10, 2]]], [[0, [12, 4], 1], [1, [10, 2], 0]]), ('regression #6', [[[8, 0], [12, 4], [8, 4], [8, 0]], [[9, 1], [9, 6], [5, 6], [9, 1]]], [[1, [9, 1], 0]]), ('regression #7', [[[0, 0], [6, 0], [6, 6], [0, 6], [0, 0]], [[6, 2], [9, 2], [9, 4], [6, 2]]], [[1, [6, 2], 0]]), ('regression #8', [[[0, 0], [6, 0], [6, 6], [0, 6], [0, 0]], [[9, 2], [6, 2], [6, 4], [9, 2]]], [[1, [6, 2], 0], [1, [6, 4], 0]]), ('regression #14', [[[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]]], [[1, [2, 4], 0], [1, [6, 4], 0]]), ('regression #15', [[[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]], [[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[0, 8], [8, 8], [8, 12], [0, 12], [0, 8]]], [[0, [2, 4], 1], [0, [2, 8], 2], [0, [6, 4], 1], [0, [6, 8], 2]])], [('regression #6', [[[8, 0], [12, 4], [8, 4], [8, 0]], [[9, 1], [9, 6], [5, 6], [9, 1]]], [[1, [9, 1], 0]]), ('regression #7', [[[0, 0], [6, 0], [6, 6], [0, 6], [0, 0]], [[6, 2], [9, 2], [9, 4], [6, 2]]], [[1, [6, 2], 0]]), ('regression #8', [[[0, 0], [6, 0], [6, 6], [0, 6], [0, 0]], [[9, 2], [6, 2], [6, 4], [9, 2]]], [[1, [6, 2], 0], [1, [6, 4], 0]]), ('control #9', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[10, 10], [12, 10], [12, 12], [10, 12], [10, 10]]], []), ('regression #10', [[[0, 0], [8, 8], [0, 8], [0, 0]], [[3, 4], [9, 1], [9, 9], [3, 4]]], []), ('regression #11', [[[0, 0], [8, 8], [0, 8], [0, 0]], [[4, 4], [8, 0], [9, 9], [4, 4]]], [[0, [8, 8], 1], [1, [4, 4], 0]]), ('regression #14', [[[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]]], [[1, [2, 4], 0], [1, [6, 4], 0]]), ('regression #15', [[[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]], [[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[0, 8], [8, 8], [8, 12], [0, 12], [0, 8]]], [[0, [2, 4], 1], [0, [2, 8], 2], [0, [6, 4], 1], [0, [6, 8], 2]])], [('control #0', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]]], []), ('control #9', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[10, 10], [12, 10], [12, 12], [10, 12], [10, 10]]], []), ('regression #10', [[[0, 0], [8, 8], [0, 8], [0, 0]], [[3, 4], [9, 1], [9, 9], [3, 4]]], []), ('regression #11', [[[0, 0], [8, 8], [0, 8], [0, 0]], [[4, 4], [8, 0], [9, 9], [4, 4]]], [[0, [8, 8], 1], [1, [4, 4], 0]]), ('regression #12', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 1], [8, 1], [8, 3], [4, 3], [4, 1]]], [[1, [4, 1], 0], [1, [4, 3], 0]]), ('control #13', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]], [[8, 0], [12, 0], [12, 4], [8, 4], [8, 0]]], []), ('regression #14', [[[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]]], [[1, [2, 4], 0], [1, [6, 4], 0]]), ('regression #15', [[[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]], [[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[0, 8], [8, 8], [8, 12], [0, 12], [0, 8]]], [[0, [2, 4], 1], [0, [2, 8], 2], [0, [6, 4], 1], [0, [6, 8], 2]])], [('control #0', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]]], []), ('regression #1', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 2], [4, 0]]], [[1, [4, 2], 0]]), ('regression #2', [[[4, 0], [8, 0], [8, 4], [4, 4], [4, 2], [4, 0]], [[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]]], [[0, [4, 2], 1]]), ('regression #3', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]], [[0, 4], [4, 4], [4, 8], [0, 8], [0, 4]]], []), ('regression #12', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 1], [8, 1], [8, 3], [4, 3], [4, 1]]], [[1, [4, 1], 0], [1, [4, 3], 0]]), ('control #13', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]], [[8, 0], [12, 0], [12, 4], [8, 4], [8, 0]]], []), ('regression #14', [[[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]]], [[1, [2, 4], 0], [1, [6, 4], 0]]), ('regression #15', [[[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]], [[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[0, 8], [8, 8], [8, 12], [0, 12], [0, 8]]], [[0, [2, 4], 1], [0, [2, 8], 2], [0, [6, 4], 1], [0, [6, 8], 2]])]]
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 | [] | [] | Passed |
| regression #1 | [[1, [4, 2], 0]] | [[1, [4, 2], 0]] | Passed |
| regression #2 | [[0, [4, 2], 1]] | [[0, [4, 2], 1]] | Passed |
| regression #3 | [] | [] | Passed |
| regression #4 | [[0, [4, 4], 1], [1, [2, 4], 0]] | [[0, [4, 4], 1], [1, [2, 4], 0]] | Passed |
| regression #5 | [[0, [12, 4], 1], [1, [10, 2], 0]] | [[0, [12, 4], 1], [1, [10, 2], 0]] | Passed |
| regression #14 | [[1, [6, 4], 0], [1, [2, 4], 0]] | [[1, [2, 4], 0], [1, [6, 4], 0]] | Failed |
| regression #15 | [[0, [6, 4], 1], [0, [6, 8], 2], [0, [2, 8], 2], [0, [2, 4], 1]] | [[0, [2, 4], 1], [0, [2, 8], 2], [0, [6, 4], 1], [0, [6, 8], 2]] | Failed |
SHA-256 / 6ef38d63d824a0e1d7bbbe4170ee83c6f623340283bd2186d3ae45fe92d7e6ee
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 = x
out = []
for i, P in enumerate(polys):
for v in P[:-1]:
for j, Q in enumerate(polys):
if i == j:
continue
for a, b in zip(Q, Q[1:]):
if v == a or v == b:
continue
cross = (b[0] - a[0]) * (v[1] - a[1]) - (b[1] - a[1]) * (v[0] - a[0])
if cross == 0 and min(a[0], b[0]) <= v[0] <= max(a[0], b[0]) and min(a[1], b[1]) <= v[1] <= max(a[1], b[1]):
out.append([i, list(v), j])
return sorted(out, key=lambda t: t[0])
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control #0', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]]], []), ('regression #1', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 2], [4, 0]]], [[1, [4, 2], 0]]), ('regression #2', [[[4, 0], [8, 0], [8, 4], [4, 4], [4, 2], [4, 0]], [[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]]], [[0, [4, 2], 1]]), ('regression #3', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]], [[0, 4], [4, 4], [4, 8], [0, 8], [0, 4]]], []), ('regression #4', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[2, 4], [6, 4], [6, 8], [2, 8], [2, 4]]], [[0, [4, 4], 1], [1, [2, 4], 0]]), ('regression #5', [[[8, 0], [12, 4], [8, 4], [8, 0]], [[10, 2], [14, 2], [14, 6], [10, 2]]], [[0, [12, 4], 1], [1, [10, 2], 0]]), ('regression #14', [[[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]]], [[1, [2, 4], 0], [1, [6, 4], 0]]), ('regression #15', [[[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]], [[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[0, 8], [8, 8], [8, 12], [0, 12], [0, 8]]], [[0, [2, 4], 1], [0, [2, 8], 2], [0, [6, 4], 1], [0, [6, 8], 2]])], [('regression #3', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]], [[0, 4], [4, 4], [4, 8], [0, 8], [0, 4]]], []), ('regression #4', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[2, 4], [6, 4], [6, 8], [2, 8], [2, 4]]], [[0, [4, 4], 1], [1, [2, 4], 0]]), ('regression #5', [[[8, 0], [12, 4], [8, 4], [8, 0]], [[10, 2], [14, 2], [14, 6], [10, 2]]], [[0, [12, 4], 1], [1, [10, 2], 0]]), ('regression #6', [[[8, 0], [12, 4], [8, 4], [8, 0]], [[9, 1], [9, 6], [5, 6], [9, 1]]], [[1, [9, 1], 0]]), ('regression #7', [[[0, 0], [6, 0], [6, 6], [0, 6], [0, 0]], [[6, 2], [9, 2], [9, 4], [6, 2]]], [[1, [6, 2], 0]]), ('regression #8', [[[0, 0], [6, 0], [6, 6], [0, 6], [0, 0]], [[9, 2], [6, 2], [6, 4], [9, 2]]], [[1, [6, 2], 0], [1, [6, 4], 0]]), ('regression #14', [[[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]]], [[1, [2, 4], 0], [1, [6, 4], 0]]), ('regression #15', [[[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]], [[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[0, 8], [8, 8], [8, 12], [0, 12], [0, 8]]], [[0, [2, 4], 1], [0, [2, 8], 2], [0, [6, 4], 1], [0, [6, 8], 2]])], [('regression #6', [[[8, 0], [12, 4], [8, 4], [8, 0]], [[9, 1], [9, 6], [5, 6], [9, 1]]], [[1, [9, 1], 0]]), ('regression #7', [[[0, 0], [6, 0], [6, 6], [0, 6], [0, 0]], [[6, 2], [9, 2], [9, 4], [6, 2]]], [[1, [6, 2], 0]]), ('regression #8', [[[0, 0], [6, 0], [6, 6], [0, 6], [0, 0]], [[9, 2], [6, 2], [6, 4], [9, 2]]], [[1, [6, 2], 0], [1, [6, 4], 0]]), ('control #9', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[10, 10], [12, 10], [12, 12], [10, 12], [10, 10]]], []), ('regression #10', [[[0, 0], [8, 8], [0, 8], [0, 0]], [[3, 4], [9, 1], [9, 9], [3, 4]]], []), ('regression #11', [[[0, 0], [8, 8], [0, 8], [0, 0]], [[4, 4], [8, 0], [9, 9], [4, 4]]], [[0, [8, 8], 1], [1, [4, 4], 0]]), ('regression #14', [[[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]]], [[1, [2, 4], 0], [1, [6, 4], 0]]), ('regression #15', [[[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]], [[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[0, 8], [8, 8], [8, 12], [0, 12], [0, 8]]], [[0, [2, 4], 1], [0, [2, 8], 2], [0, [6, 4], 1], [0, [6, 8], 2]])], [('control #0', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]]], []), ('control #9', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[10, 10], [12, 10], [12, 12], [10, 12], [10, 10]]], []), ('regression #10', [[[0, 0], [8, 8], [0, 8], [0, 0]], [[3, 4], [9, 1], [9, 9], [3, 4]]], []), ('regression #11', [[[0, 0], [8, 8], [0, 8], [0, 0]], [[4, 4], [8, 0], [9, 9], [4, 4]]], [[0, [8, 8], 1], [1, [4, 4], 0]]), ('regression #12', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 1], [8, 1], [8, 3], [4, 3], [4, 1]]], [[1, [4, 1], 0], [1, [4, 3], 0]]), ('control #13', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]], [[8, 0], [12, 0], [12, 4], [8, 4], [8, 0]]], []), ('regression #14', [[[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]]], [[1, [2, 4], 0], [1, [6, 4], 0]]), ('regression #15', [[[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]], [[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[0, 8], [8, 8], [8, 12], [0, 12], [0, 8]]], [[0, [2, 4], 1], [0, [2, 8], 2], [0, [6, 4], 1], [0, [6, 8], 2]])], [('control #0', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]]], []), ('regression #1', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 2], [4, 0]]], [[1, [4, 2], 0]]), ('regression #2', [[[4, 0], [8, 0], [8, 4], [4, 4], [4, 2], [4, 0]], [[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]]], [[0, [4, 2], 1]]), ('regression #3', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]], [[0, 4], [4, 4], [4, 8], [0, 8], [0, 4]]], []), ('regression #12', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 1], [8, 1], [8, 3], [4, 3], [4, 1]]], [[1, [4, 1], 0], [1, [4, 3], 0]]), ('control #13', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]], [[8, 0], [12, 0], [12, 4], [8, 4], [8, 0]]], []), ('regression #14', [[[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]]], [[1, [2, 4], 0], [1, [6, 4], 0]]), ('regression #15', [[[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]], [[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[0, 8], [8, 8], [8, 12], [0, 12], [0, 8]]], [[0, [2, 4], 1], [0, [2, 8], 2], [0, [6, 4], 1], [0, [6, 8], 2]])]]
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 | [] | [] | Passed |
| regression #1 | [[1, [4, 2], 0]] | [[1, [4, 2], 0]] | Passed |
| regression #2 | [[0, [4, 2], 1]] | [[0, [4, 2], 1]] | Passed |
| regression #3 | [] | [] | Passed |
| regression #4 | [[0, [4, 4], 1], [1, [2, 4], 0]] | [[0, [4, 4], 1], [1, [2, 4], 0]] | Passed |
| regression #5 | [[0, [12, 4], 1], [1, [10, 2], 0]] | [[0, [12, 4], 1], [1, [10, 2], 0]] | Passed |
| regression #14 | [[1, [6, 4], 0], [1, [2, 4], 0]] | [[1, [2, 4], 0], [1, [6, 4], 0]] | Failed |
| regression #15 | [[0, [6, 4], 1], [0, [6, 8], 2], [0, [2, 8], 2], [0, [2, 4], 1]] | [[0, [2, 4], 1], [0, [2, 8], 2], [0, [6, 4], 1], [0, [6, 8], 2]] | Failed |
SHA-256 / 424a5e1fd6233afa199953a8f80f6d9f8ed7e2876df26f171da1510bd03ad3d4
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 = x
out = []
for i, P in enumerate(polys):
for v in P[:-1]:
for j, Q in enumerate(polys):
if i == j:
continue
for a, b in zip(Q, Q[1:]):
if v == a or v == b:
continue
cross = (b[0] - a[0]) * (v[1] - a[1]) - (b[1] - a[1]) * (v[0] - a[0])
if cross == 0 and min(a[0], b[0]) <= v[0] <= max(a[0], b[0]) and min(a[1], b[1]) <= v[1] <= max(a[1], b[1]):
out.append([i, list(v), j])
return sorted(out)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control #0', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]]], []), ('regression #1', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 2], [4, 0]]], [[1, [4, 2], 0]]), ('regression #2', [[[4, 0], [8, 0], [8, 4], [4, 4], [4, 2], [4, 0]], [[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]]], [[0, [4, 2], 1]]), ('regression #3', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]], [[0, 4], [4, 4], [4, 8], [0, 8], [0, 4]]], []), ('regression #4', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[2, 4], [6, 4], [6, 8], [2, 8], [2, 4]]], [[0, [4, 4], 1], [1, [2, 4], 0]]), ('regression #5', [[[8, 0], [12, 4], [8, 4], [8, 0]], [[10, 2], [14, 2], [14, 6], [10, 2]]], [[0, [12, 4], 1], [1, [10, 2], 0]]), ('regression #14', [[[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]]], [[1, [2, 4], 0], [1, [6, 4], 0]]), ('regression #15', [[[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]], [[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[0, 8], [8, 8], [8, 12], [0, 12], [0, 8]]], [[0, [2, 4], 1], [0, [2, 8], 2], [0, [6, 4], 1], [0, [6, 8], 2]])], [('regression #3', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]], [[0, 4], [4, 4], [4, 8], [0, 8], [0, 4]]], []), ('regression #4', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[2, 4], [6, 4], [6, 8], [2, 8], [2, 4]]], [[0, [4, 4], 1], [1, [2, 4], 0]]), ('regression #5', [[[8, 0], [12, 4], [8, 4], [8, 0]], [[10, 2], [14, 2], [14, 6], [10, 2]]], [[0, [12, 4], 1], [1, [10, 2], 0]]), ('regression #6', [[[8, 0], [12, 4], [8, 4], [8, 0]], [[9, 1], [9, 6], [5, 6], [9, 1]]], [[1, [9, 1], 0]]), ('regression #7', [[[0, 0], [6, 0], [6, 6], [0, 6], [0, 0]], [[6, 2], [9, 2], [9, 4], [6, 2]]], [[1, [6, 2], 0]]), ('regression #8', [[[0, 0], [6, 0], [6, 6], [0, 6], [0, 0]], [[9, 2], [6, 2], [6, 4], [9, 2]]], [[1, [6, 2], 0], [1, [6, 4], 0]]), ('regression #14', [[[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]]], [[1, [2, 4], 0], [1, [6, 4], 0]]), ('regression #15', [[[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]], [[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[0, 8], [8, 8], [8, 12], [0, 12], [0, 8]]], [[0, [2, 4], 1], [0, [2, 8], 2], [0, [6, 4], 1], [0, [6, 8], 2]])], [('regression #6', [[[8, 0], [12, 4], [8, 4], [8, 0]], [[9, 1], [9, 6], [5, 6], [9, 1]]], [[1, [9, 1], 0]]), ('regression #7', [[[0, 0], [6, 0], [6, 6], [0, 6], [0, 0]], [[6, 2], [9, 2], [9, 4], [6, 2]]], [[1, [6, 2], 0]]), ('regression #8', [[[0, 0], [6, 0], [6, 6], [0, 6], [0, 0]], [[9, 2], [6, 2], [6, 4], [9, 2]]], [[1, [6, 2], 0], [1, [6, 4], 0]]), ('control #9', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[10, 10], [12, 10], [12, 12], [10, 12], [10, 10]]], []), ('regression #10', [[[0, 0], [8, 8], [0, 8], [0, 0]], [[3, 4], [9, 1], [9, 9], [3, 4]]], []), ('regression #11', [[[0, 0], [8, 8], [0, 8], [0, 0]], [[4, 4], [8, 0], [9, 9], [4, 4]]], [[0, [8, 8], 1], [1, [4, 4], 0]]), ('regression #14', [[[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]]], [[1, [2, 4], 0], [1, [6, 4], 0]]), ('regression #15', [[[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]], [[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[0, 8], [8, 8], [8, 12], [0, 12], [0, 8]]], [[0, [2, 4], 1], [0, [2, 8], 2], [0, [6, 4], 1], [0, [6, 8], 2]])], [('control #0', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]]], []), ('control #9', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[10, 10], [12, 10], [12, 12], [10, 12], [10, 10]]], []), ('regression #10', [[[0, 0], [8, 8], [0, 8], [0, 0]], [[3, 4], [9, 1], [9, 9], [3, 4]]], []), ('regression #11', [[[0, 0], [8, 8], [0, 8], [0, 0]], [[4, 4], [8, 0], [9, 9], [4, 4]]], [[0, [8, 8], 1], [1, [4, 4], 0]]), ('regression #12', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 1], [8, 1], [8, 3], [4, 3], [4, 1]]], [[1, [4, 1], 0], [1, [4, 3], 0]]), ('control #13', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]], [[8, 0], [12, 0], [12, 4], [8, 4], [8, 0]]], []), ('regression #14', [[[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]]], [[1, [2, 4], 0], [1, [6, 4], 0]]), ('regression #15', [[[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]], [[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[0, 8], [8, 8], [8, 12], [0, 12], [0, 8]]], [[0, [2, 4], 1], [0, [2, 8], 2], [0, [6, 4], 1], [0, [6, 8], 2]])], [('control #0', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]]], []), ('regression #1', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 2], [4, 0]]], [[1, [4, 2], 0]]), ('regression #2', [[[4, 0], [8, 0], [8, 4], [4, 4], [4, 2], [4, 0]], [[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]]], [[0, [4, 2], 1]]), ('regression #3', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]], [[0, 4], [4, 4], [4, 8], [0, 8], [0, 4]]], []), ('regression #12', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 1], [8, 1], [8, 3], [4, 3], [4, 1]]], [[1, [4, 1], 0], [1, [4, 3], 0]]), ('control #13', [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[4, 0], [8, 0], [8, 4], [4, 4], [4, 0]], [[8, 0], [12, 0], [12, 4], [8, 4], [8, 0]]], []), ('regression #14', [[[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]]], [[1, [2, 4], 0], [1, [6, 4], 0]]), ('regression #15', [[[6, 4], [6, 8], [2, 8], [2, 4], [6, 4]], [[0, 0], [8, 0], [8, 4], [0, 4], [0, 0]], [[0, 8], [8, 8], [8, 12], [0, 12], [0, 8]]], [[0, [2, 4], 1], [0, [2, 8], 2], [0, [6, 4], 1], [0, [6, 8], 2]])]]
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 | [] | [] | Passed |
| regression #1 | [[1, [4, 2], 0]] | [[1, [4, 2], 0]] | Passed |
| regression #2 | [[0, [4, 2], 1]] | [[0, [4, 2], 1]] | Passed |
| regression #3 | [] | [] | Passed |
| regression #4 | [[0, [4, 4], 1], [1, [2, 4], 0]] | [[0, [4, 4], 1], [1, [2, 4], 0]] | Passed |
| regression #5 | [[0, [12, 4], 1], [1, [10, 2], 0]] | [[0, [12, 4], 1], [1, [10, 2], 0]] | Passed |
| regression #14 | [[1, [2, 4], 0], [1, [6, 4], 0]] | [[1, [2, 4], 0], [1, [6, 4], 0]] | Passed |
| regression #15 | [[0, [2, 4], 1], [0, [2, 8], 2], [0, [6, 4], 1], [0, [6, 8], 2]] | [[0, [2, 4], 1], [0, [2, 8], 2], [0, [6, 4], 1], [0, [6, 8], 2]] | Passed |
SHA-256 / 8a90d8fdf836089d69c33b7bd54c41aca48af5377b63c1aee86a6cec0da9afdf
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:24.334406+00:00.
Case digest / 14ebbb1e417913694ad79a8eb58871deae7764c8e7bf81c71402580cc68addfd