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

 Non-arithmetic Triplets (Posted on 2013-04-08)
Find nine different integers from 1 to 20 inclusive such that no combination of any three of the nine integers form an arithmetic sequence.

(For example, if two of the integers chosen were 7 and 13, then that would preclude 1, 10 and 19 from being included.)

 No Solution Yet Submitted by K Sengupta No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution--includes the symmetric opposite | Comment 3 of 9 |

CLEAR , , 25000
DIM SHARED num(9)
CLS
FOR st = 1 TO 10
num(1) = st
NEXT st

IF sb = 1 THEN strt = 1 ELSE strt = num(sb - 1) + 1
FOR newnum = strt TO 20
good = 1
FOR i = 1 TO sb - 2
FOR j = i + 1 TO sb - 1
IF num(j) - num(i) = newnum - num(j) THEN good = 0: EXIT FOR
NEXT
NEXT
IF good THEN
num(sb) = newnum

IF sb = 9 THEN
FOR i = 1 TO 9
PRINT USING "###"; num(i);
NEXT
PRINT
ELSE
END IF

END IF
NEXT
END SUB

finds

1  2  6  7  9 14 15 18 20
1  3  6  7 12 14 15 19 20

The latter solution of course represents intervals starting with the last interval of the first solution, and so forth.

 Posted by Charlie on 2013-04-08 16:03:25

 Search: Search body:
Forums (0)