Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
One-lineish, with zip, timedelta.total_seconds() and max solution in Clear category for Lightbulb Start Watching by WittyWalrus
from datetime import datetime
from typing import List, Optional
def sum_light(els: List[datetime], start_watching: Optional[datetime] = None) -> int:
return sum(max(0, (dt_end - max(start_watching or els[0], dt_start)).total_seconds()) for dt_start, dt_end in zip(els[0::2], els[1::2]))
Dec. 10, 2020
Comments: