#Python code for A374453 by John Rascoe 7/12/2024 from itertools import combinations from sympy.combinatorics.subsets import ksubsets from collections import Counter def check_tot(a): C = Counter() for i in a: for j in i: C.update({j}) for z in C.keys(): if C[z] > z: return False return True def A374453(n): c, j, t, t2 = 1, 0, [], [[]] #c count starts at 1 for the empty set. #t is a list of all combinations of subsets of the same size #t2 is a list of all valid subsets with max element <= n for i in range(n): t.append([]) subsets = list(ksubsets(list(range(1,n+1)),i+1)) for k in range(len(subsets)): for u in combinations(subsets,k+1): if check_tot(u): t[i].append(u) t2[j].append(u) c += 1 while n: t2.append([]) for i in t2[j]: for m in range(0,len(i[-1])-1): for k in t[m]: z = i+k if check_tot(z): t2[j+1].append(z) c += 1 if len(t2[j+1]) == 0: break j += 1 return c for i in range(5): print(A374453(i))