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
Harrierfalcon
The Raptor of Calcs


Super Elite (Last Title)


Joined: 25 Oct 2006
Posts: 2535

Posted: 17 Dec 2006 04:43:30 pm    Post subject:

Sorry for getting 'off topic' but here's another brain teaser:

Try to come up with ANY program at all that will calculate the exact angle formed by the 2 hands of an analog clock, given the time.

I spent all day today noodling this, and I finally came up with one. This one is not for size, but simply doing this.

Challenge: Try to do it without using any built-in formulas. Not really a challenge (mine uses none).

Reason being, we had to do this in Geometry, and for finals we got a cheat sheet we can write anything on. My teacher says that its in case anyone happened to program it into their calculator.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 17 Dec 2006 04:55:33 pm    Post subject:

[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]Prompt H,M
abs(30H-5.5M
min(Ans,360-Ans

(returns result in degrees)

Not sure what you mean by "no built-in formulas," is this good enough?

Last edited by Guest on 17 Dec 2006 04:59:01 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: 17 Dec 2006 05:36:14 pm    Post subject:

Goshdangit. How advanced in math are you? I'm a freshie in Honors Geometry.

As my brother would say, migglesphlit.

Would you mind explaining how that works? Just the last 2 lines--I'm pretty sure I know what the first 1 does.


Last edited by Guest on 17 Dec 2006 06:32:11 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: 17 Dec 2006 07:38:32 pm    Post subject:

To find the angle between the hour hand and the minute hand, I find the angle between 12 o'clock and the hour hand, and subtract the angle between 12 o'clock and the minute hand. The difference could be negative, so I take abs() of it, and it could be something like 330 degrees, so I take the smaller of the two possible angles.

If we can assume that the hour is 0 to 12, then the angle for the hour hand is 30*hour (360 degrees / 12 hours). But wait - the hour hand moves during the hour too. In fact, for each minute that passes it moves 1/60 of the distance to the next hour, which is 1/60 of 30 degrees or .5 degrees per minute. So the angle for the hour hand is 30*hour + .5*minute.

For the minute hand, the degree measure is just 6 (360 degrees / 60 minutes in an hour) degrees per minute, so its angle is 6*minutes.

We subtract these, and get 30H+.5M-6M which simplifies to 30H-5.5M.

We could actually play around with common factors a bit and get the following code, which is one byte smaller, but that's petty. Nevertheless:

[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]Prompt H,M
abs(6H-1.1M
5min(Ans,72-Ans


Last edited by Guest on 17 Dec 2006 07:38:44 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