Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # b_sum_list_gen.py
- def sum_list_gen(n):
- if n == 2:
- return [1, 1]
- result = []
- ttt = []
- for i in range(n):
- t = [n-i, i]
- result.append(t)
- if i > 1:
- ttt.append(t)
- while ttt:
- carry = ttt.pop()
- n = carry[-1]
- for i in range(1,n):
- t = carry[:-1]+[n-i, i]
- result.append(t)
- if i > 1:
- ttt.append(t)
- result.sort()
- return result
- zzz = sum_list_gen(9)
- for z in zzz:
- print z
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement