## Task 3 - 230723

Blue, yellow, and red cubes are to be placed in a row. The first cube in the row should be blue, the second should be yellow. In the row, no two cubes of the same color should be next to each other, and the color sequence of any two adjacent cubes should never be repeated. Determine the maximum possible number of cubes in a row that meets all these conditions! Provide at least one example of such a row with the maximum number of cubes and show that there cannot be such a row with more cubes!
I) If $b, g$ and $r$ denote a blue, yellow, and red cube, respectively, the following examples show that there are sequences of 7 cubes that meet all the given conditions:

$$
b, g, b, r, g, r, b ; \quad b, g, r, b, r, g, b ; \quad b, g, r, g, b, r, b
$$

II) If $w_{1}, w_{2}, w_{3}, \ldots, w_{8}, \ldots$ is a sequence of 8 or more cubes, then the 7 color sequences $\left(w_{1}, w_{2}\right),\left(w_{2}, w_{3}\right), \ldots,\left(w_{7}, w_{8}\right)$ occur within it.

For the three different colors $b, g, r$, there are only the following 6 different color sequences: $(b, g)$, $(b, r)$, $(g, b)$, $(g, r)$, $(r, b)$, $(r, g)$. This means that in a sequence of 8 or more cubes (without adjacent cubes of the same color), at least one color sequence must occur twice, which contradicts the given conditions.

From I) and II), it follows that 7 is the maximum number of cubes in a sequence of the required type.