Clock Hands Challenge
03-02-2019, 02:47 AM (This post was last modified: 03-02-2019 05:38 AM by RMollov.)
Post: #1
 RMollov Member Posts: 248 Joined: Dec 2013
Clock Hands Challenge
I wonder what would be the shortest 2 line display HP/DM calc program to show at what time (exact to a second) past given hour hands would be at 0 AND 180 degrees.
I've solved it, but I'm sure forum's geniuses would be able to come up with better solution.
03-05-2019, 07:17 PM
Post: #2
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: Clock Hands Challenge
(03-02-2019 02:47 AM)RMollov Wrote:  I wonder what would be the shortest 2 line display HP/DM calc program to show at what time (exact to a second) past given hour hands would be at 0 AND 180 degrees.

I have read this sentence several times, but obviously my command of the English language is not sufficient to get its meaning.

But then... as I write this there are more than 170 views of this thread, but still no reply (this is the first one). Maybe your idea is really a bit hard to get? For instance the part with "hour hands would be at 0 AND 180 degrees". All clocks I know have exactly one hour hand, so it can be either at 0° or 180°, but not both at the same time ("AND"). By the way: 0° and 180° relative to what?

Maybe a more detailled explanation and an example will revive this thread.

Dieter
03-05-2019, 07:30 PM
Post: #3
 Didier Lachieze Senior Member Posts: 1,227 Joined: Dec 2013
RE: Clock Hands Challenge
(03-05-2019 07:17 PM)Dieter Wrote:  I have read this sentence several times, but obviously my command of the English language is not sufficient to get its meaning.

+1, English is not my first language and I don't get what's this challenge is about. And the mention of a 2 line display program is adding to my confusion.
03-05-2019, 10:16 PM
Post: #4
 ijabbott Senior Member Posts: 910 Joined: Jul 2015
RE: Clock Hands Challenge
Perhaps RMollov means the times at which the hour and minute hands are separated by 180 degrees? That should happen 11 times per 12 hour period, mirror symmetrical about 6 o'clock.

— Ian Abbott
03-05-2019, 10:52 PM
Post: #5
 Thomas Klemm Senior Member Posts: 1,447 Joined: Dec 2013
RE: Clock Hands Challenge
(03-05-2019 10:16 PM)ijabbott Wrote:  That should happen 11 times per 12 hour period, mirror symmetrical about 6 o'clock.

Something like this?
Code:
00 { 31-Byte Prgm } 01▸LBL "CLOCK" 02 12 03 11 04 ÷ 05 →HMS 06 ENTER 07 ENTER 08 ENTER 09 6 10▸LBL 00 11 STOP 12 HMS+ 13 24 14 MOD 15 GTO 00 16 END

Example:

XEQ "CLOCK"
6.0000
7.0527
8.1055
9.1622
10.2149
11.2716
12.3244
13.3811
14.4338
15.4905
16.5433

Cheers
Thomas
03-05-2019, 11:29 PM
Post: #6
 rprosperi Senior Member Posts: 4,389 Joined: Dec 2013
RE: Clock Hands Challenge
(03-05-2019 07:17 PM)Dieter Wrote:  I have read this sentence several times, but obviously my command of the English language is not sufficient to get its meaning.

and

(03-05-2019 07:30 PM)Didier Lachieze Wrote:  +1, English is not my first language and I don't get what's this challenge is about. And the mention of a 2 line display program is adding to my confusion.

English IS my first language, and I could not follow it either; perhaps it is not RMollov's? I was going to comment but thought I'd wait to see if it was me; I guess not. The 2-line display comment threw me off as well, how is this related?

Yes, please explain this further when you can.

--Bob Prosperi
03-06-2019, 02:10 AM
Post: #7
 Valentin Albillo Senior Member Posts: 607 Joined: Feb 2015
RE: Clock Hands Challenge
.
Hi, Bob:

(03-05-2019 11:29 PM)rprosperi Wrote:  English IS my first language, and I could not follow it either; perhaps it is not RMollov's? I was going to comment but thought I'd wait to see if it was me; I guess not. The 2-line display comment threw me off as well, how is this related?

English is not my first language (that would be Spanish) but I understood it like this:

"I wonder what would be the shortest program for a 2-line display HP/DM calc (i.e.: HP42S / DM42) that shows at what time (accurate to the second) past a user-specified hour (i.e.: 0:00, 1:00, ... 23:00) would the clock's hands form an angle of either 0º or 180º."

Best regards.
V.
.

Find All My HP-related Materials here:  Valentin Albillo's HP Collection

03-06-2019, 02:43 AM
Post: #8
 rprosperi Senior Member Posts: 4,389 Joined: Dec 2013
RE: Clock Hands Challenge
(03-06-2019 02:10 AM)Valentin Albillo Wrote:  "I wonder what would be the shortest program for a 2-line display HP/DM calc (i.e.: HP42S / DM42) that shows at what time (accurate to the second) past a user-specified hour (i.e.: 0:00, 1:00, ... 23:00) would the clock's hands form an angle of either 0º or 180º."

Well, this makes sense and it is a non-trivial challenge, so it's a good guess, but I still don't follow the 2-line display aspect of the challenge. An HP-42S is, but the DM42 is not (it shows up to 5), and all the other DM models are 1-line displays. And so, if the 42S was meant specifically, why not just say 42S?

Possibly the intention is to have the program OUTPUT 2 lines, 1 for 0 degrees, and 1 for 180 degrees (hence the AND)?

Anyhow, I imagine we'll know soon when RMollov visits again and clarifies the challenge.

--Bob Prosperi
03-06-2019, 07:50 AM (This post was last modified: 03-06-2019 07:53 AM by RMollov.)
Post: #9
 RMollov Member Posts: 248 Joined: Dec 2013
RE: Clock Hands Challenge
(03-06-2019 02:10 AM)Valentin Albillo Wrote:  English is not my first language (that would be Spanish) but I understood it like this:

"I wonder what would be the shortest program for a 2-line display HP/DM calc (i.e.: HP42S / DM42) that shows at what time (accurate to the second) past a user-specified hour (i.e.: 0:00, 1:00, ... 23:00) would the clock's hands form an angle of either 0º or 180º."

Best regards.
V.
.

Thanks, Valentin, that's it! English isn't my first language too
One note, on an analog clock 13, 14 etc. do not exist, so the input ("Hour") is MOD'd to 12.
Thank you all, I should have posted here my solution which does what I meant. Here it is:

Code:
 00 { 71-Byte Prgm } 01▶LBL "CLOCK" 02 IP 03 12 04 MOD 05 STO "Hour" 06 6 07 X≤Y? 08 +/- 09 SIGN 10 180 11 × 12 30 13 RCL× ST Z 14 + 15 120 16 × 17 11 18 ÷ 19 3600 20 ÷ 21 →HMS 22 + 23 RCL "Hour" 24 11 25 ÷ 26 →HMS 27 RCL+ "Hour" 28 END

So hands (past "the" "Hour") are either on top of each other, or one is a prolongation of the other at the times in X and Y of HP42S or DM42 (if stack arrangement fits HP42's) running the program with "Hour" in X.

Thanks and sorry for the ambiguity in my first post, hope now it's clearer
03-06-2019, 05:57 PM (This post was last modified: 03-06-2019 05:57 PM by ijabbott.)
Post: #10
 ijabbott Senior Member Posts: 910 Joined: Jul 2015
RE: Clock Hands Challenge
(03-06-2019 02:10 AM)Valentin Albillo Wrote:  .
Hi, Bob:

(03-05-2019 11:29 PM)rprosperi Wrote:  English IS my first language, and I could not follow it either; perhaps it is not RMollov's? I was going to comment but thought I'd wait to see if it was me; I guess not. The 2-line display comment threw me off as well, how is this related?

English is not my first language (that would be Spanish) but I understood it like this:

"I wonder what would be the shortest program for a 2-line display HP/DM calc (i.e.: HP42S / DM42) that shows at what time (accurate to the second) past a user-specified hour (i.e.: 0:00, 1:00, ... 23:00) would the clock's hands form an angle of either 0º or 180º."

Best regards.
V.
.

So either 0º or 180º would occur every $$\frac{6}{11}$$ hours (22 times per 12 hour period, or 44 times a day).

— Ian Abbott
03-06-2019, 06:40 PM
Post: #11
 Thomas Okken Senior Member Posts: 1,091 Joined: Feb 2014
RE: Clock Hands Challenge
(03-06-2019 05:57 PM)ijabbott Wrote:  So either 0º or 180º would occur every $$\frac{6}{11}$$ hours (22 times per 12 hour period, or 44 times a day).

Not only that, but the 0° and 180° events are uniformly spaced: there is a 0° event exactly halfway between two adjacent 180° events, and vice versa. You could generalize this further by counting the moments when the hands are at right angles to each other, which always happens halfway between 0° and 180°, or 180° and 0°.
03-06-2019, 07:28 PM
Post: #12
 Thomas Klemm Senior Member Posts: 1,447 Joined: Dec 2013
RE: Clock Hands Challenge
(03-06-2019 06:40 PM)Thomas Okken Wrote:  Not only that, but the 0° and 180° events are uniformly spaced: there is a 0° event exactly halfway between two adjacent 180° events, and vice versa.

The peculiar thing happens between 5 and 6 o'clock when the order of the 0° and the 180° event changes.

Examples:

5
XEQ "CLOCK"
y: 6.0000
x: 5.2716

6
XEQ "CLOCK"
y: 6.0000
x: 6.3244

Until 5 the 0° event happens before the 180° event.
From 6 on the 0° event happens after the 180° event.

This makes the calculation of these events "past given hour" somewhat complicated.

Cheers
Thomas
03-06-2019, 10:03 PM
Post: #13
 xerxes Member Posts: 106 Joined: Jun 2014
RE: Clock Hands Challenge
It's not a RPN keystroke solution, but I hope it's ok:

Code:
INPUT H F=12/11 PRINT DMS(H*F) IF H<6 THEN PRINT DMS((H+6)*F-6) ELSE DMS((H-6)*F+6)

Calculator Benchmark
03-06-2019, 11:55 PM
Post: #14
 Joe Horn Senior Member Posts: 1,671 Joined: Dec 2013
RE: Clock Hands Challenge
(03-06-2019 10:03 PM)xerxes Wrote:  It's not a RPN keystroke solution, but I hope it's ok:

Code:
INPUT H F=12/11 PRINT DMS(H*F) IF H<6 THEN PRINT DMS((H+6)*F-6) ELSE DMS((H-6)*F+6)

Excellent! The above works on the HP-71B if a lexfile is installed which adds the DMS or HMS function (e.g. the famous, fabulous JPC ROM). If an input of 12 is allowed (since analog clocks do show a 12), then H=MOD(H,12) should be inserted after the input.

<0|ɸ|0>
-Joe-
03-07-2019, 07:21 AM
Post: #15
 RMollov Member Posts: 248 Joined: Dec 2013
RE: Clock Hands Challenge
(03-06-2019 07:28 PM)Thomas Klemm Wrote:  The peculiar thing happens between 5 and 6 o'clock when the order of the 0° and the 180° event changes.

Examples:

5
XEQ "CLOCK"
y: 6.0000
x: 5.2716

6
XEQ "CLOCK"
y: 6.0000
x: 6.3244

Until 5 the 0° event happens before the 180° event.
From 6 on the 0° event happens after the 180° event.

This makes the calculation of these events "past given hour" somewhat complicated.

Cheers
Thomas

Yes, that is the tricky bit. Thanks
03-07-2019, 02:19 PM
Post: #16
 xerxes Member Posts: 106 Joined: Jun 2014
RE: Clock Hands Challenge
A more compact version with Joe's suggestion:

Code:
INPUT H H=MOD(H,12) F=12/11 IF H<6 THEN D=-6 ELSE D=6  PRINT DMS(H*F) PRINT DMS((H-D)*F+D)

The very limited FX-180P makes it somewhat complicated, but it's possible:

Code:
P1:  01  Kin1  02  Kin2  03  1  04  2  05  /  06  1  07  1  08  *  09  Kin3  10  Kout1  11  =  12  °′″←  13  HLT  14  6  15  Kin-2  16  Kout2 P2:  01  +/-  02  x>0  03  Kin/2  04  6  05  Kin*2  06  Kout2  07  Kin+1  08  Kout3  09  Kin*1  10  Kout2  11  Kin-1  12  Kout1  13  °′″←

29 steps

Usage example: 7 P1 RUN P2

The 180° result for 6 o'clock is excluded and gives an error.

Calculator Benchmark
03-08-2019, 03:30 AM (This post was last modified: 03-09-2019 08:38 AM by RMollov.)
Post: #17
 RMollov Member Posts: 248 Joined: Dec 2013
RE: Clock Hands Challenge
[quote='xerxes' pid='113402' dateline='1551968341']
A more compact version with Joe's suggestion:

Code:
INPUT H H=MOD(H,12) F=12/11 IF H<6 THEN D=-6 ELSE D=6  PRINT DMS(H*F) PRINT DMS((H-D)*F+D)

Very elegant! Based on it here is my RPN (HP42S/DM42) take:
Code:
 00 { 39-Byte Prgm } 01▶LBL "CLOCK" 02 IP 03 12 04 MOD 05 6 06 X>Y? 07 +/- 08 LASTX 09 11 10 ÷ 11 R^ 12 RCL× ST Y 13 →HMS 14 R^ 15 RCL- ST T 16 RCL× ST Z 17 RCL+ ST T 18 →HMS 19 END

Cheers
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)