Solve #18 in Haskell.