智一面的面试题提供python的测试题
使用地址:http://www.gtalent.cn/exam/interview?token=52cf92de494f4a8b6165d817a7279966
使用python编写了一个小算法, 实现杨辉三角
上代码:
- # -*- coding = utf-8 -*-
- def triangles():
- L = [1]
- while True:
- yield L
- L.append(0)
- L = [L[i - 1] + L[i] for i in range(len(L))]
- n = 0
- for t in triangles():
- print(t)
- n += 1
- if n == 10:
- break