Problem 45 Python and Tc solutions.