Author Topic: [CHALLENGE]Logic and Optimization  (Read 31502 times)

0 Members and 1 Guest are viewing this topic.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #30 on: November 20, 2010, 02:01:14 pm »
Code: [Select]
Prompt E,N
If N(E=2
Disp "NRML
If E=2 or N=1
Disp "ALMST NRML
If ((N!=1)E!=2
Disp "WEIRD

N(E=2 won't work because if E is 2, and N is 2, it will still say Normal because N*(2=2 is 2, which is true

E=2 or N=1 won't work because if E=2 and N=1, it will still display almost normal because 1 Or 1 = 1

third one works though :D

Offline yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #31 on: November 20, 2010, 02:01:49 pm »
lol, but really, the End statements aren't needed?  :o

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #32 on: November 20, 2010, 02:12:02 pm »
lol, but really, the End statements aren't needed?  :o

TI Basic ones no :)

Offline matthias1992

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 408
  • Rating: +33/-5
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #33 on: November 20, 2010, 02:53:05 pm »
Code: [Select]
:Prompt E,N
:If E=2 and N=1
:Disp "NRML
:If E != 2 or N!=1
:Then
:If E=2 or N=1
:Then
:Disp "ALMST NRML
:Else
:Disp "WEIRD
80bytes, for the first challenge

This is missing two end statements plus it could be optimized to this:
Code: [Select]
Prompt E,N
If N(E=2
Disp "NRML
If E=2 or N=1
Disp "ALMST NRML
If ((N!=1)E!=2
Disp "WEIRD

Yours uses 6 bytes more, and mine is not missing two end statements. It is the end of a program so it does not need them.
I was refering to ScoutDavid's code not yours.
Code: [Select]
Prompt E,N
If N(E=2
Disp "NRML
If E=2 or N=1
Disp "ALMST NRML
If ((N!=1)E!=2
Disp "WEIRD

N(E=2 won't work because if E is 2, and N is 2, it will still say Normal because N*(2=2 is 2, which is true

E=2 or N=1 won't work because if E=2 and N=1, it will still display almost normal because 1 Or 1 = 1

third one works though :D
Ok scrap it I thought I was good at basic, I guesss I was wrong :(
« Last Edit: November 20, 2010, 02:53:38 pm by matthias1992 »
MASM xxxxxxxxxx aborted | SADce ====:::::: 40% -Halted until further notice| XAOS =====::::: 50% -Units done| SKYBOX2D engine ========== 100% -Pre-alpha done. Need to  document it and extend |

~Those who dream by day are cognizant of much more than those who dream by night only. -Sir Edgar Allen Poe-

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #34 on: November 22, 2010, 08:33:50 am »
Code: [Select]
:Prompt E,N
:If E=2 and N=1
:Disp "NRML
:If E != 2 or N!=1
:Then
:If E=2 or N=1
:Then
:Disp "ALMST NRML
:Else
:Disp "WEIRD
80bytes, for the first challenge

This is missing two end statements plus it could be optimized to this:
Code: [Select]
Prompt E,N
If N(E=2
Disp "NRML
If E=2 or N=1
Disp "ALMST NRML
If ((N!=1)E!=2
Disp "WEIRD

Yours uses 6 bytes more, and mine is not missing two end statements. It is the end of a program so it does not need them.
I was refering to ScoutDavid's code not yours.
Code: [Select]
Prompt E,N
If N(E=2
Disp "NRML
If E=2 or N=1
Disp "ALMST NRML
If ((N!=1)E!=2
Disp "WEIRD

N(E=2 won't work because if E is 2, and N is 2, it will still say Normal because N*(2=2 is 2, which is true

E=2 or N=1 won't work because if E=2 and N=1, it will still display almost normal because 1 Or 1 = 1

third one works though :D
Ok scrap it I thought I was good at basic, I guesss I was wrong :(


You shouldn't say that!

I need to move to Axe in Cage Match, since I suck at TI Basic :S

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [CHALLENGE]Logic and Optimization
« Reply #35 on: November 22, 2010, 01:45:15 pm »
Are End statements needed if the program being run is a sub-program?

ASHBAD_ALVIN

  • Guest
Re: [CHALLENGE]Logic and Optimization
« Reply #36 on: November 22, 2010, 01:47:10 pm »
yes, it compiles it as another program, but places the EXEC in the final product.  But if you do return, then it WON'T go back to the main prog, it end the whole thing.  To go back to the main prog, redirect to the last line of code.

EDIT: and yes ENDs are needed too :P
« Last Edit: November 22, 2010, 01:47:53 pm by ASHBAD_ALVIN »

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #37 on: November 22, 2010, 01:52:07 pm »
In certain cases you don't need an End, if it is on the last line of an IfThen statement.  Like this saves 2 bytes in the subprogram by not including the End

1st program
Code: [Select]
1->GAME
PrgmA
Disp ":D

sub program
Code: [Select]
If GAME=1:Then
Disp "You Lost
9001->Game

ASHBAD_ALVIN

  • Guest
Re: [CHALLENGE]Logic and Optimization
« Reply #38 on: November 22, 2010, 01:53:09 pm »
Hmm, I never noticed that before.  I feel informed very much so inde

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [CHALLENGE]Logic and Optimization
« Reply #39 on: November 22, 2010, 01:56:56 pm »
yes, it compiles it as another program, but places the EXEC in the final product.  But if you do return, then it WON'T go back to the main prog, it end the whole thing.  To go back to the main prog, redirect to the last line of code.

EDIT: and yes ENDs are needed too :P
This is BASIC, actually, not Axe. (Noticing you say "compiles")
In certain cases you don't need an End, if it is on the last line of an IfThen statement.  Like this saves 2 bytes in the subprogram by not including the End

1st program
Code: [Select]
1->GAME
PrgmA
Disp ":D

sub program
Code: [Select]
If GAME=1:Then
Disp "You Lost
9001->Game
Ah ok I see. And I lost the game. :(

ASHBAD_ALVIN

  • Guest
Re: [CHALLENGE]Logic and Optimization
« Reply #40 on: November 22, 2010, 01:58:50 pm »
OH THIS IS BASIC.  I see -- I thought this was Axe.  Better look more carefully next time :P

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [CHALLENGE]Logic and Optimization
« Reply #41 on: November 22, 2010, 02:22:01 pm »
No problem. That happens. :P

Offline gangsterveggies

  • LV2 Member (Next: 40)
  • **
  • Posts: 36
  • Rating: +2/-1
  • Asm rules
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #42 on: November 22, 2010, 07:47:30 pm »
Why did you choose such an odd program?
I'm waiting for someone to do a calc Farmville. Maybe one day I'll do it!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [CHALLENGE]Logic and Optimization
« Reply #43 on: November 23, 2010, 12:00:24 am »
Because it's just for the sake of optimizations. We need to keep the programs small at first. :P

I doubt many people will participate if the programs to optimize are The Reign of Legends 3. :P
« Last Edit: November 23, 2010, 12:00:50 am by DJ Omnimaga »

Offline JosJuice

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1344
  • Rating: +66/-14
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #44 on: November 23, 2010, 09:52:05 am »
I doubt many people will participate if the programs to optimize are The Reign of Legends 3. :P
WFRNG would be better.