solved problem 2 with haskell