Solved 8 with Haskell.