First problem completed with haskell.