Skip to content

Instantly share code, notes, and snippets.

@feliperyan
Created January 30, 2017 06:18
Show Gist options
  • Save feliperyan/1a050915e4db049a8c4f84b527d1aa53 to your computer and use it in GitHub Desktop.
Save feliperyan/1a050915e4db049a8c4f84b527d1aa53 to your computer and use it in GitHub Desktop.
Round Robin Algo
from copy import deepcopy
def go_round_robin(list_of_lists):
robin = deepcopy(list_of_List)
i = len(robin)
while len(robin) > 0:
j = i % len(robin)
try:
print(robin[j].pop(0))
except IndexError as e:
robin.pop(j)
i -= 1
i+=1
a = ['a','b', 'c']
b = ['d', 'e']
c = ['f', 'g', 'h', 'j']
original = [a, b, c]
go_round_robin(original)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment