Last active
April 10, 2017 22:18
-
-
Save tupy/c2acd87610d18cfa68262e9ce7508814 to your computer and use it in GitHub Desktop.
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
# -*- coding: utf-8 -*- | |
import random | |
TEAMS = 3 | |
PLAYERS_BY_TEAM = 6 | |
groups = { | |
'star': ['Bako', 'JP', 'Vitot', 'Bruno'], | |
'ataque': ['Genê', 'André', 'Lucas Carvalho', 'Ladeia'], | |
'zaga': ['Rabello', 'Tupy', 'Marcinho', 'Pezão', 'Gustavo'], | |
'lateral': ['Flavio', 'Ina', 'Frodinho'], | |
'meia': ['Corcel', 'Marcos Goes'], | |
} | |
# Randomize | |
for k, v in groups.iteritems(): | |
random.shuffle(v) | |
teams = {i:[] for i in range(TEAMS)} | |
while len(groups) > 0: | |
for i in range(TEAMS): | |
for k in groups.keys(): | |
players = groups[k] | |
if players: teams[i].append(players.pop(0)) | |
else: del groups[k] | |
if len(teams[i]) >= PLAYERS_BY_TEAM: | |
break | |
for i, team in teams.iteritems(): | |
print('Team %d: %s' % (i+1, ', '.join(team))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment