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.
TI-Basic Brain Teasers =>
TI-BASIC
Author |
Message |
|
stlcards08
Newbie
Joined: 04 Mar 2007 Posts: 35
|
Posted: 03 May 2007 10:24:09 pm Post subject: |
|
|
I've got a new teaser that should be easy for most of you guys (took me almost 2 hours to figure out, nearly the whole drive to Kentucky). Make a program under 80 bytes to find the mode of a list. (mines at 81 with MODE as the program name, I didn't really bother to try and make it smaller because of how long it took to make it work) |
|
Back to top |
|
|
thornahawk μολών λαβέ
Active Member
Joined: 27 Mar 2005 Posts: 569
|
Posted: 03 May 2007 10:35:45 pm Post subject: |
|
|
Should the program also work for multimodal lists, like {1,2,4,4,4,4,5,5,5,5,6,11}? :)
thornahawk |
|
Back to top |
|
|
stlcards08
Newbie
Joined: 04 Mar 2007 Posts: 35
|
Posted: 03 May 2007 10:38:06 pm Post subject: |
|
|
thornahawk wrote: Should the program also work for multimodal lists, like {1,2,4,4,4,4,5,5,5,5,6,11}? :)
thornahawk
[post="102833"]<{POST_SNAPBACK}>[/post]
Mine doesn't, but I'll give you a cookie if it does. |
|
Back to top |
|
|
Weregoose Authentic INTJ
Super Elite (Last Title)
Joined: 25 Nov 2004 Posts: 3976
|
Posted: 04 May 2007 02:16:33 am Post subject: |
|
|
I got mine in 49 bytes. (It only returns the rightmost number with the highest frequency.)
I'll try to find a smaller method.
[EDIT]
Using a different approach, I got a program that's only 46 bytes!
However, it crashes if the highest frequency is one or two.
[EDIT×2]
I guess I should note that both of these programs start with [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]Ans→listname.
Last edited by Guest on 15 Jun 2007 02:54:21 am; 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: 04 May 2007 11:28:27 am Post subject: |
|
|
I wrote a 61-byte prgmMODE that returns a list of all modes. I too would like this number to be smaller.
(at the moment, my program uses both L1 and L2, and it's not the speediest thing in the world either)
(okay, I suppose I could get it smaller by renaming the lists, like last time)
Last edited by Guest on 04 May 2007 11:58:20 am; edited 1 time in total |
|
Back to top |
|
|
Weregoose Authentic INTJ
Super Elite (Last Title)
Joined: 25 Nov 2004 Posts: 3976
|
Posted: 04 May 2007 01:35:23 pm Post subject: |
|
|
Well, I now have a program in 38 bytes that zeros out all elements that don't belong to the modal set (i.e., it works for multimodal inputs). One has to scroll through the list afterwards to find the results, but it does work, and I feel no further obligation to make it look pretty.
Last edited by Guest on 04 May 2007 01:38:04 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: 04 May 2007 02:06:39 pm Post subject: |
|
|
That's... cheating.
I wrote a 34-byte program that finds the largest mode for any list of real numbers that aren't too huge (actually, it works as long as they don't have too huge a range).
By sacrificing another byte, you can make the allowed range go up considerably.
Edit: when the old brainteaser topic was split up, the solutions to this teaser ended up in a different topic: Weregoose's here and mine here.
Last edited by Guest on 02 Oct 2007 11:24:07 pm; edited 1 time in total |
|
Back to top |
|
|
|
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