4. Arrange the digits $1,2,3,4,5,6,7,8$ to form two 4-digit integers whose difference is as small as possible.
Explain clearly why your arrangement achieves the smallest possible difference.
Solution
Let the two numbers be 'abcd' and 'e $\mathrm{g} h$ ', with the smaller being 'abcd'.
For a difference of less than 1000 ,
$$
e=a+1,
$$
so that the two 4-digit numbers are in consecutive thousands. All other choices have a difference of more than 1000 .

For 'efgh' to be as little above ' $e 000$ ' as possible, we use 1,2 and 3 for $f, g$ and $h$ respectively. Similarly, for ' $a b c d$ ' to be as close as possible to, but below, ' $e 000$ ' we use 8,7 and 6 for $b, c$ and $d$ respectively.

This leaves 4 and 5 , which satisfy $(*)$, to be the values of $a$ and $e$ respectively.
Therefore the smallest difference comes from $5123-4876$, which is 247 .