Solve #23 in Haskell.