Word problem - set up linear equation Four friends, Andrew, Bob, Chris and David, all have different heights. The sum of their heights is 670 cm.
Andrew is 8cm taller than Chris and Bob is 4cm shorter than David.
The sum of the heights of the tallest and shortest of the friends is 2cm more than the sum of the heights of the other two.
Find the height of each friend.

You are given that $$\begin{cases}A=C+8\\B=D-4\\A+B+C+D=670\\A\neq B\neq C\neq D\end{cases}$$ Substituting the first two in the third you obtain $$C+D=333$$ therefore
$$\begin{cases}A=C+8\\B=329-C\\D=333-C\\A\neq B\neq C\neq D\end{cases}$$
Now compare the sums by pairs to check which pairs satisfy the condition in the second to last sentence (i.e. that sums differ by 2): $$A+B=337 \qquad \text{ vs } \qquad C+D=333 \qquad 337-333=4\neq2\text{ no }$$ $$A+D=341 \qquad \text{ vs } \qquad B+C=329 \qquad 341-329=12\neq2\text{ no }$$ So, since $A>C$ the only possibility is that $A$ is the tallest and $D$ the shortest  $$A+C=2C+8 \qquad \text{ vs } \qquad B+D=662-2C \qquad \text{ yes }$$ which gives $$2C+8=662-2C+2 \implies 4C=656 \implies C=164$$
