Add solution to Problem 24