Solve #35 in Haskell.