# combinations of a strange magic square

The following question has been described to me by my math teacher:

The diagram below is to be filled in so that each white square contains a different whole number from 1 to 12 (inclusive) and the four numbers in the squares along each edge have the same total.

The question is:

In how many different ways can this be done correctly???

Let's start by filling out the gaps in the grid with letters to make it easier to describe:

.----.---.---.---.
| 5  | y | 3 | x |
:----+---+---+---:
| a  |   |   | c |
:----+---+---+---:
| b  |   |   | d |
:----+---+---+---:
| 12 | p | q | 6 |
'----'---'---'---'


The sum of all the numbers in the grid must be 4n - (5 + 6 + 12 + x), where n is the sum of each edge, and x is the missing corner number. This is because the numbers in the corners are counted twice each when summing the edges. As we know the grid is filled by the numbers 1 to 12 inclusive, we know that this is equal to 78: 78 = 4n - (5 + 6 + 12 + x).

We now need to find x. Rearranging, we get 78 + (5 + 6 + 12 + x) = 4n, so 101 + x must be divisible by 4. As 3 has already been used in the grid, we are left with the possibilities of 7 or 11.

If x = 7, n = 27, so y in our diagram must be equal to 8. Looking now at the left column, the only remaining pair of numbers that sum to 10 for a and b are 1 and 9. Moving to the right column, c and d need to sum to 14. The only pair of numbers that fulfils this requirement is 4 and 10. Finally, looking at p and q on the bottom row, we need these two numbers to sum to 9, however the only numbers remaining are 2 and 11. We can therefore exclude the possibility that x = 7.

We now know that x must equal 11. This means that n = 28, so y = 9. Looking at the bottom row, we need p + q = 10. The only free pair of numbers which fulfils this is 2 and 8. Moving on to the left-hand column, we require a + b = 11. The remaining possibilities are 1 and 10, or 4 and 7. Finally, we look at the right-hand column - we again need c + d = 11. The only solution remaining is the pair of numbers that weren't used to fill a and b.

The number of correct solutions, therefore, assuming we fill the numbers in in that order, is the number of choices for p, multiplied by the number of choices for a, multiplied by the number of choices for c. This is equal to 2 x 4 x 2 = 16.