Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- l = [1, 2, 3, 4, 5]
- sums = {}
- while len(l) :
- l_sum = sum(l)
- sums[l_sum] = l
- print(sums)
- print()
- l.pop()
- {15: [1, 2, 3, 4, 5]}
- {15: [1, 2, 3, 4], 10: [1, 2, 3, 4]}
- {15: [1, 2, 3], 10: [1, 2, 3], 6: [1, 2, 3]}
- {15: [1, 2], 10: [1, 2], 6: [1, 2], 3: [1, 2]}
- {15: [1], 10: [1], 6: [1], 3: [1], 1: [1]}
- {15: [1, 2, 3, 4, 5]}
- {15: [1, 2, 3, 4, 5], 10: [1, 2, 3, 4]}
- {15: [1, 2, 3, 4, 5], 10: [1, 2, 3, 4], 6: [1, 2, 3]}
- {15: [1, 2, 3, 4, 5], 10: [1, 2, 3, 4], 6: [1, 2, 3], 3: [1, 2]}
- {15: [1, 2, 3, 4, 5], 10: [1, 2, 3, 4], 6: [1, 2, 3], 3: [1, 2], 1: [1]}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement