Smaller Clock Hand Angle
Problem statement
Given an analog-clock time with integer hour and minutes, return the smaller angle in degrees between the hour hand and the minute hand.
The hour hand moves continuously as the minutes advance. The answer is in the inclusive range [0, 180].
Function
clockAngle(hour: int, minutes: int) → doubleExamples
Example 1
hour = 3minutes = 30return = 75.0The minute hand is at 180 degrees and the hour hand is at 105 degrees.
Example 2
hour = 12minutes = 0return = 0.0Both hands point to 12.
Example 3
hour = 1minutes = 57return = 76.5The direct difference is 283.5 degrees, so the smaller angle is 360 - 283.5 = 76.5 degrees.
Constraints
1 <= hour <= 12.0 <= minutes <= 59.- Answers within
10^-5of the exact value are accepted.