Solve #34 in Haskell.