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 eugene100372
from datetime import datetime
from typing import List,Optional
def sum_light(els: List[datetime], start_watching: Optional[datetime] = None) -> int:
if not (sw:=start_watching): sw=els[0]
return sum(((d2-sw)*(d2>sw)-(d1-sw)*(d1>sw)).total_seconds()
for d1,d2 in zip(els[::2],els[1::2]))
Jan. 17, 2021
Comments: