Solves problem 3 haskell