Assume that $(X,d)$ is compact, and that $f: X \to X$ is continuous. Show that the function $g(x) = d(x,f(x))$ is continuous and has a minimum point.
Consider the function $g(x) = d(x,f(x))$. If $g$ is continuous, then $\forall \epsilon >0 \ \exists \delta > 0$ such that $$d(x,y) < \delta \implies d(g(x), g(y)) < \epsilon.$$ Since $f$ is continuous and that $X$ is compact, we have that $f: X \to X$ is uniformly continuous. Therefore, $\forall \epsilon > 0 \ \exists \delta > 0 \ \text{such that} \ d(x,y) < \delta \implies d(f(x),f(y))< \epsilon.$
But how do we go on from here, considering $d(g(x),g(y)) = d(d(x,f(x)),d(y,f(y)))$ gets quite messy?
As noted in the comments, $g: X \rightarrow \mathbb R$. Drawing a picture can be helpful. Since $f$ is continuous, when $x$ and $y$ are close to eachother $f(x)$ and $f(y)$ are close to each other, so $d(x, f(x))$ and $d(y,f(y))$ cannot differ by a large amount. We can formalize an argument as follows, using the triangle inequality, naturally:
$d(x,f(x)) \leq d(f(x), f(y)) + d(x,f(y)) \leq d(f(x), f(y)) + d(x,y) + d(y,f(y)).$
Similarly,
$d(y,f(y))) \leq d(f(x), f(y)) + d(x,y) + d(x,f(x)).$
It follows that
$|d(x,f(x)) - d(y,f(y))| \leq d(f(x), f(y)) + d(x,y).$
Now take $\min(\epsilon, \delta)$ as your $\delta$ (the $\delta$ comes from the uniform continuity of $f$). So $g$ is continuous. Since $X$ is compact, it attains a minimum.