Problem 55 solution