Solves problem 15 in haskell