#Python program for A375763 by John Rascoe 8/28/2024 from collections import Counter def right_ins(a,b): #finds the first available spot to add 'b' to 'a' starting from the right side of 'a' if b == (1,2,): return b+a else: for i in range(len(a)): if a[i]+1 == b[0] and a[i+1]+1 == b[1]: return(a[:i+1]+b+a[i+1::]) def T_NE(a, row): #returns the rows of the triangle for NE paths from (0,0) to (n,n+a-1) up to 'row' x = tuple(range(1,a+1)) A = [] # nested list of tuples representing the NE paths as compositions T = [] # nested list of counted weights of tuples in A for n in range(row): S = set() T.append([]) A.append([]) if n<1: A[n].append(x) T[n].append(1) S.add(x) else: C = Counter() for i in A[n-1]: for j in range(max(i)): y = right_ins(i,(j+1,j+2,)) if y not in S: C.update({sum(y)}) A[n].append(y) S.add(y) T[n].extend([C[i] for i in C]) return T def A375763(rowmax): for i in T_NE(3,rowmax+1): print(i) A375763(6)