# Can those squares form an imperfect square [duplicate]

Given a non-empty array of positive integers, determine if it is possible to take squares with side lengths specified by each integer, and arrange them in space such that they form a square.

The output can have anything as truthy / falsey values, and the input array may contain duplicates.

For the truthy testcase [3,2,2,2,1,1,1,1], a possible way to arrange the square is:

aaabb
aaabb
aaaef
ccddg
ccddh


where each letter represents a different square. The lengths of the squares are completely specified by the given array.

Numberphile did a video on that which inspired me to write this challenge. He called this an imperfect square. This is so shortest code wins.

## Testcases

Truthy:

[1]
[2]
[3]
[3,2,2,2,1,1,1,1]
[12,11,11,7,5,5,4,3,3,2,2,1,1]


Falsy:

[2,1]
[2,2,2]
[3,4]

• Please add test cases. Jun 7, 2017 at 14:36
• This one is about square nor a rectangle, but it's a similar thing. Jun 7, 2017 at 14:45
• I have edited two of your truthy testcases because they were wrong. Jun 7, 2017 at 14:56
• Thanks. I worked both of them out by hand and did some mistakes as i typed them in. Jun 7, 2017 at 14:57
• I thought this was as easy as checking all the ints in the array squared equalled a square number till I saw the [3,4] test case. Jun 7, 2017 at 15:11