Haskell solution for 018