Add solution for problem 9.