Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started 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 :)
-
Does it need to ask specifically for eyes and noses? Or can it just be something like Prompt I,N?
53 bytes of code
Prompt I,N
sum({I,N}={2,1→I
"NRML
If not(I
"WEIRD
If I=1
"ALMST "+Ans
Ans
Edit: Removed Pause
-
Does it need to ask specifically for eyes and noses? Or can it just be something like Prompt I,N?
54 bytes
Prompt I,N
sum({I,N}={2,1→I
"NRML
If not(I
"WEIRD
If I=1
"ALMST "+Ans
Pause Ans
You can change Pause Ans to Ans.
-
Yeah, yeah, yeah. I know, I just copied my program from my calc...
-
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
-
Why does it take 63 bytes when I enter it into my calculator?
-
63 bytes for the entire program including name and header, not just the code.
-
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).
-
: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?
-
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.
-
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.
-
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.
-
Okay, here is what I have, weighing in at 208 bytes of code:
ClrHome
Input "BASE1:",B
Input "BASE2:",C
Input "NUMBER:",Str1
DelVar D"0123456789ABCDEFGHIJKLMNOPQRSTUV→Str2
length(Str1→E
For(A,1,E
D+B^(E-A)(-1+inString(Str2,sub(Str1,A,1→D
End
iPart(log(D)/log(C
Ans-not(not(fPart(Ans→B
For(A,0,B
D/C^(B-A→D
Str1+sub(Str2,iPart(Ans+1),1→Str1
C^(B-A)fPart(D→D
End
sub(Str1,E+1,B+1
-
Where do you find this code ?
-
: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
-
Where do you find this code ?
I made it :D It took me about 17 minutes, but I made it :D
-
: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:
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
-
Where do you find this code ?
I made it :D It took me about 17 minutes, but I made it :D
Ok, sorry, there is some difference with my code :
: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
:End
sub(Str1,1,length(Str1)-A
200 bytes, 36 bases.
-
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. ;)
-
What do you mean? I don't understand.
-
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'?
-
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"
-
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?
-
kinda, Lone + ly = Lonely
Notice + able = noticeable
Bride + al = Bridal
but the final words gotta make sense, obviously. XD
-
: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:
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.
-
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
I had no idea of this tricks though :P
-
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
I had no idea of this tricks though :P
Ah, well, it didn't work for me... It just displayed all three phrases.
-
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
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
-
What? It wasn't MY code! :D
-
What? It wasn't MY code! :D
:O!!! Sorry!
Now I see, it was mathias code, SORRY!
-
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
-
lol, but really, the End statements aren't needed? :o
-
lol, but really, the End statements aren't needed? :o
TI Basic ones no :)
-
: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:
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.
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 :(
-
: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:
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.
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
-
Are End statements needed if the program being run is a sub-program?
-
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
-
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
1->GAME
PrgmA
Disp ":D
sub program
If GAME=1:Then
Disp "You Lost
9001->Game
-
Hmm, I never noticed that before. I feel informed very much so inde
-
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
1->GAME
PrgmA
Disp ":D
sub program
If GAME=1:Then
Disp "You Lost
9001->Game
Ah ok I see. And I lost the game. :(
-
OH THIS IS BASIC. I see -- I thought this was Axe. Better look more carefully next time :P
-
No problem. That happens. :P
-
Why did you choose such an odd program?
-
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
-
I doubt many people will participate if the programs to optimize are The Reign of Legends 3. :P
WFRNG would be better.
-
Lol but I meant extremly large programs. ROL3 is about 100 KB, if I remember. :P
-
maybe I'll try whenever I have a leftover time XD
-
Lol but I meant extremly large programs. ROL3 is about 100 KB, if I remember. :P
Wow, Applications tend to be larger, though
-
Yeah, a few of them are, like Chips Challenge.
-
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 :)
-
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.
-
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
-
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
-
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
-
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.
-
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...
1→B
ClrHome
Disp " ROCK"," PAPER"," SCISSORS
Repeat A=105
Output(B,1,"}
Repeat A
getKey→A
End
Output(B,1," ;There is a space there
B+(A=34)-(A=25
If Ans>3 or not(Ans
1+2not(Ans
Ans→B
End
B-1→B
randInt(0,2→A
"WIN!
If B=3fPart((A+2)/3
"LOSE.
If B=A
"TIE.
ClrHome
Disp Ans,"CALC:","YOU:
A
For(A,0,1
Output(A+2,6,sub("ROCKPAPERSCISSORS",5 nCr Ans,Ans²+4
B
End
-
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.
-
most people at my school are satisfied with being shown the puzzle pack :P
-
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?
-
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?
-
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.
-
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)
-
Ah, well, it slows it down slightly from what I can tell (I could be wrong), but it isn't by much.
-
1→B
ClrHome
Disp " ROCK"," PAPER"," SCISSORS
Repeat A=105
Output(B,1,"}
Repeat Ans
Getkey
End
Output(B,1," ;There is a space there
B+(Ans=34)-(Ans=25
If A>3 Or not(Ans
1+2not(Ans
Ans→B
End
B-1→B
randInt(0,2→A
"WIN!
If B=3fPart((A+2)/3
"LOSE.
If B=A
"TIE.
ClrHome
Disp Ans,"CALC:","YOU:
A
For(A,0,1
Output(A+2,6,sub("ROCKPAPERSCISSORS",5 nCr Ans,Ans²+4
B
End
That should work :D
-
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.
-
Enough edits? :P
Anyway, all that I can remember changing is eliminating the Getkey->A because you change the A before the loop repeats.
-
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.
-
I will optimize this if it kills me.
/me hopes it doesn't kill him
-
Crap! I must hurry up and add some unoptimisations!
-
And where's Runer? The Extreme Optimizer ;D
1→B
ClrHome
Disp " ROCK"," PAPER"," SCISSORS
Repeat A=105
Output(B,1,"}
Repeat Ans
Getkey
End
Output(B,1," ;There is a space there
B+(Ans=34)-(Ans=25
If A>3 Or not(Ans
1+2not(Ans
Ans→B
End
B-1→B
randInt(0,2→A
"WIN!
If B=3fPart((A+2)/3
"LOSE.
If B=A
"TIE.
ClrHome
Disp Ans,"CALC:","YOU:
A
For(A,0,1
Output(A+2,6,sub("ROCKPAPERSCISSORS",5 nCr Ans,Ans²+4
B
End
Nice, it looks really well, probably optimized as well as it can be.
-
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).
-
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.
-
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).
-
: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
-
Wow. 14 bytes saved. That is awesome! I've almost never used the DeltaList thing and the int(3rand thing is just... wow. Nice.
-
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.
-
It's fun! I think I can optimise my TTT game a little more though...
-
How big is it currently so we know what to try to beat?
-
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!)
-
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.
-
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
-
There is a topic somewhere about screen flipping with an app (CalcSys I think) so ya. But glad you got it figured out.
-
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 >.>
0
For(A,1,length(Str1
2Ans+(sub(Str1,A,1)="1
End
-
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
.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
-
Hehe awesome :D I attempted to make it almost exactly that one line code until I realised the string would be backwards.
0
For(A,1,length(Str1
2Ans+expr(sub(Str1,A,1
End
27 bytes XD
-
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
.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