TITLE: What's the size of the biggest set of numbers from 1 to 100 so that no number is the average of any other two?
QUESTION [8 upvotes]: John wants to build a set of numbers, from the range of 1 to 100. The only rule is that in that set no number can be the average of any other two. For example, if the set contains the numbers 1 and 3, then 2 cannot be present. What’s the size of the biggest set that John can build?
More precisely, if L is "John's set", then
$$ \forall x,y,z \in L : z \ne \frac{x+y}{2} $$ and
$$ \forall x \in L : 1 \leq x \leq 100$$
We want to find the cardinality of L.

PS: This problem appeared on a Sunday newspaper many years ago. On the following week they published a solution that was wrong. I was able to solve it computationally but never mathematically.

REPLY [8 votes]: You can solve the problem via integer linear programming as follows. Let $n=100$.  For $i\in\{1,\dots,n\}$, let binary decision variable $x_i$ indicate whether $i\in L$.  The problem is to maximize $\sum_{i=1}^n x_i$ subject to
$$x_i + x_{i+d} + x_{i+2d} \le 2 \quad \text{for $i\in\{1,\dots,n-2\}$ and $d\in\{1,\dots,\lfloor(n-i)/2\rfloor\}$}.$$
The optimal objective value turns out to be $27$, attained by
$$L=\{1,5,7,10,11,14,16,24,26,29,30,33,35,39,66,70,72,75,76,79,81,89,91,94,95,98,100\}.$$
See https://oeis.org/A003002 for more terms.  Such a set is called a Salem-Spencer set, and asymptotic bounds are known for the largest cardinality.