Each of the capital letters in bold in this 3x3 grid is to be substituted by a different digit from 1 to 9 such that :
- Each of A, C, G and I is even, and:
- The sum of the digits in each of the four 2x2 subgrids is equal.
A B C
D E F
G H I
Disregarding the rotations and reflections, how many distinct solutions are there?
2 5 4
9 3 7
6 1 8
2 9 4
3 7 1
6 5 8
from
a = 2
FOR c = 4 TO 6 STEP 2
FOR g = c + 2 TO 8 STEP 2
i = 20 - a - c - g
FOR b = 1 TO 9 STEP 2
FOR d = 1 TO 9 STEP 2
IF d <> b THEN
FOR f = 1 TO 9 STEP 2
IF f <> d AND f <> b THEN
FOR h = 1 TO 9 STEP 2
IF h <> d AND h <> b AND h <> f THEN
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
PRINT
PRINT a; b; c
PRINT d; e; f
PRINT g; h; i
END IF
END IF
END IF
END IF
END IF
NEXT
END IF
NEXT
END IF
NEXT
NEXT
NEXT
NEXT
|
Posted by Charlie
on 2009-08-18 16:31:33 |