Problem Representation In The Form Of a Tree
The shapes are defined in a multiway tree to reduce the number of checks needed to find whether a shape fits into a position. Implementing a tree reduced the number of checks from 19 when going through all the shapes one by one to a maximum of 6 checks. The root node is 0,0 - the origin. It has 4 children, [0,1], [1,0], [0,-1] [-1,0] so that shapes can be checked in all directions from the origin.