Discontinuous at infinitely many points While doing a worksheet on real analysis I came across the following problem.
$Q$. Let $f$ be a function defined on $[0,1]$ with the following property.
For every $y \in R$, either there is no $x$ in $[0,1]$ for which $f(x)=y$ or there are exactly two values of $x$ in $[0,1]$ for which $f(x)=y$.
(a) Prove that $f$ cannot be continuous on $[0,1]$.
(b) Construct a function $f$ which has the above property.
(c) Prove that any such function with this property has infinitely many discontinuous on $[0,1]$.
I really have absolutely no idea how to solve the problem. Even constructing the function is proving pretty difficult. Any help would be appreciated asap.

For a fairly simple concrete example for (b), for $a<b$ let 
$$f_{a,b}:(a,b]\to\Bbb R:x\mapsto\begin{cases}
x-a,&\text{if }a<x\le\frac12(a+b)\\
\frac12(b-a)-x,&\text{if }\frac12(a+b)\le x\le b\;.
\end{cases}$$
The graph consists of the straight line segment of slope $1$ from $\langle a,0\rangle$ to $\left\langle\frac12(a+b),\frac12(b-a)\right\rangle$ and the straight line segment of slope $-1$ from there to $\langle b,0\rangle$, not including the point $\langle a,0\rangle$.
Let $g_0=f_{\frac12,1}$, $g_1=f_{\frac14,\frac12}+\frac14$, $g_2=f_{\frac18,\frac14}+\frac38$, and in general let
$$g_n=f_{2^{-(n+1)},2^{-n}}+\frac12-\frac1{2^{n+1}}$$
for $n\in\Bbb N$. Finally, let
$$g:[0,1]\to[0,1]:x\mapsto\begin{cases}
g_n(x),&\text{if }2^{-(n+1)}<x\le 2^{-n}\\
0,&\text{if }x=0\;;
\end{cases}$$
then $g$ has the desired property and is discontinuous precisely at the points $x=2^{-n}$ for $n\in\Bbb Z^+$ and $x=0$. Here is a rough sketch of part of $g$:

