Codility - Lesson 5: solution to StoneWall (Sigma 2012) in PHP (Test score: 100%)