Problem 69: Much more efficient solution