MathDB

2017 Brazil National Olympiad

Part of Brazil National Olympiad

Subcontests

(6)

Combinatorics with lock screen passwords of cellphones

4. We see, in Figures 1 and 2, examples of lock screens from a cellphone that only works with a password that is not typed but drawn with straight line segments. Those segments form a polygonal line with vertices in a lattice. When drawing the pattern that corresponds to a password, the finger can't lose contact with the screen. Every polygonal line corresponds to a sequence of digits and this sequence is, in fact, the password. The tracing of the polygonal obeys the following rules:
i. The tracing starts at some of the detached points which correspond to the digits from 11 to 99 (Figure 3).
ii. Each segment of the pattern must have as one of its extremes (on which we end the tracing of the segment) a point that has not been used yet.
iii. If a segment connects two points and contains a third one (its middle point), then the corresponding digit to this third point is included in the password. That does not happen if this point/digit has already been used.
iv. Every password has at least four digits.
Thus, every polygonal line is associated to a sequence of four or more digits, which appear in the password in the same order that they are visited. In Figure 1, for instance, the password is 218369, if the first point visited was 22. Notice how the segment connecting the points associated with 33 and 99 includes the points associated to digit 66. If the first visited point were the 99, then the password would be 963812963812. If the first visited point were the 66, then the password would be 693812693812. In this case, the 66 would be skipped, because it can't be repeated. On the other side, the polygonal line of Figure 2 is associated to a unique password.
Determine the smallest n(n4)n (n \geq 4) such that, given any subset of nn digits from 11 to 99, it's possible to elaborate a password that involves exactly those digits in some order.