Solution to Problem 69



Congratulations to this week's winner

Nathan Pauli

Partial solutions were also received from Joshua Durham, Ray Kremer.  Additional partial solutions were submitted by Jure Velkavrh and Ivan Lisac, Maxim Ovsjanikov, Philippe Fondanaiche, Burkart Venzke.


Let's start with a sequence  n1, n2 ,..., nkwhich can be moved to all zeroes.  In each move, one of the entries is made zero; I'll say that entry was cleared by the move.

It's easy to see that the following "rules" must be followed:

  1. each entry ni must be no greater than i after each move,
  2. if there are two entries which may be cleared, it's the smaller of the two which must be cleared.
To see what the value of each ni should be, let qi denote the total number of times that the i 'th entry is cleared.  The i 'th entry started as ni and was increased one time for each time every time that a higher entry was cleared.  Hence  is the number of times the i 'th entry had the value i, i.e.
Note that qk = 1, and nk = k  since the k 'th entry must be cleared once, and once cleared it remains zero forever after that.  These equations can be solved uniquely, starting with qk, using rule 1 above, namely that nnever exceeds i.

As an example, consider the case k = 8.  We start with q8 = 1, n8 = 8.  Then 7q7 n7 +q8, which gives q7 = 1, n7 = 7. We proceed to 6q6 = n6 + q7 +q8, and q6 = 1, n6 = 4. Similarly, q5 = 1, n5 = 2. Now it gets interesting.  We next have 4q4 n4 + q5 + q6 +q7 + q8 = n4 + 4, and q4 = 2, n4 = 4.  Completing the calculations gives q3 = 3, n3 = 3; q2 = 5, n2 = 1; q1 = 2, n1 = 1.  The unique longest sequence of length 8 which can be cleared is therefore 1,1,3,4,2,4,6,8.

The total number of moves required is the sum either of ni 's or of the  qi's, both sums being, of course, equal; in the above example this number is 29.   I know of no closed form for this number, but would love to hear of one.

Note that the formula above for computing the entries can be easily automated and programmed into even the simplest of programmable calculators.

You are visitor number 2840 to this page.
Page last updated 18 October 1999.