# Thread: an interesting magic square

1. ## an interesting magic square

Given a 4x4 matrix with numbers $\displaystyle a_1, a_2, ... a_{16}$:

$\displaystyle \begin{bmatrix} a_1&a_2&a_3&a_4 \\ a_5&a_6&a_7&a_8 \\ a_9&a_{10}&a_{11}&a_{12} \\ a_{13}&a_{14}&a_{15}&a_{16} \end{bmatrix}$

Find numbers $\displaystyle a_n$ such that each of the $\displaystyle a_n$ is one of the numbers from 1 to 16 (each number is used exactly once), the sum of the numbers in each row and column sum to 34, and the sums of the following sets of numbers also equals 34: $\displaystyle (a_1, a_4, a_{13}, a_{16}), (a_6, a_7, a_{10}, a_{11}), (a_2, a_3, a_{14}, a_{15}), (a_5, a_8, a_9, a_{12})$

2. Hello, icemanfan!

This is a classic (very old) problem.

Given a 4x4 matrix: .$\displaystyle \begin{bmatrix} a_1&a_2&a_3&a_4 \\ a_5&a_6&a_7&a_8 \\ a_9&a_{10}&a_{11}&a_{12} \\ a_{13}&a_{14}&a_{15}&a_{16} \end{bmatrix}$

Find numbers $\displaystyle a_n$ such that each of the $\displaystyle a_n$ is one of the numbers
from 1 to 16 (each number is used exactly once),
the sum of the numbers in each row and column sum to 34,
and the sums of the following sets of numbers also equals 34:

. . $\displaystyle \begin{bmatrix}*&\cdot&\cdot&* \\ \cdot&\cdot&\cdot&\cdot \\ \cdot&\cdot&\cdot&\cdot \\ *&\cdot&\cdot&*\end{bmatrix}$ . . $\displaystyle \begin{bmatrix}\cdot&\cdot&\cdot&\cdot \\ \cdot&*&*&\cdot \\ \cdot&*&*&\cdot \\ \cdot&\cdot&\cdot&\cdot \end{bmatrix}$ . . $\displaystyle \begin{bmatrix}\cdot&*&*&\cdot \\ \cdot&\cdot&\cdot&\cdot \\ \cdot&\cdot&\cdot&\cdot \\ \cdot&*&*&\cdot\end{bmatrix}$ . . $\displaystyle \begin{bmatrix}\cdot&\cdot&\cdot&\cdot \\ *&\cdot&\cdot&* \\ *&\cdot & \cdot & * \\ \cdot&\cdot&\cdot&\cdot \end{bmatrix}$

The simplest solution:

. . . $\displaystyle \begin{array}{|c|c|c|c|} \hline 1 & 15 & 14 & 4 \\ \hline 12 & 6 & 7 & 9 \\ \hline\ 8 & 10 & 11 & 5 \\ \hline 13 & 3 & 2 & 16 \\ \hline \end{array}$

This magic square satisfies the above requirements
. . and has a sum of 34 in the followng positions:

The two diagonals:

. . . $\displaystyle \begin{bmatrix}*&\cdot&\cdot&\cdot \\ \cdot&*&\cdot&\cdot \\ \cdot&\cdot&*&\cdot \\ \cdot&\cdot&\cdot&*\end{bmatrix}$ . . $\displaystyle \begin{bmatrix}\cdot&\cdot&\cdot&* \\ \cdot&\cdot&*&\cdot \\ \cdot&*&\cdot&\cdot \\ *&\cdot&\cdot&\cdot\end{bmatrix}$

The corner 2x2's:

. . . $\displaystyle \begin{bmatrix}*&*&\cdot&\cdot \\ *&*&\cdot&\cdot \\ \cdot&\cdot&\cdot&\cdot \\ \cdot&\cdot&\cdot&\cdot \end{bmatrix}$ . . $\displaystyle \begin{bmatrix}\cdot&\cdot&*&* \\ \cdot&\cdot&*&* \\ \cdot&\cdot&\cdot&\cdot \\ \cdot&\cdot&\cdot&\cdot \end{bmatrix}$ . . $\displaystyle \begin{bmatrix}\cdot&\cdot&\cdot&\cdot \\ \cdot&\cdot&\cdot&\cdot\\ *&*&\cdot&\cdot \\ *&*&\cdot&\cdot \end{bmatrix}$ . . $\displaystyle \begin{bmatrix}\cdot&\cdot&\cdot&\cdot \\ \cdot&\cdot&\cdot&\cdot \\ \cdot&\cdot&*&* \\ \cdot&\cdot&*&* \end{bmatrix}$

These two "rectangles":

. . . $\displaystyle \begin{bmatrix}\cdot&*&\cdot&\cdot \\ *&\cdot&\cdot&\cdot \\ \cdot&\cdot&\cdot&* \\ \cdot&\cdot&*&\cdot \end{bmatrix}$ . . $\displaystyle \begin{bmatrix}\cdot&\cdot&*&\cdot \\ \cdot&\cdot&\cdot&* \\ *&\cdot&\cdot&\cdot \\ \cdot&*&\cdot&\cdot \end{bmatrix}$

3. With your restrictions only, Iceman, there are 8200 solutions
(including mirrors) with 1 in top left corner

4. Adding Soroban's, plus these 4 (x's = 34):
x o x o : o x o x : o o o o : o o o o
o o o o : o o o o: x o x o : o x o x
o o o o : o o o o: x o x o : o x o x
x o x o : o x o x : o o o o : o o o o

Here's 2 solutions:
01 06 12 15 : 01 07 12 14
11 16 02 05 : 10 16 03 05
14 09 07 04 : 15 09 06 04
08 03 13 10 : 08 02 13 11

5. . . . . For Your Information . . .

You can easily reconstruct that Magic Square with this procedure.

Draw a 4-by-4 grid and mentally note the cells on the two diagonals.

. . $\displaystyle \begin{array}{|c|c|c|c|}\hline * &\;\;&\;\;&* \\ \hline &*&*& \\ \hline &*&* & \\ \hline *&&&* \\ \hline \end{array}$

Starting at the upper-left, write the numbers 1-to-16,
. . in order, down the grid,
. . but only in the diagonal cells.

. . $\displaystyle \begin{array}{|c|c|c|c|}\hline {\color{blue}1} &\;\;&\;\;&{\color{blue}4} \\ \hline & {\color{blue}6} & {\color{blue}7} & \\ \hline & {\color{blue}10}& {\color{blue}11} & \\ \hline {\color{blue}13}&&& {\color{blue}16} \\ \hline \end{array}$

Starting at the lower-right, write the numbers 1-to-16
. . in order, up the grid,
. . but only in the unoccupied cells.

. . $\displaystyle \begin{array}{|c|c|c|c|}\hline 1 &{\color{red}15}&{\color{red}14}&4 \\ \hline {\color{red}12}&6&7&{\color{red}9}\\ \hline {\color{red}8}&10&11 &{\color{red}5} \\ \hline 13&{\color{red}3}&{\color{red}2}&16 \\ \hline \end{array}$

. . There!

6. Very nice solutions, Wilmer and Soroban.

This was the first one I came up with:

$\displaystyle \begin{bmatrix}15 & 4 & 14 & 1 \\ 12 & 7 & 9 & 6 \\ 5 & 10 & 8 & 11 \\ 2 & 13 & 3 & 6 \end{bmatrix}$

Inspired by the smaller matrix

$\displaystyle \begin{bmatrix} 4 & 1 \\ 1 & 4 \end{bmatrix}$

I started with this:

$\displaystyle \begin{bmatrix} 16 & 4 & 13 & 1 \\ 12 & 8 & 9 & 5 \\ 5 & 9 & 8 & 12 \\ 1 & 13 & 4 & 16 \end{bmatrix}$

Then I either added one or subtracted one from the numbers in the starred positions:

$\displaystyle \begin{bmatrix} * & 4 & * & 1 \\ 12 & * & 9 & * \\ 5 & * & 8 & * \\ * & 13 & * & 16 \end{bmatrix}$

Assuming that $\displaystyle a_{n} = n$, then just reverse or flip the diagonals to get a magic square (further operations will produce the remaining 879 normal magic squares).