Problem 7 solution.