Problem 10 solution.