Skip to content
Snippets Groups Projects
statistics.py 853 B
Newer Older
Ruben Anthony Gonzalez's avatar
Ruben Anthony Gonzalez committed
import changeme
import os

team_vals = {}
if not os.path.isfile(changeme.res_file_path):
    print("No results given yet")
    exit(1)


with open(changeme.res_file_path) as f:
    for l in f:
        ret_val, team_id, flag = l.strip().split(" ", 2)
        ret_val = int(ret_val)
        team_id = int(team_id)
        if team_id not in team_vals:
            team_vals[team_id] = [0] * len(changeme.MESSAGES)

        team_vals[team_id][ret_val] += 1


def make_row(entries):
    column_width = 3 + max(map(len, changeme.MESSAGES))
    return "|" + "|".join([x.ljust(column_width, " ") for x in entries]) + "|"

header = make_row(["team_id"] + changeme.MESSAGES)

print("-" * len(header))
print(header)
print("-" * len(header))

for t in sorted(team_vals.keys()):
    print(make_row([str(t)] + list(map(str, team_vals[t]))))

print("-" * len(header))