Last active
January 6, 2016 17:14
-
-
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".
This file contains hidden or 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
#!/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