VikkaLorel

stairs with custom steps

Apr 27th, 2020
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. def solve_any(end, X):
  2.     solutions = [0]
  3.     for _ in range(end, 0, -1):
  4.         val = 0
  5.         n = len(solutions)
  6.         for el in X:
  7.             if n == el:
  8.                 val += 1
  9.             if n-el > 0:
  10.                 val += solutions[n-el]
  11.         solutions.append(val)
  12.     return solutions[-1]
  13.  
  14. a = solve_any(10, {1, 3, 5})
  15. print(a)
Advertisement
Add Comment
Please, Sign In to add comment