Python Forum

Full Version: The Best way to fit a bag with a size
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I need to find the best way to make an exact 1000g pot by choosing 120g to 350g pieces from an array. If I don't find 1000, I can go up to 1015.

[0] 330
[1] 250
[2] 333
[3] 334
[4] 280
[5] 333
[6] 334
If I choose 2,3 and 5 I can get that exact value.
I've currently made some changes to KnapSack, but I couldn't adapt to just one dimension.