Given two integers hour and minutes, return the smaller angle (in degrees) formed between the hour and minute hands of an analog clock.
The answer should be a floating point number. Answers within 10⁻⁵ of the actual answer will be accepted.
Function Signature
def angle_clock(hour: int, minutes: int) -> float:
Rules
-
The clock is a 12-hour analog clock with no seconds hand.
-
The hour hand moves continuously as the minutes pass, so at 12:30 it sits halfway between 12 and 1.
-
Of the two angles between the hands, return the smaller one, so the result is between 0 and 180 inclusive.
Constraints
-
1 <= hour <= 12
-
0 <= minutes <= 59
-
Answers within
10⁻⁵
of the actual answer are accepted.
Examples
Input: hour = 12, minutes = 30
Output: 165
At 12:30, the minute hand is at 180 degrees and the hour hand is at 15 degrees. The angle between them is 165 degrees.
Input: hour = 3, minutes = 30
Output: 75
At 3:30, the minute hand is at 180 degrees and the hour hand is at 105 degrees. The angle between them is 75 degrees.