Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Readable solution in Clear category for Sun Angle by snlpejpn
def sun_angle(time: str) -> int:
# converted into minutes so that it would be easier to distinguish cases like 18:00 and 18:01
minutes = int(time[0:2])*60 + int(time[3:]) - 6*60
if 0 <= minutes <= 720:
return round(minutes * 15/60, 2)
else:
return "I don't see the sun!"
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!")
March 8, 2021
Comments: