Mystical squares

Consider a 3 × 3 3 \times 3 square, where each 1 × 1 1 \times 1 square is filled with one of the integers from 1 to 13. A square is called mystical if each row sums to a multiple of 13, each column sums to a multiple of 13 and each of the two main diagonals sums to a multiple of 13. How many mystical squares are there?

Details and assumptions

Numbers in the square are not necessarily distinct.

2 mystical squares are considered different if they differ in any entry. In particular, rotations are (generally) considered distinct.


The answer is 169.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

4 solutions

Thomas Beuman
Nov 26, 2013

First off, note that we can cast the problem into modulo 13 13 language: the integers to choose from are representatives of the 13 13 congruence classes, one of each. All rows, columns and diagonals should add up to zero (modulo 13 13 ).

Now consider the sum of all the rows ­­- this is in effect the sum of all the entries. Since each row independently should add up to zero, the total sum should too.

Next, consider the sum of the two diagonals, the center row and the center column, all together. This again must be zero. Note that this sum again involves all entries, but the entry in the center square is now counted four times instead of once. So, when we take the difference of this sum with the previous sum, we conclude that the center entry, multiplied by 3 3 ( = 4 1 =4-1 ), must be zero. Therefore, since 3 3 and 13 13 are coprime, the entry itself must be zero (i.e. 13 13 ).

Now let us put two numbers a a and b b in the top corner squares. The other squares are then fixed:

a a b b b a 0 a b b a + b a \begin{matrix} a & -a-b & b \\ b-a & 0 & a-b \\ -b & a+b & -a \end{matrix}

It is easy to verify that this satisfies all constraints. Therefore, for every choice of a a and b b , there is exactly one solution (remember that we have exactly one representative of each congruence class). The answer is thus the number of ways in which a a and b b can be chosen, which is 1 3 2 = 169 13^2 = \boxed{169}

Finally, let us consider what happens when 13 13 is replaced with n n . The only property of 13 13 that we used, is that it is coprime with 3 3 . Therefore, similarly, if n n is not divisible by 3 3 , the answer is n 2 n^2 .

If n n is divisible by 3 3 , the center square could also contain n / 3 n/3 or 2 n / 3 2n/3 . In each case, we could apply the same argument and make a similar matrix with a a 's and b b 's, but it is also sufficient to notice that adding n / 3 n/3 or 2 n / 3 2n/3 to all elements of a solution gives another one. This gives a one-to-one-to-one relation between the solutions featuring either zero, n / 3 n/3 or 2 n / 3 2n/3 in the center. The answer thus becomes 3 n 2 3n^2 in this case.

impressive

Sagar Jha - 7 years, 6 months ago
Dhruv Bhasin
Nov 26, 2013

Let's name the elements of our mystical square as a,b,c,d,f,g,h,i with a b c being the first row, d e f the second and g h i the third. It gets cumbersome to try put values in the square to meet the required condition so we should find some relation among the variables of the square to get an easy approach to the problem. Note that a + e + i = 13 q a+e+i=13q which gives i = 13 q e a i=13q-e-a and similarly from b + e + h = 13 p b+e+h=13p we get h = 13 p b e h=13p-b-e and we can also obtain g = 13 r e c g=13r-e-c

adding these three equations,

g + h + i = 13 ( p + q + r ) ( a + b + c ) 3 e g+h+i=13(p+q+r)-(a+b+c)-3e

Note that the terms g + h + i g+h+i and a + b + c a+b+c are also multiples of 13
which means that

13 s = 13 ( p + q + r ) 13 t 3 e 13s=13(p+q+r)-13t-3e

\Rightarrow 3 e = 13 ( p + q + r s t ) 3e=13(p+q+r-s-t)

Therefore, 13 e 13|e which means that e = 13 e=13 because e can only take value between 1 and 13 .

So, putting e = 13 e=13 in our previous equations we get

g = 13 c g=13-c

h = 13 b h=13-b

i = 13 a i=13-a

similarly the other two remaining quantities d & f can be written in terms of a,b & c . Therefore, to every value of ordered triplet of (a,b,c) , we get unique values of d,f,g,h & i and hence a unique mystical square. So, the no. of mystical squares is in one-one correspondence with the no. of ordered triplets (a,b,c) satisfying

a + b + c = 13 z a+b+c=13z where, clearly, z can take values 1,2 & 3 . so putting these values of z one by one in the above equation, we can get the required no. of ordered triplets by using the technique of Generating Functions .

z=1 gives 66 ordered triplets z=2 gives 102 and z=3 gives 1 triplet .

Therefore the required answer is

66 + 102 + 1 = 169 66+102+1=169

excellent way..... just e is missing while taking the elements name int the first line

Ujjwal Mani Tripathi - 7 years, 6 months ago

Log in to reply

Thanks :) And yes i noticed the missing 'e' just after submitting the solution.

Dhruv Bhasin - 7 years, 6 months ago
Ron van den Burg
Nov 26, 2013

Subtract 1 from all the numbers in the problem and you will get: "Fill squares with numbers from 0 to 12. All the 8 sums (rows, columns and main diagonals) add up to 10 ( m o d 13 ) 10 (mod 13) .

Now choose a, b, c in the left-upper, centre and right-upper square respectively. This fixes all the other squares: the upper-middle square becomes a b -a-b ; the bottom row becomes 10 b c 10-b-c , a + b c a+b-c , 10 a c 10-a-c respectively. The middle row then becomes: b + c a b+c-a , c c , a + c b a+c-b .

Checking all the 8 sums gives 6 times a value of 10 (mod 13), by construction; the two other sums give 3 c = 10 ( m o d 13 ) 3c=10 (mod 13) or (times 9): c = 12 ( m o d 13 ) c=12 (mod 13) .

So all solutions must have a center square containing 12 and both corner cells in the top row can have any number, giving 13x13 possibilities.

Stated in original terms: the center square must contain the number ( 12 m o d 13 ) + 1 = 13 (12 mod 13) + 1=13 and all the 8 sums add up to ( 10 m o d 13 ) + 3 (10 mod 13) + 3 and are thus a multiple of 13. There are 13 x 13 = 169 13x13=169 possibilities. QED.

Qi Huan Tan
May 20, 2014

Denote the ith row and the jth column by (i,j). (1,1)+(2,2)+(3,3), (2,1)+(2,2)+(2,3) and (3,1)+(2,2)+(1,3) are divisible by 13. Their sum, (1,1)+(2,1)+(3,1)+(1,3)+(2,3)+(3,3)+3(2,2) is also divisible by 13. Since (1,1)+(2,1)+(3,1) and (1,3)+(2,3)+(3,3) are both divisible by 13, 3(2,2) is divisible by 13. Since gcd(3,13)=1, (2,2) is divisible by 13 and (2,2)=13 [1<=(2,2)<=13]. Note that each value of (1,1) and (3,1) determines a unique mystical square. [This needs some explanation. While it's clear that the entires will be uniquely determined, it is not immediately obvious that what results is a mystical square - Calvin] There is a bijection from the value of (1,1) and (3,1) to the mystical square. Since there are 13 possible values for (1,1) and 13 possible values for (3,1), there are 13*13=169 mystical squares.

As is often the case in magic squares, the middle square holds the key.

Calvin Lin Staff - 7 years ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...