Solved problem2 in haskell and perl.

Also discovered  Haskell is divine :sunglasses: