# Python code for A372646 - John Rascoe 5/13/2024 from collections import Counter from math import isqrt def addp(x): z = [] z.append(x+(x[-1]+1,)) z.append((x[0]+1,)+x) if x[-1] > 1: z.append(x+(x[-1]-1,)) if x[0] > 1: z.append((x[0]-1,)+x) return(z) def A372646_rowlist(row_max): S = {(1,)} s = [[(1,)]] P = [[0],[0,1]] Pt = [] #Builds triangle with rows and columns inverted first for i in range(row_max+1): C = Counter() s.append([]) P.append([]) for j in s[i]: for k in addp(j): if k not in S and sum(k) <= row_max: C.update({sum(k)}) S.add(k) s[i+1].append(k) for n in range((((i+2)*(i+3))//2)+1): P[i+2].append(C[n]) #inverting triangle and truncating leading 0's for n in range(row_max+1): Pt.append([]) for k in range( ((isqrt(8*(n+1))+1)//2)-1 , (2*(n+2))//3 ): if n <= len(P[k])-1: Pt[n].append(P[k][n]) else: Pt[n].append(0) for i in range(len(Pt)): print(Pt[i]) A372646_rowlist(12)