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 $1$ to $9$ (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 $2$. Notice how the segment connecting the points associated with $3$ and $9$ includes the points associated to digit $6$. If the first visited point were the $9$, then the password would be $963812$. If the first visited point were the $6$, then the password would be $693812$. In this case, the $6$ 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 (n \geq 4)$ such that, given any subset of $n$ digits from $1$ to $9$, it's possible to elaborate a password that involves exactly those digits in some order.
Attachments:
