Skip to content

Instantly share code, notes, and snippets.

@flyte
Last active January 6, 2016 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flyte/ae77741b435783276051 to your computer and use it in GitHub Desktop.
Save flyte/ae77741b435783276051 to your computer and use it in GitHub Desktop.
Sorting hat for VGOC Premiershit 2016. Save as hat.py and run with "python hat.py".
#!/usr/bin/env python
from random import shuffle
from itertools import izip_longest
POOL_NAMES = ("Pool 1", "Pool 2")
if __name__ == "__main__":
pools = {}
for pool_name in POOL_NAMES:
pools[pool_name] = []
inpt = None
while inpt != "":
inpt = raw_input("Enter a name to go in %s or hit Enter when done\n-> " % pool_name)
if inpt:
pools[pool_name].append(inpt)
shuffle(pools[pool_name])
teams = izip_longest(*pools.values())
for i, team in enumerate(teams, 1):
print "Team %s:" % i
print ", ".join(str(x) for x in team)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment