All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Adjacent Square Sum (Posted on 2013-05-20)
Arrange the numbers 1 to 15 inclusively in a straight line in such a way that any two adjacent numbers add up to a perfect square.

*** Disregard reflections.

 No Solution Yet Submitted by K Sengupta No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 P 'n P and then ... | Comment 2 of 3 |
After playing around I decided to begin with 1. I chose 15 to make my next square. That set up a chain whereby I could only choose one number at a time tomake my next square.  Eventually I arrived at 9 with 8 unplaced.  Then came realisation, 8 could be the beginning of the string.

Now KS did say to ignore reflections.  I wondered about any other possiblities.  This program listing gives just:
8 1 15 10 6 3 13 12 4 5 11 14 2 7 9 and
9 7 2 14 11 5 4 12 13 3 6 10 15 1 8.

DIM st(15)
DIM used(15)
FOR a = 1 TO 15
IF used(a) = 0 THEN
used(a) = 1
st(1) = a
FOR b = 1 TO 15
IF used(b) = 0 THEN
used(b) = 1
st(2) = b
IF SQR(a + b) = INT(SQR(a + b)) THEN
FOR c = 1 TO 15
IF used(c) = 0 THEN
used(c) = 1
st(3) = c
IF SQR(b + c) = INT(SQR(b + c)) THEN
FOR d = 1 TO 15
IF used(d) = 0 THEN
used(d) = 1
st(4) = d
IF SQR(c + d) = INT(SQR(c + d)) THEN
FOR e = 1 TO 15
IF used(e) = 0 THEN
used(e) = 1
st(5) = e
IF SQR(d + e) = INT(SQR(d + e)) THEN
FOR f = 1 TO 15
IF used(f) = 0 THEN
used(f) = 1
st(6) = f
IF SQR(e + f) = INT(SQR(e + f)) THEN
FOR g = 1 TO 15
IF used(g) = 0 THEN
used(g) = 1
st(7) = g
IF SQR(f + g) = INT(SQR(f + g)) THEN
FOR h = 1 TO 15
IF used(h) = 0 THEN
used(h) = 1
st(8) = h
IF SQR(g + h) = INT(SQR(g + h)) THEN
FOR i = 1 TO 15
IF used(i) = 0 THEN
used(i) = 1
st(9) = i
IF SQR(h + i) = INT(SQR(h + i)) THEN
FOR j = 1 TO 15
IF used(j) = 0 THEN
used(j) = 1
st(10) = j
IF SQR(i + j) = INT(SQR(i + j)) THEN
FOR k = 1 TO 15
IF used(k) = 0 THEN
used(k) = 1
st(11) = k
IF SQR(j + k) = INT(SQR(j + k)) THEN
FOR l = 1 TO 15
IF used(l) = 0 THEN
used(l) = 1
st(12) = l
IF SQR(k + l) = INT(SQR(k + l)) THEN
FOR m = 1 TO 15
IF used(m) = 0 THEN
used(m) = 1
st(13) = m
IF SQR(l + m) = INT(SQR(l + m)) THEN
FOR n = 1 TO 15
IF used(n) = 0 THEN
used(n) = 1
st(14) = n
IF SQR(m + n) = INT(SQR(m + n)) THEN
FOR o = 1 TO 15
IF used(o) = 0 THEN
used(o) = 1
st(15) = o
IF SQR(n + o) = INT(SQR(n + o)) THEN
FOR z = 1 TO 15
PRINT st(z);
NEXT: PRINT
END IF
used(o) = 0
END IF
NEXT

END IF
used(n) = 0
END IF
NEXT

END IF
used(m) = 0
END IF
NEXT

END IF
used(l) = 0
END IF
NEXT

END IF
used(k) = 0
END IF
NEXT

END IF
used(j) = 0
END IF
NEXT

END IF
used(i) = 0
END IF
NEXT

END IF
used(h) = 0
END IF
NEXT

END IF
used(g) = 0
END IF
NEXT

END IF
used(f) = 0
END IF
NEXT

END IF
used(e) = 0
END IF
NEXT

END IF
used(d) = 0
END IF
NEXT

END IF
used(c) = 0
END IF
NEXT

END IF
used(b) = 0
END IF
NEXT
used(a) = 0
END IF
NEXT

 Posted by brianjn on 2013-05-21 02:18:24

 Search: Search body:
Forums (0)