# Sum of rows and columns.

In the puzzle, each square is to contain a digit from one to nine. No digit can appear twice in the same row or column. The sums of each row and column are given. Find one of the two solutions.

In this question, the puzzles is

The numbers are the sum of each row and column. Is there any specific way to approach this?

You can start of generally by looking at the row with the highest number and the column with the highest number. Row sum = 21 and column sum = 24. This cell where they intersect should contain the largest number. From there pick another cell in the row or column and work backwards. This is a general approach on how to start.

The immediate way to start is to note that

There is only one way to make 7 from three unique digits, and similarly there is also only one way to make 24.

Thus,

The second and third columns are some permutation of 789 and 124, respectively.

Then,

to make the 10 across in the top row, we have to start with both the 7 and the 1, which leaves us with a 2 in the top left. Using the 8 in the middle column would force 181, which doubles a number. Using the 2 in the third column will cause problems when we try to use the 1 in the second row (we'll need the 4 for the bottom row, see below) because that will leave us with 18 to go, forcing 991, doubling a number again.)

Similarly,

the 4 is required as part of the 21 on the bottom line, because that's the only number that leaves us a small enough remainder to be made up by 2 single-digit numbers (8+9); then we can use either the 8 or the 9 in the middle column, which gives us our two possible solutions.

Filling in the last square is then obvious, and we end up with

271
982
894

or

271
892
984

• your "Similarly" statement has a flaw in it. MUST be isn't accurate – Jason V Jul 26 '17 at 17:30
• @Jason should be fully accurate now. :-) – Hellion Jul 26 '17 at 18:05
• much better:) and now you have BOTH solutions:) – Jason V Jul 26 '17 at 18:07

I think Hellion has the right approach for a puzzle like this. This instance is certainly simple enough to do more or less by inspection. However, since the OP was asking for an approach, I thought a more analytical one might be worth looking at. And as I worked through it, it became clear that there are some interesting characteristics here that may be entertaining.

First, let's set four variables, $a$, $b$, $c$, and $d$, which is enough to establish the whole matrix.

$$\left(\begin{array}{ccc} a & b & 10-a-b \\ c & d & 19-c-d \\ 19-a-c & 24-b-d & a+b+c+d-22 \end{array}\right)$$

The bottom right cell can be calculated two ways, and obviously these should yield the same result. This is the equivalent of saying that the sum of the row-sums should be the same as the sum of the column-sums (which I checked before I did anything else).

Now, we can set up a bunch of inequalities, since we know that all these numbers are between 1 and 9. The thing that turns out to be interesting (spoiler alert) is that the inequalities can be gradually refined by adding them together and stuff.

Start with all the cells being between 1 and 9, and rearrange into a more readable format.

$$\begin{array}{cccccccc} 10 & \leq & +a & & +c & & \leq & 18 \\ 15 & \leq & & +b & & +d & \leq & 23 \\ 1 & \leq & +a & +b & & & \leq & 9 \\ 10 & \leq & & & +c & +d & \leq & 18 \\ 23 & \leq & +a & +b & +c & +d & \leq & 31 \\ \end{array}$$

There are now refinements we are able to make. Firstly, the lack of repeated numbers in a row or column means that we can say that the maximum sum of two elements should be 17, rather than 18, and the minimum sum with similar logic is 2. Hence

$$\begin{array}{cccccccc} 10 & \leq & +a & & +c & & \leq & 17 \\ 15 & \leq & & +b & & +d & \leq & 23 \\ 2 & \leq & +a & +b & & & \leq & 9 \\ 10 & \leq & & & +c & +d & \leq & 17 \\ 23 & \leq & +a & +b & +c & +d & \leq & 31 \\ \end{array}$$

Also, we can do an operation where we mix equations in various ways and then keep the tightest option. I'll spell out the first few operations.

Add the first and second inequalities, and add the third and fourth inequalities. These, along with the existing fifth inequality, give various expressions for $a+b+c+d$, and we can keep the tightest of these.

$$\begin{array}{rccccccc} 25 & \leq & +a & +b & +c & +d & \leq & 40 \\ 12 & \leq & +a & +b & +c & +d & \leq & 26 \\ 23 & \leq & +a & +b & +c & +d & \leq & 31 \\ \implies 25 & \leq & +a & +b & +c & +d & \leq & 26 \\ \end{array}$$

Already, these bounds are tightening up nicely, and the process has been largely mechanical. Here's another example. I'll take the fourth inequality in $c+d$ and multiply it through by $-1$. This I will add to the inequality for $a+b+c+d$, and use the result to refine the inequality for $a+b$.

$$\begin{array}{rccccccr} -17 & \leq & & & -c & -d & \leq & -10 \\ 25 & \leq & +a & +b & +c & +d & \leq & 26 \\ 8 & \leq & +a & +b & & & \leq & 16 \\ \implies 8 & \leq & +a & +b & & & \leq & 9 \\ \end{array}$$

One can go on in this fashion and deduce that $16\leq c+d\leq 17$ and so on. Eventually there are just a few cases to consider and the answers Hellion worked out can be found. Obviously this method is more interesting when the question is more complex, but hopefully some will find this approach entertaining. With pen and paper, the refinements can be made relatively easily on a single matrix.

02 07 01
09 08 02
08 09 04

02 07 01
08 09 02
09 08 04

How i got it

I saw 24 and realized it needed 9 8 7 as none could duplicate in the same row then i just threw numbers at it until it worked!

• 2 appears twice. – Beastly Gerbil Jul 26 '17 at 17:09
• @BeastlyGerbil they can appear twice, just not in the same row or column – Jason V Jul 26 '17 at 17:10
• Oh oops. In that case this is probably correct though there may be multiple answers – Beastly Gerbil Jul 26 '17 at 17:10
• @BeastlyGerbil looking at it, OP is correct. There exists only two answers – Jason V Jul 26 '17 at 17:26

Nothing to add to other responses except that they could have made the puzzle answer unique by changing the lower left number from 19 to one of 12,13,18 or 20.