2. Let $n$ be a natural number and $C$ be a non-negative real number. Determine the number of sequences of real numbers $1, x_{2}, \ldots, x_{n}, 1$ such that the absolute value of the difference between any two consecutive terms of the sequence is equal to $C$.
Solution. Let us assume that the sequence $1, x_{2}, \ldots, x_{n}, 1$ satisfies the condition of the problem. Then

$$
\left|1-x_{2}\right|=\left|x_{2}-x_{3}\right|=\ldots=\left|x_{n}-1\right|=C
$$

Also

$$
x_{n}-1=\left(x_{n}-x_{n-1}\right)+\left(x_{n-1}-x_{n-2}\right)+\ldots+\left(x_{2}-1\right)
$$

where the number of pairs of parentheses on the right side is $n-1$. We consider two cases: $n$ is odd and $n$ is even.

Case 1. $n$ is odd, i.e., $n-1$ is even.

Then equation (2) is of the form

$$
\Delta_{1} C=\underbrace{\Delta_{2} C A_{3} C \ldots \Delta_{n} C}_{n-1}
$$

where $A_{i} \in\{-,+\}, 1 \leq i \leq n$. The choice of $A_{i} \in\{-,+\}, 2 \leq i \leq n$ determines the sequence $1, x_{2}, \ldots, x_{n}, 1$ which satisfies condition (1). Note that the sum on the right side of the equation

$$
A_{1} C=\underbrace{\Delta_{2} C A_{3} C \ldots \Delta_{n} C}_{n-1}
$$

(for one choice of $\Delta_{i} \in\{-,+\}, 2 \leq i \leq n$) is an even number of times $C$, while the left side is $\pm C$, i.e., an odd number of times $C$. Therefore, the right side is equal to $\pm 2 k C$, for some $k \in \mathbb{N}$, and the left side is equal to $\pm C$. The latter is possible only if $C=0$ and then we get the sequence $1=x_{2}=\ldots=x_{n}$, i.e., there is only one sequence with the desired property.

Case 2. $n$ is even, i.e., $n-1$ is odd.

If $C=0$, then $1=x_{2}=\ldots=x_{n}$. Let $C>0$. Then again from equation (2) we get

$$
\Delta_{1} C=\underbrace{\Delta_{2} C \Delta_{3} C \ldots \Delta_{n} C}_{n-1} .
$$

Thus, the problem reduces to the number of choices of $A_{i} \in\{-,+\}, 2 \leq i \leq n$ such that

$$
\Delta_{1} C=\underbrace{\Delta_{2} C \Delta_{3} C \ldots \Delta_{n} C}_{n-1}
$$

If on the left side of the equation we have $+C$, then from the right side of the equation the difference between the number of positive and negative constants must be exactly 1, i.e., $+C$ must occur $\frac{n-2}{2}+1=\frac{n}{2}$ times, and $-C$ exactly $\frac{n-2}{2}$ times. Such a choice can be made in $\binom{n-1}{n / 2}=\binom{n-1}{(n-2) / 2}$ ways (from a sequence of length $n-1$ we choose $n / 2$ positions where $+C$ will stand, and on the remaining positions $-C$ will appear). In the same number of ways, the sum on the right side can be written if from the left it is $-C$. Therefore, the total number of such records is $2\binom{n-1}{n / 2}$.

Finally, if we denote by $r=r(n, C)$ the number of sequences that satisfy the condition of the problem, then

$$
r= \begin{cases}1, & C=0 \\ 0, & \text { n is odd and } C>0 \\ 2\binom{n-1}{n / 2}, & \text { n is even and } C>0 .\end{cases}
$$