## Task B-1.5.

Two friends, Esma and Ljerka, came up with a game: each letter of their names is replaced by a digit from 1 to 5 according to a given table. Thus, the name Esma has the code 4431, and Ljerka has 24351.

The digits of the obtained code $a_{1} a_{2} \ldots a_{k}$ are used for moving in steps of the same length. Starting from the initial point, one moves $a_{1}$ steps north, and for each subsequent digit $a_{i}$, one turns $90^{\circ}$ to the left and walks $a_{i}$ steps in that direction (thus $a_{2}$ steps west, $a_{3}$ steps south, $a_{4}$ steps east, and so on). The process is repeated (after the last digit, it starts again with the first digit of the code)

| 1 | 2 | 3 | 4 | 5 |
| :---: | :---: | :---: | :---: | :---: |
| $\mathrm{A}$ | $\mathrm{B}$ | $\mathrm{C}$ | $\mathrm{C}$ | $\mathrm{C}$ |
| $\mathrm{D}$ | $\mathrm{D} \check{Z}$ | $\mathrm{P}$ | $\mathrm{E}$ | $\mathrm{F}$ |
| $\mathrm{G}$ | $\mathrm{H}$ | $\mathrm{I}$ | $\mathrm{J}$ | $\mathrm{K}$ |
| $\mathrm{L}$ | $\mathrm{LJ}$ | $\mathrm{M}$ | $\mathrm{N}$ | $\mathrm{NJ}$ |
| $\mathrm{O}$ | $\mathrm{P}$ | $\mathrm{R}$ | $\mathrm{S}$ | S S |
| $\mathrm{T}$ | $\mathrm{U}$ | $\mathrm{V}$ | $\mathrm{Z}$ | $\check{Z}$ |

until returning to the initial point.

Esma concluded that she would never return to the starting point with her code. Why?

Ljerka returned to the starting point after exactly $5 n$ steps. Determine $n$ and prove that any person with 5 letters in their name will return to the starting point after at most 4 cycles, or repetitions of the code.
## Solution.

Without loss of generality, assume that Esma and Ljerka started from the point $(0,0)$.

![](https://cdn.mathpix.com/cropped/2024_05_30_1c7eac828d9f4d45279fg-05.jpg?height=554&width=851&top_left_y=1156&top_left_x=611)

Esma's movement looks like this:

First loop: $(0,0),(0,4),(-4,4),(-4,1),(-3,1)$

Second loop: $(-3,1),(-3,5),(-7,5),(-7,2),(-6,2)$

Third loop: $(-6,2),(-6,6),(-10,6),(-10,3),(-9,3)$.

After the $k$-th loop, the coordinates of the final point change to $(-3 k, k)$, so Esma obviously cannot return to the starting point because the final points lie on a single line.

Ljerka's movement looks like this:

First loop: $(0,0),(0,2),(-4,2),(-4,-1),(1,-1),(1,0)$

Second loop: $(1,0),(-1,0),(-1,-4),(2,-4),(2,1),(1,1)$

Third loop: $(1,1),(1,-1),(5,-1),(5,2),(0,2),(0,1)$

Fourth loop: $(0,1),(2,1),(2,5),(-1,5),(-1,0),(0,0)$

Ljerka needed 4 loops to return to the point from which she started.

Since each loop consisted of $2+4+3+5+1=15$ steps, Ljerka needed a total of 60 steps, so the desired $n=12$.

Let the code name be a 5-letter word abcde, where $a, b, c, d, e \in\{1,2,3,4,5\}$. Starting from the point $(x, y)$, we move up by $a$, left by $b$, down by $c$, right by $d$, and up again by $e$, arriving at the point $(x-b+d, y+a-c+e)$.

In the second loop, we start from this point and move left by $a$, down by $b$, right by $c$, up by $d$, and left by $e$, arriving at the point $(x-b+d-a+c-e, y+a-c+e-b+d)$.

![](https://cdn.mathpix.com/cropped/2024_05_30_1c7eac828d9f4d45279fg-06.jpg?height=677&width=602&top_left_y=621&top_left_x=727)

In the third loop, we start from this point and move down by $a$, right by $b$, up by $c$, left by $d$, and down again by $e$, arriving at the point $(x-b+d-a+c-e+b-d, y+a-c+e-b+d-a+c-e) = (x-a+c-e, y-b+d)$.

In the fourth loop, we start from this point and move right by $a$, up by $b$, left by $c$, down by $d$, and right by $e$, arriving at the point $(x-a+c-e+a-c+e, y-b+d+b-d) = (x, y)$.

A person with a 5-letter name needs 4 loops to return to the starting point.

## NATIONAL MATHEMATICS COMPETITION

## 2nd grade - high school - B variant

## October 26, 2020.