Given the natural $n$. We shall call word sequence from $n$ letters of the alphabet, and distance $\rho(A, B)$ between words $A=a_1a_2\dots a_n$ and $B=b_1b_2\dots b_n$ , the number of digits in which they differ (that is, the number of such $i$, for which $a_i\ne b_i$). We will say that the word $C$ lies between words $A$ and $B$ , if $\rho (A,B)=\rho(A,C)+\rho(C,B)$. What is the largest number of words you can choose so that among any three, there is a word lying between the other two?
Problem
Source: SRMC 2018 P3
Tags: combinatorics, Combinatorics of words
06.09.2018 13:33
We claim that the answer is $n + 1$ for $n \neq 2$ and $n + 2$ for $n = 2$. This is achieved for $n \neq 2$ by taking all words consisting of $k$ letters "a" followed by $n - k$ letters "b" for all $0 \leq k \leq n$. For $n = 2$, we can take all words consisting of letters "a" and "b". Now call a set of words good if it has the described propery. Suppose $S$ is any good set. We will show that $|S| \leq n + 1$ if $n \neq 2$ and $|S| \leq n + 2$ if $n = 2$. First note that for any three words $A, B, C$ we have $\rho(A, C) + \rho(C, B) \geq \rho(A, B)$ with equality if and only if for each $i$, either $c_i = a_i$ or $c_i = b_i$. It follows that for any $1 \leq i \leq n$, at most two distinct letters occur on the $i$-th position in words in $S$. So we can WLOG assume that all words in $S$ are binary strings of length $n$. The claim now follows for $n \leq 2$, so from now on assume that $n \geq 3$. By considering all strings in $S$ relative to a fixed string in $S$, we can WLOG assume that $S$ contains the string consisting of $n$ zeros. Now interpret each string from $S$ as a subset of the set $[n] = \{1, 2, \ldots, n\}$. We have the following two claims: Claim 1. For any distinct non-empty $A, B \in S$, either $A \cap B = \emptyset$ or $A \subset B$, or $B \subset A$. Proof: Note that for any distinct non-empty $A, B \in S$, either $\emptyset$ lies between $A, B$, meaning that $A, B$ are disjoint, or WLOG $A$ lies between $\emptyset$ and $B$, which implies that $A \subset B$. $\square$ Claim 2. No three non-empty subsets in $S$ are pairwise disjoint. Proof: Assume otherwise, then there exist non-empty $A, B, C \in S$ such that $A \cap B = B \cap C = C \cap A = \emptyset$. WLOG $B$ lies between $A$ and $C$, but then taking some $b \in B$ implies that either $b \in A$ or $b \in C$, which is absurd. $\square$ Let $S' = S \setminus \{\emptyset\}$. If the subsets in $S'$ form a chain, we have $|S'| \leq n$, so suppose this is not the case. Take disjoint $X, Y \in S'$ so that $|X| + |Y|$ is maximum. Then for each $Z \in S' \setminus \{X, Y\}$, either $Z \subset X$, or $Z \subset Y$, or $X, Y \subset Z$ (it is impossible that $X \subset Z$ and $Y \cap Z = \emptyset$ by maximality of $|X| + |Y|$). Let these classes of subsets in $S' \setminus \{X, Y\}$ be $S_1, S_2, S_3$ respectively. If $[n] \in S'$, then note that we must have $X \cup Y = [n]$ and $S_1, S_2$ must be empty, thus $|S'| \leq 3 \leq n$. So suppose that $[n] \not \in S$. Note that the subsets from $S_1$ form a chain. Indeed, otherwise we would have some $Z_1, Z_2 \in S_1$ with $Z_1 \cap Z_2 = \emptyset$, so the triple $(Z_1, Z_2, Y)$ would contradict Claim 2. Hence, $|S_1| \leq |X| - 1$ and similarly $|S_2| \leq |Y| - 1$. Note also that the subsets in $S_3$ form a chain by Claim 1., which implies that $|S_3| \leq n - |X| - |Y|$ (since $[n] \not \in S'$). Finally, $$|S| = |S' \setminus \{X, Y\}| + 3 = |S_1| + |S_2| + |S_3| + 3 \leq (|X| - 1) + (|Y| - 1) + (n - |X| - |Y|) + 3 = n + 1,$$as claimed.