How to construct the set E invoving an almost constant function? Assume that $f$ is a function from $\mathbb{R}$ to $\mathbb{R}$, and for all $h\in \mathbb{R}$, the set $E_h=\{x:f(x+h)-f(x)\neq 0,x\in \mathbb{R}\}$ is a finite set which has no more than 2016 elements.  Prove that there exists a set $E$ which has no more than $1008$ elements, such that $f$ is a constant in $\mathbb{R}\backslash E$.
To solve this problem, I think it needs a keen observation.  What I have thought is first to prove $f(\mathbb{R})$ have no more than 1008 elements, but it is hard for me.  How can I do this?
 A: Let $x_m=min(E_1)+1$ and $x_M=max(E_1)$.
We claim that $f(x)=f(x_m-1)$ for all $x<x_m$. In fact, assume by contradiction that $x<x_m$ and $f(x)\ne f(x_m-1)$. Then $f(x)=f(x-n)$ for all $n\in\Bbb{N}$, since otherwise $f(x-j)\ne f(x-j-1)$ for some $j\in\Bbb{N}_0$ and then $x-j-1\in E_1$, but $x-j-1<x_m-1=min(E_1)$. Similarly $f(x_m-1)=f(x_m-1-n)$ for all $n\in\Bbb{N}$. 
But then  $x-n\in E_h$ for $h=x_m-1-x$ and $n\in \Bbb N$, since
$$
f(x-n)=f(x)\ne f(x_m-1)=f(x_m-1-n)=f(x-n+h),
$$
and this is impossible, since $E_h$ is finite, and so we have proven the claim.
Similarly one proves that $f(x)=f(x_M+1)$ for all $x>x_M$. 
So $f(x)=c$ for $x<x_m$ and $f(x)=C$ for $x>x_M$. But if $c\ne C$, then for $h>x_M-x_m$ we would have infinitely many $x\in E_h$, so $c=C$.
Consequently $f(x)=c$ for all $x$ outside the interval $[x_m,x_M]$. 
Now take $h$ sufficiently big, for example take $h=3(x_M-x_m)$. 
Then $f(x)\ne c$ for some $x\in [x_m,x_M]$, if and only if $x,x-h\in E_h$. Since there are at most 2016 elements in $E_h$, there are at most 1008 elements  $x$ such that $f(x)\ne c$.
A: Observation: If $x\in E_h$ then $x+h\in E_h$. So if $x$ is a member of $E_h$ then at least one of the endpoints of $h$-neighborhood must be in $E_h$. By choosing $h$ appropriately we can have only one of it $h$. So for each $x$ we can associate one of the endpoints. 
Fix $h$. Suppose we enumerate $E_h$ from small to big. That is 
$$
E_h=\{x_1, x_2, \dots x_r  \}
$$
where $x_1<x_2\dots<x_r$. Note that we have $f(x_1+nh)=f(x_1)$ for $x_1+nh<x $ for all $n\in \mathbb{Z}$. 
To understand this, consider the first point on the left of $x_1$ with a distance $h$. Call it $x^\prime$. If $f(x^\prime)\neq f(x_1)$ then $x^\prime \in E_h$ which contradicts with the fact that $x_1$ being minimum of $E_h$. Now take the point, say $x^{\prime\prime}$ on the left of $x^\prime$ with a distance $h$ i.e., so the distance between this point and $x_1$ is $2h$. Similarly, $f(x^\prime)=f(x^{\prime\prime})$, otherwise we have contradiction. Proceeding similar way we have the statement.
Now we claim that for any $x_1<x<x_2$ we have $f(x_1)=f(x)$. If not, then we have $f(x_1)\neq f(x)$. Now, let $\delta=x-x_1$ and note that $\mid\delta \mid <\mid h\mid$. First note any point on the left of $x$ with a distance $nh$ for some $n\in\mathbb{Z}$, it has the same value with $x$. That is, for $x+nh<x$ we have $f(x)=f(x+nh)$. If not, $x_1$ is not minimum of $E_h$ which contradiction.  Consider $E_\delta$ and note that 
$$
f(x_1+nh)=f(x_1) \text{ for all } x_1+nh<x_1 \\
f(x+nh)=f(x) \text{ for all } x+nh<x, \text{ and }\\
f(x)\neq f(x_1)
$$
This implies that we will have countable set of points in the form of $x_1+nh<x_1$ and $x+nh<x$ in $E_\delta$ which contradicts finiteness of $E_\delta$. This implies that $f(x)=f(x_1)$ for all $_1<x< x_2$, which then implies $f(t)=f(x_1)$ for all $t< x_2$.
Repeating these arguments we can see that $f$ is constant on the right hand side of maximum and finally $f$ is constant on $\mathbb{R}\setminus E_h$. Choose $h$ so that you can have Observation satisfied so that $E$ has $\leq 1008$ elements.
