leetpycode/medium/angle_between_hands_of_a_clock.py

8 lines
No EOL
322 B
Python

# https://leetcode.com/problems/angle-between-hands-of-a-clock
class Solution:
def angleClock(self, hour: int, minutes: int) -> float:
minute = 360 / 60 * minutes
hour = hour % 12
hour = 360 / 12 * hour + 360 / 12 / 60 * minutes
return min(abs(hour - minute), 360 - abs(hour - minute))