Given a set of objects, how to calculate how many fit in a given volume?
This is more an algorithm question than programming, but it's implemented in programming so I'm asking it here.
I have a set of given objects with different known dimensions and need to figure out the max of objects that can be put inside another volume of known dimensions. What algorithms exist to explore this problem other than a combinatorial brute-force approach?
Also, if I assume they are not arranged, how many will fit?
Another way to look at it:
- What's the max of a set of LEGO blocks I can assemble to put inside a box and how do I calculate it?
- What's the max of a set开发者_开发问答 of LEGO blocks I can drop inside a box without arranging them and how do I calculate it?
This is a classic CS problem - read the wiki entry on Knapsack problem.
精彩评论