Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Sun Angle by Darka
def sun_angle(time):
minutes=(((ord(time[0])-48)*10+(ord(time[1])-48))*60)+((ord(time[3])-48)*10)+(ord(time[4])-48)
if(minutes>1080 or minutes<360):
return "I don't see the sun!"
else:
angle=(minutes-360)/4
'''if(time[0]=='0' and time[1]<'6'):
return "I don't see the sun!"
elif(time[0]=='1' and time[1]>='8' and time[3]>'0' and time[4]>'0'):
return "I don't see the sun!"
else:
minutes=(((ord(time[0])-48)*10+(ord(time[1])-48))*60)+((ord(time[3])-48)*10)+(ord(time[4])-48)
angle=(minutes-360)/4'''
return angle
if __name__ == '__main__':
print("Example:")
print(sun_angle("07:00"))
#These "asserts" using only for self-checking and not necessary for auto-testing
assert sun_angle("07:00") == 15
assert sun_angle("01:23") == "I don't see the sun!"
print("Coding complete? Click 'Check' to earn cool rewards!")
Nov. 29, 2018
Comments: