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