I am trying to solve this problem for over a month now. I have a list of numbers and these variables:
list_num = [1, 1, 2, 3, 5, 6, 1, 1, 3, 4, 4]
#x is number of numbers in combination eg. if x = 5 combiantions will look like this [n,n,n,n,n], where n is possible member of list _num
x = 5
#y is a sum of numbers inside combination
y = 10
I have a need to generate all possible combinations of this numbers in the way that x is number of numbers in combination and the y is the sum of numbers in combination, also the number of repeating inside list_num must be considered.
I can do this by generating all possible combination and by eliminating the combinations that are not determined by my rules but this method is messy and I cant use it with large number of data. In mine original program list_num can have hundreds of numbers and variables x and y can have large values.
Couple of the combinations for this example:
comb1 = [1,1,2,3,3], x = 5, y = 10
comb2 = [1,1,1,2,5], x = 5, y = 10
comb3 = [1,1,1,1,6], x = 5, y = 10
...
I would appreciate some new ideas, I do not have any left :)
xandy?