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: 07 May 2007 04:43:06 am    Post subject:

Meanwhile... I have here a nice and easy Wink brain teaser for everybody:

You have two matrices of (possibly) different dimensions stored in [A] and [B]. Write a program (as short and/or as efficient as possible) that stores the Kronecker product [A]⊗[B] into matrix [C].

:D

thornahawk
Back to top
Harrierfalcon
The Raptor of Calcs


Super Elite (Last Title)


Joined: 25 Oct 2006
Posts: 2535

Posted: 09 May 2007 06:22:25 am    Post subject:

Possibly. Could you clarify what the elements of the matrix should hold?

EDIT: Never mind, a quick glance at Wikipedia clarified. Now, about these elements...


Last edited by Guest on 09 May 2007 06:26:33 am; edited 1 time in total
Back to top
thornahawk
μολών λαβέ


Active Member


Joined: 27 Mar 2005
Posts: 569

Posted: 09 May 2007 06:31:14 am    Post subject:

I'll give an example to clarify for everybody:

If

[A]=[[1,2][3,4]] and [B]=[[1,1,1][1,1,1]]

then [C] should contain

[[1 1 1 2 2 2]
[1 1 1 2 2 2]
[3 3 3 4 4 4]
[3 3 3 4 4 4]]

;)

thornahawk
Back to top
Harrierfalcon
The Raptor of Calcs


Super Elite (Last Title)


Joined: 25 Oct 2006
Posts: 2535

Posted: 09 May 2007 06:32:08 am    Post subject:

Making to work for any dimensions is the biggest problem, methinks.

Last edited by Guest on 09 May 2007 06:32:15 am; edited 1 time in total
Back to top
thornahawk
μολών λαβέ


Active Member


Joined: 27 Mar 2005
Posts: 569

Posted: 09 May 2007 06:35:04 am    Post subject:

It's not that hard. Wink I'll post my solution after I see at least two attempts.

thornahawk
Back to top
Harrierfalcon
The Raptor of Calcs


Super Elite (Last Title)


Joined: 25 Oct 2006
Posts: 2535

Posted: 09 May 2007 06:45:45 am    Post subject:

How many bytes is it? I just want an idea of if i should be using built-in functions or For( loops...
Back to top
thornahawk
μολών λαβέ


Active Member


Joined: 27 Mar 2005
Posts: 569

Posted: 09 May 2007 07:08:50 am    Post subject:

Not counting the program name, the solution I have is 85 bytes. I'm ready to see smaller programs, if there are. ;)

thornahawk
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 09 May 2007 05:28:58 pm    Post subject:

thornahawk wrote:
Not counting the program name, the solution I have is 85 bytes. I'm ready to see smaller programs, if there are. ;)

thornahawk
[post="103450"]<{POST_SNAPBACK}>[/post]
Right now I have two solutions, both 87 bytes without the program name. I'm working on finding out what I'm missing.
Back to top
Harrierfalcon
The Raptor of Calcs


Super Elite (Last Title)


Joined: 25 Oct 2006
Posts: 2535

Posted: 09 May 2007 07:45:02 pm    Post subject:

If you insist...
Code:
:dim([A])dim([B->dim([C]
Yeah. That's as far as I got.
Back to top
thornahawk
μολών λαβέ


Active Member


Joined: 27 Mar 2005
Posts: 569

Posted: 13 May 2007 04:47:46 am    Post subject:

The solution to the Kronecker product teaser:

(highlight below)

dim([A]→L1
For(I,1,L1(1
[A](I,1)[B]
For(J,2,L1(2
augment(Ans,[A](I,J)[B]
End
If I>1
augment([C]T,AnsT)T
Ans→[C]
End
[C]


:)

thornahawk
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 13 May 2007 11:26:20 am    Post subject:

I had much the same thing, but couldn't think of the right way to handle the [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]If I>1 case (I had an If-Then-Else loop).

I partially compensated for that with an optimization that works on the calculator even though it makes no mathematical sense: you can replace [font="courier new;font-size:9pt;line-height:100%;color:darkblue"][A](I,1)[.B] with [font="courier new;font-size:9pt;line-height:100%;color:darkblue"][.B][A](I,1 to save a byte, and the same for [font="courier new;font-size:9pt;line-height:100%;color:darkblue"][A](I,J. Using [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]Ans(1 in the first For( loop, and using [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]LA instead of [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]L1 helps too.

Oh and here's a 65-byte (ignoring the title) program for a matrix with a border:

[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]List>matr(binomcdf(9,0),augment({1},binomcdf(8,1)),[A]
augment({1},binomcdf(16,1
List>matr(Ans,not(Ans),[.B]
[A][B]T->[A]


I suppose it also has the useful trait of being independent of matrix size (you can just change the numbers and it will work).

Last edited by Guest on 13 May 2007 01:45:00 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