Scala solution to a puzzle with tiles.