Add solution to Problem 8