solved problem 1 with haskell