I have the following problem:
Let $f:\{0, 1, 2, 3, 4, 5\} \rightarrow \{0, 1, 2\}$ a function. Prove that exists $g:\{0, 1, 2, 3, 4, 5\} \rightarrow \{0, 1, 2\}$, such that $g(i) \neq g(i +1)$, $g(i) \neq f(i)$ with $i \in \{0, 1, 2, 3, 4, 5\}$ and $g(0)\neq g(5)$.
My attempt:
Let $g:\{0, 1, 2, 3, 4, 5\} \rightarrow \{0, 1, 2\}$ be a function that satifies that $g(i) \neq f(i)$ for all $i \in \{0, 1, 2, 3, 4, 5\}$. Now, we execute the following algorithm $M$, in order to "fix" the function:
Set $i = 0$. (Remember that $i \in \mathbb{Z_{6}})$.
Repeat the following procedure, while $g(j) = g(j+1)$ for some $j \in \mathbb{Z_{6}}$:
If $g(i) = g(i+1)$, then $g(i+1) = a$ with $a \in \{0, 1, 2\} \setminus \{g(i), f(i+1)\}$.
Set $i = i + 1$
Now, let's introduce a definition:
We say that the $n$ - jump of $i$ is equal to the absolute value of the difference between $g(i)$ and $g(i+1)$.
It's trivial to prove that the preceding algorithm $M$ is able to "fix" in the first six iterations, the functions that only have $2$ - jumps, or only have $1$ - jumps, due to the parity of the elements of the domain.
Now, consider the functions that combines $2$ - jumps and $1$ - jumps. If we execute $M$ over $g$, and we complete the first six iterations, we have two cases:
$g(5) \neq g(0)$, so we are done, since for the construction of the algorithm, we can be sure that the condition $g(i) \neq g(i +1)$ for all $i \in \mathbb{Z_{6}}$ is satisfied.
$g(5) = g(0)$, this is the case which I am stuck since we would have to consider more than $2^{8}$ cases. Do you have any ideas?
Hope you can help me, thanks! :)