Solve #36 in Haskell.