How to find the hour and minute for the times when the hour and minute needles will be exactly over each other?

Varanasi Software Junction: Hours and Minutes Hands Coincide




First of all let us analyze the problem. The hour hand moves 30 degrees for a 360 degree movement of the minute hand. Therefore if the hour hand is currently at h angle then the minute will be at 12*h angle. The other thing is that beyond 360 we have to get back between 0 and 360 therefore we will take the modulus.

Here is the Python code for finding this out.


hour=0
interval=0.1
a=[]
print("Hour angle =",0,", Minute angle ",0,", Hour=",0,", Minute=",0)
prevhour=0
prevminute=0
prevdifference=0
hour=interval
while hour<360:
    minute=12*hour
    minute=minute%360
    minute=round(minute,3)
    hour=round(hour,3)
    difference=hour-minute
    difference=round(difference,3)
    if prevdifference>0 and difference<0:
        print("Hour angle =",hour,", Minute angle ",minute,", Hour=",hour//30,", Minute=",round(minute/6,3))
    prevhour=hour
    prevminute=minute
    prevdifference=difference
    hour=hour+interval

The output


Varanasi Software Junction: Hours and Minute hands coincide




Post a Comment

0 Comments