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.