Solve #46 in Haskell.