Substitute each of the capital letters in bold in this 3x3 grid by a different digit from 1 to 9 such that the sum of digits in each of the four 2x2 subgrids is equal to 9*E.
A B C
D E F
G H I
What will be the arrangement(s) (disregarding reflections and rotations), if keeping all the other conditions unchanged, the sum of digits in each of the four 2x2 subgrids is equal to 7*E?
To avoid reflections/rotations, A is the lowest corner and C is less than G:
CLS
FOR a = 1 TO 6
used(a) = 1
FOR c = a + 1 TO 8
used(c) = 1
FOR g = c + 1 TO 9
used(g) = 1
FOR i = 1 TO 9
IF used(i) = 0 THEN
used(i) = 1
FOR b = 1 TO 9
IF used(b) = 0 THEN
used(b) = 1
FOR d = 1 TO 9
IF used(d) = 0 THEN
used(d) = 1
FOR f = 1 TO 9
IF used(f) = 0 THEN
used(f) = 1
FOR h = 1 TO 9
IF used(h) = 0 THEN
used(h) = 1
IF a + d = c + f THEN
IF b + c = h + i THEN
IF f + i = d + g THEN
IF g + h = a + b THEN
e = 45 - a - b - c - d - f - g - h - i
IF a + b + d + e = 9 * e OR a + b + d + e = 7 * e THEN
PRINT
PRINT a; b; c
PRINT d; e; f
PRINT g; h; i
PRINT (a + b + d + e) / e
END IF
END IF
END IF
END IF
END IF
used(h) = 0
END IF
NEXT
used(f) = 0
END IF
NEXT
used(d) = 0
END IF
NEXT
used(b) = 0
END IF
NEXT b
used(i) = 0
END IF
NEXT i
used(g) = 0
NEXT g
used(c) = 0
NEXT c
used(a) = 0
NEXT a
produces
1 9 2
8 3 7
4 6 5
7
3 4 5
9 2 7
6 1 8
9
4 3 5
9 2 8
6 1 7
9
In each case, the multiple appears below the array.
|
Posted by Charlie
on 2009-08-14 15:34:21 |