Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Clean code solution in Clear category for Sun Angle by Pouf
from typing import Union
def sun_angle(time: str) -> Union[str, int]:
SUNRISE_TIME_IN_MINUTES = 360
SUNSET_TIME_IN_MINUTES = 1080
SUNRISE_TO_SUNSET = SUNSET_TIME_IN_MINUTES - SUNRISE_TIME_IN_MINUTES
hours, minutes = [int(n) for n in time.split(":")]
total_minutes = hours * 60 + minutes
minutes_since_sunrise = total_minutes - SUNRISE_TIME_IN_MINUTES
sun_angle = minutes_since_sunrise / SUNRISE_TO_SUNSET * 180
if 0 <= sun_angle <= 180:
return sun_angle
return "I don't see the sun!"
June 28, 2020
Comments: