Discuss / Python / test

吃梗

#1 Created at ... [Delete] [Delete and Lock User]
def triangles(max):
    n = 0    
    l = [1]
    while n < max:
        yield l
        a = [1]
        b = [l[i] + l[i + 1] for i in range(len(l) - 1)]
        a.extend(b)
        a.append(1)
        l = a
        n += 1    
    return 'done'

  • 1

Reply