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

Home > Numbers
8_Primes III (Posted on 2013-10-21) Difficulty: 3 of 5

No Solution Yet Submitted by brianjn    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solutions Comment 1 of 1

The program reads the file created for the first 8 primes puzzle, to examine for the requested conditions.

DEFDBL A-Z
OPEN "8primesb.txt" FOR INPUT AS #1
mindiffdg = 999
CLS
DO
   LINE INPUT #1, l$
   a$ = MID$(l$, 2, 3)
   b$ = MID$(l$, 7, 3)
   c$ = MID$(l$, 12, 3)
   a1 = VAL(LEFT$(a$, 1)): a2 = VAL(MID$(a$, 2, 1)): a3 = VAL(RIGHT$(a$, 1))
   b1 = VAL(LEFT$(b$, 1)): b2 = VAL(MID$(b$, 2, 1)): b3 = VAL(RIGHT$(b$, 1))
   c1 = VAL(LEFT$(c$, 1)): c2 = VAL(MID$(c$, 2, 1)): c3 = VAL(RIGHT$(c$, 1))
   IF a1 = a2 AND b1 = a1 AND c2 = c3 AND c3 = b3 THEN
    IF a1 <> c3 THEN
      REDIM used(9)
      used(a1) = 1: used(b3) = 1: uct = 2
      IF used(a3) = 0 THEN used(a3) = 1: uct = uct + 1
      IF used(b2) = 0 THEN used(b2) = 1: uct = uct + 1
      IF used(c1) = 0 THEN used(c1) = 1: uct = uct + 1
      IF uct = 4 THEN
         r0 = (ct \ 16) * 5 + 1: c0 = (ct MOD 16) * 5 + 1
         LOCATE r0, c0
         PRINT a$
         LOCATE r0 + 1, c0: PRINT b$
         LOCATE r0 + 2, c0: PRINT c$: PRINT
         ct = ct + 1
      END IF
    END IF
   END IF
LOOP UNTIL EOF(1)
CLOSE 1

PRINT ct

OPEN "8primesb.txt" FOR INPUT AS #1
ct = 0

DO
   LINE INPUT #1, l$
   a$ = MID$(l$, 2, 3)
   b$ = MID$(l$, 7, 3)
   c$ = MID$(l$, 12, 3)
   a1 = VAL(LEFT$(a$, 1)): a2 = VAL(MID$(a$, 2, 1)): a3 = VAL(RIGHT$(a$, 1))
   b1 = VAL(LEFT$(b$, 1)): b2 = VAL(MID$(b$, 2, 1)): b3 = VAL(RIGHT$(b$, 1))
   c1 = VAL(LEFT$(c$, 1)): c2 = VAL(MID$(c$, 2, 1)): c3 = VAL(RIGHT$(c$, 1))
   IF a1 = a2 AND b1 = a1 AND c2 = c3 AND c3 = b3 THEN
    IF a1 = c3 THEN
      REDIM used(9)
      used(a1) = 1: uct = 1
      IF used(a3) = 0 THEN used(a3) = 1: uct = uct + 1
      IF used(b2) = 0 THEN used(b2) = 1: uct = uct + 1
      IF used(c1) = 0 THEN used(c1) = 1: uct = uct + 1
      IF uct = 4 THEN
         r0 = (ct \ 16) * 5 + 21: c0 = (ct MOD 16) * 5 + 1
         LOCATE r0, c0
         PRINT a$
         LOCATE r0 + 1, c0: PRINT b$
         LOCATE r0 + 2, c0: PRINT c$: PRINT
         ct = ct + 1
      END IF
    END IF
   END IF
LOOP UNTIL EOF(1)
CLOSE 1

PRINT ct

OPEN "8primesb.txt" FOR INPUT AS #1
ct = 0

DO
   LINE INPUT #1, l$
   a$ = MID$(l$, 2, 3)
   b$ = MID$(l$, 7, 3)
   c$ = MID$(l$, 12, 3)
   a1 = VAL(LEFT$(a$, 1)): a2 = VAL(MID$(a$, 2, 1)): a3 = VAL(RIGHT$(a$, 1))
   b1 = VAL(LEFT$(b$, 1)): b2 = VAL(MID$(b$, 2, 1)): b3 = VAL(RIGHT$(b$, 1))
   c1 = VAL(LEFT$(c$, 1)): c2 = VAL(MID$(c$, 2, 1)): c3 = VAL(RIGHT$(c$, 1))
   IF a1 = a2 AND b1 = a1 AND c2 = c3 AND c3 = b3 THEN
    IF a1 = c3 THEN
      REDIM used(9)
      used(a1) = 1: uct = 1
      IF used(a3) = 0 THEN used(a3) = 1: uct = uct + 1
      IF used(b2) = 0 THEN used(b2) = 1: uct = uct + 1
      IF used(c1) = 0 THEN used(c1) = 1: uct = uct + 1
      IF uct = 3 THEN
         r0 = (ct \ 16) * 5 + 31: c0 = (ct MOD 16) * 5 + 1
         LOCATE r0, c0
         PRINT a$
         LOCATE r0 + 1, c0: PRINT b$
         LOCATE r0 + 2, c0: PRINT c$: PRINT
         ct = ct + 1
      END IF
    END IF
   END IF
LOOP UNTIL EOF(1)
CLOSE 1

PRINT ct

For part 1 it finds 19 solutions:

223  223  223  227  227  331  331  449  557  557  661  773  881  881  881  887
251  271  281  283  293  359  389  421  523  593  659  751  809  839  859  823
311  311  311  733  733  199  199  911  733  733  199  311  199  199  199  733


887  997  997
853  953  983
733  733  733

It finds no solutions for part 2, and 4 solutions for part 3:

113  113  337  337
151  181  353  383
311  311  733  733


  Posted by Charlie on 2013-10-21 20:21:42
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (16)
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