Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def solve_any(end, X):
- solutions = [0]
- for _ in range(end, 0, -1):
- val = 0
- n = len(solutions)
- for el in X:
- if n == el:
- val += 1
- if n-el > 0:
- val += solutions[n-el]
- solutions.append(val)
- return solutions[-1]
- a = solve_any(10, {1, 3, 5})
- print(a)
Advertisement
Add Comment
Please, Sign In to add comment