Programming a clock exercise « Next Oldest | Next Newest »

 ▼ Mike Reed Member Posts: 82 Threads: 15 Joined: Jan 2008 01-08-2009, 06:23 PM ```Here's a little exercise for ya - participation voluntary. You are a starship pilot and routinely make port at many different worlds. Each world's rotation is different; some slower, resulting in a longer day, and some faster resulting in a shorter one. Compounding the problem is the fact that the "Local governments" of these worlds have not adopted a "standard" 24 hour day. Some have 20 "hours" some 25, etc, AND the "hour" does not necessarily have 60 "minutes", nor a "minute" 60 seconds. You want to build an electronic watch (or clock) that you can set for the period (length of a day expressed in "Earth" hours), number of hours per period, number of minutes per hour, and number of seconds per minute. The clock will then accurately keep time for you on the planet you are visiting. The timekeeping abilities of this clock (and the programming language for it) are exactly the equivalent of an HP48-SX (see - i DID get HP calculator in there somewhere ;-) )Your task is to write the smallest program possible to make the clock work. Period Planet (std hrs) Hrs/period Min/Hr Sec/min Adaen 28.376 25 90 90 Baell 20.421 18 75 50 Calea 22.381 20 60 60 Dawaer 26.258 20 100 50 OK - you can throw rocks at me now... ;oD ``` ▼ Allen Senior Member Posts: 562 Threads: 27 Joined: Oct 2006 01-08-2009, 08:38 PM May I assume since the speed of the starship and the mass of the planets is not noted that relativestic time dilation effects are not to be corrected for in any of the the clocks? And that the standard SI unit for a second is consistent across the worlds. Alternatively, I could assume that "STD HRS" in the table above refers to a standard 3600 seconds that we might have on earth. Edited: 8 Jan 2009, 8:47 p.m. ▼ Mike Reed Member Posts: 82 Threads: 15 Joined: Jan 2008 01-09-2009, 10:17 AM Quote: May I assume since the speed of the starship and the mass of the planets is not noted that relativestic time dilation effects are not to be corrected for in any of the the clocks? Yes, discount relativistic dilation; the clock is for use while grounded on a planet - your starship's control console has a clock that is for use while in transit. :o) And that the standard SI unit for a second is consistent across the worlds. NO - that's the problem. The duration of each unit hour/minute/second is different on each world and none correspond to the same units on earth. For instance on the planet Adaen, whose rotational period is 28.376 EARTH hours, their day is divided into 25 local hours, each consisting of 90 local minutes which in turn consist of 90 local seconds. The rotational period of Adaen is 25.000 Adaen hours. Alternatively, I could assume that "STD HRS" in the table above refers to a standard 3600 seconds that we might have on earth. Yep; STD HRS refer to time as measured HERE on good old Terra Firma! David Hayden Senior Member Posts: 528 Threads: 40 Joined: Dec 2008 01-13-2009, 10:02 AM What is desired accuracy of the clock? For example, one Adaen second is about 4132.55 ticks of the HP 49's clock (which has 8192 ticks per earth second). So if I round off to 4133 ticks per Adaen second then I can get an answer, but it will drift, being off my 11.59 earth seconds after one Adaen day. Not much of a clock. At the other extreme, we could say that the clock should run for eternity and remain accurate to within one clock tick forever. That's a bigger challenge. ▼ Mike Reed Member Posts: 82 Threads: 15 Joined: Jan 2008 01-13-2009, 11:02 AM Quote: What is desired accuracy of the clock? For example, one Adaen second is about 4132.55 ticks of the HP 49's clock (which has 8192 ticks per earth second). So if I round off to 4133 ticks per Adaen second then I can get an answer, but it will drift, being off my 11.59 earth seconds after one Adaen day. Not much of a clock. True - not much of a clock... I'm only looking for "wristwatch" accuracy here, not "atomic clock". My Casio G-Shock is good for about 7 seconds a week which should be fine. Looking at the numbers for Adaen, it appears it may be necessary to add or subtract (4133/11.59)/25 "leap" ticks each hour to keep a reasonable accuracy in the timepiece. The clock program should calculate this itself, and take care of it for you. At the other extreme, we could say that the clock should run for eternity and remain accurate to within one clock tick forever. That's a bigger challenge. That would be a MUCH bigger challenge, especially within the parameters of the problem, as i don't THINK the HP48sx has a Caesium clock in it! LOL

 Possibly Related Threads... Thread Author Replies Views Last Post HP Prime - Revision Suggestion - Setting the Clock Bill Triplett 5 461 11-15-2013, 12:36 AM Last Post: Joe Horn Prime incase anybody missed the clock Dougggg 5 406 10-19-2013, 04:05 PM Last Post: Geoff Quickfall Using your HP-65 as a clock! Don Shepherd 24 1,257 10-08-2013, 11:53 AM Last Post: Don Shepherd WP-34s clock program Andrew Nikitin 8 508 06-09-2013, 11:20 PM Last Post: Andrew Nikitin Cool math clock Bruce Bergman 28 1,506 04-10-2013, 03:13 AM Last Post: Siegfried (Austria) Programming exercise Gerson W. Barbosa 32 1,418 08-23-2012, 07:42 PM Last Post: Gerson W. Barbosa hp clock does not talk to hp 71 Hans Holzach 15 725 07-29-2012, 04:13 PM Last Post: Hans Holzach OT: Mechanical CPU clock Ethan Conner 1 210 04-19-2012, 01:23 AM Last Post: Mike Morrow [WP34s] Accurate Clock Katie Wasserman 1 188 04-08-2012, 01:25 AM Last Post: Walter B Re: RPN Programming exercise (HP-42S) Gerson W. Barbosa 1 183 02-27-2012, 05:51 PM Last Post: Marcus von Cube, Germany

Forum Jump: