-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday13.py
More file actions
66 lines (53 loc) · 877 Bytes
/
day13.py
File metadata and controls
66 lines (53 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# 1,3,5 steps problem
def f(n):
if n<0:
return 0
elif n==0:
return 1
return f(n-1)+f(n-2)
def g(n):
a,b =1,2
for _ in range(n-1):
a,b=b,a+b
return a
def h(n):
a,b=1,2
if n<1:
return 0
elif n==1:
return a
elif n==2:
return b
for _ in range(n-2):
b=a+b
a=b-a
return b
def d(n):
dp=[0]*(n+1)
if n<0:
return 0
elif n==0:
dp[0]=1
return dp[0]
dp[n]= d(n-1)+d(n-2)
return dp[n]
def l(n):
dp=[0]*(n+1)
dp[0]=0
dp[1]=1
dp[2]=2
if n<1:
return 0
elif n==1:
return 1
else:
print("here")
for i in range(2,n):
dp[i+1]=dp[i]+dp[i-1]
print(dp[i+1])
return dp[n]
#print(f(25))
#print(g(50))
#print(h(50))
#print(d(50))
print(l(10))