Angle Between Hands of a Clock
Solution
class Solution:
def angleClock(self, hour: int, minutes: int) -> float:
# Calculate the angle of the minute hand
min_angle = minutes * 6
# Calculate the angle of the hour hand
# Note: hour % 12 converts 12 to 0
hour_angle = (hour % 12) * 30 + (minutes * 0.5)
# Find the absolute difference between the two angles
diff = abs(hour_angle - min_angle)
# We want the smaller angle
return min(diff, 360 - diff)
