Pallete packing optimization

Dear all,

a standard European pallete has a size of 120 x 80 cm (for transporting goods).

I am trying to program a solution which tells me how to put a maximum of boxes on this pallette.
Those boxes are all of the same size and can not go over the edge of the pallete.

I only managed to divide the left size after placing a box by the space needed by a box, but this will result in a wrong amount as your box is always a rectangle.

So my question is: How can I figure out a solution which lets me know how many complete rectangles I can still place on the pallete?
You have to consider the x and y direction separately. The basic math is rather simple:

count_x = palette_size_x / box_size_x;

box_count (the amount of boxes) = count_x * count_Y;

Imagine you have a box 12 x 8 cm. Define palette_size_x = 120, palette_size_y = 80.

if you choose box_size_x = 8, box_size_y = 12 box_count is 90
if you choose box_size_x = 12, box_size_y = 8 box_count is 100

hint: to optimize you may need to fill the left over (to get this you need the modulus operator %)

EDIT: better naming
Last edited on
Topic archived. No new replies allowed.