Solves problem 9