Last active
June 5, 2020 13:19
-
-
Save wjt/1449133be81182573e4243edb93c7903 to your computer and use it in GitHub Desktop.
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/python3 | |
| import argparse | |
| import random | |
| import itertools | |
| NAMES = [ | |
| "@bkarnow", | |
| "@danigm", | |
| "@dylan-m", | |
| "@geri", | |
| "@jprvita", | |
| "@manuq", | |
| "@mwleeds", | |
| "@ramcq", | |
| "@renatop", | |
| "@wjt", | |
| "@erikos", | |
| ] | |
| def main(): | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--group-size", type=int, default=3) | |
| parser.add_argument("names", type=argparse.FileType("r"), nargs="?") | |
| args = parser.parse_args() | |
| if args.names: | |
| names = args.names.read().splitlines() | |
| else: | |
| names = NAMES | |
| random.shuffle(names) | |
| slices = [names[i :: args.group_size] for i in range(args.group_size)] | |
| groups = list(itertools.zip_longest(*slices)) | |
| for i, row in enumerate(groups, 1): | |
| names = ", ".join(f"{name}" for name in row if name) | |
| print(f"Group {i}: {names}") | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment