0

Sorry couldn't think of a better title. So here is an example of my problem. I have a list of items that have values such as 120, 100, 70, 65, 30 20. Now I want combination of 3 of these that will be close to 165.

I was looking into solutions using the napsack idea however I don't know how to make some of the solutions for that work when we have two limiting factors being number of items allowed and the max value.

Any direction or help would be great.

We could use the example I gave... List we have 120,100,70,65,30,20 I'm looking for a combination of 3 numbers that is under 165. I'm hoping that the system I use will be scalable to change both the 165, and number allowed in the combination.

2

1 Answer 1

2

The pseudo-polynomial solution to subset sum problem can be used to solve your problem too.

Execute the algorithm described there and then look for the highest number s smaller than 165 for which Q(n, s) is true.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.