A somewhat pathological function For educational purposes, I need a function $f:\Bbb R\to \Bbb R$ that meets the following properties, or a proof that it doesn't exist:


*

*Continuous.

*For every $x\in\Bbb R$, $f^{-1}(\{x\})$ is infinite and bounded.


I have been thinking on the problem for a while, and intuition tells me that such a function doesn't exist, but I'm not sure where to begin to find a proof.
Hints for a proof or a counterexample (or a reference for it) are welcome.
 A: Let $h: [0,1]\to [0,1]\times [0,1]$ be a surjective continuous function such that $h(0)=(0,0)$, $h(1)=(1,1)$. Extend this function to a map 
$$
H: {\mathbb R}\to {\mathbb R}^2
$$
so that 
$$
H(t+ n)= H(t) + (n,n)
$$
for every $n\in {\mathbb Z}, t\in {\mathbb R}$. Lastly, take $f$ to the the composition of $H$ with the coordinate projection to the $y$-axis.  
A: First define $f(x)$ for $x\in [0,1]$ as follow: Take  a continuous surjection $g:[0,1]\to [0,1]\times [0,1]$ with $g(0)=(0,0)$ and $g(1)=(1,1).$ Let $p_1(x,y)=x$ for $(x,y)\in [0,1]\times [0,1].$ Let  $f(x)=p_1(g(x))$ for $x\in [0,1].$ 
For $x\in [0,1]$  each member of $g^{-1}(\{x\}\times [0,1])$ belongs to $f^{-1}\{x\}.$  Now $g$ is a surjection; therefore the cardinal of $f^{-1}\{x\}$ is the cardinal of $\Bbb R.$ 
For $x\in \Bbb R$ let $[x]$ denote the largest integer not exceeding $x$ (an older notation for Floor$(x)$.) 
Now for any $x\in \Bbb R$ define $f(x)=[x]+f(x-[x]).$
Reference topics for the function $g$: Space-filling curve, Peano curve.
A: This is one of those questions where probability theory can give you a great intuition on how to explicitly construct such a function.
Consider a two-sided Brownian motion $(B_x)_{x\in \Bbb R}$, and then let $f(x)=B_x+x$.
I claim that with probability $1$, the function $f$ has the two properties you want. It is trivially continuous. Moreover the strong law of large numbers shows that $$\lim_{|x| \to \infty}\frac{f(x)}{x}=1,\;\;\;\;\;a.s.$$ which easily implies that $f^{-1}(\{a\})$ is bounded and nonempty for any $a \in \Bbb R.$ Furthermore, using a time-inversion property together with the strong Markov property and the fact that Brownian motion returns to $0$ unboundedly often, one can show that $f^{-1}(\{a\})$ is infinite (in fact, uncountable) for any $a \in \Bbb R$.
