Problem 4 in Python.
Problem 4 solved in Haskell.