Maths Olympiad Prep

Library / /724 of 740

, 2017

Combinatorics Difficulty 5.9 AIME, harder Prove it United States

Problem:

Yannick has a bicycle lock with a 4-digit passcode whose digits are between 00 and 99 inclusive. (Leading zeroes are allowed.) The dials on the lock are currently set at 00000000. To unlock the lock, every second he picks a contiguous set of dials, and increases or decreases all of them by one, until the dials are set to the passcode. For example, after the first second the dials could be set to 11001100, 00100010, or 99999999, but not 09090909 or 01900190. (The digits on each dial are cyclic, so increasing 99 gives 00, and decreasing 00 gives 99.) Let the complexity of a passcode be the minimum number of seconds he needs to unlock the lock. What is the maximum possible complexity of a passcode, and how many passcodes have this maximum complexity? Express the two answers as an ordered pair.

Solution

Solution:

To simplify the solution, we instead consider the equivalent problem of reducing a passcode to 00000000 using the given move.

Given a passcode a1a2a3a4a_{1} a_{2} a_{3} a_{4}, define a differential of the passcode to be a quintuple (d1,d2,d3,d4,d5)(d_{1}, d_{2}, d_{3}, d_{4}, d_{5}) such that diaiai1(mod10)d_{i} \equiv a_{i}-a_{i-1} \pmod{10} for i=1,2,3,4,5i=1,2,3,4,5, where we define a0=a5=0a_{0}=a_{5}=0.

Claim 1: For any passcode, there exists a differential that satisfies the following two conditions:
- d1+d2+d3+d4+d5=0d_{1}+d_{2}+d_{3}+d_{4}+d_{5}=0;
- The range (difference between the maximum and minimum) of these five numbers is at most 1010.

Proof: We first see that the differential defined by di=aiai1d_{i}=a_{i}-a_{i-1} satisfy the first condition since the sum of the five numbers is a5a0=0a_{5}-a_{0}=0. Suppose that a differential satisfying the first condition has a range greater than 1010, then we take one of the largest number dmd_{m} and one of the smallest number dnd_{n} (where dmdn>10d_{m}-d_{n}>10), and replace the former by dm10d_{m}-10 and the latter by dn+10d_{n}+10. This will either reduce the range or reduce the number of maximal and minimal numbers, so the process will terminate after finitely many iterations. Thus we can find a differential that satisfies both conditions.

(Note: we call such a differential a standard differential from now on, although it is important to remember that there may be more than one standard differential for one passcode. As a corollary, all of the numbers in a standard differential must be in the range [9,9][-9,9], as a number greater than 99 will be more than 1010 away from a negative number, and similar for a number smaller than 9-9.)

Given a passcode, we define the magnitude of one of its standard differentials to be the sum of all the positive values in the differential (which is also the absolute value of the sum all the negative values).

Claim 2: The magnitude of a passcode's standard differential is equal to the passcode's complexity.

Proof: Obviously 00000000 is the only passcode with complexity 00 whose standard differential has magnitude 00. Suppose that the magnitude of a standard differential is MM, then it suffices show that the magnitude can be reduced to 00 in MM moves, and that the magnitude can only decrease by at most 11 with each move.

The first part can be shown via the following algorithm. When the magnitude is not zero, there must be a positive number did_{i} and a negative number djd_{j}. WLOG assume that i<ji<j, then after taking the dials ai,ai+1,,aj1a_{i}, a_{i+1}, \ldots, a_{j-1} and decreases them all by 11, did_{i} decreases by 11 and djd_{j} increases by 11. This will decrease the magnitude by 11 (and the differential remains standard), so by repeating this process MM times we can bring the magnitude down to 00.

For the second part, we assume WLOG that we take the dials ai,ai+1,,aj1a_{i}, a_{i+1}, \ldots, a_{j-1} and decrease them all by 11, and then did_{i} is replaced by di=di1d_{i}'=d_{i}-1 and dj=dj+1d_{j}'=d_{j}+1. If the differential remains standard, then the magnitude decreases by 11 (when di>0d_{i}>0 and dj<0d_{j}<0), remains the same (when either di0d_{i} \leq 0 and dj<0d_{j}<0 or di>0d_{i}>0 and dj0d_{j} \geq 0), or increases by 11 (when di0d_{i} \leq 0 and dj0d_{j} \geq 0).

In the latter two cases, it is possible that the differential is no longer standard.

If the magnitude previously remained the same (WLOG suppose that di>0d_{i}>0 and dj0d_{j} \geq 0), then there exists a negative dkd_{k} that is minimal such that djdk=10d_{j}-d_{k}=10 and now djd_{j}' is the unique maximum. Replacing dkd_{k} by dk+10=djd_{k}+10=d_{j} and djd_{j}' by dj10=dk+1d_{j}'-10=d_{k}+1 will reduce the magnitude by 11, and the new differential will be standard because the unique maximum djd_{j}' is no longer present and the minimum is now either dkd_{k} or dk+1d_{k}+1. This means that the magnitude decreases by at most 11.

If the magnitude previously increased by 11 (when di0d_{i} \leq 0 and dj0d_{j} \geq 0), then there exists either a negative dkd_{k} that is (previously) minimal such that djdk=10d_{j}-d_{k}=10, or a positive dld_{l} that is (previously) maximal such that dldi=10d_{l}-d_{i}=10, or both. By similar logic as the previous case, replacing dkd_{k} by dk+10d_{k}+10 and djd_{j}' by dj10d_{j}'-10, or replacing dld_{l} by dl10d_{l}-10 and did_{i}' by di+10d_{i}'+10 (or both, if both dkd_{k} and dld_{l} exist), will decrease the magnitude by 11, and ensure that the new differential is standard. The replacement will decrease the current magnitude by at most 22, this means that the original magnitude decreases by at most 11 in total.

These considerations finishes the second part and therefore the proof.

With this claim, we also see that the magnitudes of all possible standard differentials of a given passcode are the same, so the choice of the differential is irrelevant.

We can now proceed to find the maximum possible complexity. Suppose that there are mm positive numbers and nn negative numbers in the differential, and suppose that the maximum and the minimum are xx and y-y respectively. Since the sum of all positive numbers is at most mxm x and the absolute value of the sum of all negative numbers is at most nyn y, the complexity is at most C=min(mx,ny)C=\min (m x, n y). It suffices to maximize CC under the condition that m+n5m+n \leq 5 and x+y=x(y)10x+y=x-(-y) \leq 10. It is not difficult to see (via casework) that the maximal CC is 1212, achieved by m=2,n=3,x=6,y=4m=2, n=3, x=6, y=4 or m=3,n=2,x=4,y=6m=3, n=2, x=4, y=6. In the first case, the digits must increase from 00 by 66 twice and decrease by 44 three times (and reduced modulo 1010), which gives the passcode 62846284; in the second case the digits increase by 44 three times and decrease by 66 twice instead, which gives the passcode 48264826. Since all inequalities are tight, these two passcodes are the only ones that have the maximal complexity of 1212.

Want a route through all this instead of an archive? The track puts 2,000 problems in a working order, from AMC 10 level to the IMO shortlist.

Source: MathNet, licensed CC-BY-4.0. Statement reproduced verbatim; metadata (topic, difficulty) added by this project.