Solved 4 with Haskell.