Problem

Source: 2023 IGMO Round 2 p1 International Gamma Mathematics Olympiad

Tags: combinatorics



Let $b = b_kb_{k-1}...b_2b_1$ be a binary string (string that consists of $1$’s and $0$’s only) of length $k$, where $k$ is a positive integer. Based on this binary string we generate a two-dimensional “path” $a_0 \to a1 \to ... \to a_k$ such that $$a_0 = (0, 0),\,\,\, a_1 =\begin{cases}(1, 0), \,\,\, if \,\,\,b_1 = 1 \\ (-1, 0)\,\,\, if \,\,\,b_1 = 0 \end{cases}$$$$_{a_{n+1}}=\begin{cases} a_n + (1, 0),\,\,\, if \,\,\, b_{n+1} = 1, b_n = 0 \\ a_n + (0, 1),\,\,\, if \,\,\,b_{n+1} = 1, b_n = 1 \\ a_n - (1, 0),\,\,\, if \,\,\,b_{n+1} = 0, b_n = 1 \\ a_n - (0, 1),\,\,\, if \,\,\,b_{n+1} = 0, b_n = 0\end{cases} \,\,\, \,\,\, for \,\,\, n \in \{2, ..., k-1\}$$ We call a binary string $b$ ideal if and only if the path generated by $b$ ends in $(0, 0)$. For example $b = 1100$ is ideal, because it generates the following path: $$\underbrace{(0, 0)}_{a_0} \to \underbrace{(-1, 0)}_{a_1} \to \underbrace{(-1,-1) }_{a_2} \to \underbrace{(0,-1) }_{a_3} \to \underbrace{(0, 0) }_{a_4} .$$Let $S(k)$ be the set of all ideal binary strings of length $k$. For each positive integer $k$, characterize all elements of $S(k)$ and find an explicit formula for the number of elements in the set $S(k)$.