solve problem 1 in Haskell