I have a problem to solve in JavaScript and I am not sure where to start. I will have an array of values.
[1000, 500, 400, 300, 200, 100]
I will be given two numbers
X number of array elements to use.
N Value that the elements must add up to
Sorry but as I don't know where to start, I do not have any attempted code to share.
Any tips on where to start would be greatly appreciated
Edit,
So for example X = 4 N = 1700,
I would want all combinations of 1700 with four elements of the array, all array elelemnts can be used as many times as required
[[1000,500,100,100], [1000,400,200,100],[1000,300,300,100],[ 500,500,500,200],[500,500,400,300],[500,400,400,490]]
No negative numbers allowed and N will always be a sum reachable with X number array elements, with no remainder,
for example X = 5, N = 6900 would never happen,