DECLARE SUB addOn (row!, col!)
DECLARE FUNCTION isPrime! (x!)
CLEAR , , 25000
CLS
DATA 17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113
DIM SHARED prime(24), gr(5, 5), used(25), rowTot, prUsed(24), corrCol(25), wrongRow(25)
DIM SHARED solCt, ordCt, rtot(5)
FOR i = 1 TO 24: READ prime(i): NEXT
DATA 4,6,14,15,17
FOR row = 1 TO 5
READ gr(row, 1)
used(gr(row, 1)) = 1
NEXT row
DATA 5,4,3,1,4,1,2,3,5,4,2,5,2,1,1,2,1,3,2,4,3,3,4,5,5
FOR i = 1 TO 25
READ corrCol(i)
NEXT
DATA 1,3,4,1,5,2,3,5,4,2,5,3,2,3,4,4,5,2,1,4,3,1,1,5,2
FOR i = 1 TO 25
READ wrongRow(i)
NEXT
FOR i = 1 TO 25
LOCATE wrongRow(i), corrCol(i) * 4
PRINT i;
NEXT
LOCATE 10, 1
OPEN "primesel.dat" FOR OUTPUT AS #1
OPEN "primesel.txt" FOR OUTPUT AS #2
addOn 1, 2
CLOSE
PRINT solCt, ordCt
SUB addOn (row, col)
FOR i = 1 TO 25
rowTotSave = rowTot
IF used(i) = 0 AND corrCol(i) = col AND wrongRow(i) <> row THEN
used(i) = 1
gr(row, col) = i
IF col = 2 THEN
rowTot = gr(row, 1) + gr(row, col)
ELSE
rowTot = rowTot + gr(row, col)
END IF
IF col = 5 THEN
IF isPrime(rowTot) THEN
IF prUsed(isPrime(rowTot)) = 0 THEN
prUsed(isPrime(rowTot)) = 1
IF row = 5 THEN
FOR r = 1 TO 5
rtot(r) = 0
FOR c = 1 TO 5
PRINT #1, USING "###"; gr(r, c);
rtot(r) = rtot(r) + gr(r, c)
NEXT
PRINT #1, " "; rtot(r)
NEXT
PRINT #1,
solCt = solCt + 1
ordered = 1
FOR r = 2 TO 5
IF rtot(r) <= rtot(r - 1) THEN ordered = 0
NEXT
IF ordered THEN
ordCt = ordCt + 1
FOR r = 1 TO 5
FOR c = 1 TO 5
PRINT #2, USING "###"; gr(r, c);
NEXT
PRINT #2, " "; rtot(r)
NEXT
PRINT #2,
END IF
ELSE
addOn row + 1, 2
END IF
prUsed(isPrime(rowTot)) = 0
END IF
END IF
ELSE
addOn row, col + 1
END IF
used(i) = 0
END IF
rowTot = rowTotSave
NEXT
END SUB
FUNCTION isPrime (x)
FOR i = 1 TO 24
IF prime(i) = x THEN isPrime = i: EXIT FUNCTION: ELSE IF prime(i) > x THEN EXIT FOR
NEXT
isPrime = 0
END FUNCTION
finds 1440 solutions in all, in 61 of which the primes are in numeric order. Those 61 are:
4 7 3 2 25 41
6 11 22 5 9 53
14 16 8 20 1 59
15 13 21 10 24 83
17 19 18 23 12 89
4 7 3 2 25 41
6 11 22 5 9 53
14 16 18 10 1 59
15 13 8 23 24 83
17 19 21 20 12 89
4 7 3 2 25 41
6 16 22 5 12 61
14 11 8 10 24 67
15 13 21 23 1 73
17 19 18 20 9 83
4 7 3 2 25 41
6 19 22 5 9 61
14 11 8 10 24 67
15 13 21 23 1 73
17 16 18 20 12 83
4 7 3 5 12 31
6 11 21 2 1 41
14 16 18 10 9 67
15 13 8 23 24 83
17 19 22 20 25 103
4 7 3 5 12 31
6 11 21 2 1 41
14 16 18 10 9 67
15 19 8 23 24 89
17 13 22 20 25 97
4 7 3 5 12 31
6 16 8 2 9 41
14 11 18 23 1 67
15 13 21 10 24 83
17 19 22 20 25 103
4 7 3 5 12 31
6 16 8 2 9 41
14 11 18 23 1 67
15 19 21 10 24 89
17 13 22 20 25 97
4 7 3 5 12 31
6 19 8 2 24 59
14 13 22 23 1 73
15 11 18 10 25 79
17 16 21 20 9 83
4 7 3 5 12 31
6 19 8 2 24 59
14 16 18 10 9 67
15 11 21 23 1 71
17 13 22 20 25 97
4 7 3 5 12 31
6 19 8 2 24 59
14 16 22 20 1 73
15 11 18 10 25 79
17 13 21 23 9 83
4 7 3 5 24 43
6 11 22 2 12 53
14 16 8 20 9 67
15 13 21 23 1 73
17 19 18 10 25 89
4 7 3 5 24 43
6 11 22 2 12 53
14 16 8 20 9 67
15 19 21 23 1 79
17 13 18 10 25 83
4 7 3 5 24 43
6 16 8 20 9 59
14 11 22 23 1 71
15 13 18 2 25 73
17 19 21 10 12 79
4 7 3 5 24 43
6 16 22 2 1 47
14 13 8 23 9 67
15 11 18 10 25 79
17 19 21 20 12 89
4 7 3 5 24 43
6 16 22 2 1 47
14 19 8 23 9 73
15 11 18 10 25 79
17 13 21 20 12 83
4 7 3 5 24 43
6 19 8 2 12 47
14 13 22 23 1 73
15 11 18 10 25 79
17 16 21 20 9 83
4 7 3 5 24 43
6 19 8 2 12 47
14 16 18 10 9 67
15 11 21 23 1 71
17 13 22 20 25 97
4 7 3 5 24 43
6 19 8 2 12 47
14 16 22 20 1 73
15 11 18 10 25 79
17 13 21 23 9 83
4 7 3 5 24 43
6 19 22 2 12 61
14 11 18 23 1 67
15 13 8 10 25 71
17 16 21 20 9 83
4 7 3 5 24 43
6 19 22 2 12 61
14 16 8 20 9 67
15 11 21 23 1 71
17 13 18 10 25 83
4 7 3 20 9 43
6 11 22 2 12 53
14 16 8 5 24 67
15 13 21 23 1 73
17 19 18 10 25 89
4 7 3 20 9 43
6 11 22 2 12 53
14 16 8 5 24 67
15 19 21 23 1 79
17 13 18 10 25 83
4 7 3 20 9 43
6 16 8 5 24 59
14 11 22 23 1 71
15 13 18 2 25 73
17 19 21 10 12 79
4 7 3 20 9 43
6 16 22 2 1 47
14 11 8 10 24 67
15 13 21 5 25 79
17 19 18 23 12 89
4 7 3 20 9 43
6 19 8 2 12 47
14 11 18 23 1 67
15 13 22 5 24 79
17 16 21 10 25 89
4 7 3 20 9 43
6 19 22 2 12 61
14 16 8 5 24 67
15 11 21 23 1 71
17 13 18 10 25 83
4 7 3 20 9 43
6 19 22 5 1 53
14 11 8 10 24 67
15 13 18 2 25 73
17 16 21 23 12 89
4 7 18 2 12 43
6 19 8 5 9 47
14 16 3 10 24 67
15 11 21 23 1 71
17 13 22 20 25 97
4 7 18 5 9 43
6 19 8 2 12 47
14 16 3 10 24 67
15 11 21 23 1 71
17 13 22 20 25 97
4 11 3 5 24 47
6 7 22 23 1 59
14 16 8 20 9 67
15 13 18 2 25 73
17 19 21 10 12 79
4 11 3 10 9 37
6 7 8 2 24 47
14 16 22 20 1 73
15 13 21 5 25 79
17 19 18 23 12 89
4 11 3 10 9 37
6 7 22 2 24 61
14 19 8 5 25 71
15 13 21 23 1 73
17 16 18 20 12 83
4 11 3 10 9 37
6 7 22 23 1 59
14 16 8 5 24 67
15 13 18 2 25 73
17 19 21 20 12 89
4 11 3 10 9 37
6 7 22 23 1 59
14 16 8 5 24 67
15 19 18 2 25 79
17 13 21 20 12 83
4 11 3 20 9 47
6 7 22 23 1 59
14 16 8 5 24 67
15 13 18 2 25 73
17 19 21 10 12 79
4 11 8 2 12 37
6 7 22 23 1 59
14 16 3 10 24 67
15 13 21 5 25 79
17 19 18 20 9 83
4 11 8 5 9 37
6 7 22 2 24 61
14 19 3 10 25 71
15 13 21 23 1 73
17 16 18 20 12 83
4 11 8 5 9 37
6 7 22 23 1 59
14 16 3 10 24 67
15 13 18 2 25 73
17 19 21 20 12 89
4 11 8 5 9 37
6 7 22 23 1 59
14 16 3 10 24 67
15 19 18 2 25 79
17 13 21 20 12 83
4 13 3 2 9 31
6 7 22 23 1 59
14 16 8 5 24 67
15 11 18 10 25 79
17 19 21 20 12 89
4 13 3 2 9 31
6 11 21 20 1 59
14 16 8 5 24 67
15 7 22 10 25 79
17 19 18 23 12 89
4 13 3 2 9 31
6 11 21 20 1 59
14 16 8 5 24 67
15 7 22 23 12 79
17 19 18 10 25 89
4 13 3 2 9 31
6 16 8 5 24 59
14 11 18 23 1 67
15 7 22 10 25 79
17 19 21 20 12 89
4 13 3 2 25 47
6 7 22 23 1 59
14 16 8 20 9 67
15 11 18 5 24 73
17 19 21 10 12 79
4 13 3 2 25 47
6 16 8 20 9 59
14 11 18 23 1 67
15 7 22 5 24 73
17 19 21 10 12 79
4 13 3 5 12 37
6 7 8 2 24 47
14 16 18 10 9 67
15 11 21 23 1 71
17 19 22 20 25 103
4 13 3 5 12 37
6 7 8 2 24 47
14 16 22 20 1 73
15 11 18 10 25 79
17 19 21 23 9 89
4 13 3 5 12 37
6 7 8 23 9 53
14 16 18 10 1 59
15 11 21 2 24 73
17 19 22 20 25 103
4 13 3 5 12 37
6 7 22 2 24 61
14 16 8 20 9 67
15 11 21 23 1 71
17 19 18 10 25 89
4 13 3 5 12 37
6 7 22 23 1 59
14 11 8 10 24 67
15 19 18 2 25 79
17 16 21 20 9 83
4 13 3 5 12 37
6 7 22 23 1 59
14 16 8 20 9 67
15 11 21 2 24 73
17 19 18 10 25 89
4 13 3 5 12 37
6 19 8 2 24 59
14 11 18 23 1 67
15 7 22 10 25 79
17 16 21 20 9 83
4 16 3 2 12 37
6 7 22 23 1 59
14 11 8 10 24 67
15 13 21 5 25 79
17 19 18 20 9 83
4 16 3 2 12 37
6 11 21 20 1 59
14 13 8 23 9 67
15 7 22 5 24 73
17 19 18 10 25 89
4 16 3 5 9 37
6 7 8 2 24 47
14 11 18 23 1 67
15 13 21 10 12 71
17 19 22 20 25 103
4 16 3 5 9 37
6 7 8 2 24 47
14 13 22 23 1 73
15 11 18 10 25 79
17 19 21 20 12 89
4 16 3 5 9 37
6 7 22 2 24 61
14 11 18 23 1 67
15 13 8 10 25 71
17 19 21 20 12 89
4 16 3 5 9 37
6 7 22 23 1 59
14 11 8 10 24 67
15 13 18 2 25 73
17 19 21 20 12 89
4 16 3 5 9 37
6 7 22 23 1 59
14 11 8 10 24 67
15 19 18 2 25 79
17 13 21 20 12 83
4 16 3 5 9 37
6 19 8 2 24 59
14 11 18 23 1 67
15 7 22 10 25 79
17 13 21 20 12 83
A sampling from the overall 1440, chosen with each of the four possibilities for row 1, column 2:
4 7 3 2 25 41
6 11 8 5 1 31
14 16 18 10 9 67
15 19 22 23 24 103
17 13 21 20 12 83
4 11 3 5 24 47
6 19 22 23 9 79
14 16 8 20 25 83
15 7 18 2 1 43
17 13 21 10 12 73
4 13 8 10 12 47
6 11 21 5 24 67
14 16 22 20 25 97
15 7 18 2 1 43
17 19 3 23 9 71
4 16 21 2 24 67
6 7 8 20 12 53
14 11 18 5 25 73
15 13 22 10 1 61
17 19 3 23 9 71
|
Posted by Charlie
on 2012-04-04 08:44:48 |