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

Home > Numbers
Primed Groups (Posted on 2010-09-19) 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 3

DECLARE FUNCTION isPrime! (x!)
DATA      19,1,7,16,49
DATA      43,3,4,5,41
DATA      61,64,2,11,49
DATA      37,11,53,36,23
DATA      31,25,29,59,9

FOR r = 1 TO 5
FOR c = 1 TO 5
  READ gr1(r, c)
NEXT
NEXT

CLS

DIM SHARED prime(50)

DATA    2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 41 , 43 , 47 , 53 , 59
DATA    61 , 67 , 71 , 73 , 79 , 83 , 89 , 97 , 101 , 103 , 107 , 109 , 113 , 127 , 131
DATA    137 , 139 , 149 , 151 , 157 , 163 , 167 , 173 , 179 , 181 , 191 , 193 , 197
DATA    199 , 211 , 223 , 227 , 229
       
FOR i = 1 TO 50: READ prime(i): NEXT
       
FOR r = 1 TO 5
FOR c = 1 TO 5
   gr2(r, c) = gr1(r - 1, c) + gr1(r + 1, c) + gr1(r, c - 1) + gr1(r, c + 1)
   LOCATE r + 3, c * 8
   IF isPrime(gr2(r, c)) THEN PRINT gr2(r, c); :  ELSE PRINT "  .  ";
NEXT
NEXT

FUNCTION isPrime (x)
  good = 0
  FOR i = 1 TO 50
    IF x = prime(i) THEN good = 1: EXIT FOR
  NEXT
  isPrime = good
END FUNCTION

shows

 .      29       .      61       .
83       .      17       .      103
 .       .       .       .       .
103     179      .       .       .
 .      71      137      .       .

where only the prime totals are shown for the resulting matrix. There are nine of them.

Then:

   10   dim Grnum(10),H(10),Used(10)
   20   data 17,29,61,71,83,103,103,137,179
   30   for I=1 to 9:read Grnum(I):Ovrtot=Ovrtot+Grnum(I):next
   50   H(1)=1:gosub *Addon2(2)
  999   end
 2000   *Addon2(Ptr)
 2010   local I,J,Strt
 2015   if Ptr @ 3=1 then Strt=H(Ptr-3)+1:else Strt=H(Ptr-1)+1
 2020   for I=Strt to 9
 2021    if Used(I)>0 then goto *NotThis
 2025    if Ptr @ 3=0 and prmdiv(Grnum(H(Ptr-2))+Grnum(H(Ptr-1))+Grnum(I))<Grnum(H(Ptr-2))+Grnum(H(Ptr-1))+Grnum(I) then goto *NotThis
 2030    H(Ptr)=I:Used(I)=1
 2040    if Ptr=9 then
 2090             :for J=1 to 9:print Grnum(H(J));:next:print
 2091    :for J1=0 to 6 step 3:Tt=0:for J2=1 to 3:Tt=Tt+Grnum(H(J1+J2)):next:print Tt;:next:print:print
 2100     :else
 2110        :gosub *Addon2(Ptr+1)
 2120     Used(I)=0
 2125   *NotThis
 2130   next
 2190   return
 
 prints
 
  17  29  61  71  83  103  103  137  179
  107  257  419
 
  17  29  61  71  83  103  103  137  179
  107  257  419
 
  17  29  103  61  83  137  71  103  179
  149  281  353
 
  17  29  103  61  83  137  71  103  179
  149  281  353
 
  17  61  179  29  103  137  71  83  103
  257  269  257
 
  17  61  179  29  103  137  71  83  103
  257  269  257
 
  17  71  103  29  61  83  103  137  179
  191  173  419
 
  17  71  103  29  103  179  61  83  137
  191  311  281
 
  17  71  103  29  61  83  103  137  179
  191  173  419
 
  17  71  103  29  103  179  61  83  137
  191  311  281
 
  17  103  137  29  61  83  71  103  179
  257  173  353
 
  17  103  137  29  61  179  71  83  103
  257  269  257
 
  17  103  137  29  61  83  71  103  179
  257  173  353
 
  17  103  137  29  61  179  71  83  103
  257  269  257
 


In each solution, the first three are the first group; the middle three are the second group; and the last three are the third group.

Each solution is listed twice, as the two 103's are considered distinct by the program. So there are actually 7 solutions, not 14.

The grouping totals are shown in the line below the groupings.


  Posted by Charlie on 2010-09-20 14:21:32
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