Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
tournaments.csv
Player name,ELO
HijabiKathy,887
Ugo Flickerman,1099
Rinderteufel,1134
N3rdicus,1241
SilkyZ,1259
Lyrelda,1266
GFX47,1353
Paragod,1452
The Great Eye,1792
Chrysophylax,2005
chilio6,2012
Mahrgell,2034
Pieniek,2093
mumpsimus,2472
gtresd,2534
Bockwurst,2757
@thisfred

This comment has been minimized.

Copy link
Owner Author

commented Aug 24, 2018

from pprint import pprint
import random
import csv

seed = 'Oblivion'
random.seed(seed)

with open('tournament.csv', 'r', newline='') as f:
    players = []
    for row in csv.reader(f):
        players.append(row[0])

pot_size = int((len(players) - 1) / 4)

pots = [players[i:i + pot_size] for i in range(1, len(players), pot_size)]
for pot in pots:
    random.shuffle(pots)

groups = zip(*pots)

for n, group in enumerate(groups):
    print(chr(n + 65))
    for player in group:
        print(player)
@thisfred

This comment has been minimized.

Copy link
Owner Author

commented Aug 24, 2018

output:

A
SilkyZ
The Great Eye
Pieniek
HijabiKathy

B
Lyrelda
Chrysophylax
mumpsimus
Ugo Flickerman

C
GFX47
chilio6
gtresd
Rinderteufel

D
Paragod
Mahrgell
Bockwurst
N3rdicus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.