#Generating restricted growth sequences in RGC order #initialization reset() n=6 # length of the sequences, changeable b=[] for i in range(n+1): b.append(0) L=[] def type(): t=tuple(b[1:n+1]) L.append(t) print L.index(t)+1,t def Omega_SE(w,p): return p def Omega_A(w,p): if p>1 and b[p]>b[p-1]: return w+2 else: return w+1 def Omega_R(w,p): if p>1 and b[p]>w: return w+2 else: return w+1 def Omega_S(w,p): return b[p]+1 #Generating procedure, change XX in the function call #with SE, A, R, or S to generate the desired list def Gen1(k,x,drc,v): b[k]=x if k==n: type() else: u=Omega_XX(v,k) if drc%2==0: for i in range(u+1): Gen1(k+1,i,i,u-1) else: for i in range(u,-1,-1): Gen1(k+1,i,i+1,u-1) #Main call Gen1(1,0,0,0)