Back in
An Arrangement of 15 you were asked to place the numbers 1 to 15 in a line so that any two adjacent numbers summed to a square number.
Now, try to arrange the numbers from 1 to 32 in a circle, so any two adjacent numbers again sum a square number.
The numbers, and the total of each number with the number before:
1 9
15 16
10 25
26 36
23 49
2 25
14 16
22 36
27 49
9 36
16 25
20 36
29 49
7 36
18 25
31 49
5 36
11 16
25 36
24 49
12 36
13 25
3 16
6 9
30 36
19 49
17 36
32 49
4 36
21 25
28 49
8 36
This is one of two found by the following program. The other is just the reverse of this one.
DECLARE SUB addOn (p!)
CLEAR , , 5000
DIM SHARED posn(32), used(32)
CLS
posn(1) = 1: used(1) = 1
addOn 2
SUB addOn (p)
FOR i = 2 TO 32
IF used(i) = 0 THEN
t = posn(p - 1) + i
sqroot = INT(SQR(t) + .5)
IF sqroot * sqroot = t THEN
posn(p) = i
IF p = 32 THEN
t = posn(1) + posn(32)
sqroot = INT(SQR(t) + .5)
IF sqroot * sqroot = t THEN
FOR j = 1 TO 32
IF j = 1 THEN k = 32: ELSE k = j - 1
PRINT USING "###"; posn(j); posn(j) + posn(k)
NEXT
PRINT
END IF
ELSE
used(i) = 1
addOn p + 1
used(i) = 0
END IF
END IF
END IF
NEXT
END SUB
|
Posted by Charlie
on 2005-01-09 19:25:52 |