I need all weekdays for two days.
Example:
Wednesday - Friday = Wednesday, Thursday, Friday
3 - 5 = 3, 4, 5
Saturday - Tuesday = Saturday, Sunday, Monday, Tuesday
6 - 2 = 6, 7, 1, 2
I am sure there is a smart algorithm to solve this problem. The only algorithms I can come up with use either a loop or an operator if.
There must be an elegant way to solve this problem. I use numbers 1-7 for weekdays, but 0-6 is good too.
The best I could come up with:
def between(d1, d2):
alldays = [0,1,2,3,4,5,6,0,1,2,3,4,5,6]
offset = 8 if d1 > d2 else 1
return alldays[d1:d2 + offset]
between(0, 4)
between(5,2)