What method can be used to solve a magic square problem without just guessing?

The problem is as follows:

Fill out the empty boxes of the figure from below by writing an integer number on each of them such in a way that by summing three numbers which are in the same row, column or diagonal we can obtain always the same sum. From this which is the number which will occupy the square with orange shade?

The figure is shown below: • 17

• 11

• 18

• 10

• 19

I tried different methods by plugin numbers randomly but at no avail. I also read the article at Wikipedia about magic square and calculating the magic constant but this has not helped me at all.

Therefore I couldn't get to an answer to this, so I was hoping somebody could tell me if there is an algorithm or method that is proven to work to solve these problem without just "guessing".

Please, try to use the most details as possible as I'm not good at using imagination. Do not just fill out the drawing and say that's it. This is not what I'm looking for.

So can somebody help me to get an answer to this problem the most detailed way possible?

• The Wikipedia article assumes that the numbers in a square of side $n$ are from $1$ to $n^2$. You can calculate the magic constant from that, but it doesn't help here because your numbers are not contiguous. – Ross Millikan Apr 7 '18 at 14:53
• @RossMillikan Interesting I wasn't even aware of that. So I end up at the starting point. It looks that the magic constant doesn't offer much help for solving these problems. – Chris Steinbeck Bell Apr 7 '18 at 15:08
• If you knew the constant for your square the problem would be trivial. The challenge is to derive it. saulspatz has given a good strategy which will work any time you start with three known cells in a $3 \times 3$ grid, two of which are in a row. – Ross Millikan Apr 7 '18 at 15:12
• @RossMillikan Sorry if I say this but I'm slow at making pictures in my brain from ideas of others. Why it would be trivial?. Does it mean that knowing less numbers would had rendered the problem not being solved by that strategy?. Out of curiosity. Does a magic square can offer many solutions or none at all a-la solving a system of equations?. – Chris Steinbeck Bell Apr 7 '18 at 15:43

I'm adding this answer borrowing @saulspatz suggestions If somebody like me is also struggling with these kinds of questions.

So I'll try to do step-by-step solution:

Initially we have this diagram and it can be seen that there is a constant to be added to a number $x$, thus we label to the orange shade square that variable.

From the first column it is known that the resulting sum is $x+15$

See figure from below:

Therefore in the first row we have to fill out the blank space with something so that by summed with $x$ we also get that previous $x+15$.

Since I cannot do it mentally I'll add an additional variable named $a$ as an aid for doing this momentary computation. But it can be omitted if desired.

so:

$$x+3+a=x+15$$ $$a=15-3$$ $$a=12$$

See figures 1 and figure 2.

To get the diagonal we know already that we have:

$$12+10=22$$

To get $x+15$ I'll use again that auxiliary variable to fill out the blank space in terms of $\textrm{x+something}$

$$a+22=x+15$$ $$a=x-7$$

This is indicated in figure 3 and figure 4.

We continue the process by filling up the remaining spaces:

For the second row, third column blank space I used again that auxiliary variable.

$$x-7+5+a=x+15$$

$$a=17$$

For this you can see it how it was filled in figure 5 and figure 6.

For the third row, second column the blank space is filled as follows:

$$3+x-7+a=x+15$$

$$a=19$$

This is seen in figure 7 and figure 8

Finally all that is left to do is fill out the last blank space, third row, third column:

$$12+17+a=x+15$$

$$a=x+3-17$$

$$a=x-14$$

And this is seen in figure 9 and figure 10.

At this point we can calculate the sum by equating the diagonals from both directions, from northwest to southeast with the diagonal from northeast to southwest.

See figure 11

$$x+x-7+x-14=12+10+x-7$$

$$2x-14=22$$

$$2x=36$$

$$x=18$$

Therefore by replacing in the figure we get to:

Since all the sums check:

$$18+3+12=15+18=33$$

$$5+11+17=16+17=33$$

$$10+19+4=29+4=33$$

$$18+5+10=23+10=33$$

$$3+11+19=14+19=33$$

$$12+17+4=12+21=33$$

Then both diagonals

$$18+11+4=29+4=33$$

$$12+11+10=12+21=33$$

So the number must be $18$

See figure 12 for details.

So that's it. This process as mentioned in the comments seems a good strategy when the problem is stated this way, hope it can help others as well.

Suppose you put $x$ in the orange square. Then adding up the numbers in the first column gives a square constant of $x+15$. To make the first row work, the number in the upper right-hand corner must be $12.$ Now to compute the northeast-southwest diagonal we may proceed this way. We know two number in the diagonal already, $10$ and $12$. Suppose the central number is $y$ so that the sum of the diagonal elements is $22+y$. This must be equal to the square constant so $22+y=x+15$ and $y=x-7$. That is, the central number is $x-7$.

Now you can figure out all the remaining squares. Eventually you will get an equation you can solve for $x$ because you can compute the value in a square from the sum of the row elements or the sum of the column elements, and these numbers must be the same.

Go for it!

• Why the "northeast-southwest" diagonal the center square must be $x-7$ Is it because $10+12-15=7$ so that is the number that is off from $x$? By trying on my own I've found that I can put $17$ in the second square from the third column, $x-14$ the third square from that third column and $19$ in the third square from the second column. From this I assumed that the diagonal of the square going from northwest to southeast is $3x-21$ and this equated to the other diagonal $x+15$ makes $x=18$. Not sure if this is what goes along your method. – Chris Steinbeck Bell Apr 7 '18 at 15:39
• I added some more details to my answer. – saulspatz Apr 7 '18 at 15:48
• Funny thing is the same letter you used is what I did in my sketchbook but it looks that I followed your procedure and got to the answer. Do you mind if I borrow your ideas?. I am adding how I got to the solution by following your directions. Out of curiosity I wonder if this method would had worked if let's say the "third number" would had been in the same column of the other two?. Is there a way for such these problems cannot have a solution or many solutions?. Can you enlighten me with that?. – Chris Steinbeck Bell Apr 7 '18 at 16:00
• @ChrisSteinbeckBell: If you had three numbers in a row you would know the constant. Say you start with a square with $1,2,3$ down the left column. You know the constant is $6$. You can put $x$ in the top center and $5-x$ in the top right. Then the center gets $x-2$ and we keep going. I haven't finished, but you should. I believe you will find $x$. – Ross Millikan Apr 7 '18 at 16:07
• @RossMillikan Thanks for that, but when can say that a magic square cannot be solved or that many solutions can fit?. By the way from your last comment I tried to follow that and I found that $x=4$. I don't know if this can be done mentally but I had to use paint as an aid for calculations. – Chris Steinbeck Bell Apr 7 '18 at 16:54