Find all continuous function from $(\mathbb{R},d_{2})$ to $(\mathbb{R},d_{disc})$ and all continuous function other way around

The set of real numbers is equipped with two metrics: the standard metric $d_{2}(x,y)=|x-y|$ and discrete metrics $d_{disc}(x,y)=1$ if $x\neq y$ and $d_{disc}(x,y)=0$ if $x= y$. I have to find all continuous function from $(\mathbb{R},d_{2})$ to $(\mathbb{R},d_{disc})$ and also all continuous function from $(\mathbb{R},d_{disc})$ to $(\mathbb{R},d_{2})$.

I do not know how to even start with solving this. Any help?


$f:(\mathbb{R}, d_{disc}) \rightarrow (\mathbb{R}, d_2)$

Then you can show $f$ is continuous.

(If the domain is endowed with a discerte metric then any function defined on that domain must be continuous irrespective of the target metric space)

Proof : 1) Choose any open set $U\in \tau(d_2) $ , then $$f^{-1}(U)\subset \Bbb{R}$$

And, $\tau(d_{disc}) ={\scr{P}}(\Bbb{R})$

In other words, every subset of $\Bbb{R}$ in the discrete metric is open (also closed) .

Hence, $$f^{-1}(U)\in \tau(d_{disc})$$

So, any function $f:(\mathbb{R}, d_{disc}) \rightarrow (\mathbb{R}, d_2)$ is continuous.

Now, in other direction, $f:(\mathbb{R}, d_2) \rightarrow (\mathbb{R}, d_{disc})$ is continuous then $f(\Bbb{R})$ being continuous image of connected set must be connected in the space $(\mathbb{R}, d_{disc})$ .

And we know only connected subsets of $(\mathbb{R}, d_{disc})$ are all one point sets.

(Check: If more than one point is included then you can able to find a non-trivial proper clopen (both open and closed) subset)

Hence, $f(\Bbb{R}) ={c} , $ for some $c\in \Bbb{R}$

Hence, $f$ is a constant function.