Skip to content

Instantly share code, notes, and snippets.

@RaffaeleSgarro
Created January 25, 2013 16:30
Show Gist options
  • Save RaffaeleSgarro/4635795 to your computer and use it in GitHub Desktop.
Save RaffaeleSgarro/4635795 to your computer and use it in GitHub Desktop.
Distribute tasks among assignees
# 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