Continuous function f such that its inverse takes exactly two values in R except at three points. Let $f:\mathbb{R} \to [1,3]$ be a continuous function such that $f^{-1}(1)$ and $f^{-1}(3)$ are singletons  and $f^{-1}(x)$  consists of exactly two real numbers $\forall x\in (1,2) \cup (2,3)$.Then prove that the cardinality  of $f^{-1}(2)$ is either 1 or uncountable.
I am able to define a function $f(x)$ for the case when $f^{-1}(2)$ is uncountable as shown below :
Let $A(-3,2)\,,B(-2,3)\,,C(1,1)\,,D(3,2)$ be four points. 
The function $f(x)=\begin{cases}
2&amp;,x\le -3 \\
\text{line}\,\, AB&amp;,-3\le x \le -2\\
\text{line}\,\, BC&amp;,-2\le x \le 1\\
\text{line} \,\,CD&amp;,1\le x \le 3\\
2&amp;,x\ge 3
\end{cases}$\
For the function $f$, the pre image of 2 is uncountable.
I am not able to draw a graph for the case $f^{-1}(2)$ is singleton.Help please.And how do we prove the two cases analytically ? Thank you for the help.
For the case $f^{-1}(2)$ singleton you could create a graph that goes:

as $x \to -\infty$, $f(x) \to 2+$

as $x \to +\infty$, $f(x) \to 2-$

$f(-1) = 3$

$f(1) = 1$

$f(0) = 2$

and then join it up with a smooth line. As $x$ increases, it goes up from just above $2$ till $3$, then it goes down through $2$ to $1$, and then goes up again slowly till just below $2$.

Is that the sort of thing you had in mind?
For the case $f^{-1}(2)$ singleton you could create a graph that goes:

as $x \to -\infty$, $f(x) \to 2+$

as $x \to +\infty$, $f(x) \to 2-$

$f(-1) = 3$

$f(1) = 1$

$f(0) = 2$

and then join it up with a smooth line. As $x$ increases, it goes up from just above $2$ till $3$, then it goes down through $2$ to $1$, and then goes up again slowly till just below $2$.

Is that the sort of thing you had in mind?