Solved 6 with Haskell.