Solves problem 7 haskell