Subfield: Combinatorics


Question: Let $k$ be a positive integer. Lexi has a dictionary $\mathcal{D}$ consisting of some $k$-letter strings containing only the letters $A$ and $B$. Lexi would like to write either the letter $A$ or the letter $B$ in each cell of a $k \times k$ grid so that each column contains a string from $\mathcal{D}$ when read from top-to-bottom and each row contains a string from $\mathcal{D}$ when read from left-to-right.

What is the smallest integer $m$ such that if $\mathcal{D}$ contains at least $m$ different strings, then Lexi can fill her grid in this manner, no matter what strings are in $\mathcal{D}$ ?

Solution:
We claim the minimum value of $m$ is $2^{k-1}$.

Firstly, we provide a set $\mathcal{S}$ of size $2^{k-1}-1$ for which Lexi cannot fill her grid. Consider the set of all length- $k$ strings containing only $A \mathrm{~s}$ and $B \mathrm{~s}$ which end with a $B$, and remove the string consisting of $k$  $B \mathrm{~s}$. Clearly there are 2 independent choices for each of the first $k-1$ letters and 1 for the last letter, and since exactly one string is excluded, there must be exactly $2^{k-1}-1$ strings in this set.

Suppose Lexi tries to fill her grid. For each row to have a valid string, it must end in a $B$. But then the right column would necessarily contain $k B \mathrm{~s}$, and not be in our set. Thus, Lexi cannot fill her grid with our set, and we must have $m \geqslant 2^{k-1}$.

Now, consider any set $\mathcal{S}$ with at least $2^{k-1}$ strings. Clearly, if $\mathcal{S}$ contained either the uniform string with $k A \mathrm{~s}$ or the string with $k B \mathrm{~s}$, then Lexi could fill her grid with all of the relevant letters and each row and column would contain that string.

Consider the case where $\mathcal{S}$ contains neither of those strings. Among all $2^{k}$ possible length$k$ strings with $A \mathrm{~s}$ and $B \mathrm{~s}$, each has a complement which corresponds to the string with $B$ s in every position where first string had $A$ s and vice-versa. Clearly, the string with all $A$ s is paired with the string with all $B$ s. We may assume that we do not take the two uniform strings and thus applying the pigeonhole principle to the remaining set of strings, we must have two strings which are complementary.

Let this pair of strings be $\ell, \ell^{\prime} \in \mathcal{S}$ in some order. Define the set of indices $\mathcal{J}$ corresponding to the $A \mathrm{~s}$ in $\ell$ and thus the $B \mathrm{~s}$ in $\ell^{\prime}$, and all other indices (not in $\mathcal{J}$ ) correspond to $B \mathrm{~s}$ in $\ell$ (and thus $A$ s in $\ell^{\prime}$ ). Then, we claim that Lexi puts an $A$ in the cell in row $r$, column $c$ if $r, c \in \mathcal{J}$ or $r, c \notin \mathcal{J}$, and a $B$ otherwise, each row and column contains a string in $\mathcal{S}$.

We illustrate this with a simple example: If $k=6$ and we have that $A A A B A B$ and $B B B A B A$ are both in the dictionary, then Lexi could fill the table as follows:

| A | A | A | B | A | B |
| :---: | :---: | :---: | :---: | :---: | :---: |
| A | A | A | B | A | B |
| A | A | A | B | A | B |
| B | B | B | A | B | A |
| A | A | A | B | A | B |
| B | B | B | A | B | A |

Suppose we are looking at row $i$ or column $i$ for $i \in \mathcal{J}$. Then by construction the string in this row/column contains $A \mathrm{~s}$ at indices $k$ with $k \in \mathcal{J}$ and $B$ s elsewhere, and thus is precisely $\ell$. Suppose instead we are looking at row $i$ or column $i$ for $i \notin \mathcal{J}$. Then again by construction the string in this row/column contains $A$ s at indices $k$ with $k \notin \mathcal{J}$ and $B$ s elsewhere, and thus is precisely $\ell^{\prime}$. So each row and column indeed contains a string in $\mathcal{S}$.

Thus, for any $\mathcal{S}$ with $|\mathcal{S}| \geqslant 2^{k-1}$, Lexi can definitely fill the grid appropriately. Since we know $m \geqslant 2^{k-1}, 2^{k-1}$ is the minimum possible value of $m$ as claimed.

Final answer: $2^{k-1}$