Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # list_unique_sum_of_12.py
- def t12(z):
- L = z
- sss = [[z]]
- ppp = []
- zzz = []
- while 1:
- while len(sss[0]) < L:
- if z > 1:
- t = sss[0][:-1]+[z-1]
- if t not in ppp:
- if sum(t) < L:
- sss.append(t)
- ppp.append(t)
- if sum(sss[0])+z > L:
- z = max(0,z-1)
- else:
- sss[0].append(z)
- zzz.append(sss.pop(0))
- if sss:
- z = sss[0][-1]
- else:
- break
- zzz.sort(reverse=1)
- return zzz
- zzz = t12(12)
- for z in zzz:
- print(z)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement