Advertisement
biswasrohit20

climb

Apr 4th, 2021
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. import sys
  2.  
  3.  
  4. # Input: n is an int of how many climbing holds there are
  5. # Output: return an integer of how many distinct ways there are to reach the last hold (order matters)
  6. def distinct_ways(n):
  7. def fib(m):
  8. if m <= 1:
  9. return m
  10. return fib(m - 1) + fib(m - 2)
  11.  
  12. def countWays(s):
  13. return fib(s + 1)
  14.  
  15. return countWays(n)
  16.  
  17.  
  18. def main():
  19.  
  20. # read number of holds
  21. n = int(input())
  22.  
  23. # get the result from your call to distinct_ways()
  24. result = distinct_ways(n)
  25.  
  26. # print the result to standard output
  27. print(result)
  28.  
  29.  
  30. if __name__ == "__main__":
  31. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement