FAILURE MAP
← Case archive

FA-5896 / Planar geometry / Open access

Polygon boundary lattice points · case 01

Only vertices are counted, excluding lattice points along edges.

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

ROOT CAUSE

Only vertices are counted, excluding lattice points along edges.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return sum(math.gcd(abs(a[0]-b[0]),abs(a[1]-b[1])) for a,b in zip(points,points[1:]+points[:1]))

Unsuccessful approach: Counting both endpoints per edge duplicates every vertex.

Case contract

Integer coordinates and lengths, with exact arithmetic except for indicated division results. Lengths are nonnegative. Rectangles are (xmin,ymin,xmax,ymax) with ordered bounds; coordinate vectors have matching dimensions. Input is the ordered integer vertices of a simple nondegenerate lattice polygon, without a repeated closing vertex. Exact operational definition: sum(math.gcd(abs(a[0]-b[0]),abs(a[1]-b[1])) for a,b in zip(points,points[1:]+points[:1]))

Why this case matters

Small exact fixtures expose this error without platform timing, external services, or probabilistic observations. Planar geometry results depend on the stated convention.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(points):
    return len(points)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([(0, 0), (2, 0), (2, 2), (0, 2)],)', solve(*([(0, 0), (2, 0), (2, 2), (0, 2)],)), 8)
check('fixture 2: ([(0, 0), (1, 0), (0, 1)],)', solve(*([(0, 0), (1, 0), (0, 1)],)), 3)
check('fixture 3: ([(0, 0), (3, 0), (0, 3)],)', solve(*([(0, 0), (3, 0), (0, 3)],)), 9)
check('fixture 4: ([(1, 1), (4, 1), (4, 3), (1, 3)],)', solve(*([(1, 1), (4, 1), (4, 3), (1, 3)],)), 10)
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
fixture 1: ([(0, 0), (2, 0), (2, 2), (0, 2)],)48Failed
fixture 2: ([(0, 0), (1, 0), (0, 1)],)33Passed
fixture 3: ([(0, 0), (3, 0), (0, 3)],)39Failed
fixture 4: ([(1, 1), (4, 1), (4, 3), (1, 3)],)410Failed

SHA-256 / 88bc9e4b0490664ebe3e8af8457b0e7b8029c52eebcfb8ff63f93028aad1d40b

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(points):
    return sum(math.gcd(abs(a[0]-b[0]),abs(a[1]-b[1]))+1 for a,b in zip(points,points[1:]+points[:1]))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([(0, 0), (2, 0), (2, 2), (0, 2)],)', solve(*([(0, 0), (2, 0), (2, 2), (0, 2)],)), 8)
check('fixture 2: ([(0, 0), (1, 0), (0, 1)],)', solve(*([(0, 0), (1, 0), (0, 1)],)), 3)
check('fixture 3: ([(0, 0), (3, 0), (0, 3)],)', solve(*([(0, 0), (3, 0), (0, 3)],)), 9)
check('fixture 4: ([(1, 1), (4, 1), (4, 3), (1, 3)],)', solve(*([(1, 1), (4, 1), (4, 3), (1, 3)],)), 10)
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
fixture 1: ([(0, 0), (2, 0), (2, 2), (0, 2)],)128Failed
fixture 2: ([(0, 0), (1, 0), (0, 1)],)63Failed
fixture 3: ([(0, 0), (3, 0), (0, 3)],)129Failed
fixture 4: ([(1, 1), (4, 1), (4, 3), (1, 3)],)1410Failed

SHA-256 / dbf32b004af4ca7e53aae2acc7745b28b04fb9126a4ccef35c043db086aa84ab

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(points):
    return sum(math.gcd(abs(a[0]-b[0]),abs(a[1]-b[1])) for a,b in zip(points,points[1:]+points[:1]))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([(0, 0), (2, 0), (2, 2), (0, 2)],)', solve(*([(0, 0), (2, 0), (2, 2), (0, 2)],)), 8)
check('fixture 2: ([(0, 0), (1, 0), (0, 1)],)', solve(*([(0, 0), (1, 0), (0, 1)],)), 3)
check('fixture 3: ([(0, 0), (3, 0), (0, 3)],)', solve(*([(0, 0), (3, 0), (0, 3)],)), 9)
check('fixture 4: ([(1, 1), (4, 1), (4, 3), (1, 3)],)', solve(*([(1, 1), (4, 1), (4, 3), (1, 3)],)), 10)
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
fixture 1: ([(0, 0), (2, 0), (2, 2), (0, 2)],)88Passed
fixture 2: ([(0, 0), (1, 0), (0, 1)],)33Passed
fixture 3: ([(0, 0), (3, 0), (0, 3)],)99Passed
fixture 4: ([(1, 1), (4, 1), (4, 3), (1, 3)],)1010Passed

SHA-256 / bedaaf00d21ae57f2179797f0e7829a1ae9a0503745c2c996ac8a54fe02e1f27

Verification & scope

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

Case digest / aa97ccbd69df724f3739b5ef06c65a12fcfce7ddafe5daceb15c14b370e56efe