solution to Problem 18