Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
__ solution in Uncategorized category for Weekend Counter by Cjkjvfnby
from datetime import date
def checkio(from_date, to_date):
result = ((to_date - from_date).days // 7) * 2
day_to = to_date.weekday()
day_from = from_date.weekday()
if day_from > day_to:
return result + min(2, 7 - day_from)
else:
return result + max(day_to - 4, 0) - max(day_from - 5, 0)
if __name__ == '__main__':
assert checkio(date(2013, 9, 18), date(2013, 9, 23)) == 2, "1st example"
assert checkio(date(2013, 1, 1), date(2013, 2, 1)) == 8, "2nd example"
assert checkio(date(2013, 2, 2), date(2013, 2, 3)) == 2, "3rd example"
Dec. 17, 2013
Comments: