Magic Square is a very common-place puzzle requiring some numerical reasoning. I was introduced to it when I was in high-school, one of the first puzzles I encountered. It has been asked on and off in exams. And even CAT has asked a question on it! What the puzzle?

Consider a 3 × 3 grid having 9 cells. You need to fill in each of the numbers 1 to 9, each number being used exactly once, in this grid such that the sum of each of the three rows, the three columns and the two diagonals is the same.

Try it on your own. If you don’t get it, here is hint number 1 ….

Try to find what will be the sum of each row or column or diagonal.

If we add the sum of each of the three rows (or columns), we are effectively adding all the 9 numbers. Thus, the sum of the sum of each of the three rows (or columns) will be  1+2+3+……+9 = Σ9 = 45

⇒ Dividing this 45 equally amongst three rows (or columns), the sum of each row should be 45/3 = 15. Thus the sum of each columns and each diagonal should also be 15.

By the way, if you would like to watch a video instead of read/work through this post, you can watch it here. However I would advise you to continue with this post since it saves time and also allows you to work your way through the puzzle on your own instead of watching it being solved. Continuing ….

Now that we know each row or column or diagonal adds to 15, let’s find how many distinct triplets exist for each of the number such that sum of the triplets is 15.

Consider triplets with 1 i.e. {1, ? , ?} Can you work out how many different possibilities are there such that the sum is 15?

And if this is the case with 1, the smallest number, a similar case should also exist with 9, the highest number. Because the constraints at both the end will be similar. Hopefully you can observe the symmetry while working out {1, ?, ?} and {9, ?, ?}

Repeat this for each of …

{2, ?, ?} and {8, ?, ?}

{3, ?, ?} and {7, ?, ?}

{4, ?, ?} and {6, ?, ?}

And finally {5, ?, ?}

With each of 1, 9, 3 & 7 we have just two triplets adding up to 15

1 + {6 + 8} or 1 + {5 + 9}

9 + {4 + 2} or 9 + {5 + 1}

3 + {5 + 7} or 3 + {4 + 8}

7 + {5 + 3} or 7 + {6 + 2}

With each of 2, 8, 4 & 6 we have just three triplets adding up to 15

2 + {6 + 7} or 2 + {5 + 8} or 2 + {4 + 9}

8 + {4 + 3} or 8 + {5 + 2} or 8 + {6 + 1}

4 + {5 + 6} or 4 + {3 + 8} or 4 + {2 + 9)

6 + {5 + 4} or 6 + {7 + 2} or 6 + {8 + 1}

And with 5, we have four triplets ….

5 + {4 + 6} or 5 + {3 + 7} or 5 + {2 + 8} or 5 + {1 + 9}

Lastly, we need to analyse the cells …. are all the cells in the grid identical? Or are they somewhat different considering their placement in the entire grid?

E.g. consider the centre cell.

The number in the centre cell will be part of how many triplets that add to 15? Thus, which number can be placed in this cell?

This should be a major break-through. Now go ahead and analyse what other types of cells exist and of how many triplets adding to 15, will they be a part of?

Since the central cell has to be part of 4 triplets … the middle row, the middle column and each of the two diagonals …

…..the only number that has 4 triplets adding to 15 i.e. 5 …. only 5 can be placed in the centre cell.

Since each of the corner cells is part of three triplets …

… the numbers 2, 8, 4 & 6 have to be in the four corners …

Lastly, since each of the shaded cell in image below is a part of just two triplets …

the numbers 1, 9, 3 & 7 have to be in these 4 cells.

Having mapped the possible numbers to the possible cells, all one needs is to make a start … if there are multiple possibilities, for a cell or number, just choose one and proceed … and you will see that entire grid can be filled very easily. Go through the following video to realise how the seemingly many ways to fill the grid is just a reflection or rotation of the same one way … the relative positions of the numbers remain the same in all the possible way, just the perspective/orientation changes. But before watching the video, finish filling the grid in at least one way all by yourself.

Now this CAT question from CAT 2017, slot 2 should be a no-brainer.

The numbers 1, 2, 3, …, 9 are arranged in a 3 × 3 square grid in such a way that each number occurs once and the entries along each column, each row, and each of the two diagonals add up to the same value. If the top left and the top right entries of the grid are 6 and 2, respectively, then the bottom middle entry is: [TITA]

Follow-up question:

Fill each of 9 consecutive odd numbers in the 9 cells of a 3×3 grid, each number being used exactly once, such that the sum of each of the three rows, the three columns and the two diagonals is 75.

Trivia

There is a 4×4 magic square i.e. filling numbers 1 to 16 in a 4×4 grid which is far more interesting than the above. I came across it in Dan Brown’s book The Lost Symbol (which also has an interesting trivia about phi, φ, the golden ratio). This magic square is more magical because a lot more than just rows, columns and diagonals add to the same sum.

16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1

In addition to all the 4 rows, all the 4 columns and the 2 diagonals, the following also add up to the same 34 …

All the 4 quadrants i.e. 2×2 grid at upper-left, upper-right, lower-left, lower-right corners.

The 2×2 grid at the centre also add up to 34.

And the 4 cells at the corners, they too add to 34 !!!