Given four integers H, M, L1, and L2, which denotes the time as hour and minutes in a Clock of 12-Hour format and L1 and L2 denotes the length of hour hand and minute hand respectively. The task is to find the distance between the endpoints of the hour and minutes hand.
Input: H = 10, M = 30, L1 = 3, L2 = 4
At 10:30, distance between end point of hour hand and minute hand is 6.47898
Approach: The idea is to find the angle between the hour hand and minute hand at the given time and then the distance between the end points of the hour hand and minute hand can be computed with the help of the cosine formulae –
Distance Between End Points of the Hour and minute hand =
Below is the implementation of the above approach:
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Distance traveled by Hour and Minute hand in given Time interval
- 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
- Ways to choose three points with distance between the most distant points <= L
- Time taken per hour for stoppage of Car
- Program to calculate distance between two points
- Program for distance between two points on earth
- Hammered distance between N points in a 2-D plane
- Program to calculate distance between two points in 3 D
- Find the maximum possible distance from origin using given points
- Check whether it is possible to join two points given on circle such that distance between them is k
- Find points at a given distance on a line of given slope
- Haversine formula to find distance between two points on a sphere
- Find integral points with minimum distance from given set of integers using BFS
- Find the integer points (x, y) with Manhattan distance atleast N
- Sort an Array of Points by their distance from a reference Point
- Maximum distance between two points in coordinate plane using Rotating Caliper's Method
- Calculate speed, distance and time
- Time until distance gets equal to X between two objects moving in opposite direction
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.