Two persons, A and B, set up an incantation contest in which they spell incantations (i.e. a finite sequence of letters) alternately. They must obey the following rules: i) Any incantation can appear no more than once; ii) Except for the first incantation, any incantation must be obtained by permuting the letters of the last one before it, or deleting one letter from the last incantation before it; iii)The first person who cannot spell an incantation loses the contest. Answer the following questions: a) If A says '$STAGEPREIMO$' first, then who will win? b) Let $M$ be the set of all possible incantations whose lengths (i.e. the numbers of letters in them) are $2009$ and containing only four letters $A,B,C,D$, each of them appearing at least once. Find the first incantation (arranged in dictionary order) in $M$ such that A has a winning strategy by starting with it.
Problem
Source: Italy TST 2009 p6
Tags: modular arithmetic, combinatorics proposed, combinatorics
24.02.2013 22:30
Call an incantation of length $n$ new if it is the first spoken incantation of length $n$. First, we find necessary and sufficient conditions that a new incantation is winning. If a new incantation $I$ is winning, every incantation that can be formed by deleting a letter from $I$ (the resulting incantation is of course new as well) must be losing, since otherwise the other player would simply delete the appropriate letter and win the contest. Furthermore, the number of permutations of the letters in $I$ must be odd. If it were even, the other player could keep permuting the letters and force the first player to delete a letter from $I$. But we just established that deleting a letter from $I$ is losing, so this would mean $I$ is losing. This criteria is clearly sufficient as well, since the first player can force the second player to delete a letter from $I$, leaving the latter in a losing position. This immediately answers (a); $\text{STAGEPREIMO}$ has an even number of permutations, so it must be losing for player A (i.e. B will win) Now consider a string of length $2009$ with $a$ occurrences of $\text{A}$, $b$ occurrences of $\text{B}$, and so on. If this string is to be winning for player A, the number of permutations of its letters must be odd. That is, \[\binom{2009}{a, b, c, d} \equiv 1 \pmod{2}\] We have $2009 = 11111011001_2$. Let $a = a_{10}a_{9}\dots a{}_{0}{}_2$ and likewise for $b, c, d$. Then by Lucas' Theorem, \[\binom{2009}{a, b, c, d} \equiv \binom{1}{a_{10}, b_{10}, c_{10}, d_{10}} \dots \binom{0}{a_{1}, b_{1}, c_{1}, d_{1}} \binom{1}{a_{0}, b_{0}, c_{0}, d_{0}} \pmod{2}\] For all of these terms to be odd, they must be nonzero, so there can be no carries in the binary addition $a + b + c + d = 2009$. Then since $b, c, d > 0$ and no two of $a, b, c, d$ can have two $1$s in the same place value, we maximize the number of occurrences of $\text{A}$ by letting $a = 11111000000_2 = 1984$, $b = 10000_2 = 16$, $c = 1000_2 = 8$, and $d = 1_2 = 2$. We now show this is indeed a winning incantation for A. By our earlier criteria, the incantation $\ell$ is winning iff it has an odd number of permutations and all incantations formed by deleting a letter from $\ell$ are losing. We know $\ell$ has an odd number of permutations, so we need to check that all of its "substrings" are losing. Let us represent a string with $x, y, z, w$ occurrences of $\text{A, B, C, D}$ respectively by the tuple $(x, y, z, w)$. Then $(1984, 16, 8, 1)$ is winning if each of $(1983, 16, 8, 1)$, $(1984, 15, 8, 1)$, $(1984, 16, 7, 1)$, and $(1984, 16, 8, 0)$ are losing. There are carries in the binary addition of the first three (since two of the numbers are adding are odd), so they are automatically losing. Then we only need to show $(1984, 16, 8, 0)$ is losing as well. $(1984, 16, 8, 0)$ has an odd number of permutations, so for it to be losing we need it to have a winning substring. $(1983, 16, 8, 0)$ and $(1984, 15, 8, 0)$ are losing, since $1983$ and $15$ have $1$s in a place value which $8$ has a $1$ in as well. Thus we need $(1984, 16, 7, 0)$ to be winning. We can now repeat the argument. This string has an odd number of permutations, so we need its three substrings to be losing. $(1983, 16, 7, 0)$ and $(1984, 15, 7, 0)$ are losing since they contain two odd numbers. Then we simply need $(1984, 16, 6, 0)$ to be losing. This string has an odd number of permutations, so we need it to have a winning substring. $(1983, 16, 6, 0)$ and $(1983, 15, 6, 0)$ will not do since the $1983$ and $15$ will overlap the binary expansion of $6$. Then we need $(1983, 16, 5, 0)$ to be winning. Repeating as necessary, we need $(1983, 0, 0, 0)$ to be winning. Clearly it is, since the game is deterministic from here. The first player says incantations of odd length and the second player incantations of even length, until ultimately the first player will say $\text{A}$ to which the second player has no response. Then $(1984, 16, 8, 1)$ is winning, as claimed, and so the first incantation in dictionary order for which A has a winning strategy is \[\text{AA\dots ABB \dots BCC \dots CD}\] where there are $1984$ occurrences of $\text{A}$, $16$ occurrences of $\text{B}$, $8$ occurrences of $\text{C}$, and a single $\text{D}$.
07.11.2020 21:28
Wait, how do you know you can't spell an incantation? Am I missing something?