DECLARE FUNCTION count! (a$, b$)
DATA 4,12,10,2,6,8
DATA 3,84,108,91,10,60,40
DATA 11,105,576,2310,198,30,264
DATA 13,52,200,2990,286,52,40
DATA 5,108,420,45,156,330,120
DATA 9,180,72,140,126,18,153
DATA 7,33,133,1190,140,546,120
FOR i = 1 TO 6: READ colDiv(i): NEXT
FOR row = 1 TO 6
READ rowDiv(row)
FOR col = 1 TO 6
READ cellVal(row, col)
NEXT
NEXT
FOR row = 1 TO 6
FOR col = 1 TO 6
IF cellVal(row, col) MOD rowDiv(row) = 0 THEN xfact = 1: ELSE xfact = 0
IF cellVal(row, col) MOD colDiv(col) = 0 THEN yfact = 1: ELSE yfact = 0
IF cellVal(row, col) MOD (rowDiv(row) + colDiv(col)) = 0 THEN sumfact = 1: ELSE sumfact = 0
IF cellVal(row, col) MOD ABS(rowDiv(row) - colDiv(col)) = 0 AND ABS(rowDiv(row) - colDiv(col)) > 1 THEN
difffact = 1
ELSE
difffact = 0
END IF
IF cellVal(row, col) MOD (rowDiv(row) * colDiv(col)) = 0 THEN prodfact = 1: ELSE prodfact = 0
IF (xfact OR yfact) AND (xfact = 0 OR yfact = 0) THEN satis$(row, col) = "1"
IF sumfact THEN satis$(row, col) = satis$(row, col) + "2"
IF difffact THEN satis$(row, col) = satis$(row, col) + "3"
IF prodfact THEN satis$(row, col) = satis$(row, col) + "4": ELSE satis$(row, col) = satis$(row, col) + "5"
PRINT TAB(col * 6); satis$(row, col);
NEXT
PRINT
NEXT
PRINT
PRINT "+-+-+-+-+-+-+"
FOR row = 1 TO 6
PRINT "|";
FOR col = 1 TO 6
a$ = satis$(row, col)
b$ = satis$(row, col + 1)
IF count(a$, b$) <> 1 THEN PRINT " |"; : ELSE PRINT " ";
NEXT: PRINT
PRINT "+";
FOR col = 1 TO 6
a$ = satis$(row, col)
c$ = satis$(row + 1, col)
IF count(a$, c$) <> 1 THEN PRINT "-+"; : ELSE PRINT " +";
NEXT: PRINT
NEXT
FUNCTION count (a$, b$)
ct = 0
FOR i = 1 TO LEN(a$)
IF INSTR(b$, MID$(a$, i, 1)) > 0 THEN ct = ct + 1
NEXT
count = ct
END FUNCTION
first shows the conditions met by each of the 36 cells in the matrix:
24 34 235 125 35 135
235 15 24 34 135 34
4 25 24 34 15 135
125 34 1235 135 24 34
34 35 15 34 35 125
235 125 24 34 24 125
Then this is converted to the equivalent maze as determined by the rule for transitioning from one cell to another:
+-+-+-+-+-+-+
| | | |
+ +-+ +-+-+ +
| | |
+-+ +-+-+-+ +
| | | | |
+-+-+ + +-+ +
| | | | |
+-+ +-+ +-+-+
| | |
+ + +-+-+-+-+
| | |
+-+-+-+-+-+-+
Manually placing *'s along the solving path, this becomes:
+-+-+-+-+-+-+
|* | | |
+ +-+ +-+-+ +
|* *| |
+-+ +-+-+-+ +
| |* * | | |
+-+-+ + +-+ +
| |* *| | |
+-+ +-+ +-+-+
| * | |
+ + +-+-+-+-+
| |* * * * *|
+-+-+-+-+-+-+
The numbers of the cells are, in order:
84, 105, 576, 200, 2990, 45, 420, 72, 133, 1190, 140, 546, 120
|
Posted by Charlie
on 2010-09-22 02:39:37 |