I'm totally beginner. So, I'll appreciate that you be kind. I've got this situation:
A range of days (let's say work shifts), and a differents humans that cannot be cover work shifts on specifics days. Each day of the range have to be cover by two workers.
So, the newbie solution I found is that display in lists one below another the days free for each worker, with a 0 mark when they cannot work.
period_of_time = range(1,10)
human_1 = [1, 3, 4, 8, "Human 1"]
human_2 = [5, 6, "Human 2"]
human_3 = [8, 9, "Human 3"]
human_4 = [2, 4, 6, "Human 4"]
humans = [human_1, human_2, human_3, human_4]
def looping_function(in_humans):
new = []
for d in period_of_time:
if d not in in_humans:
new.append(d)
else:
new.append(0)
print(str(new) + " " + human_id + "\n")
for a in humans:
in_humans = a
human_id = a[-1]
looping_function(in_humans)
It's works fine.
[0, 2, 0, 0, 5, 6, 7, 0, 9] Human 1
[1, 2, 3, 4, 0, 0, 7, 8, 9] Human 2
[1, 2, 3, 4, 5, 6, 7, 0, 0] Human 3
[1, 0, 3, 0, 5, 0, 7, 8, 9] Human 4
And it's useful for now. Considering that I working on it just for learning propuses. Now I want to eliminate random items from the lists, in orden to have only two humans each day of the range. I'm stuck here.
Aucun commentaire:
Enregistrer un commentaire