# Omnimaga

## Calculator Community => TI Calculators => TI-BASIC => Topic started by: Munchor on November 20, 2010, 06:20:03 am

Title: [CHALLENGE]Logic and Optimization
Post by: Munchor on November 20, 2010, 06:20:03 am
Hey, I have a small tricky challenge, make a program that allows the user to input the number of Eyes and Noses they have.

The program shall return

"NRML" to 2 eyes 1 nose
"ALMST NRML" to 1 nose 3 eyes or 2 eyes 3 noses (so, only one of them correct) AND
"WEIRD" to none of the correct

I have done it, in a program that takes 80bytes.

You have to make it 80 bytes too or even less!

GOOD LUCK! First successful reply wins, if the winner wants a prize I can make a special image for him :)
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on November 20, 2010, 06:26:51 am
Does it need to ask specifically for eyes and noses? Or can it just be something like Prompt I,N?
53 bytes of code
Code: [Select]
`Prompt I,Nsum({I,N}={2,1→I"NRMLIf not(I"WEIRDIf I=1"ALMST "+AnsAns`
Edit: Removed Pause
Title: Re: [CHALLENGE]Logic and Optimization
Post by: JosJuice on November 20, 2010, 06:35:24 am
Does it need to ask specifically for eyes and noses? Or can it just be something like Prompt I,N?
54 bytes
Code: [Select]
`Prompt I,Nsum({I,N}={2,1→I"NRMLIf not(I"WEIRDIf I=1"ALMST "+AnsPause Ans`
You can change Pause Ans to Ans.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on November 20, 2010, 06:36:20 am
Yeah, yeah, yeah. I know, I just copied my program from my calc...
Title: Re: [CHALLENGE]Logic and Optimization
Post by: matthias1992 on November 20, 2010, 07:35:24 am
I've tried a couple of things by now, none of it worked... it's pretty tricky. The only way to better Xeda's program is to make "NRML the Normal token which you can find under [MODE] and "ALMST NRML to "not(Normal

not really what you were asking for but optimizations nevertheless
Title: Re: [CHALLENGE]Logic and Optimization
Post by: coolsnake on November 20, 2010, 07:43:09 am
Why does it take 63 bytes when I enter it into my calculator?
Title: Re: [CHALLENGE]Logic and Optimization
Post by: DJ Omnimaga on November 20, 2010, 09:55:01 am
63 bytes for the entire program including name and header, not just the code.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: kindermoumoute on November 20, 2010, 10:36:01 am
New challenge : make a base converter from most base possible to most base possible less than 300 bytes (my program got 200 bytes for 36 bases).
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Munchor on November 20, 2010, 11:13:24 am
Code: [Select]
`:Prompt I,N:sum({I,N}={2,1→I:"NRML:If not(I:"WEIRD:If I=1:"ALMST "+Ans:Ans`
WOW! That is just wow... man, wow.

Winner:Xeda112358

Want a prize? xD

I'll post my 80 bytes code (which I thought was great) here later lol
New challenge : make a base converter from most base possible to most base possible less than 300 bytes (my program got 200 bytes for 36 bases).

Yay, a new challenge! Even though I don't understand completely what to do :s
TI Basic?
Title: Re: [CHALLENGE]Logic and Optimization
Post by: kindermoumoute on November 20, 2010, 11:27:45 am
TI-Basic sure, gtranslate say : you must make a base converter (eg binary to hex ,...) with a maximum of base compatibility (less 300 bytes).

EDIT : need minimum 10 bases compatibility.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: JosJuice on November 20, 2010, 12:03:43 pm
TI-Basic sure, gtranslate say : you must make a base converter (eg binary to hex ,...) with a maximum of base compatibility (less 300 bytes).

EDIT : need minimum 10 bases compatibility.
This explanation is more confusing.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: kindermoumoute on November 20, 2010, 12:09:50 pm
OK, the challenge is to make the best base converter (NB: decimal, binary, octal, hexadecimal are examples of bases). The program size is 300 bytes maximum. And the converter needs to convert at least 10 bases.

The program requires a number to the user. He then asked the base of this number (basic input), then the base in which we will convert the number (base release). Don't forget display result.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on November 20, 2010, 12:29:51 pm
Okay, here is what I have, weighing in at 208 bytes of code:
Code: [Select]
`ClrHomeInput "BASE1:",BInput "BASE2:",CInput "NUMBER:",Str1DelVar D"0123456789ABCDEFGHIJKLMNOPQRSTUV→Str2length(Str1→EFor(A,1,ED+B^(E-A)(-1+inString(Str2,sub(Str1,A,1→DEndiPart(log(D)/log(CAns-not(not(fPart(Ans→BFor(A,0,BD/C^(B-A→DStr1+sub(Str2,iPart(Ans+1),1→Str1C^(B-A)fPart(D→DEndsub(Str1,E+1,B+1`
Title: Re: [CHALLENGE]Logic and Optimization
Post by: kindermoumoute on November 20, 2010, 12:50:49 pm
Where do you find this code ?
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Munchor on November 20, 2010, 12:52:11 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
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on November 20, 2010, 12:54:21 pm
Where do you find this code ?
Title: Re: [CHALLENGE]Logic and Optimization
Post by: matthias1992 on November 20, 2010, 12:57:55 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,NIf N(E=2Disp "NRMLIf E=2 or N=1Disp "ALMST NRMLIf ((N!=1)E!=2Disp "WEIRD`
Title: Re: [CHALLENGE]Logic and Optimization
Post by: kindermoumoute on November 20, 2010, 01:03:17 pm
Where do you find this code ?

Ok, sorry, there is some difference with my code :
Code: [Select]
`:Input "Number :",Str1:Input "From Base :",C:Input "to Base :",D:"123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ→Str2:length(Str1→A:0:For(Ɵ,1,A:Ans+C^(A-Ɵ)inString(Str2,sub(Str1,Ɵ,1:End:Ans→B:"0"+Str2→Str2:While B:int(B/D→C:sub(Str2,B-DC+1,1)+Str1→Str1:C→B:Endsub(Str1,1,length(Str1)-A`
200 bytes, 36 bases.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: yunhua98 on November 20, 2010, 01:08:57 pm
New challenge!
make the smallest program possible with the final "e" rule for english.  (I had to make this yesterday, shows how you can use calcs in english too, XD)
I have 331 bytes with an 8 letter title

bascically, it lets you enter the root word, and the suffix, and combines it for you.  ;)
Title: Re: [CHALLENGE]Logic and Optimization
Post by: MRide on November 20, 2010, 01:09:50 pm
What do you mean? I don't understand.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Munchor on November 20, 2010, 01:11:15 pm
New challenge!
make the smallest program possible with the final "e" rule for english.  (I had to make this yesterday, shows how you can use calcs in english too, XD)
I have 331 bytes with an 8 letter title

bascically, it lets you enter the root word, and the suffix, and combines it for you.  ;)

I'm not getting it either 'e-rule'?
Title: Re: [CHALLENGE]Logic and Optimization
Post by: yunhua98 on November 20, 2010, 01:11:59 pm
the rule:  A word ending in "e" plus a suffix starting with a consonent, the final "e" isn't dropped, if the suffix starts with a vowel, it is dropped, unless the root word's "e" is precede by a "c" or a "g" and the suffix starts with an "a" or "o"
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Munchor on November 20, 2010, 01:13:41 pm
the rule:  A word ending in "e" plus a suffix starting with a consonent, the final "e" isn't dropped, if the suffix starts with a vowel, it is dropped, unless the root word's "e" is precede by a "c" or a "g" and the suffix starts with an "a" or "o"

Example?

Mode ---> Modable?
Name ---> Namable?
Title: Re: [CHALLENGE]Logic and Optimization
Post by: yunhua98 on November 20, 2010, 01:14:52 pm
kinda, Lone + ly = Lonely
Notice + able = noticeable
Bride + al = Bridal

but the final words gotta make sense, obviously.  XD
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on November 20, 2010, 01:15:59 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,NIf N(E=2Disp "NRMLIf E=2 or N=1Disp "ALMST NRMLIf ((N!=1)E!=2Disp "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.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Munchor on November 20, 2010, 01:33:04 pm
Code: [Select]
`Prompt E,NIf N(E=2Disp "NRMLIf E=2 or N=1Disp "ALMST NRMLIf ((N!=1)E!=2Disp "WEIRD`
I had no idea of this tricks though :P
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on November 20, 2010, 01:34:51 pm
Code: [Select]
`Prompt E,NIf N(E=2Disp "NRMLIf E=2 or N=1Disp "ALMST NRMLIf ((N!=1)E!=2Disp "WEIRD`
I had no idea of this tricks though :P
Ah, well, it didn't work for me... It just displayed all three phrases.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Munchor on November 20, 2010, 01:35:56 pm
Code: [Select]
`Prompt E,NIf N(E=2Disp "NRMLIf E=2 or N=1Disp "ALMST NRMLIf ((N!=1)E!=2Disp "WEIRD`
I had no idea of this tricks though :P
Ah, well, it didn't work for me... It just displayed all three phrases.

How stupid of me, trust you!

Hhaha, just kidding, but the code makes sense even without trying it LOL
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on November 20, 2010, 01:37:36 pm
What? It wasn't MY code! :D
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Munchor on November 20, 2010, 01:38:47 pm
What? It wasn't MY code! :D

:O!!! Sorry!

Now I see, it was mathias code, SORRY!
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Builderboy on November 20, 2010, 02:01:14 pm
Code: [Select]
`Prompt E,NIf N(E=2Disp "NRMLIf E=2 or N=1Disp "ALMST NRMLIf ((N!=1)E!=2Disp "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
Title: Re: [CHALLENGE]Logic and Optimization
Post by: yunhua98 on November 20, 2010, 02:01:49 pm
lol, but really, the End statements aren't needed?  :o
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Munchor on November 20, 2010, 02:12:02 pm
lol, but really, the End statements aren't needed?  :o

TI Basic ones no :)
Title: Re: [CHALLENGE]Logic and Optimization
Post by: matthias1992 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,NIf N(E=2Disp "NRMLIf E=2 or N=1Disp "ALMST NRMLIf ((N!=1)E!=2Disp "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,NIf N(E=2Disp "NRMLIf E=2 or N=1Disp "ALMST NRMLIf ((N!=1)E!=2Disp "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 :(
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Munchor 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,NIf N(E=2Disp "NRMLIf E=2 or N=1Disp "ALMST NRMLIf ((N!=1)E!=2Disp "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,NIf N(E=2Disp "NRMLIf E=2 or N=1Disp "ALMST NRMLIf ((N!=1)E!=2Disp "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
Title: Re: [CHALLENGE]Logic and Optimization
Post by: DJ Omnimaga on November 22, 2010, 01:45:15 pm
Are End statements needed if the program being run is a sub-program?
Title: Re: [CHALLENGE]Logic and Optimization
Post by: ASHBAD_ALVIN 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
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Builderboy 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->GAMEPrgmADisp ":D`
sub program
Code: [Select]
`If GAME=1:ThenDisp "You Lost9001->Game`
Title: Re: [CHALLENGE]Logic and Optimization
Post by: ASHBAD_ALVIN on November 22, 2010, 01:53:09 pm
Hmm, I never noticed that before.  I feel informed very much so inde
Title: Re: [CHALLENGE]Logic and Optimization
Post by: DJ Omnimaga 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->GAMEPrgmADisp ":D`
sub program
Code: [Select]
`If GAME=1:ThenDisp "You Lost9001->Game`
Ah ok I see. And I lost the game. :(
Title: Re: [CHALLENGE]Logic and Optimization
Post by: ASHBAD_ALVIN 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
Title: Re: [CHALLENGE]Logic and Optimization
Post by: DJ Omnimaga on November 22, 2010, 02:22:01 pm
No problem. That happens. :P
Title: Re: [CHALLENGE]Logic and Optimization
Post by: gangsterveggies on November 22, 2010, 07:47:30 pm
Why did you choose such an odd program?
Title: Re: [CHALLENGE]Logic and Optimization
Post by: DJ Omnimaga 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
Title: Re: [CHALLENGE]Logic and Optimization
Post by: JosJuice 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.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: DJ Omnimaga on November 23, 2010, 03:22:49 pm
Lol but I meant extremly large programs. ROL3 is about 100 KB, if I remember. :P
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Yeong on November 24, 2010, 10:14:09 am
maybe I'll try whenever I have a leftover time XD
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Munchor on November 24, 2010, 12:15:21 pm
Lol but I meant extremly large programs. ROL3 is about 100 KB, if I remember. :P

Wow, Applications tend to be larger, though
Title: Re: [CHALLENGE]Logic and Optimization
Post by: DJ Omnimaga on November 24, 2010, 04:02:59 pm
Yeah, a few of them are, like Chips Challenge.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Munchor on November 27, 2010, 09:36:01 am
Yeah, a few of them are, like Chips Challenge.

All my friends at school have their Applications menu very slow, because they don't delete stuff like 'Nederland', 'French', 'Deutch' and ScienceTools of all languages, CellSheet of all languages.

I only have 10 applications, though :)
Title: Re: [CHALLENGE]Logic and Optimization
Post by: DJ Omnimaga on November 27, 2010, 02:19:22 pm
You should see TI-Nspire OS 2.0 in 84+ mode after a fresh install. It comes with about 1.3 MB of flash APPs. It takes about 3 seconds to open the APPS menu and you have about 200 KB of archive left.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Munchor on November 28, 2010, 10:14:46 am
You should see TI-Nspire OS 2.0 in 84+ mode after a fresh install. It comes with about 1.3 MB of flash APPs. It takes about 3 seconds to open the APPS menu and you have about 200 KB of archive left.

Which is good because that means it has ScienceToolsPT and CellSheetPT which I sell to my friends who have SE's or 84+ that don't include these
Title: Re: [CHALLENGE]Logic and Optimization
Post by: DJ Omnimaga on November 29, 2010, 12:00:59 am
Lol you actually make money from those apps? Make sure to not get caught or anything. X.x

But I hate having so many apps because the app menu is so slow and everytime I reinstall the Nspire OS I need to devote full of time to deleting those apps. X.x
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Munchor on November 29, 2010, 09:12:59 am
Lol you actually make money from those apps? Make sure to not get caught or anything. X.x

But I hate having so many apps because the app menu is so slow and everytime I reinstall the Nspire OS I need to devote full of time to deleting those apps. X.x

I make money more for connecting calcs, press the Link button and sending files, from any calculator to any calculator, most of the times not mine ;P
Title: Re: [CHALLENGE]Logic and Optimization
Post by: DJ Omnimaga on November 29, 2010, 10:53:52 pm
Oh, that. Yeah some people do that at school. I think it's fine, because it discourages people from always asking you programs. It's insane how many people kept begging me for games at school. It got annoying at one point and I lost patience and stopped giving games except my new stuff. Some people charges like \$0.50 or \$1 for doing it.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on January 20, 2011, 10:35:36 pm
Hey, can anybody optimise this a little more without changing any of the output (like how it is displayed)? I am going to give some more thought to it as well, but it is fun crushing these simple games into as little space as possible :D

It's Rock Paper Scissors if you were wondering...
Code: [Select]
`1→BClrHomeDisp " ROCK"," PAPER"," SCISSORSRepeat A=105Output(B,1,"}Repeat AgetKey→AEndOutput(B,1,"                                     ;There is a space thereB+(A=34)-(A=25If Ans>3 or not(Ans1+2not(AnsAns→BEndB-1→BrandInt(0,2→A"WIN!If B=3fPart((A+2)/3"LOSE.If B=A"TIE.ClrHomeDisp Ans,"CALC:","YOU:AFor(A,0,1Output(A+2,6,sub("ROCKPAPERSCISSORS",5 nCr Ans,Ans²+4BEnd`
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Scipi on January 20, 2011, 11:15:34 pm
I don't really see any more optimizations you could do honestly. Maybe merge a few lines together and separate with : but that's about all I can see.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: willrandship on January 20, 2011, 11:23:13 pm
most people at my school are satisfied with being shown the puzzle pack :P
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on January 20, 2011, 11:28:38 pm
Merging lines and using ":" does not save any bytes of memory and slows the code down a little, so I avoid using the semicolon as a line break.

Didja like my math with the string?
Title: Re: [CHALLENGE]Logic and Optimization
Post by: meishe91 on January 21, 2011, 12:12:59 am
Merging lines and using ":" does not save any bytes of memory and slows the code down a little, so I avoid using the colon as a line break.

Didja like my math with the string?

Fixed ;)

Also, nah, I don't see any optimizations or anything. Wait for Nemo though and he might :P

I don't remember what nCr does, could you enlighten us?
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on January 21, 2011, 12:18:09 am
Oh, I noticed that the offset in the string was 1 for Rock, 5 for Paper and 10 for Scissors. {1,5,10} happens to be the first 3 numbers in the 5th row of Pascals Triangle. I think nCr is n!/((n-r)!r!) so plug in 5 nCr 1 would be 5!/(4!1!)=120/24=5.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: DJ Omnimaga on January 21, 2011, 01:23:20 am
Merging lines and using ":" does not save any bytes of memory and slows the code down a little, so I avoid using the semicolon as a line break.

Didja like my math with the string?
It slows the code down? O.O I never noticed that. I sometimes use the : to reduce scrolling time accross a 15 KB program when an error occurs (I hate waiting 789 hours for scrolling and sometimes I don't have enough space for DCS7)
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on January 21, 2011, 07:56:31 am
Ah, well, it slows it down slightly from what I can tell (I could be wrong), but it isn't by much.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: AngelFish on January 21, 2011, 11:21:10 am
Code: [Select]
`1→BClrHomeDisp " ROCK"," PAPER"," SCISSORSRepeat A=105Output(B,1,"}Repeat AnsGetkeyEndOutput(B,1,"                                     ;There is a space thereB+(Ans=34)-(Ans=25If A>3 Or not(Ans1+2not(AnsAns→BEndB-1→BrandInt(0,2→A"WIN!If B=3fPart((A+2)/3"LOSE.If B=A"TIE.ClrHomeDisp Ans,"CALC:","YOU:AFor(A,0,1Output(A+2,6,sub("ROCKPAPERSCISSORS",5 nCr Ans,Ans²+4BEnd`
That should work :D
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on January 21, 2011, 11:25:54 am
You need A later in the loop, so it won't work :(

EDIT: Never mind :D

You put A>3 instead of Ans :P I didn't catch that immediately... Nice! 2 bytes saved :D

REEDIT: Nevermind, you DO need A to complete the Repeat A=105 loop.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: AngelFish on January 21, 2011, 12:44:06 pm
Enough edits?  :P

Anyway, all that I can remember changing is eliminating the Getkey->A because you change the A before the loop repeats.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on January 21, 2011, 02:04:43 pm
It doesn't change A to my knowledge; It only changes B which determines the location of the cursor. It needs A to stay intact because pressing enter returns 105 which exits the loop.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: AngelFish on January 21, 2011, 02:35:39 pm
I will optimize this if it kills me.
/me hopes it doesn't kill him
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on January 21, 2011, 05:02:16 pm
Crap! I must hurry up and add some unoptimisations!
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Munchor on January 21, 2011, 08:07:24 pm
And where's Runer? The Extreme Optimizer ;D

Code: [Select]
`1→BClrHomeDisp " ROCK"," PAPER"," SCISSORSRepeat A=105Output(B,1,"}Repeat AnsGetkeyEndOutput(B,1,"                                     ;There is a space thereB+(Ans=34)-(Ans=25If A>3 Or not(Ans1+2not(AnsAns→BEndB-1→BrandInt(0,2→A"WIN!If B=3fPart((A+2)/3"LOSE.If B=A"TIE.ClrHomeDisp Ans,"CALC:","YOU:AFor(A,0,1Output(A+2,6,sub("ROCKPAPERSCISSORS",5 nCr Ans,Ans²+4BEnd`
Nice, it looks really well, probably optimized as well as it can be.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on January 21, 2011, 08:13:31 pm
I wanted to challenge people to make one, but I wanted to keep the same graphics and stuff, so I just posted it instead :( But... I don't know if I should do this... Okee, I will! How about I pose this challenge. Make a Tic-Tac-Toe game that has user input, win/lose/tie detection and has AI that is more than a random number generator. Try to post the smallest version (I have a few that I liked giving out to friends at school. The calc usually won). Oh, and make it so that the user can choose if they are X versus Calc,O versus Calc, or if it is two player (X versus O).
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Munchor on January 21, 2011, 08:16:36 pm
I wanted to challenge people to make one, but I wanted to keep the same graphics and stuff, so I just posted it instead :( But... I don't know if I should do this... Okee, I will! How about I pose this challenge. Make a Tic-Tac-Toe game that has user input, win/lose/tie detection and has AI that is more than a random number generator. Try to post the smallest version (I have a few that I liked giving out to friends at school. The calc usually won). Oh, and make it so that the user can choose if they are X versus Calc,O versus Calc, or if it is two player (X versus O).

Woah, Tic Tac Toe AI? That looks challenging. I once made a TIC TAC TOE game, but it was Axe and it was two players on one calculator.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on January 21, 2011, 08:27:54 pm
My first "major" BASIC program was a source for tic-tac-toe my brother found on the internet. It was just two people could play on the calc. I later made my version which was about half the size and had AI and 2 player. But I still appreciate that first program because it exposed me to all sorts of new commands (I had no idea what getKey did or that it existed as well as Goto or Lbl or Text( or a bajillion others).
Title: Re: [CHALLENGE]Logic and Optimization
Post by: calc84maniac on January 21, 2011, 08:45:07 pm
Code: [Select]
`:DelVar BClrHome:Disp " ROCK"," PAPER"," SCISSORS:Repeat A=105:Output(B+1,1,"}:Repeat Ans:getKey→A:End:Output(B+1,1," :B+sum(DeltaList(Ans={25,34:Ans-3int(Ans/3→B:End:int(3rand→A:"WIN!:If B=3fPart((A+2)/3:"LOSE.:If B=A:"TIE.:ClrHome:Disp Ans,"CALC:","YOU::A:For(A,2,3:Output(A,6,sub("ROCKPAPERSCISSORS",5 nCr Ans,Ans2+4:B:End`
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on January 21, 2011, 08:54:19 pm
Wow. 14 bytes saved. That is awesome! I've almost never used the DeltaList thing and the int(3rand thing is just... wow. Nice.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: meishe91 on January 21, 2011, 09:04:47 pm
Nice, Calc84maniac!

If I have time I'll try to come up with a Tic-Tac-Toe game to your challenge specifications but no promise.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on January 21, 2011, 09:05:34 pm
It's fun! I think I can optimise my TTT game a little more though...
Title: Re: [CHALLENGE]Logic and Optimization
Post by: meishe91 on January 21, 2011, 10:15:30 pm
How big is it currently so we know what to try to beat?
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on January 21, 2011, 10:54:57 pm
Oh, jeez, my calc just crashed, sorry. I think it was around 600 bytes. I could be wrong. I'll get it back again after I finish a mini project for a friend. (My calc screen is flipped upside down for some reason! It was a mistake, but still!)
Title: Re: [CHALLENGE]Logic and Optimization
Post by: z80man on January 22, 2011, 01:58:59 am
Oh, jeez, my calc just crashed, sorry. I think it was around 600 bytes. I could be wrong. I'll get it back again after I finish a mini project for a friend. (My calc screen is flipped upside down for some reason! It was a mistake, but still!)
I've seen this happen before. Not to get technical, but this happened to me when I was running some asm code to put my lcd in test mode. I'm not entirely sure what happened, but I suspect the x auto decrement was swiched on by accident  causing everything drawn to the screen to be drawn upside down. This is true if the very top row of your lcd looks normal. If you take a battery out and put back in, then your calc should be fine.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on January 22, 2011, 02:01:33 am
We figured out what was wrong... On my 84+SE, the display Driver is slightly different in that sending a value from 0C to 0F causes the screen to flip in some way (even if you RAM clear). I made blue scale when I learned about that :D
Title: Re: [CHALLENGE]Logic and Optimization
Post by: meishe91 on January 22, 2011, 02:29:54 pm
There is a topic somewhere about screen flipping with an app (CalcSys I think) so ya. But glad you got it figured out.
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on May 01, 2012, 04:21:33 pm
So, binary base to base 10 conversion, who's up for it? ^_^
Input: Str1 is the binary string
Output: Decimal value in Ans (not a string).

My first attempt is 30 bytes >.> (of code)

EDIT: Also, the string should work like this:
101=5
000101=5
101000=40
EDIT2: I should show the code >.>
Code: [Select]
`0For(A,1,length(Str12Ans+(sub(Str1,A,1)="1End`
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Builderboy on May 01, 2012, 04:56:29 pm
I was able to do 25 bytes, but my input string is backwards, and it takes Ans as the string input instead of Str1 D:  It also has the benefit of being a single line

Code: [Select]
`.5sum(seq(expr(sub(Ans,X,1))2^X,X,1,length(Ans`
Your program can be simplified with the use of expr() as well, instead of the ="1
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Xeda112358 on May 01, 2012, 05:07:59 pm
Hehe awesome :D I attempted to make it almost exactly that one line code until I realised the string would be backwards.
Code: [Select]
`0For(A,1,length(Str12Ans+expr(sub(Str1,A,1End`27 bytes XD
Title: Re: [CHALLENGE]Logic and Optimization
Post by: Yeong on May 01, 2012, 11:54:47 pm
I was able to do 25 bytes, but my input string is backwards, and it takes Ans as the string input instead of Str1 D:  It also has the benefit of being a single line

Code: [Select]
`.5sum(seq(expr(sub(Ans,X,1))2^X,X,1,length(Ans`
Your program can be simplified with the use of expr() as well, instead of the ="1
I'm scared of what TI-BASIC can do sometimes O.o