Data Science, Python, Planning, Vacation, Algorithms.
# Sort holidays and extend them to the nearest weekends for holiday in sorted(public_holidays): start = holiday end = holiday # Extend backwards and forwards to include weekends and adjacent holidays while start.weekday() > 4 or (start - timedelta(days=1)) in public_holidays: start -=