Bilbo, Gandalf, and Nitzan play the following game. First, Nitzan picks a whole number between $1$ and $2^{2022}$ inclusive and reveals it to Bilbo. Bilbo now compiles a string of length $4044$ built from the three letters $a,b,c$. Nitzan looks at the string, chooses one of the three letters $a,b,c$, and removes from the string all instances of the chosen letter. Only then is the string revealed to Gandalf. He must now guess the number Nitzan chose. Can Bilbo and Gandalf work together and come up with a strategy beforehand that will always allow Gandalf to guess Nitzan's number correctly, no matter how he acts?
Problem
Source: 2022 Israel TST test 10 P1
Tags: combinatorics, TST, Israel
onyqz
15.09.2024 16:08
Say the left-most letter of the string is on place $1$ and the right-most letter is on place $4044$. The other places are $2$ to $4043$ respectively from left to right.
Bilbo tells Gandalf, that he will use $c$ as a separator and will put them on places $2k, 1\leq k \leq 2022$. Moreover, he will use $a$ to indicate $1$ in binary representation and $b$ to indicate $0$ in binary representation. These will be put on places $2k+1, 0\leq k \leq 2021$.
Bilbo also tells Gandalf that there is one exception: if the number Nitzan chooses is $2^{2022}$, then his string will only consist of $a$'s. Gandalf will thus immediately know Nitzan's number, if he gets a empty string or a string with only $a$.
When Bilbo sees Nitzan's number and it is not $2^{2022}$, he converts it to it's binary representation, then to it's $a,b$-representation and puts it's last letter (left-most letter) on place $1$, the letter besides it on place $3$ and so on (note that numbers $1$ to $2^{2022}-1$ need at most $2022$ digits in binary, hence we have enough places to represent these numbers).
Now, if Nitzan decides to remove all $c$s, then Gandalf sees a string in $a,b$-representation, which he converts to binary and then to decimal and he knows Nitzan's number.
If Nitzan removes $a$ or $b$, then Gandalf sees, due to the separators $c$, where these $a$s or $b$s are missing. He thus puts them back, converts the number in $a,b$-representation to binary and then to decimal and again knows Nitzan's number.
Hence we conclude, that Bilbo and Gandalf can work together s.t. Gandalf always knows Nitzan's number, no matter how he acts. $\square$