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

Home > Numbers
8_Primes IV (Posted on 2013-11-06) Difficulty: 3 of 5
From this set of digits {1,1,2,4,7,9,9,9,9} allot one digit to each cell of a 3 x 3 array so that each column and major diagonal (read top-down) and row (read left-to-right) is a 3-digit prime number, resulting in 8 primes in all.

Then repeat the process using this set: {1,1,1,3,4,6,9,9,9}.

See The Solution 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

DEFDBL A-Z
OPEN "8primesb.txt" FOR INPUT AS #1

CLS

DO
   LINE INPUT #1, l$
   a$ = MID$(l$, 2, 3)
   b$ = MID$(l$, 7, 3)
   c$ = MID$(l$, 12, 3)
   abc$ = a$ + b$ + c$
   good = 1
   FOR i = 1 TO 9
     ix = INSTR(abc$, MID$("112479999", i, 1))
     IF ix = 0 THEN good = 0: EXIT FOR
     abc$ = LEFT$(abc$, ix - 1) + MID$(abc$, ix + 1)
   NEXT
   IF good THEN
           PRINT a$: PRINT b$: PRINT c$: PRINT
           ct = ct + 1
   END IF
LOOP UNTIL EOF(1)
CLOSE 1
'CLOSE 2

PRINT ct

ct = 0

OPEN "8primesb.txt" FOR INPUT AS #1

DO
   LINE INPUT #1, l$
   a$ = MID$(l$, 2, 3)
   b$ = MID$(l$, 7, 3)
   c$ = MID$(l$, 12, 3)
   abc$ = a$ + b$ + c$
   good = 1
   FOR i = 1 TO 9
     ix = INSTR(abc$, MID$("111346999", i, 1))
     IF ix = 0 THEN good = 0: EXIT FOR
     abc$ = LEFT$(abc$, ix - 1) + MID$(abc$, ix + 1)
   NEXT
   IF good THEN
           PRINT a$: PRINT b$: PRINT c$: PRINT
           ct = ct + 1
   END IF
LOOP UNTIL EOF(1)
CLOSE 1
'CLOSE 2

PRINT ct

finds for part 1

419
929
971

499
127
991

941
929
719

and for part 2:

419
691
139

461
139
919

461
193
919

619
349
191

619
499
131

631
149
991

641
139
991

641
193
991

691
499
311


  Posted by Charlie on 2013-11-06 17:30:35
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 (15)
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