problem12 in haskell