Angle Between Hands of a Clock
Solution
class Solution:
def angleClock(self, hour: int, minutes: int) -> float:
# Calculate the angles from the 12 o'clock position
minute_angle = minutes * 6
# Calculate base hour angle and add the minute offset
hour_angle = (hour % 12) * 30 + (minutes * 0.5)
# Find the absolute difference between the two hands
diff = abs(hour_angle - minute_angle)
# Return the smaller of the two possible angles
return min(diff, 360 - diff)
