Square Deal
Jump to navigation
Jump to search
This problem asks us if we can arrange 3 input rectangles to form a square.
Note that there are very few overall configurations of the rectangles.
- identify the 6 edge lengths of the 3 rectangle
- iterate through any pairs of matching edge lengths
- "simulate" joining the two triangles
- check if either of the two edge lengths of the third rectangle match either of them from the newly formed rectangle
- check if the combination forms a square
One could also (loosely):
- calculate the total area of the rectangles, and thus the area and side length of the square
- evaluate if any sum of the rectangles edges matches that of the square
- evaluate whether the rectangles assembled in that fashion form a valid square