Problem 15 solution