# 3x3 self-descriptive squares

A self-descriptive square is a square grid filled with integers such that:

1. The sum of the numbers in any row describes the number of times that row’s rightmost number appears in the square.
2. The sum of the numbers in any column describes the number of times that column's lowermost number appears in the square.
3. Each number in the square must appear exactly once in the rightmost column or the lowermost row. In other words, a $$N \times N$$ self-descriptive square must contain exactly $$2N-1$$ distinct numbers.

Below is an example of such a 3x3 square. Here the sum of numbers in the first row is 2 and the rightmost number in that row (0) appears twice in the square. The sum of numbers in the third column is 3 and the lowermost number in that column (2) appears three times in the square. Also note that the square contains exactly 5 distinct numbers and they all appear just once in the rightmost column or the lowermost row (so condition 3 holds).

Can you find another 3x3 self-desriptive square that is not a permutation of rows/columns of the current one? Good luck!

• Just curious how many possible solutions are there for this puzzle ? (I think I found one, should i look for more ?) – Nobody Sep 30 '19 at 9:48
• I am only aware of one more solution... – Dmitry Kamenetsky Sep 30 '19 at 9:51
• I presume by excluding permutations of rows/columns of the above solution, you also intend to exclude the transpose of those solutions? – spyr03 Sep 30 '19 at 16:44
• @spyr03 Yes correct, exclude transpose too. – Dmitry Kamenetsky Sep 30 '19 at 22:06

I think I figured it out after a bit of trial and error (if there is a method of calculating it please comment)

2 -2 2 | 2
0 -2 3 | 1
0 5 -2 | 3
-------------------------
2 1 3

*I have horrible formatting feel free to edit the spoilerblock to make it better/more readable

• Well done! You got it. – Dmitry Kamenetsky Sep 30 '19 at 9:53

There are infinitely many solutions, some of them are in this form:

To generate them:

Initially, carefully pick $$(A,B,C,D)$$ so that there is no duplicate numbers. For example, this is one possible solution where $$(A,B,C,D) = (1,2,3,4)$$:

And to make them infinity:

Increment each $$A,B,C,D$$ by one!

• I am so sorry I forgot one extra, but very important condition. I have updated the problem statement in condition 3. Sorry for misleading you. – Dmitry Kamenetsky Sep 30 '19 at 6:26
• +1 athin for soling the Puzzle as originally stated, even if not the final solution for the final puzzle. – BmyGuest Sep 30 '19 at 6:38

I also found the same answer as Karan

2 -2 2 | 2
0 -2 3 | 1
0 5 -2 | 3
----------------
2 1 3

My method was as follows

From condition 3, we can parameterise the matrix with 5 variables
. . A | r1
. . B | r2
E D C | r3
----------------
c1 c2 c3

Since C occurs r3 times in the grid (rule 1) and c3 times in the grid (rule 2), it follows that r3 = c3.

Since there are 9 squares to fill in the grid, and each number in the grid is at the end of a row or column, $$r_1 + r_2 + r_3 + c_1 + c_2 = 9$$. As each row and column ends with a number, the total for that row or column must be at least 1. $$r_1, r_2, r_3, c_1, c_2 >= 1$$.
Searching for possible values for $$r_1$$ through $$c_2$$ yields ~$$70$$ results.

(1, 1, 1, 1, 5), (1, 1, 1, 5, 1), (1, 1, 1, 2, 4), $$\dots$$

As the sum of the rows is the same of as the sum of the columns, $$r_1 + r_2 + r_3 = c_1 + c_2 + c_3$$, and $$r_3 = c_3$$, the first two rows and columns sum to the same value. $$r_1 + r_2 = c_1 + c_2$$. We can ignore any permutation of (1, 1, 1, 2, 4) as there is no way to assign the numbers so that $$r_1 + r_2 = c_1 + c_2$$. We can discard any permutation that does not satisfy that above constraint.

As we can make a trivial new solution by swapping the first and second row, the first and second column, and transposing the matrix, we can w.l.o.g. reduce the possible row and column totals down to 5 general cases

. . A | 1
. . B | 1
E D C | 5
----------------
1 1 5

. . A | 3
. . B | 1
E D C | 1
----------------
3 1 1

. . A | 3
. . B | 1
E D C | 1
----------------
2 2 1

. . A | 2
. . B | 2
E D C | 1
----------------
2 2 1

. . A | 2
. . B | 1
E D C | 3
----------------
2 1 3

Next I bruteforced

The first case has one possiblity which immediately leads to a contradiction. Each dot becomes a C, and comparing the first two rows $$C + C + A = 1 = C + C + B$$ leads to the conclusion that A and B are not distinct, contradicting rule 3.

Searching through each possible assignment of variables for viable matrices gave:
$$r_1, r_2, r_3, c_1, c_2$$: viable / possible
1, 1, 5, 1, 1: 0 / 1
3, 1, 1, 1, 3: 0 / 6
1, 1, 5, 1, 1: 0 / 12
2, 2, 1, 2, 2: 2 / 24
2, 1, 3, 1, 2: 4 / 24

However half of these are actually the same matrix transposed and with the variables relabelled. So the 3 possible assignments of variables are
E A A | 2
B D B | 2
E D C | 1
----------------
2 2 1

This one can actually be ruled out by summing the first two rows and columns, and noticing that it cannot produce integer values for the variables.
$$E + A + A + B + D + B + E + B + E + A + D + D = 3(A + B + D + E) = 8$$.
Potentially there are some answers with rational fraction solutions, but I did not look for any.
A C A | 2
E C B | 1
E D C | 3
----------------
2 1 3

C C A | 2
E A B | 1
E D C | 3
----------------
2 1 3

Since these are systems of linear equations, I could solve them to get the original solution, and the other solution given in the linked answer. So I'm pretty sure these are the only two integral solutions.

The solution is:

There are no other 3x3 self-descriptive squares

If you are interested to learn more about self-descriptive squares and their exotic relatives then please read my paper: https://arxiv.org/pdf/1905.10191.pdf