Takeaway squares

Today I worked through the final five problems from the 2010 AMC10 Paper A, an American Maths Challenge. It was the very last problem that turned out to be my favourite:

Jim starts with a positive integer n and creates a sequence of numbers. Each successive number is obtained by subtracting the largest possible integer square less than or equal to the current number, until zero is reached. For example, if Jim starts with n = 55, then his sequence contains five numbers: 55, 6, 2, 1, 0.

What is the smallest value of n for which his sequence contains eight numbers?


Tractor trouble

From the 2013 Pink Kangaroo:

Yurko saw a tractor slowly pulling a long pipe down the road. Yurko walked along beside the pipe in the same direction as the tractor, and counted 140 paces to get from one end to the other. He then turned around and walked back to the other end, taking only 20 paces. The tractor and Yurko kept to a uniform speed, and Yurko’s paces were all 1 metre long.

How long was the pipe?