A 3x3 magic square is an array of nine distinct positive integers such that the sum of the numbers in each row, each column, and each of the two diagonals is the same. In the following magic square:
What are the possible values of the lower left corner? And what is the maximum possible value of any number in the array?
The possibilities are
6 17 7 8 15 10 10 13 13 12 11 16 14 9 19
11 10 9 13 11 9 15 12 9 17 13 9 19 14 9
13 3 14 12 7 14 11 11 14 10 15 14 9 19 14
16 7 22 18 5 25 20 3 28 22 1 31
21 15 9 23 16 9 25 17 9 27 18 9
8 23 14 7 27 14 6 31 14 5 35 14
so long as the number in the upper right corner is under 1,735,334, as that is as far as the following program got:
CLS
rw = 2
DO
a13 = a13 + 1
t = a13 + 9 + 14 ' rt col
a22 = 0
DO
a22 = a22 + 1
a31 = t - a13 - a22 ' ll to ur
a32 = t - a31 - 14 ' bot row
a21 = t - 9 - a22 ' mid row
a11 = t - 14 - a22 ' ul to lr
a12 = t - a11 - a13 ' top row
IF a11 + a21 + a31 = t THEN ' lt col
IF a12 + a22 + a32 = t THEN ' mid col
IF a31 > 0 AND a21 > 0 AND a11 > 0 AND a22 > 0 AND a32 > 0 AND a12 > 0 THEN
ct = ct + 1
IF ct > 5 THEN rw = rw + 6: ct = 1
LOCATE rw, ct * 11 - 4
PRINT USING "## ## ##"; a11;
PRINT USING "## ## ##"; a12;
PRINT USING "## ## ##"; a13;
LOCATE rw + 1, ct * 11 - 4
PRINT USING "## ## ##"; a21;
PRINT USING "## ## ##"; a22;
PRINT USING "## ## ##"; 9;
LOCATE rw + 2, ct * 11 - 4
PRINT USING "## ## ##"; a31;
PRINT USING "## ## ##"; a32;
PRINT USING "## ## ##"; 14;
END IF
END IF
END IF
LOOP UNTIL a31 < 0 OR a21 < 0 OR a11 < 0
LOOP
For each value of a13 (row 1, col 3) tried it starts a22 at zero and continues until increased values of a22 cause other squares to become negative (the ones that go down as a22 goes up, for a given a13 value).
The lower left corner is anywhere from 5 to 13 and the biggest number is 35.
|
Posted by Charlie
on 2006-12-21 15:37:28 |