Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- N = 3 # Number of variables
- S = 4 # Sum of variables
- def f(array,n):
- s = sum(array)
- if n == 1:
- print array + [S-s]
- else:
- for i in xrange(0,S+1-s):
- f(array + [i],n-1)
- f([],N)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement