Add solution to Problem 6