select a part of vector, summing up to a certain number

24 Views Asked by At

I have a vector of numbers, of the length 24. Something like: [1,5,1,0,5,3.....] If these would be price tags of goods, and my budget would be 15 dollars, what is the way to choose all the combinations that are as close to my budget as possible?