Hmm. I would have taken a different tactic...
Assume that you have an infinite number of standard containers with a given length/width/height. You also have a finite number of items to go in the containers, each item having its own l/w/h (which can be different for each item).
The trick then would be to pack items in containers such that each container can hold no more items... but optimizing for empty space.
Order of packing then becomes the issue.
Actual code is left as an exersise for the reader. :-)
WARNING: You are logged into reality as root.