Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Clean and simple (post-fix) solution in Clear category for Sun Angle by Celshade
def sun_angle(time: str) -> int:
"""Return the angle of the sun at the given time.
The total window of sunlight is dawn -> dusk (6am -> 6pm) - this gives a
total of 12 hours (720 minutes) between the angles of 0 - 180 degrees. The
sun moves 0.25 degrees per minute (15.0 degrees per hour).
Args:
time: The given time.
"""
hour = int(time[:2])
if 6 <= hour <= 18: # Hour is between dawn and dusk
minutes = ((hour - 6) * 60) + int(time[3:])
if minutes > 720:
return "I don't see the sun!"
angle = round((0.25 * minutes), 2)
return angle
else:
return "I don't see the sun!"
July 20, 2020
Comments: