The intervals [0,1/2] and (1/2,1] both have the cardinality of the continuum, so there exists a bijective function from (1/2,1] to [0,1/2]. Define if , and if . Then f takes each value in its range exactly twice.

On the other hand, if you wanted f to be acontinuousfunction, then I guess the answer would be different.