Add solution for problem 3.