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
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 05 Mar 2008 12:47:31 pm    Post subject:

Make a routine as small as possible that reverses a list.
Example: {2,2,5,4} becomes {4,5,2,2}
Input and output are in L1.
Size is number of bytes in the Memory Menu minus length of name. (I got 24 bytes, try to beat it!)
Back to top
Super Speler
Super Awesome Dude


Calc Guru


Joined: 28 Nov 2005
Posts: 1391

Posted: 05 Mar 2008 03:29:51 pm    Post subject:

I got:

Quote:
seq(L1(X),X,dim(X),1,-1


Have yet to test it though.


Last edited by Guest on 05 Mar 2008 03:30:56 pm; edited 1 time in total
Back to top
TheStorm


Calc Guru


Joined: 17 Apr 2007
Posts: 1233

Posted: 05 Mar 2008 04:53:07 pm    Post subject:

speler yours should be
Quote:
seq(L1(X),X,dim(L1),1,-1
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 05 Mar 2008 04:56:25 pm    Post subject:

My best attempt is 23 bytes:
cumSum(abs(L1→X
SortD(LX,L1


Last edited by Guest on 04 Aug 2010 01:19:03 pm; edited 1 time in total
Back to top
vuurrobin


Advanced Member


Joined: 09 Aug 2006
Posts: 428

Posted: 05 Mar 2008 04:59:57 pm    Post subject:

thats what I got too.

I also tried something with sortD(, but that was 1 byte larger.

Quote:
:cumsum(binomcdf(dim(L1)-1,0->L2
:sortD(L2,L1


edit: I was referring to super speler.


Last edited by Guest on 05 Mar 2008 05:01:15 pm; edited 1 time in total
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 05 Mar 2008 05:03:53 pm    Post subject:

A related teaser: use the same technique to rotate the elements of a list: the first element should go to the end, while the rest get shifted over one space (I have 21 bytes, not counting the title)
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 05 Mar 2008 08:02:33 pm    Post subject:

Curses! Mine was pretty darn close to that:
cumSum(L1 or 1→X
SortD(LX,L1


And for the second one (21 bytes, yay):
0L1→X
SortD(LX,L1


Last edited by Guest on 04 Aug 2010 01:18:10 pm; edited 1 time in total
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 06 Mar 2008 12:48:28 pm    Post subject:

Aha! Darkerline's method for the first problem does not always work! (Try it with {1,1,0,0,0}) So I'm still in the lead!
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 06 Mar 2008 01:21:12 pm    Post subject:

Your method doesn't work for all complex numbers. My method just doesn't work for a single element (0). I think I win.

Edit: here are some alternatives.

23 bytes wrote:
cumSum(e^(L1→X
SortD(LX,L1


25 bytes wrote:
cumSum(1+0L1→X
SortD(LX,L1


Last edited by Guest on 06 Mar 2008 01:32:21 pm; edited 1 time in total
Back to top
vuurrobin


Advanced Member


Joined: 09 Aug 2006
Posts: 428

Posted: 06 Mar 2008 02:42:59 pm    Post subject:

to make that latest one smaller:

Quote:
cumSum(not(0L1→X
SortD(LX,L1
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 06 Mar 2008 04:51:18 pm    Post subject:

Then it will no longer work for complex numbers Sad Try computing not(0i) and see what you get.

Last edited by Guest on 06 Mar 2008 04:51:47 pm; edited 1 time in total
Back to top
TheStorm


Calc Guru


Joined: 17 Apr 2007
Posts: 1233

Posted: 06 Mar 2008 05:38:40 pm    Post subject:

but 0 times i would be zero wouldn't it?
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 06 Mar 2008 05:39:16 pm    Post subject:

The problem is with the not(.
Back to top
vuurrobin


Advanced Member


Joined: 09 Aug 2006
Posts: 428

Posted: 06 Mar 2008 06:12:24 pm    Post subject:

the problem is that 0i isn't the same as 0. one is a real variable and the other is a complex variable. stupid I didn't saw that.
Back to top
luby
I want to go back to Philmont!!


Calc Guru


Joined: 23 Apr 2006
Posts: 1477

Posted: 07 Mar 2008 07:55:09 am    Post subject:

How's about this?
Quote:
cumSum(1+0L1
SortD(Ans,L1


Edit: 22 bytes.


Last edited by Guest on 07 Mar 2008 07:55:51 am; edited 1 time in total
Back to top
TheStorm


Calc Guru


Joined: 17 Apr 2007
Posts: 1233

Posted: 07 Mar 2008 07:58:38 am    Post subject:

Wow, no one thought to use ans for that until now I guess we all need to be hit with weregoose's stick of optimization.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 07 Mar 2008 09:28:26 am    Post subject:

Erm, Ans doesn't work with SortA and SortD. That's why we never thought of using it...
Back to top
JoostinOnline


Active Member


Joined: 22 Aug 2007
Posts: 559

Posted: 07 Mar 2008 07:17:59 pm    Post subject:

DarkerLine wrote:
Erm, Ans doesn't work with SortA and SortD. That's why we never thought of using it...
[post="121160"]<{POST_SNAPBACK}>[/post]

Commands like that have always annoyed me.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 08 Mar 2008 01:20:40 pm    Post subject:

It makes sense from the point of view of memory usage. The one advantage of selection sort (among the many disadvantages) is that it's in-place. If you allowed SortA( and SortD( to deal with list expressions, not just list variables, they would have to return a value, which would mean creating a duplicate of the list.
Back to top
Ed H


Member


Joined: 30 Nov 2007
Posts: 138

Posted: 19 May 2008 09:45:06 pm    Post subject:

DarkerLine wrote:
A related teaser: use the same technique to rotate the elements of a list: the first element should go to the end, while the rest get shifted over one space (I have 21 bytes, not counting the title)


22 bytes, and it doesn't write to a list:
augment(deltaList(cumSum(Ans)),{Ans(1
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
    » Goto page 1, 2  Next
» View previous topic :: View next topic  
Page 1 of 2 » All times are UTC - 5 Hours

 

Advertisement