Solves problem 9.