#!/usr/bin/python
#

include = [5, 0, 2]
exclude = []

#
days_on = [0]*7
if include == []:
    days_on = [1]*7
else:
    for x in include:
        if x == "weekday":
            days_on[0:5] = [1]*5
        elif x == "weekend":
            days_on[5:6] = [1]*2
        else:
            days_on[int(x)] = 1

if (exclude != []):
    for x in exclude:
        if x == "weekday":
            days_on[0:5] = [0]*5
        elif x == "weekend":
            days_on[5:6] = [0]*2
        else:
            days_on[int(x)] = 0

print "days_on:", days_on

if 1 not in days_on:
    print "ALL days off!!"
    quit()

# All we want now is to determine the days back for the specific day we
# have. So for testing we loop over all of them...
# Rather then testing whether we need to loop round to the other end of
# the array, we double its length and just make a straight run.
# We know we'll hit a 1 to terminate the loop, as we've check above that
# there is one.
#
for dow in range(0, 7):
   days_on_2wk = (days_on + days_on)
   change = 0
   check_day = dow + 7  # Move into second half
   while True:
        change += 1 
        check_day -= 1
        if days_on_2wk[check_day]:
            break

   print "dow:", dow, " days back:", change
    
