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
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 30 Aug 2007 06:04:36 am    Post subject:

Challenge #26 – [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]K holds the result of a [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]getKey instruction. It may or may not pertain to a number 1 through 9 on the number pad. If it does, then display the associating digit on the label of the key. If not, then display the normal [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]getKey value for the key that was pressed. For example, [+] should still return [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]95. Do this in 34 bytes from inside a program (subtracting the length of the title from the byte count).

(For the record: I would be impressed if anyone matched my answer. It took some brainwork!)

Last edited by Guest on 30 Aug 2007 06:09:27 am; edited 1 time in total
Back to top
Harrierfalcon
The Raptor of Calcs


Super Elite (Last Title)


Joined: 25 Oct 2006
Posts: 2535

Posted: 30 Aug 2007 07:07:07 am    Post subject:

Hm...I have the formula for converting a keypress to it's corresponding number...

First try, 66 bytes. Hm.
Second try, 73. Something's telling me this doesn't like me.
Third try, 66 again.
Fourth try, 58 bytes. I'm getting somewhere...
Fifth try, 56 bytes. Closer still!
Spoiler wrote:
:K
:If Ans>71 and Ans<103 and min(10fPart(.1Ans)≠{1,5
:max(0,26-3int(.1Ans)+10fPart(.1Ans
Where do I have too many bytes...?
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 30 Aug 2007 08:20:33 am    Post subject:

My routine uses only one relational operator and no [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]If, if that helps.
I'm curious to see what others find! There are many ways to do this.

Last edited by Guest on 30 Aug 2007 08:21:38 am; edited 1 time in total
Back to top
TheStorm


Calc Guru


Joined: 17 Apr 2007
Posts: 1233

Posted: 30 Aug 2007 08:50:22 am    Post subject:

What about look up tables can they be used?
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 30 Aug 2007 08:57:38 am    Post subject:

However you like. Honestly, though, I doubt that any form of a lookup will get it down to 34 bytes.
Back to top
TheStorm


Calc Guru


Joined: 17 Apr 2007
Posts: 1233

Posted: 30 Aug 2007 09:03:41 am    Post subject:

I was thinking a string but I still can't get my code right Sad.

Got it! No wait 60 bytes, darn Sad
spoiler wrote:
:K-(K>71)(K+expr(sub('789KK456KK123K",K-61-5int(.1K-5),1

my new unfinished code is 29 bytes
Quote:
:10fPart(.1k)+17-3int(.1K-3
the problem is with conditionals it is ~50 bytes oh and ha my code is one byte shorter than harriers but we both need conditionals under 5 bytes for it to work.

Last edited by Guest on 30 Aug 2007 02:52:34 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: 30 Aug 2007 02:06:58 pm    Post subject:

Also, your first piece of code doesn't work for, say, K=0.

Edit: first try: 75 bytes. Blargh.


Last edited by Guest on 30 Aug 2007 02:46:09 pm; edited 1 time in total
Back to top
TheStorm


Calc Guru


Joined: 17 Apr 2007
Posts: 1233

Posted: 30 Aug 2007 02:47:30 pm    Post subject:

Weregoose wrote:
Challenge #26 – [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]K holds the result of a [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]getKey instruction. It may or may not pertain to a number 1 through 9 on the number pad. If it does, then display the associating digit on the label of the key. If not, then display the normal [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]getKey value for the key that was pressed. For example, [+] should still return [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]95. Do this in 34 bytes from inside a program (subtracting the length of the title from the byte count).

(For the record: I would be impressed if anyone matched my answer. It took some brainwork!)
[post="111874"]<{POST_SNAPBACK}>[/post]

IT dosen't have to work for 0 acording to the origonal post
Oh wait I miss typed it. thx Xpheonix


Last edited by Guest on 30 Aug 2007 03:36:02 pm; edited 1 time in total
Back to top
Xphoenix


Elite


Joined: 04 Apr 2007
Posts: 756

Posted: 30 Aug 2007 03:20:57 pm    Post subject:

He means 0 as in, no key is pressed (K=0 if getKey returned 0).
Back to top
Harrierfalcon
The Raptor of Calcs


Super Elite (Last Title)


Joined: 25 Oct 2006
Posts: 2535

Posted: 30 Aug 2007 03:58:47 pm    Post subject:

Hmm...well, I'll try out a few more ideas after I finish my homework. I'm positive I can get lower than 56 bytes...
Back to top
Sage Orator


Advanced Member


Joined: 23 Apr 2006
Posts: 337

Posted: 30 Aug 2007 04:38:25 pm    Post subject:

First try, 59 bytes
Second try, 57 bytes

I'll try again later.

Meh, 54 bytes.


Last edited by Guest on 30 Aug 2007 05:18:13 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: 30 Aug 2007 05:10:18 pm    Post subject:

I've gotten 44 bytes, which is still off from the mark, but better than my abysmal failure the first time...

Inspired by TheStorm, I came up with:
Quote:
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]expr(sub("K456K987KKK123K",min(15,abs(K-80)),1


Last edited by Guest on 30 Aug 2007 05:12:00 pm; edited 1 time in total
Back to top
Harrierfalcon
The Raptor of Calcs


Super Elite (Last Title)


Joined: 25 Oct 2006
Posts: 2535

Posted: 30 Aug 2007 05:21:14 pm    Post subject:

Weregoose wrote:
However you like. Honestly, though, I doubt that any form of a lookup will get it down to 34 bytes.
[post="111886"]<{POST_SNAPBACK}>[/post]
DarkerLine wrote:
I've gotten 44 bytes, which is still off from the mark, but better than my abysmal failure the first time...

Inspired by TheStorm, I came up with:
Quote:
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]expr(sub("K456K987KKK123K",min(15,abs(K-80)),1

[post="111918"]<{POST_SNAPBACK}>[/post]
I'd guess, from Goose's words, he didn't use a LUT. Hm.

Goose, when you say "relational operator," you mean [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]min(
, [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]max(, and things like that, right?

Last edited by Guest on 30 Aug 2007 05:23:14 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: 30 Aug 2007 05:29:57 pm    Post subject:

I think he means <, >, and things like that.
Back to top
Harrierfalcon
The Raptor of Calcs


Super Elite (Last Title)


Joined: 25 Oct 2006
Posts: 2535

Posted: 30 Aug 2007 05:31:48 pm    Post subject:

Yeah, but I was under the impression that someone like Goose would call those what they are, i.e "logical operators."

What did you mean, Goose?
Back to top
TheStorm


Calc Guru


Joined: 17 Apr 2007
Posts: 1233

Posted: 30 Aug 2007 05:37:59 pm    Post subject:

MY best is 50 but I don't see how this is possible because you need more than 20 bytes just for conditionals to make it only work with the numpad then your actual formula can only take 14 bytes which i do not think is possible.
Back to top
Harrierfalcon
The Raptor of Calcs


Super Elite (Last Title)


Joined: 25 Oct 2006
Posts: 2535

Posted: 30 Aug 2007 05:40:50 pm    Post subject:

If it took Goose some real thinking to figure it out, then you can be sure than only a select others will be able to think of it within 24 hours.

/me is still twiddling...

EDIT: Storm?
Quote:
102→K:10fPart(.1K)+17)-
3int(.1K-3
                                    -2
Try again.

EDIT#2: Hehe, I can shave off a single byte after 30 minutes of thinking. XD


Last edited by Guest on 30 Aug 2007 06:23:26 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: 30 Aug 2007 07:23:54 pm    Post subject:

Harrierfalcon wrote:
Yeah, but I was under the impression that someone like Goose would call those what they are, i.e "logical operators."

What did you mean, Goose?
[post="111922"]<{POST_SNAPBACK}>[/post]


Actually, someone like Goose would not call those "logical operators", since they are not logical operators. The commonly accepted definition refers to <, =, >, <=, >=, != as relational operators. Logical operators are and, or, xor, and so on.
Back to top
Harrierfalcon
The Raptor of Calcs


Super Elite (Last Title)


Joined: 25 Oct 2006
Posts: 2535

Posted: 30 Aug 2007 07:29:31 pm    Post subject:

Hm...I'm definitely too into calculators--I assumed they were "logical operators" because they're in the same key menu as and, or, etc.

XD

Still not doing so well here...
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 30 Aug 2007 09:52:41 pm    Post subject:

Harrierfalcon wrote:
I'd guess, from Goose's words, he didn't use a LUT.
Now that I look at this more carefully, I do have something on the first line which could be referred to as a lookup (somewhat) but it didn't start that way – it only realized itself for optimization purposes, and is only there to prep a line beneath it. It is also very small. :)

Last hint: I didn't use any strings. Neat idea, though.


Last edited by Guest on 30 Aug 2007 09:57:46 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
    » Goto page 1, 2, 3  Next
» View previous topic :: View next topic  
Page 1 of 3 » All times are UTC - 5 Hours

 

Advertisement