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
thornahawk
μολών λαβέ


Active Member


Joined: 27 Mar 2005
Posts: 569

Posted: 19 Nov 2007 05:13:15 am    Post subject:

You are given two lists in L1 and L2, possibly of different lengths, each representing a list of polynomial coefficients. (With regards to coefficient ordering, use whichever of "constant term first" or "coefficient of largest-degree term first" is more convenient).

The challenge is to write the shortest program that generates the Sylvester matrix corresponding to those two polynomials.

thornahawk
Back to top
angel14995


Member


Joined: 13 Oct 2007
Posts: 181

Posted: 19 Nov 2007 08:56:38 pm    Post subject:

I've got it, it's not pretty, but I got it
Spoiler wrote:
:SortA(L1
:SortA(L2
:-1+dim(L1 /->/ M
:-1+dim(L2 /->/ N
:{(M+N),(M+N)} /->/ dim([A]
:Fill(0,[A]
:For(A,1,N
:A /->/ C
:For(B,C,M+C
:L1(B-C+1 /->/ [A](A,B
:End
:End
:For(A,1,M
:A /->/ C
:For(B,C,N+C
:L2(B-C+1 /->/ [A](A+N,B
:End
:End
:[A]


And it's 143 bytes to boot!
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 20 Nov 2007 06:10:39 am    Post subject:

angel14995, your program doesn't work for all inputs (notably small ones). I'm pretty sure you can go back and optimize it a bit, too...

Here's mine ([s]102[/s] 101 bytes):
Spoiler wrote:
[s]1+max(dim(L1),dim(L2→dim(L2[/s] dim(L1)-2+dim(L2→dim(L2
For(X,0,1
Repeat Ans(dim(Ans
dim(L2→dim(L1
List►matr(L1,[B]
[B]
If X or not(L1(1
augment([A],[B]
Ans→[A]
augment({0},L1→L1
End
L2→L1
End
[A][font="arial"]τ
In this program, problems arise if the first or last coefficients are explicitly defined to be zero. This also destroys the original lists. :(

[EDIT] – Fix made in the first line.

P.S., removing the transpose instruction would offer another matrix having the same determinant and would also save one more byte, bringing the total to 100. :)

[EDIT×2]

Don't tell me that no one spotted the other error that I just now fixed after three days. This program should work now.


Last edited by Guest on 04 Sep 2010 08:33:34 pm; edited 1 time in total
Back to top
angel14995


Member


Joined: 13 Oct 2007
Posts: 181

Posted: 20 Nov 2007 06:54:52 am    Post subject:

Weregoose wrote:
angel14995, your program doesn't work for all inputs (notably small ones).


Unless I am reading it wrong, or I am just being plain stupid, here is how I interpreted it:
Spoiler wrote:
In the list, the value of m and n are one less than the total number of values in the list. Since M+N gives us the width and height of the matrix, then they are two less than the dimensions of L1 and L2 added. If the dimensions are 1 and 2, then it would be a 1*1 matrix. If it is 2 and 2, it would be a 2*2 matrix. If it is 3*2, it is a 3*3 matrix. I don't know if the outputs for anything lower than 1*2 is accurate, but then I'll fix it.


And I know there are optimizations, I just need to find them Smile
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 20 Nov 2007 06:56:05 am    Post subject:

Oh wow, mine is the one that screws up, not yours. I misread the articles on Sylvester Matrices. So, I'll attempt to fix mine now, sorry. Razz
Back to top
angel14995


Member


Joined: 13 Oct 2007
Posts: 181

Posted: 20 Nov 2007 06:59:24 am    Post subject:

I win in finishing it first, you'll win it getting it uber small. And misreading the article. Lol
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 20 Nov 2007 07:03:13 am    Post subject:

Okay, my fix allowed me to save more space. :biggrin:

It is now roughly 4:00 AM here, and I'm about to go to bed. (Excuses, excuses...)


Last edited by Guest on 20 Nov 2007 07:04:15 am; edited 1 time in total
Back to top
JoostinOnline


Active Member


Joined: 22 Aug 2007
Posts: 559

Posted: 20 Nov 2007 11:57:38 am    Post subject:

I don't know who Spoiler is, but he sure is smart...
Very Happy


Last edited by Guest on 20 Nov 2007 01:09:29 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