Skip to content

Instantly share code, notes, and snippets.

@yavor-atanasov
Created December 12, 2018 11:16
Show Gist options
  • Save yavor-atanasov/612aae116168b8cd0d81d0218ca15c4d to your computer and use it in GitHub Desktop.
Save yavor-atanasov/612aae116168b8cd0d81d0218ca15c4d to your computer and use it in GitHub Desktop.
import random as r
a = [
["Yavor Atanasov", "Steve Birks", "Paul Clifford", "Ashley Davis", "Tom Cartwright"],
["Richard Close", "Nawaid Shamim", "Pawel Bartoszek", "Daniel Harper"],
["Russell Thom", "Tom Petty", "Umesh Telang", "Alistair Wooldrige", "Elliot Thomas"],
["Gilbert Agum", "John Shields", "Paul Merry", "Mark Gledhill", "Rachel Evans", "Giovanni Lenguito", "Andre Oosthuizen"]
]
teams = (set(), set(), set())
names = ["Breakery", "LeakyBucket", "CacheMiss"]
r.shuffle(names)
while True:
if set(map(len, teams)) == {7}:
break
for t in teams:
if len(t) < 7:
try:
l = r.choice(range(len(a)))
t.add(a[l].pop(r.choice(range(len(a[l])))))
except IndexError:
a.pop(l)
print "\n".join([
"{0}: {1}".format(k, ", ".join(v))
for k, v in dict(zip(names, teams)).items()
])
@AWooldrige
Copy link

Is there a python3 version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment