Add problem 2 solution in Python.
Cleaned up C code.