Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- # Input: n is an int of how many climbing holds there are
- # Output: return an integer of how many distinct ways there are to reach the last hold (order matters)
- def distinct_ways(n):
- n1 = 1
- n2 = 2
- if (n == 1):
- return 1
- elif (n == 2):
- return 2
- else:
- for i in range(2, n):
- n3 = n1 + n2
- n1 = n2
- n2 = n3
- return n3
- def main():
- # read number of holds
- n = int(input())
- # get the result from your call to distinct_ways()
- result = distinct_ways(n)
- # print the result to standard output
- print(result)
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement