Very slow Problem 5 solution in Python.
Assert solution for Problem 5.