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):
- def fib(m):
- if m <= 1:
- return m
- return fib(m - 1) + fib(m - 2)
- def countWays(s):
- return fib(s + 1)
- return countWays(n)
- 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