def triangles(): L=[] while True: if len(L)==0: L=[1] elif len(L) == 1: L=[1,1] else: L0=L[:] L=[1,1] for idx,val in enumerate(L0): if(idx != len(L0)-1): L.insert(-1,L0[idx+1]+val) yield L
Sign in to make a reply
relative660
def triangles(): L=[] while True: if len(L)==0: L=[1] elif len(L) == 1: L=[1,1] else: L0=L[:] L=[1,1] for idx,val in enumerate(L0): if(idx != len(L0)-1): L.insert(-1,L0[idx+1]+val) yield L