Solved prob 50 with haskell