Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools
- import collections
- winners = [ ("ARS", "A", "ENG"), ("NAP", "B", "ITA"), ("BAR", "C", "ESP"), ("ATH", "D", "ESP"), ("MON", "E", "FRA"), ("DOR", "F", "GER"), ("LEI", "G", "ENG"), ("JUV", "H", "ITA") ]
- losers = [ ("PSG", "A", "FRA"), ("BEN", "B", "POR"), ("MC", "C", "ENG"), ("BAY", "D", "GER"), ("LEV", "E", "GER"), ("RM", "F", "ESP"), ("POR", "G", "POR"), ("SEV", "H", "ESP") ]
- result_map = dict(map(lambda (t,g,c): (t, collections.defaultdict(int)), winners + losers))
- for loser_perm in itertools.permutations(losers):
- matchups = zip(winners, loser_perm);
- if all(map(lambda (w,l): w[1] is not l[1] and w[2] is not l[2] , matchups)):
- for match in matchups:
- result_map[match[0][0]][match[1][0]] += 1;
- result_map[match[1][0]][match[0][0]] += 1;
- for (t, poss) in result_map.items():
- total = sum(c for (opp, c) in poss.items())
- print t
- for (opp, c) in poss.items():
- print " {:s}: {:.2f}% ".format(opp, (c * 100.0 / total)),
- print
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement