'find best size for rectangles to fit into square [duplicate]
I have n 19:10 rectangles, which I can resize. I want to fit all n into a 8000x8000 square.
What's the largest size the rectangles can have? And how should they be distributed?
For example, n = 2 means the rectangles can be as wide as the box, 8000, as tall as (10/19)*8000 = 4210.5, and should just be placed in a 1x2 tower.
For n = 4 the best arrangement is 2x2, not 1x4.
How can these best arrangements be calculated?
Solution 1:[1]
By your n=4 case, we can infer that no rectangles can be rotated to fit into leftover gaps, a la tetris?
Like this arrangement with one rectangle rotated (so 10:19)
[19x10]|10|
[19x10]| x|
[19x10]|19| = (19+10) x (10*3) = 29 x 30
29x30 can fit better (larger rectangles) into a 8000x8000 square than the 2 by 2 distribution.
If no rectangles can be rotated, another (just as valid) 2 by 2 configuration might look like this:
[19x10][19x10]
[19x10][ ]
[19x10][ ] = (19*2) x (10*3) = 38x30
We would have some space over at the bottom right, but the rectangles would be the same size as the 2 by 2 configuration.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
