Created
December 22, 2019 20:36
-
-
Save MegaLoler/b0e7fcef50ef8124a39cfebef8c8bafe to your computer and use it in GitHub Desktop.
simple script to help determine rankings by comparing combinations
This file contains 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 python3 | |
# simple script to help determine rankings by comparing combinations | |
import sys | |
from itertools import combinations | |
with open(sys.argv[1]) as f: | |
items = list(line.strip() for line in f.readlines()) | |
scores = {item: 0 for item in items} | |
matchups = list(combinations(items, 2)) | |
print(f'There are going to be {len(matchups)} matchups.') | |
for a, b in matchups: | |
print('Matchup:') | |
print(f'\tA) {a}') | |
print(f'\tB) {b}') | |
while True: | |
choice_str = input('Which wins? (A/B) ') | |
if choice_str in 'AB': | |
choice = (a, b)[0 if choice_str == 'A' else 1] | |
scores[choice] += 1 | |
print('Scores:') | |
print(f'{scores[a]} "{a}"') | |
print(f'{scores[b]} "{b}"') | |
print() | |
break | |
else: | |
print("Please enter either 'A' or 'B'.") | |
ranked = sorted(items, key=lambda item: scores[item], reverse=True) | |
print('Results:') | |
for i, item in enumerate(ranked): | |
print(f'{i+1:>3}. {item} ({scores[item]})') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment