Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Clock Angle by BrianMcleod
def clock_angle(time):
h, m = map(int, time.split(':'))
angle = ((h%12 * 30.0 + m * 0.5) - m*6.0 + 360)%360
return angle if angle <= 180 else 360 - angle
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert clock_angle("02:30") == 105, "02:30"
assert clock_angle("13:42") == 159, "13:42"
assert clock_angle("01:42") == 159, "01:42"
assert clock_angle("01:43") == 153.5, "01:43"
assert clock_angle("00:00") == 0, "Zero"
assert clock_angle("12:01") == 5.5, "Little later"
assert clock_angle("18:00") == 180, "Opposite"
Oct. 21, 2018