Solve #27 in Haskell.