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

Home > Numbers
Prime Central (Posted on 2008-12-10) 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 One example of each possible x. | Comment 2 of 6 |
 7349  5623  8293  5273  4253  2269  8761        7349  8461
 1009  1117  1223  2333  1447  1553  1663        1889  1993
 2003  8111  1229  6337  5449  1559  1669        2887  1999
 1171  9319  1171  1913  9137  1117  7919        7193  7919
 3048  203   3272  361   448   951   1319  0     1069  291

The number under each is the number of possible arrangements of primes that would work for that x, when requiring that all the 4-digit primes be different.

  100     dim Usable(15),Taken(15)
  110   cls
  200     for X=0 to 99 step 11
  300       Ct=0:SCt=0
  400       N=1000
  500       while N<9999
  600         N=nxtprm(N)
  700         if N<9999 then
  800          :M=int((N@1000)/10)
  900          :if M=X then
 1000            :Ct=Ct+1
 1100            :Usable(Ct)=N
 1200       wend
 1300       for I=1 to 15:Taken(I)=0:next
 1400       for R2=1 to Ct
 1500        if Taken(R2)=0 then
 1600          :Taken(R2)=1
 1700       :for R3=1 to Ct
 1800        :if Taken(R3)=0 then
 1900          :Taken(R3)=1
 2000       :for C2=1 to Ct
 2100        :if Taken(C2)=0 then
 2200          :Taken(C2)=1
 2300       :for C3=1 to Ct
 2400        :if Taken(C3)=0 then
 2500          :Taken(C3)=1
 2600       :for D1=1 to Ct
 2700        :if Taken(D1)=0 then
 2800          :Taken(D1)=1
 2900       :for D2=1 to Ct
 3000        :if Taken(D2)=0 then
 3100          :Taken(D2)=1
 3200          :G21=int(Usable(R2)/1000)
 3300          :G31=int(Usable(R3)/1000)
 3400          :G24=Usable(R2)@10
 3500          :G34=Usable(R3)@10
 3600          :G12=int(Usable(C2)/1000)
 3700          :G13=int(Usable(C3)/1000)
 3800          :G42=Usable(C2)@10
 3900          :G43=Usable(C3)@10
 4000          :G11=int(Usable(D1)/1000)
 4100          :G14=int(Usable(D2)/1000)
 4200          :G44=Usable(D1)@10
 4300          :G41=Usable(D2)@10
 4400          :R1=1000*G11+100*G12+10*G13+G14
 4500          :R4=1000*G41+100*G42+10*G43+G44
 4600          :C1=1000*G11+100*G21+10*G31+G41
 4700          :C4=1000*G14+100*G24+10*G34+G44
 4800          :if prmdiv(R1)=R1 and prmdiv(R4)=R4 and prmdiv(C1)=C1 and prmdiv(C4)=C4 then
 4810   :Good=1:if R1=R4 or R1=C1 or R1=C4 or R4=C1 or R4=C4 or C1=C4 then Good=0:endif
 4811   :if R1=Usable(R2) or R1=Usable(R3) or R1=Usable(C2) or R1=Usable(C3) or R1=Usable(D1) or R1=Usable(D2) then Good=0:endif
 4812   :if R4=Usable(R2) or R4=Usable(R3) or R4=Usable(C2) or R4=Usable(C3) or R4=Usable(D1) or R4=Usable(D2) then Good=0:endif
 4813   :if C4=Usable(R2) or C4=Usable(R3) or C4=Usable(C2) or C4=Usable(C3) or C4=Usable(D1) or C4=Usable(D2) then Good=0:endif
 4814   :if C1=Usable(R2) or C1=Usable(R3) or C1=Usable(C2) or C1=Usable(C3) or C1=Usable(D1) or C1=Usable(D2) then Good=0:endif
 4880           :if Good then
 4890            :SCt=SCt+1
 4900             :if SCt=1 then
 4901               :locate int(X*6/11)+1,3:print R1;
 4902               :locate int(X*6/11)+1,4:print Usable(R2);
 4903               :locate int(X*6/11)+1,5:print Usable(R3);
 4904               :locate int(X*6/11)+1,6:print R4;
 4905             :endif
 4910           :endif
 5000          :endif
 5100          :Taken(D2)=0
 5200        :endif
 5250       :next D2
 5300          :Taken(D1)=0
 5400        :endif
 5500       :next D1
 5600          :Taken(C3)=0
 5700        :endif
 5800       :next C3
 5900          :Taken(C2)=0
 6000        :endif
 6100       :next C2
 6200          :Taken(R3)=0
 6300        :endif
 6400       :next R3
 6500          :Taken(R2)=0
 6600        :endif
 6700        next R2
 7000   locate int(6*X/11)+1,8:print SCt
 7100     next X


  Posted by Charlie on 2008-12-10 20:36:39
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 (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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