Let $S$ be a subset of $\{1,2,3,\ldots,1989\}$ such that no two members of $S$ differ by $4$ or $7$. What is the largest number of elements $S$ can have?
In any $11$ consecutive integers, at most $5$ can be chosen: arrange them in the cycle $x,x+4,x+8,x+1,x+5,x+9,x+2,x+6,x+10,x+3,x+7$, where neighbors differ by $4$ or $7$; no two neighbors can both be chosen in an $11$-cycle.
$\{1,4,6,7,9\}$ works within each block of $11$, and repeating it with period $11$ works throughout. Since $1989=11\cdot180+9$ and the last $9$ numbers can still contain $5$ of them ($1,4,6,7,9$):
Let $S$ be a subset of $\{1,2,3,\ldots,2024\}$ such that no two members of $S$ differ by $5$ or $8$. What is the largest number of elements $S$ can have?