Maths Olympiad Prep

Library / /191 of 224

Combinatorics Difficulty 7.0 National Olympiad Prove it Belarus

A code lock has 10 keys labeled by digits from 0 to 9. The lock is opened by entering a code of 4 keys that are not necessarily different. It is opened as soon as the correct keys are pressed consequently, no matter what keys have been pressed earlier. For example, if the code happens to be 20022002, the sequence 4567789200245677892002 will open the lock, but the sequence 2020220202 will not.
What is the minimal length of a sequence that will guarantee opening the lock regardless of what code is?

Solution

Answer: 1000310003.
We need to find the shortest sequence of decimal digits that includes every 4-digit sequence as a (consecutive) subsequence. Since there are 10410^4 possible codes, and an nn-digit sequence has at most n3n-3 distinct 4-digit subsequences, the answer must be at least 104+3=1000310^4 + 3 = 10003.

We will construct a sequence of length 104+310^4+3 that fulfills the condition. We define a directed graph G=(V,E)G = (V, E) whose vertex set VV consists of all 3-digit sequences. The edge set EE contains all ordered pairs of the form (abc,bcd)(abc, bcd). (This implies that also pairs (aaa,aaa)(aaa, aaa) are edges.) The in-degree of a vertex is defined as the number of edges directed toward the vertex, obviously, the in-degree of every vertex in GG is 1010. Symmetrically, the out-degree of every vertex is also 1010. Note also that GG is (strongly) connected.

By a well-known argument, a connected directed graph has an Euler circuit if and only if the in-degree of any vertex equals its out-degree. We can now construct the required sequence as follows. Start from any vertex, say 000000, and begin the sequence by the digits of that vertex. Follow the Euler circuit, and at each edge (abc,bcd)(abc, bcd) add dd to the sequence. It is easily proved by induction that after the edge (abc,bcd)(abc, bcd) has been followed, the four last digits of the sequence are ABCDABCD. Since the Euler circuit passes through every edge, the resulting sequence includes every 4-digit sequence. There are 10310^3 vertices, each of which is the starting point of 1010 edges, so all in all there are 10410^4 edges. Thus the length of the sequence is 3+1043 + 10^4 as required.

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.