Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for Lightbulb Start Watching by sMiTeOne
from datetime import datetime
def sum_light(els, start_watching = None):
bulb = False
seconds = 0
for x, y in enumerate(els):
bulb = not bulb
if bulb is False:
if start_watching and (y - start_watching).total_seconds() > 0:
seconds += (y - start_watching).total_seconds()
start_watching = None
elif start_watching is None:
seconds += (y - els[x - 1]).total_seconds()
return int(seconds)
Jan. 25, 2021