Functions from $\mathbb{R}^{n}$ to $[0,1]$.

There's a question on which I am really stuck, but probably the answer might be very easy. Here is the statement. Consider ($\mathbb{R}^{n},d)$ [where $d$ is the Euclidean metric]. Let $x_{1}$ and $x_{2}$ be two distinct vectors in $\mathbb{R}^{n}$. The question is to show that there's a continuous map $f:\mathbb{R}^{n} \to [0,1]$ (with the absolute value metric) such that $f(x_{1})=0$ and $f(x_{2})=1$. Any hint?

• Use a scaling operation to make $x_1$ and $x_2$ a distance of $1$ away from each other and then rotate the line between them to line up with the $x$ axis. Then contract the space down to the $x$ axis. By the $x$ axis I mean the $x_1$ out of $x_1 ... x_n$. – John Douma Sep 12 '15 at 3:02

Let $r = d(x_1, x_2)$. Then set $$f(x) = \begin{cases} 1 - \frac{2d(x,x_2)}{r} \quad (d(x,x_2) < \frac{r}{2}) \\ 0 \quad \text{otherwise} \end{cases}$$ This works in arbitrary metric spaces.
$$f(x)=\frac{d(x,x_1)}{d(x,x_1)+d(x,x_2)}.$$
This also works in general metric spaces, and also works if $x_1$ and $x_2$ are replaced with closed disjoint sets. This is called a Urysohn Function.