What I'm looking to do is find a way that I can have my code return all the combinations of values from a list that add to a variable, returning each answer as a list. For instance,
target_number = 8
usingnumbers = [1, 2, 4, 8]
returns:
[8]
[4, 4]
[4, 2, 2]
[4, 2, 1, 1]
[4, 1, 1, 1, 1]
[2, 2, 1, 1, 1, 1]
[2, 1, 1, 1, 1, 1, 1]
[1, 1, 1, 1, 1, 1, 1, 1]
And so on. I'd like repeated values to be discarded, for instance [4, 2, 2], [2, 4, 2], [2, 2, 4] are all technically valid, but I'd like just one of these to be shown. Ideally, I'd want the code to also return the number of times each number appears in each list, but I'm sure I can do that for myself.
In psuedocode:
Not that difficult.