Shorten problem 29's solution