Adding problem 9 solution.