Subfield: Combinatorics


Question: The leader of an IMO team chooses positive integers $n$ and $k$ with $n>k$, and announces them to the deputy leader and a contestant. The leader then secretly tells the deputy leader an $n$-digit binary string, and the deputy leader writes down all $n$-digit binary strings which differ from the leader's in exactly $k$ positions. (For example, if $n=3$ and $k=1$, and if the leader chooses 101, the deputy leader would write down 001, 111 and 100.) The contestant is allowed to look at the strings written by the deputy leader and guess the leader's string. What is the minimum number of guesses (in terms of $n$ and $k$ ) needed to guarantee the correct answer?

Solution:
Let $X$ be the binary string chosen by the leader and let $X^{\prime}$ be the binary string of length $n$ every digit of which is different from that of $X$. The strings written by the deputy leader are the same as those in the case when the leader's string is $X^{\prime}$ and $k$ is changed to $n-k$. In view of this, we may assume $k \geqslant \frac{n}{2}$. Also, for the particular case $k=\frac{n}{2}$, this argument shows that the strings $X$ and $X^{\prime}$ cannot be distinguished, and hence in that case the contestant has to guess at least twice.

It remains to show that the number of guesses claimed suffices. Consider any string $Y$ which differs from $X$ in $m$ digits where $0<m<2 k$. Without loss of generality, assume the first $m$ digits of $X$ and $Y$ are distinct. Let $Z$ be the binary string obtained from $X$ by changing its first $k$ digits. Then $Z$ is written by the deputy leader. Note that $Z$ differs from $Y$ by $|m-k|$ digits where $|m-k|<k$ since $0<m<2 k$. From this observation, the contestant must know that $Y$ is not the desired string.

As we have assumed $k \geqslant \frac{n}{2}$, when $n<2 k$, every string $Y \neq X$ differs from $X$ in fewer than $2 k$ digits. When $n=2 k$, every string except $X$ and $X^{\prime}$ differs from $X$ in fewer than $2 k$ digits. Hence, the answer is as claimed.
Firstly, assume $n \neq 2 k$. Without loss of generality suppose the first digit of the leader's string is 1 . Then among the $\left(\begin{array}{l}n \\ k\end{array}\right)$ strings written by the deputy leader, $\left(\begin{array}{c}n-1 \\ k\end{array}\right)$ will begin with 1 and $\left(\begin{array}{l}n-1 \\ k-1\end{array}\right)$ will begin with 0 . Since $n \neq 2 k$, we have $k+(k-1) \neq n-1$ and so $\left(\begin{array}{c}n-1 \\ k\end{array}\right) \neq\left(\begin{array}{c}n-1 \\ k-1\end{array}\right)$. Thus, by counting the number of strings written by the deputy leader that start with 0 and 1, the contestant can tell the first digit of the leader's string. The same can be done on the other digits, so 1 guess suffices when $n \neq 2 k$.

Secondly, for the case $n=2$ and $k=1$, the answer is clearly 2. For the remaining cases where $n=2 k>2$, the deputy leader would write down the same strings if the leader's string $X$ is replaced by $X^{\prime}$ obtained by changing each digit of $X$. This shows at least 2 guesses are needed. We shall show that 2 guesses suffice in this case. Suppose the first two digits of the leader's string are the same. Then among the strings written by the deputy leader, the prefices 01 and 10 will occur $\left(\begin{array}{c}2 k-2 \\ k-1\end{array}\right)$ times each, while the prefices 00 and 11 will occur $\left(\begin{array}{c}2 k-2 \\ k\end{array}\right)$ times each. The two numbers are interchanged if the first two digits of the leader's string are different. Since $\left(\begin{array}{c}2 k-2 \\ k-1\end{array}\right) \neq\left(\begin{array}{c}2 k-2 \\ k\end{array}\right)$, the contestant can tell whether the first two digits of the leader's string are the same or not. He can work out the relation of the first digit and the



other digits in the same way and reduce the leader's string to only 2 possibilities. The proof is complete.

Final answer: 2 if $n=2 k$ and 1 if $n \neq 2 k$