Skip to content

Instantly share code, notes, and snippets.

@thisfred
Created August 24, 2018 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thisfred/49b76f95ec3fad8caad1def52eb7b629 to your computer and use it in GitHub Desktop.
Save thisfred/49b76f95ec3fad8caad1def52eb7b629 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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
Copy link
Author

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