Proving such a function is always constant Let $I \subset R$ be an interval. Let $f : I \to R$ be a continuous function.
Assume that $I := [a, b]$. Assume that for all $c, d \in [a, b]$ such that $c < d$, there exists $e \in [c,d]$ such that $f(e) = f(a)$ or $f(e) = f(b)$. Prove that $f$ is a constant.
Consider this statement: For all $c \in [a,b], f(c) \in \{f(a),f(b)\}$
I figured that proving this statement would allow me to prove the function to be constant, but I'm unable to do so. Any thoughts?

You need to use intermediate value property of continuous functions.
Suppose $f(a) =f(b) $. If $f$ is not constant in $[a, b] $ then there is some value of $f$ which differs from $f(a) =f(b) $ and let's suppose this value $f(c) > f(a) $ (the case $f(c) <f(a) $ is handled in a similar manner). By continuity there is an interval of type $[c-\delta, c+\delta] $ where all values of $f$ are greater than $f(a) $. And this contradicts the given hypotheses. Thus $f$ must be a constant function.
The case when $f(a) \neq f(b) $ leads us to a contradiction as shown next. Let's us assume $f(a) <f(b) $ and choose $k$ such that $f(a) <k<f(b) $. By intermediate value property there is a $c\in(a, b) $ for which $f(c) =k$. And by continuity there is an interval of type $[c-\delta, c+\delta] $ where all values of $f$ lie strictly between $f(a)$ and $f(b) $. This contradiction shows that we must have $f(a) =f(b) $ and as shown earlier the function is constant. 
