Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. import itertools
  2. import collections
  3.  
  4. 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") ]
  5. 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") ]
  6. result_map = dict(map(lambda (t,g,c): (t, collections.defaultdict(int)), winners + losers))
  7. for loser_perm in itertools.permutations(losers):
  8.   matchups = zip(winners, loser_perm);
  9.   if all(map(lambda (w,l): w[1] is not l[1] and w[2] is not l[2] , matchups)):
  10.     for match in matchups:
  11.       result_map[match[0][0]][match[1][0]] += 1;
  12.       result_map[match[1][0]][match[0][0]] += 1;
  13. for (t, poss) in result_map.items():
  14.   total = sum(c for (opp, c) in poss.items())
  15.   print t
  16.   for (opp, c) in poss.items():
  17.     print " {:s}: {:.2f}% ".format(opp, (c * 100.0 / total)),
  18.   print
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement