Created
July 21, 2016 20:57
-
-
Save macndesign/e4660fcc68fc115ed58355fa591a446f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Cadastro de Jogadores | |
In [91]: p1 = 'phelip maia figueredo jorge'.split() | |
In [92]: p2 = 'mario milson joao frota'.split() | |
In [93]: p3 = 'romario bebeto rai ronaldo'.split() | |
In [94]: players = [p1, p2, p3] | |
# Montagem de Times: | |
In [106]: for i, p in enumerate(players): | |
...: ts.append((i + 1, p)) | |
...: | |
In [107]: ts | |
Out[107]: | |
[(1, ['phelip', 'maia', 'figueredo', 'jorge']), | |
(2, ['mario', 'milson', 'joao', 'frota']), | |
(3, ['romario', 'bebeto', 'rai', 'ronaldo'])] | |
# Visualização de escalação | |
In [115]: for key, group in itertools.groupby(ts, lambda t: t[0]): | |
...: print(key) | |
...: for p in group: | |
...: for j in p[1]: | |
...: print('--> ', j) | |
1 | |
--> phelip | |
--> maia | |
--> figueredo | |
--> jorge | |
2 | |
--> mario | |
--> milson | |
--> joao | |
--> frota | |
3 | |
--> romario | |
--> bebeto | |
--> rai | |
--> ronaldo | |
# Jogos: | |
In [108]: [c for c in itertools.combinations(ts, 2)] | |
Out[108]: | |
[((1, ['phelip', 'maia', 'figueredo', 'jorge']), (2, ['mario', 'milson', 'joao', 'frota'])), | |
((1, ['phelip', 'maia', 'figueredo', 'jorge']), (3, ['romario', 'bebeto', 'rai', 'ronaldo'])), | |
((2, ['mario', 'milson', 'joao', 'frota']), (3, ['romario', 'bebeto', 'rai', 'ronaldo']))] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment