Find the smallest square with a list of tetrominos

2019-07-10 02:25发布

问题:

Imagine you have a list of Tetrominos (tetris shapes) that cannot rotate (19 possibilities) and you have to arrange them to make the smallest square.

For example, given:

A...
A...
A...
A...

BB..
.B..
.B..
....

.C..
.C..
CC..
....

The result should be:

A.BB
A.CB
A.CB
ACC.

as this is the smallest square that can accommodate the three inputs.

I tried to figure it out by myself but now I'm a bit confused.

Do I need to try with a certain size of square, try every possibilities and then increase that square until it's possible to place every Tetromino or is there another way?