Challenge3 implemented in Haskell