Skip to content

Commit

Permalink
添加了示例代码
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfrued committed Aug 1, 2018
1 parent c2c2786 commit 601efd9
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions Day31-35/code/homework01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 经典递归求解问题:
# 1. 迷宫寻路
# 2. 汉诺塔(梵塔)
# 3. 骑士周游
# 4. 八皇后


def f(n: int, m=1) -> int:
if n == 0 or n == 1:
return m
return f(n - 1, n * m)


def sum(n: int) -> int:
if n == 1:
return 1
return n + sum(n - 1)


def steps(n: int, m={}) -> int:
if n < 0:
return 0
elif n == 0:
return 1
else:
try:
return m[n]
except:
m[n] = steps(n - 1) + steps(n - 2) + steps(n - 3)
return m[n]


def list_depth(items: list) -> int:
max_depth = 1 if isinstance(items, list) else 0
if max_depth:
for item in items:
if isinstance(item, list):
max_depth = max(max_depth, list_depth(item) + 1)
return max_depth



def main():
mylist = [1, ['a', ['b', ['c']]],[100, [200, 300, [400, [500, [600, [700]]]]]]]
thylist = [[], [[[]]], [[], []]]
print(list_depth(mylist))
print(list_depth(thylist))


if __name__ == '__main__':
main()
Binary file added Day41-55/res/Django-Flowchart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Day41-55/res/Django-MTV.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 601efd9

Please sign in to comment.