Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: 3.1415926535 on August 13, 2009, 07:41:19 pm

Title: Optimization?
Post by: 3.1415926535 on August 13, 2009, 07:41:19 pm
My first program!

its a simple screen inverter thing.
I'd liek to know if anyone can help me optimize it and tell me why. thanks!
Code: [Select]
1→E:94→F
:1→A:1→B
:For(C,0,46,1)
:For(D,0,61,1)
:Pxl-Change(A,B)
:Pxl-Change(E,F)
:A+1→A
:E+1→E
:End
:B+1→B
:F-1→F
:1→E
:1→A
:End
Title: Re: Optimization?
Post by: noahbaby94 on August 13, 2009, 07:44:50 pm
Code: [Select]
:For(A,0,62
:For(B,0,94
:Pxl-Change(A,B
:End:End
You don't need closing parentheses and the increment on the for is option and defaults to 1. Really alot of the code is filler and can just be simplified to this.
Formatted your post too.
Title: Re: Optimization?
Post by: 3.1415926535 on August 13, 2009, 07:48:26 pm
how do you format?
and thanks!
Title: Re: Optimization?
Post by: noahbaby94 on August 13, 2009, 07:48:59 pm
code tags. [code ] code here [/code ] with out the spaces.
Title: Re: Optimization?
Post by: 3.1415926535 on August 13, 2009, 07:50:10 pm
i'm sorry if i'm sounding really stupid, but what are tags? and how do you get them
Title: Re: Optimization?
Post by: 3.1415926535 on August 13, 2009, 07:56:56 pm
how bout this program? =)

Code: [Select]


:Input "ROW=",R
:R-1→R
:If R
:2^Rbinompdf(R,.5)

Title: Re: Optimization?
Post by: Geekboy1011 on August 15, 2009, 11:27:52 am
hmm i think this is more optimized probally more that can be done though

Code: [Select]
:Input "ROW=",R
:R-1→R
                                :removed because it is not needed? works without
:2^Rbinompdf(R,.5        removed last parenthesy [ ) ] that


umm randdom q whats binompdf do ?
Title: Re: Optimization?
Post by: noahbaby94 on August 15, 2009, 11:32:04 am
Crazy shit http://tibasicdev.wikidot.com/binompdf
Title: Re: Optimization?
Post by: Geekboy1011 on August 15, 2009, 11:35:13 am
0.0 i see what you mean noah thanks 0.0
Title: Re: Optimization?
Post by: 3.1415926535 on August 15, 2009, 03:36:00 pm
oooo thanks!

I'm trying to make an inverter program that inverts diagonally instead of horizontally or vertically.
Any ideas how to do this?
Title: Re: Optimization?
Post by: 3.1415926535 on August 15, 2009, 04:03:11 pm
why do i always get a domain error when i run this program?

Code: [Select]
:5→I
:AxesOff:FnOff
:DispGraph
:Pxl-Change(X,Z+1
:Pxl-Change(X-1,Z
:Pxl-Change(X,Z-1
:Repeat A=1
:0:Repeat Ans
:getKey→K
:End
:Pxl-Change(X,Z-1
:Pxl-Change(X-1,Z
:Pxl-Change(X,Z+1
:K:X-I((Ans=25)-(Ans=34)→X
:K:Z+I((Ans=26)-(Ans=24)→Z
:(K=21 or K=105)→A
:Z+I((Z≤0)-(Z≥94)→Z
:X+I((X≤0)-(X≥60)→X
:Pxl-Change(X,Z+1
:Pxl-Change(X-1,Z
:Pxl-Change(X,Z-1
:End
:Return

Edit: when i press the goto option, it always points back to the pxl-Change(x-1,z
Title: Re: Optimization?
Post by: simplethinker on August 15, 2009, 04:05:25 pm
why do i always get a domain error when i run this program?
I think you need to initialize X and Z first, since you might be trying to change a pixel with non-integer/negative/big coordinates.
Title: Re: Optimization?
Post by: 3.1415926535 on August 16, 2009, 10:01:33 pm
oh yeah i forgot to store a value to x and z. haha silly me