Advertisement
biswasrohit20

clim2

Apr 4th, 2021
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 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. n1 = 1
  8. n2 = 2
  9. if (n == 1):
  10. return 1
  11. elif (n == 2):
  12. return 2
  13. else:
  14. for i in range(2, n):
  15. n3 = n1 + n2
  16. n1 = n2
  17. n2 = n3
  18. return n3
  19.  
  20.  
  21. def main():
  22.  
  23. # read number of holds
  24. n = int(input())
  25.  
  26. # get the result from your call to distinct_ways()
  27. result = distinct_ways(n)
  28. # print the result to standard output
  29. print(result)
  30.  
  31.  
  32. if __name__ == "__main__":
  33. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement