Solved 3 with Haskell.