in reply to Re: determine numbers of boxes needed per weight
in thread determine numbers of boxes needed per weight

But it's not a knapsack problem. It would be a knapsack problem if he has a set of fixed weights, and a set of fixed size boxes. But he doesn't - he can divide the weights anyway he wants to. He wants to minimize the number of different size boxes, with a limit on the size of an individual box. BrowserUK's solution will do. If you throw in an additional constraint on the minimum size of a box, there will be situations where you need two different size boxes.
Perl --((8:>*
  • Comment on Re^2: determine numbers of boxes needed per weight

Replies are listed 'Best First'.
Re^3: determine numbers of boxes needed per weight
by GrandFather (Saint) on Nov 24, 2005 at 10:09 UTC

    Fair enough. However without knowing the box weight (and possibly size) constraints imposed by USPS and the nature of the items being packed, it was not at all clear that OP's problem wasn't a knapsack problem. Especially if there were other criteria such as weights and/or box sizes that were better economy than others.


    DWIM is Perl's answer to Gödel