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.

To construct a function satisfying your condition, we first construct such a function $f$ on $\Bbb R$. 

Decompose $\Bbb R$ into union of $[n,n+1)$, construct a function $f$ whose restriction $f_n:[n,n+1)\to[n,n+1)$ is defined by
  $$\begin{align}
f_n(x) &= x\quad\text{;}\quad n\le x<n+\frac 12 \\
&= x-\frac 12\quad\text{;}\quad n+\frac 12 \le x <n+1
\end{align}$$
  It is not hard to verify that $f$ has the property you want (but the domain is $\Bbb R$, however). Now get any homeomorphism $h:\Bbb R\to (0,1)$ and compose it with $f$. 

The function $\bar f:[0,1]\to \Bbb R$ satisfying the condition is construct by assigning any number not in $\mathcal R(f)$ to the image of $\bar f(0)=\bar f(1) $ and
$$\bar f:=h\circ f$$
otherwise. For the sake of completeness, you can let $h=\frac 1{1+e^{x}}$.
To prove $(c)$ see Mr. Anubhav's answer.
