Skip to content

Instantly share code, notes, and snippets.

@antonshilov
Last active August 29, 2015 14:21
Show Gist options
  • Save antonshilov/69c9fbae0a713cf0dac1 to your computer and use it in GitHub Desktop.
Save antonshilov/69c9fbae0a713cf0dac1 to your computer and use it in GitHub Desktop.
print "Hello! Input format HH:MM"
time = str(raw_input("Time - "))
splittedTime = time.split(":")
try:
splittedTime = [int(i) for i in splittedTime]
except ValueError:
print "Invalid input"
exit()
splittedTime = [int(i) for i in splittedTime]
if splittedTime[0] > 23 or splittedTime[1] > 59:
print "Invalid input"
exit()
else:
if int(splittedTime[0]) > 12:
splittedTime[0] = int(splittedTime[0]) - 12
degrees = abs(splittedTime[0] * 30 - splittedTime[1] * 6)
if degrees == 360:
print 0
else:
print degrees
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment