problem 12 in haskell