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
WikiGuru
ADOS (Attention deficit... Oh! Shiny!)


Elite


Joined: 15 Sep 2005
Posts: 923

Posted: 26 Dec 2006 02:26:24 pm    Post subject:

Here's another challenge:
create the smallest program that will display a graphical menu ( Using the graph with 'text(', not 'output(' ) with these functions:

  1. Title is "TEST" (Centered)
  2. must have these items (Exactly like they are, left align):

    • 1:A
    • 2:B
    • 3:C

  3. can scroll up/down with a cursor (use '}' for the cursor)
  4. cursor should be able to wrap around (not just stop at top/bottom)
  5. can select by pressing the cooresponding number, or by pressing 2nd/enter (both of them)
  6. on A, displays "A", and quits
  7. Same for B except display "B"
  8. Same for C except display "C"
Here's an example program of what it should do (this is not the solution, I think)
The program doesn't have to clear the screen or turn axis off.

[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]Text(0,40,"TEST
Text(6,4,"1:A
Text(12,4,"2:B
Text(18,4,"3:C
6->A
lbl A
Text(A,0,"}
Getkey->B
Text(A,0,"4 spaces
A-6(B=25)+6(B=34)-18(A=1Cool+24(A=6->A
If B=92:Goto 0
If B=93:Goto 1
If B=94:Goto 2
If B!=21 or B!=105:Goto A
If A=6:Goto 0
If A=12:Goto 1
If A=18;Goto 2
Lbl 0
Disp "A
Stop
Lbl 1
Disp "B
Stop
Lbl 2
Disp "C
Stop


I hope this works, as I just typed it in and didn't try it out

Last edited by Guest on 26 Dec 2006 02:26:54 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: 26 Dec 2006 02:32:41 pm    Post subject:

[quote name='Ti-Ho' date='Dec 26 2006, 01:26 PM']Here's another challenge:
create the smallest program that will display a graphical menu ( Using the graph with 'text(', not 'output(' ) with these functions:

  1. Title is "TEST" (Centered)

  2. must have these items (Exactly like they are, left align):

    • 1:A
    • 2:B
    • 3:C


  3. can scroll up/down with a cursor (use '}' for the cursor)

  4. cursor should be able to wrap around (not just stop at top/bottom)

  5. can select by pressing the cooresponding number, or by pressing 2nd/enter (both of them)

  6. on A, displays "A", and quits

  7. Same for B except display "B"

  8. Same for C except display "C"
Here's an example program of what it should do (this is not the solution, I think)
The program doesn't have to clear the screen or turn axis off.

[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]Text(0,40,"TEST
Text(6,4,"1:A
Text(12,4,"2:B
Text(18,4,"3:C
6->A
lbl A
Text(A,0,"}
Getkey->B
Text(A,0,"4 spaces
A-6(B=25)+6(B=34)-18(A=1Cool+24(A=6->A
If B=92:Goto 0
If B=93:Goto 1
If B=94:Goto 2
If B!=21 or B!=105:Goto A
If A=6:Goto 0
If A=12:Goto 1
If A=18;Goto 2
Lbl 0
Disp "A
Stop
Lbl 1
Disp "B
Stop
Lbl 2
Disp "C
Stop


I hope this works, as I just typed it in and didn't try it out
[post="93541"]<{POST_SNAPBACK}>[/post][/quote]You can cut off 2 bytes by omitting the "Stop" at the end.
Back to top
trigkid213


Member


Joined: 30 Mar 2006
Posts: 208

Posted: 26 Dec 2006 07:59:21 pm    Post subject:

Since Stop is one token, isn't it one byte?
Back to top
Harrierfalcon
The Raptor of Calcs


Super Elite (Last Title)


Joined: 25 Oct 2006
Posts: 2535

Posted: 26 Dec 2006 08:01:10 pm    Post subject:

True, 'Stop' is one byte, but each newline is also a byte.
Back to top
luby
I want to go back to Philmont!!


Calc Guru


Joined: 23 Apr 2006
Posts: 1477

Posted: 26 Dec 2006 08:56:00 pm    Post subject:

you can also change all b's in this part
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"] A-6(B=25)+6(B=34)-18(A=1Cool+24(A=6->A

to ans.
Back to top
WikiGuru
ADOS (Attention deficit... Oh! Shiny!)


Elite


Joined: 15 Sep 2005
Posts: 923

Posted: 27 Dec 2006 10:37:15 am    Post subject:

What good will that do? After you store to A, Ans will equal A, so you won't be able to test what it is later. They're both 1 byte anyways, so size of the variable doesn't matter.
Back to top
luby
I want to go back to Philmont!!


Calc Guru


Joined: 23 Apr 2006
Posts: 1477

Posted: 27 Dec 2006 11:07:13 am    Post subject:

first of all the getkey stores to b so you can test what it is later and second of all, ans is faster then b.
Back to top
vuurrobin


Advanced Member


Joined: 09 Aug 2006
Posts: 428

Posted: 27 Dec 2006 12:00:40 pm    Post subject:

there is a bug in it.
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]A-6(B=25)+6(B=34)-18(A=1Cool+24(A=6->A

acording to me, this is supposed to be
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]A-6(ans+25)+6(ans=34)-18(A=1Cool(ans=34)+18(A=6)(ans=25->A

and this is what I have (it works, I tested it)

[color=#000000background#000000]
Text(0,40,"TEST
Text(6,4,"1:A
Text(12,4,"2:B
Text(18,4,"3:C
6->A
repeat max(B={21,105,92,93,94
Text(A,0,"}
repeat ans
Getkey->B
end
Text(A,0," <<<4 spaces>>>
A-6(ans+25)+6(ans=34)-18(A=1Cool(ans=34)+18(A=6)(ans=25->A
end
if A=6 or B=92:"A
if A=12 or B=93:"B
if A=18 or B=94:"C
disp ans

[/color]
Back to top
luby
I want to go back to Philmont!!


Calc Guru


Joined: 23 Apr 2006
Posts: 1477

Posted: 27 Dec 2006 07:02:00 pm    Post subject:

vuurrobin wrote:
A-6(ans+25)+6...


did you mean ans=25??
Back to top
simplethinker
snjwffl


Active Member


Joined: 25 Jul 2006
Posts: 700

Posted: 27 Dec 2006 08:25:09 pm    Post subject:

Didn't he say that was just an example?
Quote:
Here's an example program of what it should do (this is not the solution, I think)

So shouldn't we be worrying about writing one instead of fixing his example?
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 27 Dec 2006 09:56:24 pm    Post subject:

vuurrobin wrote:
there is a bug in it.
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]A-6(B=25)+6(B=34)-18(A=1Cool+24(A=6->A
acording to me, this is supposed to be
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]A-6(ans+25)+6(ans=34)-18(A=1Cool(ans=34)+18(A=6)(ans=25->A

and this is what I have (it works, I tested it)

[color=#000000background#000000]
Text(0,40,"TEST
Text(6,4,"1:A
Text(12,4,"2:B
Text(18,4,"3:C
6->A
repeat max(B={21,105,92,93,94
Text(A,0,"}
repeat ans
Getkey->B
end
Text(A,0," <<<4 spaces>>>
A-6(ans+25)+6(ans=34)-18(A=1Cool(ans=34)+18(A=6)(ans=25->A
end
if A=6 or B=92:"A
if A=12 or B=93:"B
if A=18 or B=94:"C
disp ans

[/color]
[post="93589"]<{POST_SNAPBACK}>[/post]
There's a bug: if I press [1] while the cursor points to "3:C", your program will output C instead of A.

The following, I think, is reasonably close to the ideal size.
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]1->S
Text(0,40,"TEST
Text(6,4,"1:A
Text(12,4,"2:B
Text(18,4,"3:C
Repeat max(K={21,92,93,94,105
Text(6S,0,"}
Repeat Ans
getKey->K
End
Text(6S,0," (3 spaces)
S+(Ans=34)-(Ans=25
Ans+3(not(Ans)-(Ans=3->S
End
If max(K={21,105
Then
S
Else
K-91
End
Disp sub("ABC",Ans,1

This isn't really an interesting challenge however, it gets too technical, and you're tempted to sacrifice quality for size.

Something that appeals more to the mathematician in me:
you're given six variables (something along the lines of [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]Prompt A,B,C,D,E,F at the beginning) that represent the three sides and angles of a triangle. Some of them have zeroes instead of the value. Solve for the unknown sides/angles if possible.
Back to top
luby
I want to go back to Philmont!!


Calc Guru


Joined: 23 Apr 2006
Posts: 1477

Posted: 27 Dec 2006 10:45:53 pm    Post subject:

simplethinker wrote:
Didn't he say that was just an example?
Quote:
Here's an example program of what it should do (this is not the solution, I think)

So shouldn't we be worrying about writing one instead of fixing his example?
[post="93605"]<{POST_SNAPBACK}>[/post]


look whom i quoted
Back to top
vuurrobin


Advanced Member


Joined: 09 Aug 2006
Posts: 428

Posted: 28 Dec 2006 09:30:16 am    Post subject:

luby wrote:
did you mean ans=25??
[post="93598"]<{POST_SNAPBACK}>[/post]


sorry for the typo :blush: , I fixed it.

DarkerLine wrote:
There's a bug: if I press [1] while the cursor points to "3:C", your program will output C instead of A.


and I thought my programm was bug-free Sad (I need a better bugspray)

DarkerLine wrote:
Something that appeals more to the mathematician in me:
you're given six variables (something along the lines of [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]Prompt A,B,C,D,E,F at the beginning) that represent the three sides and angles of a triangle. Some of them have zeroes instead of the value. Solve for the unknown sides/angles if possible.
[post="93618"]<{POST_SNAPBACK}>[/post]


I don't know if it is possible without knowing which variables are sides and which variables are angles.


Last edited by Guest on 28 Dec 2006 09:33:17 am; edited 1 time in total
Back to top
luby
I want to go back to Philmont!!


Calc Guru


Joined: 23 Apr 2006
Posts: 1477

Posted: 30 Dec 2006 03:11:44 pm    Post subject:

You would have them imput angles first then sides. or the other way around I guess.
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 02 Jan 2007 03:11:05 pm    Post subject:

DarkerLine wrote:
Something that appeals more to the mathematician in me:
you're given six variables (something along the lines of [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]Prompt A,B,C,D,E,F at the beginning) that represent the three sides and angles of a triangle. Some of them have zeroes instead of the value. Solve for the unknown sides/angles if possible.
It took me a while, but here it is finally:

[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]Prompt A,B,C,D,E,F // Sides, angles
{A,B,C→L1
{D,E,F→L2
If 3≠sum(not(L1))+sum(not(Ans
Return
Degree
{1,2,3→L3
If min(L1+L2) and 1=sum(not(L1
Then
max(L3not(L1
√(sum(L1²)-2prod(L1+not(L1))cos(L2(Ans→L1(Ans
End
If 1=sum(not(L2
180-sum(L2→L2(max(L3not(L2
If min(L2) and 2=sum(not(L1
max(L1)sin(L2)/sin(L2(max(L3not(not(L1→L1
If max(L1L2) and 1=sum(not(L1)) and 2=sum(not(L2
Then
max(L2→θ
L1(sum(L2L3/Ans→Y
L1(sum((L1>L1L2)L3
cos(θ)Ans+{1,-1}√(Y²-Ans²sin(θ)²
(Ans>0)Ans→L2
End
sum(L3not(L1→X
For(Y,1,4-dim(L2)-(2=dim(L2))max(not(L2
If 2=dim(L2
L2(Y→L1(X
Pause L1
Pause cos‾¹(Ans/prod(Ans)(.5sum(Ans²)-Ans²
.5sum(L1
Pause √(Ansprod(Ans-L1
End

This gives:
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]{a,b,c} Sides
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]{A,B,C} Angles
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]Area___ Area in units
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"][color=gray]{a,b,c} Sides on other possible triangle
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]{A,B,C} Angles on other possible triangle
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]Area___ Area of other possible triangle[/color]

The program will halt immediately if the user doesn't provide exactly three zeros and three non-zero values.
The bottom three answers will only appear when the Side-Side-Angle theorem yields two possible triangles.

Last edited by Guest on 03 Jan 2007 04:20:36 am; edited 1 time in total
Back to top
trigkid213


Member


Joined: 30 Mar 2006
Posts: 208

Posted: 02 Jan 2007 06:47:17 pm    Post subject:

Very nice! Razz As usual, your optimization skills are superb.

Allow me optimize one byte: instead of
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"](Ans>0)Ans→L2
,
how about
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]Ans(Ans>0→L2. Wink
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 02 Jan 2007 09:42:49 pm    Post subject:

trigkid213 wrote:
Allow me optimize one byte: instead of
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"](Ans>0)Ans→L2,
how about
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]Ans(Ans>0→L2Wink
Only, [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]Ans is a list at that point, and I wouldn't want to run the risk of extracting the zeroth element. Wink

Last edited by Guest on 02 Jan 2007 09:49:25 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