problem 6 in haskell
problem 7 in haskell