Add solution for Problem 6.