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

Home > Numbers
8_Primes II (Posted on 2013-10-15) 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 solution Comment 1 of 1

The program:

DEFDBL A-Z
OPEN "8primesb.txt" FOR INPUT AS #1
'OPEN "8primes2.txt" FOR OUTPUT AS #2
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 a3 + b2 + c1 = 4 THEN
     IF a1 + a2 + a3 = 11 THEN
       IF b1 + b2 + b3 = 17 THEN
        IF c1 + c2 + c3 = 5 THEN
           PRINT a$: PRINT b$: PRINT c$
        ct = ct + 1
        END IF
       END IF
     END IF
   END IF
LOOP UNTIL EOF(1)
CLOSE 1
'CLOSE 2

PRINT ct

goes through the output from the original program and finds:

641
809
311

Note that it was not necessary to check every total. The requirements were added as necessary to narrow the answer to one solution.


  Posted by Charlie on 2013-10-15 20:42:09
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 (0)
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