Suppose $f$ is continuous on $[0,2]$ and $f(0) = f(2)$. For which $a\in(0,2)$ must there exist $x,y\in[0,2]$ so that $|y − x| = a$ and $f(x) = f(y)$?

The answer is $a \in \{\frac 2 n|n\gt 1\}$ .

Proof: Take some $a \in \{\frac 2 n|n\gt 1\}$ and suppose for purposes of contradiction that $f$ is continuous on $[0,2]$ with $f(0)=f(2)$ but there are no $x, y \in [0,2]$ such that $|x-y|=a$ and $f(x)=f(y)$.

Consider the function $g(x)=f(x+a)-f(x)$ which is well defined on $[0,2-a]$ .

Then $g(x) \neq 0$ throughout $[0,2-a]$ and due to the intermediate value theorem it must either be positive throughout $[0,2-a]$ or negative throughout $[0,2-a]$.

If $g(x)\gt0$ then $f(0)\lt f(a)\lt f(2a) …\lt f(n a)=f(2)$ which contradicts the condition $f(0)=f(2)$ . Similarly if $g(x)\lt0$ then $f(0)\gt f(a)\gt f(2a) …\gt f(n a)=f(2)$ .

So no such function $f$ can exist if $a=\frac2 n$ .

On the other hand suppose $a \not \in \{\frac 2 n|n\gt 1\}$ . To show the condition need not be satisfied in this case define $f(x) = \cos(\frac{2\pi x} a) +\frac x 2(1-\cos(\frac {4\pi} a))$

Then if $|x-y|=a$ , $\cos(\frac{2\pi x} a)=\cos(\frac{2\pi y}a)$ and $|f(x)-f(y)|=\frac a 2(1-\cos(\frac{4\pi} a) ) \ne 0$, since $\cos(\frac{4\pi} a)\ne1$

But $f(2)=\cos(\frac{4\pi} a) + (1-\cos(\frac{4\pi} a))=1=f(0)$ so $f$ is a counterexample