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 DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Distance between end points of Hour and minute hand at given time
- Time when minute hand and hour hand coincide
- Calculate the angle between hour hand and minute hand
- Maximum time such that absolute difference between hour and minute lies in given range
- Time taken per hour for stoppage of Car
- Calculate speed, distance and time
- Time until distance gets equal to X between two objects moving in opposite direction
- Count paths with distance equal to Manhattan distance
- Max occurring divisor in an interval
- Count of available non-overlapping intervals to be inserted to make interval [0, R]
- Minimum time to reach a point with +t and -t moves at time t
- Distance of chord from center when distance between center and another equal length chord is given
- Distance between a point and a Plane in 3 D
- Distance between two parallel Planes in 3-D
- Distance between two parallel lines
- Puzzle | Minimum distance for Lizard
- Maximum subsequence sum such that all elements are K distance apart
- Maximum distance between two 1's in Binary representation of N
- Shortest distance between a point and a circle
- Hammered distance between N points in a 2-D plane
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.