Author Topic: Optimization?  (Read 6890 times)

0 Members and 1 Guest are viewing this topic.

Offline 3.1415926535

  • LV2 Member (Next: 40)
  • **
  • Posts: 34
  • Rating: +2/-0
    • View Profile
Optimization?
« 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
« Last Edit: August 13, 2009, 07:45:06 pm by noahbaby94 »

Offline noahbaby94

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 585
  • Rating: +29/-24
    • View Profile
    • My blog
Re: Optimization?
« Reply #1 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.
« Last Edit: August 13, 2009, 07:47:51 pm by noahbaby94 »
That's what she said!!!

Offline 3.1415926535

  • LV2 Member (Next: 40)
  • **
  • Posts: 34
  • Rating: +2/-0
    • View Profile
Re: Optimization?
« Reply #2 on: August 13, 2009, 07:48:26 pm »
how do you format?
and thanks!

Offline noahbaby94

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 585
  • Rating: +29/-24
    • View Profile
    • My blog
Re: Optimization?
« Reply #3 on: August 13, 2009, 07:48:59 pm »
code tags. [code ] code here [/code ] with out the spaces.
That's what she said!!!

Offline 3.1415926535

  • LV2 Member (Next: 40)
  • **
  • Posts: 34
  • Rating: +2/-0
    • View Profile
Re: Optimization?
« Reply #4 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

Offline 3.1415926535

  • LV2 Member (Next: 40)
  • **
  • Posts: 34
  • Rating: +2/-0
    • View Profile
Re: Optimization?
« Reply #5 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)


Offline Geekboy1011

  • The Oneironaut
  • Donator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2031
  • Rating: +119/-2
  • Dream that Awakening dream
    • View Profile
Re: Optimization?
« Reply #6 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 ?
« Last Edit: August 15, 2009, 11:32:17 am by Geekboy1011 »

Offline noahbaby94

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 585
  • Rating: +29/-24
    • View Profile
    • My blog
Re: Optimization?
« Reply #7 on: August 15, 2009, 11:32:04 am »
That's what she said!!!

Offline Geekboy1011

  • The Oneironaut
  • Donator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2031
  • Rating: +119/-2
  • Dream that Awakening dream
    • View Profile
Re: Optimization?
« Reply #8 on: August 15, 2009, 11:35:13 am »
0.0 i see what you mean noah thanks 0.0

Offline 3.1415926535

  • LV2 Member (Next: 40)
  • **
  • Posts: 34
  • Rating: +2/-0
    • View Profile
Re: Optimization?
« Reply #9 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?

Offline 3.1415926535

  • LV2 Member (Next: 40)
  • **
  • Posts: 34
  • Rating: +2/-0
    • View Profile
Re: Optimization?
« Reply #10 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

Offline simplethinker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 695
  • Rating: +16/-5
  • snjwffl
    • View Profile
Re: Optimization?
« Reply #11 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.
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the Internet, we know this is not true." -- Professor Robert Silensky



Chip's Challenge: ħ%

Offline 3.1415926535

  • LV2 Member (Next: 40)
  • **
  • Posts: 34
  • Rating: +2/-0
    • View Profile
Re: Optimization?
« Reply #12 on: August 16, 2009, 10:01:33 pm »
oh yeah i forgot to store a value to x and z. haha silly me