Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Lightbulb Start Watching by rodka81
from datetime import datetime
from typing import List, Optional
def sum_light(els: List[datetime], start_watching: Optional[datetime] = None) -> int:
total = 0
for i in range(1, len(els), 2):
if start_watching:
if els[i] <= start_watching:
continue
if els[i-1] < start_watching:
els[i-1] = start_watching
delta = els[i] - els[i-1]
total += delta.total_seconds()
return total
Nov. 20, 2020