Problem 41, 42 solution