problem 18 (and problem 67 for free)