Solution to the bricks problem..