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
luby
I want to go back to Philmont!!


Calc Guru


Joined: 23 Apr 2006
Posts: 1477

Posted: 07 May 2007 08:10:35 pm    Post subject:

New teaser:
Fastest (and smallest) way to convert an 8*12 Matrix to a string
String must contain[[ and commas separating the 0's
Back to top
Harrierfalcon
The Raptor of Calcs


Super Elite (Last Title)


Joined: 25 Oct 2006
Posts: 2535

Posted: 07 May 2007 08:15:35 pm    Post subject:

luby wrote:
New teaser:
Fastest (and smallest) way to convert an 8*12 Matrix to a string
String must contain[[ and commas separating the 0's
[post="103251"]<{POST_SNAPBACK}>[/post]
It should support up to 3-digit numbers, too.

EDIT: My solution, weighing in at 194 bytes:
[color=#000000background#000000]
:"[[→Str1
:For(A,1,8
:For(B,1,12
:[A](A,B→H
:If Ans
:Then
:"0123456789
:Str1+sub(sub(Str2,1+int(.01H),1)+sub(Str2,1+int(10fPart(.01H)),1)+sub(Str2,1+in
t(10fPart(.1H)),1),3-int(log(H)),1+int(log(H→Str1
:Else
:Str1+"0→Str1
:End
:If B<12
:Ans+",→Str1
:End
:Ans+"]→Str1
:If A<8
:Ans+"[→Str1
:End
:expr(Ans

[/color]
Note it has been optimized for speed rather than memory.

EDIT: Small opmization--4 bytes shaved off.


Last edited by Guest on 07 May 2007 08:46:27 pm; edited 1 time in total
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 07 May 2007 09:19:19 pm    Post subject:

You need only ask...

120 bytes:
Spoiler wrote:
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]"[[
For(R,1,8
For(C,1,12
For(I,0,2
Ans+sub("0123456789",1+10fPart(.1int(10^(I-2)[A](R,C))),1
End
Ans+sub(",][",1+(C=12),1+(C=12)(1-(R=8→Str1
End
End


Last edited by Guest on 15 Jun 2007 02:52:37 am; edited 1 time in total
Back to top
Harrierfalcon
The Raptor of Calcs


Super Elite (Last Title)


Joined: 25 Oct 2006
Posts: 2535

Posted: 07 May 2007 09:28:57 pm    Post subject:

Ahhh...OK, I will clarify the purpose of this. This is a matrix to string conversion, that will be processed by CELTIC2 to essentially be directly recalled into a program. Therefore, extra zeros do not help much in terms of memory, ironically. However, at the cost of ~60 bytes, I have prevented this and that this will eventually be better in the long run.

But yet again I have been impaled on your pointy stick. Smile
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 07 May 2007 09:43:06 pm    Post subject:

Replace [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]For(I,0,2 with [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]For(I,2-int(log([A](R,C))),2 to remove the leading zeros.
Back to top
Harrierfalcon
The Raptor of Calcs


Super Elite (Last Title)


Joined: 25 Oct 2006
Posts: 2535

Posted: 07 May 2007 09:51:08 pm    Post subject:

I wonder why I'm not dead yet....I figured all those holes would have caused massive blood loss by now.

It's a shame, because it should properly parse zeros too, not just nonzero stuff. I suppose you have something for that too?
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 07 May 2007 09:56:03 pm    Post subject:

[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]For(I,2-int(log([A](R,C)+not([A](R,C)))),2
Back to top
Harrierfalcon
The Raptor of Calcs


Super Elite (Last Title)


Joined: 25 Oct 2006
Posts: 2535

Posted: 07 May 2007 10:08:02 pm    Post subject:

I'm dying! I'm dyyyyinnnngggg.....
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