Python Forum
The Best way to fit a bag with a size
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The Best way to fit a bag with a size
#1
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.
Yoriz write Oct-18-2021, 08:08 PM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply
#2
This forum is focused on education. It exists to help people learn Python. We don’t exist to solve others’ problems, although that tends to be a happy byproduct of education.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020