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

Home > General
Non-arithmetic Triplets (Posted on 2013-04-08) Difficulty: 3 of 5
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.)

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

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

DECLARE SUB addOn (sb!)
CLEAR , , 25000
DIM SHARED num(9)
CLS
FOR st = 1 TO 10
  num(1) = st
  addOn 2
NEXT st

SUB addOn (sb)
  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
        addOn sb + 1
      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
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (14)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information