# Construction of a function with fibers

Could someone tell me if there exists a continuous and surjective function $f:\mathbb{R} \to \mathbb{R}$ such that $$\# \{f^{-1}(\left\{y\right\})\} = 3$$ for all $y \in \mathbb{R}$?

-

Consider $$f(x) = \sin(x \left(\bmod {3 \pi/2} \right)) - \left \lfloor\dfrac{2x}{3 \pi} \right \rfloor$$
The plot was made using mathematica $8$.
This shows it can be done. I wonder if there's a nice choice of $k$ for which $f(x)=cos(x)+kx$ would work. I tried with $k=2/3\pi$ and it looked nearly OK on my small screen graphing calculator, making me think there might be an exact choice of $k$ making it work. +1. –  coffeemath Nov 30 '12 at 11:59