-
-
Save monzee/2572256 to your computer and use it in GitHub Desktop.
Revisions
-
monzee revised this gist
May 1, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ ['E', 'D', 'J'], ] pairs = map(sorted, chain(*[combinations(row, 2) for row in data])) pairfreq = sorted(set(tuple(pair) + (pairs.count(pair),) for pair in pairs)) map(print, pairfreq) """ -
monzee revised this gist
May 1, 2012 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,8 @@ ['E', 'D', 'J'], ] pairs = map(sorted, chain(*[combinations(row, 2) for row in data])) pairfreq = sorted(set(sorted(tuple(pair) + (pairs.count(pair),) for pair in pairs))) map(print, pairfreq) """ Question: Convert following into the latter data structure in less than 30 lines: -
monzee revised this gist
May 1, 2012 . 2 changed files with 36 additions and 22 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ from __future__ import print_function from itertools import chain, combinations data = [ ['A', 'B', 'C'], ['A', 'C', 'E'], ['E', 'F', 'D'], ['D', 'A', 'J'], ['E', 'D', 'J'], ] pairs = map(sorted, chain(*[combinations(row, 2) for row in data])) map(print, sorted(set(sorted(tuple(pair) + (pairs.count(pair),) for pair in pairs)))) """ Question: Convert following into the latter data structure in less than 30 lines: List: A, B, C A, C, E E, F, D D, A, J E, D, J List A, B, 1 (frequency) A, C, 2 A, D, 1 A, E, 1 A, J, 1 B, C, 1 C, E, 1 D, E, 2 D, F, 1 D, J, 2 E, F, 1 E, J, 1 """ 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 charactersOriginal file line number Diff line number Diff line change @@ -1,22 +0,0 @@ -
Isa Goksu created this gist
May 1, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ Question: Convert following into the latter data structure in less than 30 lines: List: A, B, C A, C, E E, F, D D, A, J E, D, J List A, B, 1 (frequency) A, C, 2 A, D, 1 A, E, 1 A, J, 1 B, C, 1 C, E, 1 D, E, 2 D, F, 1 D, J, 2 E, F, 1 E, J, 1