-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLeet_70_Climbing_stairs.py
63 lines (43 loc) · 1.52 KB
/
Leet_70_Climbing_stairs.py
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
63
'''
You are climbing a staircase. It takes n steps to reach the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
1 <= n <= 45
'''
n: int = 5
#get to 10 by increments of either 1 or 2.
#steps: int = None #Count of either stepping by 1 or 2 to get to n.
#Brute force method: search through every permutation until the termination case is reached
#termination case: smallest steps summed to reached n.
# Use while loop
def num_to_binary(target:int) -> str: #function to generate the binary
if target == 0:
return str(0)
#start = target
output = ''
dividend: int = target
while dividend != 0:
remainder = dividend % 2
dividend = dividend // 2
output = str(remainder) + output
return output
def binary_to_num(largest_step: list) -> int:
pass
# def step_count(step_binary: str, target: int) -> int: #breakdown the binary to perform permutation to reach value of n. If value reached, add
# #eg: '101' for n=5; permutate through 1, then '10', then '101'
# pass
def longest_step(target:int) -> list:
step_list = []
start_num = target
while target > 0:
step_list.append(1)
target -= 1
return step_list
def binary_list(largest_step: list) -> list:
pass
def main():
print(num_to_binary(n))
most_steps = longest_step(n)
steps_binary = binary_list(most_steps)
print(bin(5))
if __name__ == '__main__':
main()