Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
total_seconds solution in Clear category for Lightbulb Intro by veky
import contextlib, datetime
def sum_light(els):
"""How long the light bulb has been turned on."""
result, it = datetime.timedelta(), iter(els)
with contextlib.suppress(StopIteration):
while ...:
start, end = next(it), next(it)
result += end - start
return result.total_seconds()
Nov. 14, 2020
Comments: