This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. TI-Basic Brain Teasers => TI-BASIC
Author Message
WikiGuru
ADOS (Attention deficit... Oh! Shiny!)


Elite


Joined: 15 Sep 2005
Posts: 923

Posted: 07 Aug 2008 08:55:37 pm    Post subject:

Here's a challenge for the FASTEST way to pack 8 characters into a real list, input from (pre-defined) Str2, and then unpack them back into Str2. It must support all characters in Str2 (at least). Str2 is defined below (just store it from the home screen)

Note: if the inputed string is not a multiple of 8 (Str2 below isn't), your String to Real program should append extra spaces at the end. Real to String doesn't need to remove these, but if you want to...

To test your programs, use this string (store int Str2):

Str2="THIS IS A TEST OF STRING TO REAL AND REAL TO STRING.+-*/ (I THINK IT WORKS)1234567890 {1,2,3,4}[2][3][4][66] DIM MISMATCH/ ABCDEFGHIJK... UHH, I THAT IS ALL I KNOW."

here's my times: (if someone wants to check them, that would be much appreciated)
tested on Wabbitemu emulating TI83+SE OS version 1.16
String to Real: 3 and 1 pixel
Real to String: 9 and 7 pixels
[color=#000000background#000000]
String to Real:

:DelVar L10->dim(L1
:"°°°°°°°°°ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-*/.,(){}[] ->Str1
:DelVar E1->C
:While fPart(length(Str2)/8
Str2+" ->Str2
:End
:length(Str2->D
:If D>7:7->D
:Repeat D+1>length(Str2
:DelVar A1+E->E
:1+dim(L1->dim(L1
:For(B,C,D
:A+inString(Str1,sub(Str2,B,1))10^(2C-2B-1->A
:End
:A10^(inString(Str1,sub(Str2,D+1,1->L1(E
:2+D->C
:8+D->D
:End

Real to String:

:DelVar E" ->Str2
:"°°°°°°°°°ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-*/.,(){}[] ->Str1
:Repeat E>=dim(L1
:E+1->E
:DelVarBL1(E->A
:While iPart(A10^(-B
:B+1->B
:End
:A10^(-B->A
:For(C,1,7
:Str2+sub(Str1,iPart(A10^(2)),1)->Str2
:fPart(A10^(2->A
:End
:Str2+sub(Str1,B-1,1->Str2
:End
:sub(Str2,2,length(Str2)-1->Str2

[/color]


Last edited by Guest on 14 Oct 2008 10:02:18 pm; edited 1 time in total
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement