Created
January 25, 2013 16:30
-
-
Save RaffaeleSgarro/4635795 to your computer and use it in GitHub Desktop.
Distribute tasks among assignees
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python 2.x | |
import random | |
import itertools | |
tasks = ['account', 'gestione classi', 'registro insegnanti', | |
'registro di classe', 'corsi di studio', 'gestione materie', 'bacheca', | |
'giornalino', 'pon', 'gestione circolari', 'gestione locali', | |
'inventario', 'viaggi', 'tasse'] | |
assignees = ["Marco", "Gabriele", "Raffaele"] | |
random.shuffle(tasks) | |
random.shuffle (assignees) | |
assignments = {} | |
for assignee in assignees: | |
assignments[assignee] = list() | |
# Act as a round-robin (circular, infinite) list | |
assignees = itertools.cycle(assignees) | |
for task in tasks: | |
assignments[assignees.next()].append(task) | |
for assignee, tasks in assignments.items(): | |
print "%s has to do:" % assignee | |
for task in tasks: | |
print " - %s" % task |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment