Let $d$ be a metric on $X$ and let $A$ be any arbitrary subset of $X$. Show that the function $f:X\to \mathbb R$ defined by $f(x)=d(x,A)$ is continuous.
Let $p\in X$. We want to show that for any open set $S$ containing $f(p)$, there exists an open neighbourhood of $p$, denoted by $O$, such that $f[O]\subset S$. If $p\in$ int $A$, then there exists an open set $O \subset A$ containing $p$. Clearly $f[O] \subset S$ since $O$ is a subset of $A$ and $f[O]= \{ 0 \}= \{f(p) \} \subset S$. If $p\in \partial A$ (boundary of A) or $p\in$ ext $A$, the situation is much harder. The reason for this being hard is that the function $d$ is not specific and is defined in terms of infimum.