Discuss / Python / 我的才是标准答案

我的才是标准答案

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

割浅借口

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

太棒了!!

割浅借口

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

我想到的是用双list:

def triangles():

    list1 = [1]

    list2 = []

    while True:

        yield list1

        list2.append(1)

        for i in range(0, len(list1)-1):

            list2.append(list1[i]+list1[i+1])

        list2.append(1)

        list1 = list2

        list2 = []

bzny虫

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

牛批!从这个代码里我仿佛看到一个冲锋的战士,要什么分类讨论,要什么复制暂存,磨磨唧唧拖泥带水。干他妈的,迭代就完了!杀了排长你就是排长,杀了连长你就是连长,无限迭代,无限输出!


  • 1

Reply