solve codingame using Haskell