Add solution for problem 1.