Created
January 27, 2020 11:49
-
-
Save hartviglarsen/71c0412e930d2d8f4fdfe3052d1deac9 to your computer and use it in GitHub Desktop.
Umbraco Unicorns
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
from argparse import ArgumentParser | |
from random import sample | |
def generate(amount_of_teams, names): | |
amount_of_names = len(names) | |
while amount_of_names > 0 and amount_of_teams > 0: | |
team = sample(names, int(amount_of_names/amount_of_teams)) | |
for name in team: | |
names.remove(name) | |
amount_of_names -= 1 | |
amount_of_teams -= 1 | |
print(f'{team}\n') | |
def main(): | |
parser = ArgumentParser() | |
parser.add_argument('-a', '--amount', help='amount of teams', default=2, type=int) | |
parser.add_argument('-n', '--names', help='delimited list of names', type=str, required=True) | |
args = parser.parse_args() | |
amount = args.amount | |
names = [str(name) for name in args.names.split(',')] | |
generate(amount, names) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment