There are 17 fundamental solutions, each of which can be trivially modified by 720 permutations of its rows and columns for a total of 12,240 variants.
Arranged as 3 rows x 5 columns, with the "1" placed at the upper left, and the first row in ascending sequence and the first column in ascending sequence, the 17 fundamental solutions are:
1 3 10 11 15
9 8 12 6 5
14 13 2 7 4
1 3 10 11 15
9 8 12 7 4
14 13 2 6 5
1 4 9 11 15
10 6 12 5 7
13 14 3 8 2
1 5 9 11 14
8 12 13 3 4
15 7 2 10 6
1 5 9 11 14
10 4 12 6 8
13 15 3 7 2
1 5 10 11 13
9 4 12 7 8
14 15 2 6 3
1 5 10 11 13
9 15 2 6 8
14 4 12 7 3
1 6 8 10 15
9 11 3 12 5
14 7 13 2 4
1 6 8 10 15
9 11 13 2 5
14 7 3 12 4
1 6 8 10 15
11 4 13 5 7
12 14 3 9 2
1 6 8 10 15
11 14 3 5 7
12 4 13 9 2
1 6 9 10 14
8 13 4 12 3
15 5 11 2 7
1 7 8 9 15
10 11 2 12 5
13 6 14 3 4
1 7 8 9 15
11 4 14 5 6
12 13 2 10 3
1 7 8 10 14
11 15 3 5 6
12 2 13 9 4
1 7 9 10 13
8 3 11 12 6
15 14 4 2 5
1 7 9 10 13
8 14 11 2 5
15 3 4 12 6
The program is:
DIM numb(15)
CLS
OPEN "1-15i3x5.txt" FOR OUTPUT AS #2
FOR b1 = 2 TO 9
numb(b1) = 1
FOR c1 = b1 + 1 TO 10
IF numb(c1) = 0 THEN
numb(c1) = 1
FOR d1 = c1 + 1 TO 11
IF numb(d1) = 0 THEN
numb(d1) = 1
e1 = 40 - 1 - b1 - c1 - d1
IF e1 >= 1 AND e1 <= 15 THEN
IF numb(e1) = 0 THEN
numb(e1) = 1
FOR a2 = 2 TO 11
IF numb(a2) = 0 THEN
numb(a2) = 1
FOR b2 = 2 TO (24 - b1 - 2)
IF b2 <= 15 THEN
IF numb(b2) = 0 THEN
numb(b2) = 1
FOR c2 = 2 TO (24 - c1 - 2)
IF c2 <= 15 THEN
IF numb(c2) = 0 THEN
numb(c2) = 1
FOR d2 = 2 TO (24 - d1 - 2)
IF d2 <= 15 THEN
IF numb(d2) = 0 THEN
numb(d2) = 1
e2 = 40 - a2 - b2 - c2 - d2
IF e2 <= 15 AND e2 >= 0 THEN
IF numb(e2) = 0 THEN
numb(e2) = 1
a3 = 24 - 1 - a2
b3 = 24 - b1 - b2
c3 = 24 - c1 - c2
d3 = 24 - d1 - d2
e3 = 24 - e1 - e2
IF 24 - 1 - a2 <= 15 AND 24 - b1 - b2 <= 15 AND 24 - c1 - c2 <= 15 AND 24 - d1 - d2 <= 15 AND 24 - e1 - e2 <= 15 THEN
IF 24 - 1 - a2 > 0 AND 24 - b1 - b2 > 0 AND 24 - c1 - c2 > 0 AND 24 - d1 - d2 > 0 AND 24 - e1 - e2 > 0 THEN
IF numb(24 - 1 - a2) = 0 AND numb(24 - b1 - b2) = 0 AND numb(24 - c1 - c2) = 0 AND numb(24 - d1 - d2) = 0 AND numb(24 - e1 - e2) = 0 THEN
IF a3 <> b3 AND a3 <> c3 AND a3 <> d3 AND a3 <> e3 AND b3 <> c3 AND b3 <> d3 AND b3 <> e3 AND c3 <> d3 AND c3 <> e3 AND d3 <> e3 THEN
PRINT 1, b1, c1, d1, e1
PRINT a2, b2, c2, d2, e2
PRINT 24 - a2 - 1, 24 - b2 - b1, 24 - c2 - c1, 24 - d2 - d1, 24 - e2 - e1
PRINT
PRINT #2, 1, b1, c1, d1, e1
PRINT #2, a2, b2, c2, d2, e2
PRINT #2, 24 - a2 - 1, 24 - b2 - b1, 24 - c2 - c1, 24 - d2 - d1, 24 - e2 - e1
PRINT #2,
ct = ct + 1
END IF
END IF
END IF
END IF
numb(e2) = 0
END IF
END IF
numb(d2) = 0
END IF
END IF
NEXT
numb(c2) = 0
END IF
END IF
NEXT
numb(b2) = 0
END IF
END IF
NEXT
numb(a2) = 0
END IF
NEXT
numb(e1) = 0
END IF
END IF
numb(d1) = 0
END IF
NEXT
numb(c1) = 0
END IF
NEXT
numb(b1) = 0
NEXT
PRINT ct
CLOSE
|
Posted by Charlie
on 2004-12-09 15:23:29 |