Skip to content

Instantly share code, notes, and snippets.

@tupy
Last active April 10, 2017 22:18
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 tupy/c2acd87610d18cfa68262e9ce7508814 to your computer and use it in GitHub Desktop.
Save tupy/c2acd87610d18cfa68262e9ce7508814 to your computer and use it in GitHub Desktop.
# -*- 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