# Find position of Hour, Minute and Second hand.

There are 12 × 60 × 60 positions on the clock face that can be occupied by hands and start/finish positions. I want to place all three hands on a clock such that I can uniquely Identify them by a single position from 0 to 60*60*12-1.

For example: h=6 (0-11) m=30 (0-59) s=0 (0-59)

position should be (Hour hand, min hand, sec hand respectively):

6 * 60 * 60 + 30 * 30 + 0 //right? I am not sure.

...? // can't figure it

...? // can't figure it

This is the formula I used:

h=h*3600+m*60+s;//seems fine
m=60*12*m+s;//wrong
s=s*12*60;//wrong Thanks!

Consider $$h,m,s$$ being the integral number of hours, minutes & seconds, respectively, as stated in the question. Also, let $$hp,mp,sp$$ be the positions of the hour, minute and second hands, respectively.

The hour hand position has contributions from the current hour, minute and second. Each integral hour adds $$3600$$ seconds. As $$60$$ minutes is one hour, each minute adds $$\frac{1}{60}$$ of an hour, i.e., $$\frac{3600}{60} = 60$$. Finally, each second adds $$\frac{1}{60}$$ of a minute, i.e., $$\frac{60}{60} = 1$$. Thus, as you state,

$$hp = (3600)h + (60)m + s \tag{1}\label{eq1}$$

The minute hand position has contributions from just the current minute and second. Each integral minute adds $$\frac{1}{60}$$ of the entire set of $$3600\times 12$$, i.e., $$\frac{3600\times 12}{60} = 60 \times 12$$. Each second adds $$\frac{1}{60}$$ of a minute, i.e., $$\frac{60 \times 12}{60} = 12$$. Thus,

$$mp = (60)(12)m + (12)s \tag{2}\label{eq2}$$

Your equation is missing the $$12$$ coefficient of $$s$$.

Finally, the second hand position has contributions just from itself. Each integral second adds $$\frac{1}{60}$$ of the entire set of $$3600\times 12$$, i.e., $$\frac{3600\times 12}{60} = 60 \times 12$$. Thus, you have

$$sp = (60)(12)s \tag{3}\label{eq3}$$

This is what you stated, even though you claimed it was wrong. To help confirm this, note that $$h = m = s = 0$$ gives $$0$$ in \eqref{eq1}, \eqref{eq2} and \eqref{eq3}. Also, $$h = 11, m = 59, s = 59$$ in \eqref{eq1} gives $$hp = 43199 = 60 \times 60 \times 12 - 1$$; $$m = 59, s = 59$$ in \eqref{eq2} gives $$mp = 43188 = 60 \times 60 \times 12 - 12$$, and $$s = 59$$ in \eqref{eq3} gives $$sp = 42480 = 60 \times 60 \times 12 - 60 \times 12$$.

For your example of $$h = 6, m = 30, s = 0$$, \eqref{eq1} gives $$hp = 23400$$, \eqref{eq2} gives $$mp = 21600$$ and \eqref{eq3} gives the second hand at $$sp = 0$$.

Lets say 12:00 am represents 0. Take the time t=42365 sec. First, divide by 3600. This gives 11 hrs, so 11 am. Then, multiply the remainder by 60. The result is 46. So far, 11:46 am. Now multiply the remainder of this last division by 60. The result is 5. The hour hand is at 11, minute hand at 46, second hand at 5.

• I think you misunderstood. Say we are given Hour,Min,Sec. So we have total of 60*60*12 positions. I want to find all 3 position (for hour minute and second hand) which will be in between 0 to 60*60*12-1. – Het Jun 28 '19 at 17:57