solved 0020 with Haskell
solved 502