I have a number of 'bricks' of different size (width and height) and a container of a fixed size. I want to layout the bricks within the container as compactly as possible starting from the top moving downwards. I've selected the criteria that the grid should be optimal at any step, given the previous steps. So far, I have the following (inefficient) code that doesn't work: I have a number of 'bricks' of different size (