Heyo, little challenge I have for you all to solve together (not my challenge, but mine to solve )
To transport palmtops, they're mass-packed into boxes without their retail packing. These palmtops are of size 2x8x12 cm (dxwxh). In the larger box, the palmtops are all aligned in the same direction. Inbetween the palmtops and between a palmtop and the 'wall' needs to be 2cm of polystyrene foam in all directions. We're trying to find the best size for the box given an amount N of palmtops. The 'best' size is the one that has the least volume.
mathematically, we're trying to minimize
V(D,W,H) = (2+4D) * (2+10W) * (2+14H) = 8 + 16D + 40W + 28H + 80DW + 112DH + 280WH + 560DWH
with D,W,H being integer values
such that D*W*H >= N and D>=1 and W>=1 and H>=1
example:
given: N = 10
best size = V(5,2,1) = 22*22*16 = 7744 cm^2
ok, so we're trying to make an algorithm that efficiently finds the best values (worst way is trying all combinations of W,H,D in the range [1,N] )
approach I had in mind was starting out with V(D,W,H)=V(N,1,1) and then raising W and H while lowering D.... but which one to raise and when to stop?
any help appreciated (other approaches welcome too of course)
one thing I noticed:
V(x,y,z) > V(y,x,z)
40y+16x+280yz+112xz > 40x+16y+280xz+112yz
24y+168yz > 24x+168xz
y(24+168z) > x(24+168z)
y>x
in words: its best to have D>=W, because the volume decreases by swapping them if its not the case
analogously: its best to have W>=H
such that we only need to search values for which:
D>=W>=H
To transport palmtops, they're mass-packed into boxes without their retail packing. These palmtops are of size 2x8x12 cm (dxwxh). In the larger box, the palmtops are all aligned in the same direction. Inbetween the palmtops and between a palmtop and the 'wall' needs to be 2cm of polystyrene foam in all directions. We're trying to find the best size for the box given an amount N of palmtops. The 'best' size is the one that has the least volume.
mathematically, we're trying to minimize
V(D,W,H) = (2+4D) * (2+10W) * (2+14H) = 8 + 16D + 40W + 28H + 80DW + 112DH + 280WH + 560DWH
with D,W,H being integer values
such that D*W*H >= N and D>=1 and W>=1 and H>=1
example:
given: N = 10
best size = V(5,2,1) = 22*22*16 = 7744 cm^2
ok, so we're trying to make an algorithm that efficiently finds the best values (worst way is trying all combinations of W,H,D in the range [1,N] )
approach I had in mind was starting out with V(D,W,H)=V(N,1,1) and then raising W and H while lowering D.... but which one to raise and when to stop?
any help appreciated (other approaches welcome too of course)
one thing I noticed:
V(x,y,z) > V(y,x,z)
40y+16x+280yz+112xz > 40x+16y+280xz+112yz
24y+168yz > 24x+168xz
y(24+168z) > x(24+168z)
y>x
in words: its best to have D>=W, because the volume decreases by swapping them if its not the case
analogously: its best to have W>=H
such that we only need to search values for which:
D>=W>=H
Last edited: