Problem 33 solution