month = [[0,1,0,1,0,1,1], [1,1,1,1,1,1,1], [0,0,0,0,0,0,1], [1,0,0,0,0,0,1]]
each nested list corresponds to a week and
each 1 corresponds to an "event" and each event has a random length between 2-14
Example:
I want to enter the event at month[0][5] with a length of 6 days
how do I make it so that the next 6 days all the "events" (including the events that cross the current week) turn 0?
Expected Output:
month = [[0,1,0,1,0,1,0], [0,0,0,0,0,1,1], [0,0,0,0,0,0,1], [1,0,0,0,0,0,1]]
>Solution :
here is one way :
week, day = 0, 5 #starting point eg: month[0][5]
event_days = 6
for _ in range(event_days):
week, day = (week + 1, 0) if day == len(month[week])-1 else (week, day + 1)
month[week][day] = 0
output:
>>
[
[0, 1, 0, 1, 0, 1, 0]
, [0, 0, 0, 0, 0, 1, 1]
, [0, 0, 0, 0, 0, 0, 1]
, [1, 0, 0, 0, 0, 0, 1]
]