Tech Interview

Box ‘o Numbers

Arrange the numbers 1 to 8 in the grid below such that adjacent numbers are not in adjacent boxes (horizontally, vertically, or diagonally):

       ___
| 1 |
=============
| 6 | 4 | 3 |
=============
| 2 | 7 | 5 |
=============
| 8 |
=====

The arrangement above, for example, is wrong because 3 & 4, 4 & 5, 6 & 7, and 7 & 8 are adjacent.

Solution

The key is putting the 1 & 8 in the center spots – which is required, because those spots both border all but one of the other spots, and 1 & 8 are the only numbers that are only adjacent to one number.

From there, the 2 & 7 are forced, then you have your choice of the next number, which then forces the rest. Really, though there are only two valid solutions, and they are mirror images of each other.

Exit mobile version