add straightforward solution for problem 9.