Distance traveled by Hour and Minute hand in given Time interval
Given two numbers H and M which denotes the length of the hour and minute hand and two time intervals(say T1 & T2) in form of HH:MM, the task is to find the distance travelled by hour hand and minute hand between time T1 and T2.
Input: H = 5, M = 7, T1 = “1:30”, T2 = “10:50”
Distance travelled by minute hand: 410.50144006906635
Distance travelled by hour hand: 24.434609527920614
Input: H = 4, M = 5, T1 = “1:30”, T2 = “10:50”
Distance travelled by minute hand: 293.21531433504737
Distance travelled by hour hand: 19.54768762233649
- Find the difference between the two time intervals T1 and T2 by using the approach discussed in this article.
- Change the time duration obtained above into minutes as:
Total Minutes = hours * 60 + minutes
- Since minute hand covers one rotation in 60 minutes therefore, number of rotations covered by minute hand(say rm) is given by
- Since hour hand covers one rotation in 60*12 = 720 minutes therefore, number of rotations covered by hour hand(say rh) is given by
- The total distance traverse by the hour hand is given by
- The total distance traverse by the minute hand is given by
Below is the implementation of the above approach:
Distance traveled by minute hand: 410.50144006906635 Distance traveled by hour hand: 24.434609527920614
Attention reader! Don’t stop learning now. Get hold of all the important mathematical concepts for competitive programming with the Essential Maths for CP Course at a student-friendly price. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.