Cubes in a box

Cubes in a box

Postby Guest » Sat Sep 12, 2020 12:57 pm

I'm programming a simple app where I have to calculate how many cubes can fit in a box. I'm trying to figure out the formula to calculate how many cubes can fit in a box given width and height properties.
The cubes are all same size (width and height).

I have tried (bw * bh) / (cw * ch) where b is Box and c is Cube to calculate the areas, but in case where bw = 6, bh = 1 and cw = 2, ch = 3 you'll get (6 * 1) / (2 * 3) = 1 but in reality such cube can't be stored in this box.

So, for example if Box is 2x2 and cubes are 1x1, I could fit 4 cubes, but for 2x6 and 4x4 I would get 0, even though they have same area.


Return to Volume & Surface

Who is online

Users browsing this forum: No registered users and 1 guest