This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. TI-Basic => TI-BASIC
United-TI Archives -> TI-Basic
 
    » Goto page Previous  1, 2, 3, 4, 5, 6  Next
» View previous topic :: View next topic  
Author Message
spandiv
-- Retired --


Active Member


Joined: 25 May 2003
Posts: 650

Posted: 08 Oct 2007 02:47:37 pm    Post subject:

simplethinker wrote:
:For(θ,1,70-S/3
:End

It looks like it's supposed to get faster and faster, but I don't notice a difference.
What calculator do you have? I'm pretty sure if you have a TI-83+SE or TI-84+/SE, then that For( loop is too small of a delay to have any effect. Try replacing 70 with a larger number.

Here is an optimization for the beginning of the program:

:Repeat Ans=92 or Ans=93
:getKey→K // You can just reuse K
:End
:"4,C}-{Ans=25,0
:If K=93:"1,Ans=34}-(Ans={21,25


The Pong program looks pretty good to me... next victim? Very Happy


Last edited by Guest on 10 Sep 2010 02:52:21 am; edited 1 time in total
Back to top
theraven17


Newbie


Joined: 07 Apr 2007
Posts: 40

Posted: 08 Oct 2007 06:31:43 pm    Post subject:

How about another classic to just keep this going? :p

Bomberman - http://www.ticalc.org/archives/files/fileinfo/350/35050.html
4893 KB


Code:
[goose]::
:1→dim({L2}
:2→{L2}(1
:Goto 00
:Lbl BO
:C→G:D-1→H:1→I
:A+1→J:B+1→M
:2→[B](J,M
:DelVar K
:Goto 9
:Lbl P
:While AB≠130
:7(B-1→C
:6(A-1→D
:Text(D,C+1,"Ω
:DelVar K
:While not(K
:not(L→L
:If N>0:Then
:T→V:U→W
:Text(6(T-1),7(U-1),Str1
:U+randInt({-}1,1→U
:T+(U=W)((T<A)-(T>A→T
:If (TU=130)+[B](T+1,U+1
:Then
:W→U
:V+(T>A)-(T<A→T
:If (TU=130)+[B](T+1,U+1:V→T
:End
:Text(6(T-1),1+7(U-1),sub(Str2,3+L,1
:If (A=T)(B=U
:Goto D
:End
:getKey→K
:If not(I)(K=21
:Then
:A+1→J:B+1→M
:C→G:D→H:1→I
:2→[B](J,M
:DelVar K
:End
:o+I→O
:If Ans
:Text(H,G," "+sub(Str2,L+1,1
:If (O>14)+I(K=45:Goto B
:Lbl 8
:End
:A→V:B→W
:A+(K=34)(A<10)-(K=25)(A>1→A
:B+(K=26)(B<13)-(K=24)(B>1→B
:Text(D,C,Str1
:If [B](A+1,B+1
:Then
:V→A:W→B
:End:End
:Goto EG
:Lbl BI
:Repeat AB=70
:2+9(B-1→C
:1+9(A-1→D
:Text({-}1,D,C,"Ω
:DelVar K
:While not(K
:not(L→L
:If N>0:Then
:Text({-}1,1+9(T-1),2+9(U-1),"
:T→V:U→W
:U+randInt({-}1,1→U
:T+(U=W)((T<A)-(T>A→T
:If (TU=70)+[B](T+1,U+1:Then
:V→T:W→U:End
:Text({-}1,1+9(T-1),2+9(U-1),sub(Str2,3+L,1
:If (A=T)(B=U
:Goto D
:End
:getKey→K
:If not(I)(K=21
:Goto BO
:Lbl 9
:o+I→O
:If Ans
:Text({-}1,H,G,sub(Str2,L+1,1
:If (O>10)+I(K=45:Goto B
:End
:A→V:B→W
:A+(K=34)(A<7)-(K=25)(A>1→A
:B+(K=26)(B<10)-(K=24)(B>1→B
:If [B](A+1,B+1
:Then
:V→A:W→B
:End
:Text({-}1,D,C,"
:End
:Goto EG
:Lbl B
:0→[B](J,M
:∟BM(1)-1→∟BM(1
:If Ans≤0:Then
:A+1→J:B+1→M
:C→G:D-(S=15→H
:ClrHome
:Pause "Out Of Bombs!
:End
:Fill 0,{L1}
:DelVar IDelVar ODelVar K
:If S≠15
:Goto B2
:Text(H,G,"φ
:If 2≠[B](J,M-1
:Then
:Text(H,G-7," ((
:1→{L1}(1
:0→[B](J,M-1
:If 2≠[B](J,M-2
:Then
:1→{L1}(2
:Text(H,G-14," ((
:0→[B](J,M-2
:End:End
:If 2≠[B](J,M+1
:Then
:1→{L1}(3
:Text(H,G+7," ))
:0→[B](J,M+1
:If 2≠[B](J,M+2
:Then
:1→{L1}(4
:Text(H,G+14," ))
:0→[B](J,M+2
:End:End
:If 2≠[B](J+1,M
:Then
:1→{L1}(5
:0→[B](J+1,M
:Text(H+6,G,"*
:If 2≠[B](J+2,M
:Then
:1→{L1}(6
:0→[B](J+2,M
:Text(H+12,G,"*
:End:End
:If 2≠[B](J-1,M
:Then
:1→{L1}(7
:Text(H-6,G,"*
:0→[B](J-1,M
:If 2≠[B](J-2,M
:Then
:1→{L1}(8
:Text(H-12,G,"*
:0→[B](J-2,M
:End:End
:Text(H,G,Str1
:If {L1}(1
:Text(H,G-7,Str1
:If {L1}(2
:Text(H,G-14,Str1
:If {L1}(3
:Text(H,G+7,Str1
:If {L1}(4
:Text(H,G+14,Str1
:If {L1}(5
:Text(H+6,G,Str1
:If {L1}(6
:Text(H+12,G,Str1
:If {L1}(7
:Text(H-6,G,Str1
:If {L1}(8
:Text(H-12,G,Str1
:If not(pxl-Test(D+3,C+1:Goto D
:N-not(pxl-Test(5+6(T-1),1+7(U-1→N
:If not(pxl-Test(56,89:Goto EX
:Goto 8
:Lbl B2
:G-2→G
:If 2≠[B](J,M-1
:Then
:Text({-}1,H,G-9,"(
:Text({-}1,H,G-6,"(
:0→[B](J,M-1
:1→{L1}(5
:If 2≠[B](J,M-2
:Then
:Text({-}1,H,G-18,"(
:Text({-}1,H,G-15,"(
:0→[B](J,M-2
:1→{L1}(6
:End:End
:If 2≠[B](J,M+1
:Then
:Text({-}1,H,G+11,")
:Text({-}1,H,G+8,")
:If 70=M(J-1
:Goto EX
:0→[B](J,M+1
:1→{L1}(7
:If 2≠[B](J,M+2
:Then
:Text({-}1,H,G+20,")
:Text({-}1,H,G+17,")
:If 70=(M+1)(J-1:Goto EX
:0→[B](J,M+2
:1→{L1}(8
:End:End
:If 2≠[B](J+1,M
:Then
:0→[B](J+1,M
:1→{L1}(1
:Text({-}1,H+9,G,"*
:Text({-}1,H+9,G+2,"*
:If 2≠[B](J+2,M
:Then
:0→[B](J+2,M
:Text({-}1,H+18,G,"*
:Text({-}1,H+18,G+2,"*
:1→{L1}(2
:End:End
:If 2≠[B](J-1,M
:Then
:Text({-}1,H-9,G,"*
:Text({-}1,H-9,G+2,"*
:0→[B](J-1,M
:1→{L1}(3
:If 2≠[B](J-2,M
:Then
:Text({-}1,H-18,G,"*
:Text({-}1,H-18,G+2,"*
:1→{L1}(4
:0→[B](J-2,M
:End:End
:Text({-}1,H,G+1,"
:For(θ,0,1
:If {L1}(5
:Text(H+θ,G-9,"         
:If {L1}(6
:Text(H+θ,G-18,"         
:If {L1}(7
:Text(H+θ,G+8,"         
:If {L1}(8
:Text(H+θ,G+17,"         
:End
:If {L1}(1
:Then
:Text({-}1,H+9,G,"
:Text({-}1,H+9,G+2,"
:End
:If {L1}(2:Then
:Text({-}1,H+18,G,"
:Text({-}1,H+18,G+2,"
:End
:If {L1}(3:Then
:Text({-}1,H-9,G,"
:Text({-}1,H-9,G+2,"
:End
:If {L1}(4:Then
:Text({-}1,H-18,G,"
:Text({-}1,H-18,G+2,"
:End
:If not(pxl-Test(D+1,C:Goto D
:N-not(pxl-Test(7+9(T-1),3+9(U-1→N
:Goto 9
:Lbl 00
:ClrHome
:"Bomberman!→Str3
:FnOff :AxesOff
:{-}62→Ymin:0→YMax:0→Xmin:94→Xmax
:PlotsOff
:"ãâÇç→Str2
:"       →Str1
:8→dim({L1}
:2→dim({L2}
:1→R
:Menu(Str3,"small level",4,"BIG LEVEL",5,"INSTRUCTIONS",I,"DIFFICULTY",DI,"EXIT",Q
:Lbl DI
:ClrHome
:Output(8,1,Str3
:Disp "DIFFICULTY?
:For(θ,0,5
:Output(4,θ+6,θ
:End
:2→A
:DelVar K
:0:Repeat K=21
:Repeat K
:A+6→C
:Output(3,Ans,"?
:Output(5,Ans,"¿
:For(θ,1,8:End
:Output(3,C,"
:Output(5,C,"
:getKey→K:End
:A+(K=26)(A<5)-(K=24)(A>0→A
:End
:A→{L2}(1
:Goto 00
:Lbl 5
:9→P:12→S
:{20,3→∟BM
:Goto NL
:Lbl 4
:12→P:15→S
:{35,3→∟BM
:Lbl NL
:If not(∟BM(1
:5→∟BM(1
:DelVar ODelVar IDelVar T
:{L2}(1→N
:ClrDraw
:Disp "LOADING...
:Output(4,4,Str3
:Output(7,1,"Bombs:
:Output(7,8,∟BM(1
:Output(8,1,"Lives:
:Output(8,8,∟BM(2
:{P,S→dim([B]
:Fill 1,[B]
:For(θ,1,P-2
:not(L→L
:sub(Str2,L+1,1
:Output(4,3,Ans
:Output(4,14,Ans
:2→[B](θ+1,1
:2→[B](θ+1,S
:End
:For(θ,2,S-1
:not(L→L
:sub(Str2,L+1,1
:Output(4,3,Ans
:Output(4,14,Ans
:2→[B](1,θ
:2→[B](P,θ
:End
:For(θ,1,33+40(S=15
:not(L→L
:sub(Str2,L+1,1
:Output(4,3,Ans
:Output(4,14,Ans
:0→[B](randInt(2,P-1),randInt(2,S-1
:End
:For(θ,3,S-1,2
:not(L→L
:sub(Str2,L+1,1
:Output(4,3,Ans
:Output(4,14,Ans
:For(Z,3,P-2,2
:2→[B](Z,θ
:End:End
:0→[B](P-1,S-2
:p-2→T:S-3→U
:0→[B](2,2
:0→[B](2,3
:0→[B](3,2
:0→[B](P-1,S-1
:1→A:1→B
:DelVar K
:ClrHome
:If S≠15
:Goto D2
:For(θ,1,13
:For(Z,1,10
:7(θ-1→C
:{-}6(Z-1→D
:[B](Z+1,θ+1
:If Ans:Then
:Line(C+1,D,C+5,D
:Line(C,D-1,C,D-4
:Line(C+6,D-1,C+6,D-4
:Line(C+1,D-5,C+5,D-5
:If Ans=2:Then
:Line(C+1,D-3,C+2,D-4
:Line(C+1,D-1,C+4,D-4
:Line(C+3,D-1,C+5,D-3
:pt-On(C+5,D-1
:Else
:Line(C+3,D-2,C+4,D-2
:pt-On(C+4,D-3
:End:End:End:End
:For(θ,0,1
:Line(84+θ,{-}57,84+θ,{-}59
:Line(88+θ,{-}57,88+θ,{-}59
:End
:Line(86,{-}56,87,{-}56
:Line(84,{-}56,86,{-}54
:Line(89,{-}56,87,{-}54
:Goto P
:Lbl D2
:For(θ,1,10
:For(Z,1,7
:9(θ-1→C
:{-}9(Z-1→D
:[B](Z+1,θ+1
:If Ans=1:Then
:Line(C+1,D,C+6,D
:Line(C,D-1,C,D-6
:Line(C+1,D-7,C+6,D-7
:Line(C+7,D-1,C+7,D-6
:Line(C+1,D-5,C+2,D-6
:Line(C+1,D-3,C+4,D-6
:Line(C+1,D-1,C+6,D-6
:Line(C+3,D-1,C+6,D-4
:Line(C+5,D-1,C+6,D-2
:End
:If Ans=2:Then
:Line(C+2,D,C+5,D
:Line(C+1,D-1,C+6,D-1
:For(W,2,5
:Line(C,D-W,C+7,D-W:End
:Line(C+1,D-6,C+6,D-6
:Line(C+3,D-7,C+4,D-7
:Line(C+4,D-2,C+5,D-3,0
:pt-Off(C+5,D-2
:End:End:End
:Line(82,{-}61,82,{-}57
:Line(83,{-}61,83,{-}58
:Line(82,{-}57,84,{-}55
:Line(85,{-}55,85,{-}58
:Line(86,{-}55,88,{-}57
:Line(88,{-}57,88,{-}61
:Line(87,{-}58,87,{-}61
:Line(84,{-}57,86,{-}57
:Goto BI
:Lbl I
:ClrDraw
:Text(0,0,"----",Str3,"----
:Text(10,0,"YOU ARE BOB AND MUST LAY
:Text(16,0,"BOMBS TO GET TO THE EXIT
:Text(22,0,"(LOWER RIGHT)
:Text(28,0,"DON'T RUN INTO DIRTY JOE!
:Text(34,0,"ER IST WARM!
:Text(40,0,"IT TAKES X HITS TO KILL HIM
:Text(46,0,"(DEPENDS ON DIFFICULTY)
:5→A
:0:Repeat Ans
:not(L→L
:Text({-}1,54,8(A-1),sub(Str2,L+3,1
:For(θ,1,100
:End
:Text({-}1,54,8(A-1),"
:A+randInt({-}1,1
:Ans+(Ans<1)-(Ans>11→A
:getKey:End
:ClrDraw
:Text(0,0,"----",Str3,"----
:Text(12,0,"KEYS--
:Text(18,0,"2ND=LAY BOMB
:Text(24,0,"CLEAR DETONATES BOMB
:"!!!!!CAUTION!!!!!→Str4
:Text(40,0,"BOMBS WILL DETONATE AFTER
:Text(46,0,"A LITTLE BIT!
:For(θ,0,90,9
:Text(57,θ,":)
:End
:0:Repeat Ans
:Text(32,0,Str4
:For(θ,1,300
:End
:getKey→K
:If not(K:Then
:Text({-}1,31,0,"           
:For(θ,1,350
:End
:getKey
:End:End
:Goto 00
:Lbl EX
:Text({-}1,20,0,"YOU BLEW UP THE
:Text({-}1,28,35,"EXIT!
:Pause
:Goto D
:Lbl EG
:10(N≤0)+∟BM(1→∟BM(1
:R+1→R
:Text({-}1,26,30,"LEVEL ",R
:Pause
:Goto NL
:Lbl D
:For(θ,0,47,2
:Vertical θ
:Vertical 94-θ
:End
:∟BM(2)-1→∟BM(2
:If Ans>0
:Goto NL
:"GAME OVER→Str1
:For(Z,1,9
:sub(Str1,Z,1
:If Ans≠"
:Then
:Text({-}1,28,9Z,Ans
:For(θ,1,250
:End:End:End
:Lbl Q
:ZStandard:AxesOn:DelVar [B]ClrHome
:Output(1,8,":)[/goose]


Just seems to be a lot of clutter... and smilies...


Last edited by Guest on 10 Sep 2010 02:52:46 am; edited 1 time in total
Back to top
JoostinOnline


Active Member


Joined: 22 Aug 2007
Posts: 559

Posted: 08 Oct 2007 06:36:36 pm    Post subject:

Would you like to specify what the goes in place of the smilies?
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 08 Oct 2007 06:42:29 pm    Post subject:

Smilies fix0red.
Back to top
alexrudd
pm me if you read this


Bandwidth Hog


Joined: 06 Oct 2004
Posts: 2335

Posted: 08 Oct 2007 08:06:23 pm    Post subject:

The game isn't very flattering to Joe if you translate the slang from German. I would suggest removing it. Razz
Back to top
IAmACalculator
In a state of quasi-hiatus


Know-It-All


Joined: 21 Oct 2005
Posts: 1571

Posted: 09 Oct 2007 05:32:31 pm    Post subject:

My gosh man, haven't you ever heard of a [­codebox]?
Back to top
spandiv
-- Retired --


Active Member


Joined: 25 May 2003
Posts: 650

Posted: 09 Oct 2007 10:53:17 pm    Post subject:

IAmACalculator wrote:
My gosh man, haven't you ever heard of a [­codebox]?
I actually said they can use whatever they want at the beginning of the thread, including [goose/], [code/], or [codebox/]. Personally, I think a [codebox/] isn't very practical because the reader has to scroll through the code to see it all; it's much easier to have all of the code available on the screen.
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 09 Oct 2007 10:57:54 pm    Post subject:

I'd rather see it in a codebox so that I don't have to scroll a mile to reach nonadjacent posts; you can usually Ctrl+click on its contents and then paste it into Notepad, Wordpad, or what-else-have-you.

Last edited by Guest on 09 Oct 2007 11:03:36 pm; edited 1 time in total
Back to top
spandiv
-- Retired --


Active Member


Joined: 25 May 2003
Posts: 650

Posted: 09 Oct 2007 11:28:27 pm    Post subject:

Weregoose wrote:
I'd rather see it in a codebox so that I don't have to scroll a mile to reach nonadjacent posts; you can usually Ctrl+click on its contents and then paste it into Notepad, Wordpad, or what-else-have-you.
Well, after seeing the code in a codebox, I actually agree with you Very Happy I suppose we can make that the standard from now on, considering most of the programs are pretty long. For consistency, would you mind doing that to the rest of the programs?

EDIT: Thanks Goose.


Last edited by Guest on 09 Oct 2007 11:59:15 pm; edited 1 time in total
Back to top
Super Speler
Super Awesome Dude


Calc Guru


Joined: 28 Nov 2005
Posts: 1391

Posted: 10 Oct 2007 05:05:25 pm    Post subject:

The *unspoken* standard has always been (as far as I've seen) codebox for long pieces of code and goose tags for short.
Back to top
CyJackX


Newbie


Joined: 26 Aug 2007
Posts: 30

Posted: 12 Oct 2007 04:50:20 pm    Post subject:

This is a prime factoring program that I started two days ago. I made one, looked on this site, and found that Weregoose had already made a very quick one, so I did use some of his quicker tactics. However, I wanted to make a program that would:
1. Use whatever prime numbers it already knows first(LMasterPrimes)
2. If none of the primes in its masterlist are known, then to use brute force (go up by 1 each time)
3. Once it's finished, add the Primes list to its MasterPrime list, basically "learning" prime numbers to first test for in the future. (This is the last 5 lines of the code)

My computer is in chinese, so when I open the .8xp in TI-Graph Link, many of the symbols show up as crazy chinese words, so I had to go through and edit some things. If you know how to solve this problem, help would be appreciated. My computer can read those symbols on these forums, but they can't seem to comprehend them from the .8xp file.

If this code is confusing, I will go through it.

0-5 : Formality, number prompt and making sure it is an integer above 2
6: Deleting the previous run's answers
7: Setting the MasterPrime element to the first one
8: Putting 2 as the very first prime in the Master Prime list. This creates the list if this is the first time running it.
9: Storing the size of the MasterPrime list to a variable because it is referenced many times
10: Putting 2 as the first number of the "Brute Force"
11: Repeat the below process until X has been divided by all its factors, making it 1
12: This continually changes the Test number until X is evenly divided by it.
13-19: This is essentially the part that I have been wracking my brains over how to best code.
13: If there are still Masterprime numbers left, move up 1
14: The Prime number from the MasterPrime list at position Z
15: If that Prime is bigger than the squareroot of X or It has reached the end of the masterprime list,
16: Use T
17: If T is bigger than the squareroot of X,
18: Then store X to ans because it must be prime.
20: Whatever was eventually stored to ans, store it to the Prime List for the initial number
21: Then divide the current X by the ans to get a smaller X
22-24: Use T as ans if there aren't any Masterprimes left


Code:
0:Input "Number? ",X
1:If fPart(X)+(X<=1
2:Then
3:Disp "    Invalid!
4:Stop
5:End
6:0-->dim(LPRIMES
7:1-->Z
8:2-->LMasterPrimes(1
9:dim(LMasterPrimes-->Y
10:2-->T
11:Repeat X=1
12:While fPart(X/Ans
13:Z+(Z<Y-->Z
14:LMasterPrimes(Ans
15:If Ans>sqrt(X) or Z>=Y
16:T+1-->T
17:If Ans>sqrt(X
18:X
19:End
20:Ans-->LPrimes(1+dim(LPrimes
21:X/Ans-->X
22:LMasterPrimes(Z
23:If Ans>sqrt(X) or Z>=Y
24:T
25:End
26:For(X,1,dim(LMasterPrimes
27:If not(max(LMasterPrimes=LPrimes(X
28:LPrimes(X-->LMasterprimes(1+dim(LMasterprimes
29:End
30:SortA(LMasterprimes
31:LPrime


I've tried many different things for the code within the While( function, but this is the best i've gotten.


Last edited by Guest on 10 Sep 2010 02:53:37 am; edited 1 time in total
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 12 Oct 2007 06:02:57 pm    Post subject:

sqrt(X or Z≥Y? Uh oh. That's performing a test on whether one of X or Z≥Y is nonzero, so all this ends up doing is taking the square root of 0 or 1. I'm sure this is not what you meant!

[EDIT]

I've fixed this for you, so I will now begin looking at the code.

Let me also clarify that LPrimes can be taken as LP and the other list LMP, correct?

[EDIT×2]

Also, is max(LMasterPrimes= supposed to be max(LMasterPrimes)=?


Last edited by Guest on 10 Sep 2010 02:54:19 am; edited 1 time in total
Back to top
CyJackX


Newbie


Joined: 26 Aug 2007
Posts: 30

Posted: 12 Oct 2007 07:10:19 pm    Post subject:

Weregoose wrote:
sqrt(X or Z≥Y? Uh oh. That's performing a test on whether one of X or Z≥Y is nonzero, so all this ends up doing is taking the square root of 0 or 1. I'm sure this is not what you meant!
I've fixed this for you, so I will now begin looking at the code.

Let me also clarify that LPrimes can be taken as LP and the other list LMP, correct?

Also, is max(LMasterPrimes= supposed to be max(LMasterPrimes)=?
[post="114370"]<{POST_SNAPBACK}>[/post]


Hm, the sqrt thing may have been a clerical error when I was putting it on the computer.

And yes, the lists are actually LP and LMP in my calculator, but I unabbreviated them when I posted them.

No, I intended the code to be max(Lmasterprimes=LPrimes(X
If LPrime(X is already in LMasterPrimes, a 1 will be returned, if LPrime(X is not in LMasterPrimes, a 0 will be returned. This was how I determined whether to add LPrime(X into LMasterprimes


Last edited by Guest on 10 Sep 2010 02:55:55 am; edited 1 time in total
Back to top
johnbasedow


Newbie


Joined: 27 Sep 2007
Posts: 21

Posted: 12 Oct 2007 10:45:11 pm    Post subject:

These are part of a program I found. Not my code, but I'd still like it optimized.

DelVar L1Prompt A,L
1->C
For(D,1,sqrt(A
If not(fPart(A/D
Then
D->L1(C
C+1->C
End
End

C-1->F

While F>0
L1(F)->G
F-1->F
A/G^2->K
If not(fPart(K
Then
blah, blah, blah... unimportant output stuff
End
End
Back to top
CyJackX


Newbie


Joined: 26 Aug 2007
Posts: 30

Posted: 14 Oct 2007 11:56:51 am    Post subject:

johnbasedow wrote:
These are part of a program I found. Not my code, but I'd still like it optimized.
[post="114376"]<{POST_SNAPBACK}>[/post]


It would help if we knew what the program was supposed to do...
Does the second half of the program NEED to calculate F going down?
Does the program use L?
I'm going to assume it doesn't need either and alter it a bit, then...

This is what I could do...

Prompt A
For(X,1,sqrt(A
If not(fPart(A/X^2
Then
???OUtput???
End
End


Is it some sort of prime checker? What do you need outputted? Because I deleted a lot of variables from the program...


Last edited by Guest on 10 Sep 2010 02:56:31 am; edited 1 time in total
Back to top
JoostinOnline


Active Member


Joined: 22 Aug 2007
Posts: 559

Posted: 14 Oct 2007 12:31:44 pm    Post subject:

Yes, I was wondering which variables need to be preserved as well. You really can't optimize somthing unless you know the point of the program.
Back to top
CyJackX


Newbie


Joined: 26 Aug 2007
Posts: 30

Posted: 18 Oct 2007 06:51:47 pm    Post subject:

With my prime program, I did this for the While section and managed to make it a little faster:


:1-->D


:While DfPart(X/Ans
:IS>(Z,Y
:LMasterPrimes(Z
:If Ans^2>X or Z>=Y
:Delvar D
:End
:While not(D)fPart(X/Ans
:T+1-->T
:If Ans^2>X
:X
:End


I wasn't sure if splitting it up into two seperate While(functions was quicker, but it seems to be.


Last edited by Guest on 10 Sep 2010 02:52:00 am; edited 1 time in total
Back to top
johnbasedow


Newbie


Joined: 27 Sep 2007
Posts: 21

Posted: 19 Oct 2007 12:55:18 am    Post subject:

The only variables that need to be preserved are A and L
Back to top
CyJackX


Newbie


Joined: 26 Aug 2007
Posts: 30

Posted: 20 Oct 2007 06:28:03 pm    Post subject:

johnbasedow wrote:
The only variables that need to be preserved are A and L
[post="114629"]<{POST_SNAPBACK}>[/post]


Really? Besides being prompted, L doesn't seem to be referenced in the rest of the code you showed. If A is needed, the code I posted earlier should work.
Back to top
CyJackX


Newbie


Joined: 26 Aug 2007
Posts: 30

Posted: 09 Nov 2007 03:23:28 pm    Post subject:

Bump?
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    » Goto page Previous  1, 2, 3, 4, 5, 6  Next
» View previous topic :: View next topic  
Page 4 of 6 » All times are UTC - 5 Hours

 

Advertisement