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
bfr


Member


Joined: 13 Feb 2006
Posts: 108

Posted: 11 Nov 2008 03:32:53 pm    Post subject:

A pack of an unknown integer amount of cards is shuffled randomly, represented by the integers 1 through 52 in a list stored in Ans. Sort it in ascending order without using SortA or SortD and return the result in either Ans or a list variable.

I've got 18 bytes (try to think about it a little bit before looking at the answer):

Quote:

seq(A,A,1,dim(Ans

er...now for the real challenge...


Also, given a pack of an unknown integer amount of cards (at least one card, with the cards being represented by the numbers 1 through amount of cards) in a random order in L1, sort it in ascending order and return the result in either Ans, L1, or another list (without using SortA, SortD, and seq(, and only storing elements from L1 into the resulting list - so, in whenever you are using -> to store to the resulting list, what must be stored has to be in terms of L1). I'm not sure how much of a challenge this actually is, and I know there are a lot of kind of unusual restrictions Razz , but I thought it was slightly interesting.... I've got 36 bytes


Last edited by Guest on 11 Nov 2008 04:06:13 pm; edited 1 time in total
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 11 Nov 2008 04:34:54 pm    Post subject:

errr using the variable A is legal right?..

44 bytes whit an 1 letter name

Quote:
{0
for(A,1,52
if max(L1=a
augment(ans,{A
end
cumsum(deltalist(ans->L1
Back to top
Ed H


Member


Joined: 30 Nov 2007
Posts: 138

Posted: 15 Nov 2008 08:33:42 pm    Post subject:

Here are some solutions: cumSum(Ans or 1 or cumSum(Ans=Ans. The second one is due to DarkerLine, and does not fail for complex inputs. Although if you're sorting integers, it doesn't make a difference.

Last edited by Guest on 15 Nov 2008 08:36:42 pm; edited 1 time in total
Back to top
bfr


Member


Joined: 13 Feb 2006
Posts: 108

Posted: 16 Nov 2008 12:49:53 am    Post subject:

Those are pretty nice

Quote:

L1->L2
For(A,1,dim(Ans
L1(A
Ans->L2(Ans
End

nothing that great... :p


...So since I don't think this challenge was that great, here's another similar semi-challenge:

Given a list in L1 that has positive real numbers, including decimals, (with no duplicates of any elements - each element occurs once), make a program to sort it in descending order without using SortA or SortD (these are the only restrictions this time :)).

I've got 43 bytes...and a slight feeling that it can it can be optimised


Last edited by Guest on 16 Nov 2008 01:25:31 am; edited 1 time in total
Back to top
Ed H


Member


Joined: 30 Nov 2007
Posts: 138

Posted: 16 Nov 2008 01:26:14 am    Post subject:

I believe my solutions were for your first challenge.
Back to top
bfr


Member


Joined: 13 Feb 2006
Posts: 108

Posted: 16 Nov 2008 01:28:26 am    Post subject:

Yeah (I edited my post afterwards)

EDIT: Haha, and I forgot about the cumSum( thing after using it in your list to number base conversion challenge


Last edited by Guest on 16 Nov 2008 01:30:45 am; edited 1 time in total
Back to top
Ed H


Member


Joined: 30 Nov 2007
Posts: 138

Posted: 03 Jan 2010 05:31:35 pm    Post subject:

I'm bringing this back, yo:

Find the shortest program that will sort an arbitrary list of real numbers without using SortA or SortD. By arbitrary, I mean this list can contain any real number, any number of times, in any order.

Let's suppose this list is in Ans and we want the output to be in Ans as well. Or, if you think it would be more convenient, input your list from L1 and output it to L1 as well.
Back to top
ztrumpet


Active Member


Joined: 06 May 2009
Posts: 555

Posted: 03 Jan 2010 06:08:48 pm    Post subject:

I have an 77 byte program, thus 67 bytes of code for Ans. It's pretty big and slow, though. I had to use seq( to maintain Ans.

Last edited by Guest on 03 Jan 2010 06:08:59 pm; edited 1 time in total
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 03 Jan 2010 06:59:57 pm    Post subject:

I have 47 bytes.
Back to top
ztrumpet


Active Member


Joined: 06 May 2009
Posts: 555

Posted: 03 Jan 2010 07:58:34 pm    Post subject:

Weregoose, is that in L1 or Ans.

I now have 65 (75) for Ans.
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 03 Jan 2010 11:27:14 pm    Post subject:

Ans; although, I found a flaw that I now have to fix. :(

[EDIT]

56 bytes!


Last edited by Guest on 01 Jul 2010 09:58:48 am; edited 1 time in total
Back to top
Ed H


Member


Joined: 30 Nov 2007
Posts: 138

Posted: 04 Jan 2010 01:24:02 am    Post subject:

I found a gimmick solution in 53 bytes. But I'm not yet satisfied with my somewhat legit version.
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