Discuss / Python / 笨方法

笨方法

Topic source

沙耶子Ver3

#1 Created at ... [Delete] [Delete and Lock User]
list = [1]
r = 1
while True:
    yield list
    i = 1
    temp = [1]
    while i < r:
        temp.append(list[i-1] + list[i])
        i = i + 1
    list = temp
    list.append(1)
    r = r + 1
return 'done'

沙耶子Ver3

#2 Created at ... [Delete] [Delete and Lock User]

L = [1] while True: yield L L = [0] + L + [0] L = [L[i] + L[i + 1] for i in range(len(L) - 1)]


  • 1

Reply