Problem 31 Solution, ~14.4 second Execution Time