0

Given a list of some integers, I would like to find every combination that can be summed to some sum S. For example for the sum S=16, and the list of integers I={3,4,5}, I'd expect to get:

5,4,4,3 (=16) 5,5,3,3 (=16) 4,4,4,4 (=16)

How do I go about finding such lists for any given S, with any list of integers S?

Note, I can be a set of any integers they don't have to be sequential. Also note, I do understand this has to do with partitions, and have done reading to the best of my ability, but I have failed to fully understand how to make sense of this.

Any help will be highly appreciated!

0 Answers0