Solve #42 in Haskell.