Puzzle Solution

See official scala center of code writeup