Advertisement
Guest User

sirquacks

a guest
Dec 20th, 2012
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.79 KB | None | 0 0
  1. import itertools
  2.  
  3.  
  4. porto = ["Portugal", "A"]
  5. arsenal = ["England", "B"]
  6. milan = ["Italy", "C"]
  7. madrid = ["Spain", "D"]
  8. donetsk = ["Ukraine", "E"]
  9. valencia = ["Spain", "F"]
  10. celtic = ["Scotland", "G"]
  11. galatasaray = ["Turkey", "H"]
  12.  
  13. psg = ["France", "A"]
  14. schalke = ["Germany", "B"]
  15. malaga = ["Spain", "C"]
  16. dortmund = ["Germany", "D"]
  17. juve = ["Italy", "E"]
  18. munich = ["Germany", "F"]
  19. barca = ["Spain", "G"]
  20. manu = ["England", "H"]
  21.  
  22.  
  23.  
  24. first = [psg,schalke,malaga,dortmund,juve,munich,barca,manu]
  25. second = [porto,arsenal,milan,madrid,donetsk,valencia,celtic,galatasaray]
  26.  
  27.  
  28. perms = list(itertools.permutations(second))
  29. possiblePerms = []
  30.  
  31. for perm in perms:
  32.     for index in xrange(8):
  33.         valid = False
  34.         if (perm[index][0] == first[index][0]) or (perm[index][1] == first[index][1]):
  35.            
  36.             break
  37.         else:
  38.             valid = True
  39.            
  40.     if valid is True:
  41.         possiblePerms.append(perm)
  42.  
  43. Tally = [[0 for i in range(8)] for j in range(8)]
  44.  
  45.  
  46. for item in possiblePerms:
  47.     for c in xrange(8):
  48.         if item[c] == porto:
  49.             Tally[c][0] += 1
  50.         if item[c] == arsenal:
  51.             Tally[c][1] += 1
  52.         if item[c] == milan:
  53.             Tally[c][2] += 1
  54.         if item[c] == madrid:
  55.             Tally[c][3] += 1
  56.         if item[c] == donetsk:
  57.             Tally[c][4] += 1
  58.         if item[c] == valencia:
  59.             Tally[c][5] += 1
  60.         if item[c] == celtic:
  61.             Tally[c][6] += 1
  62.         if item[c] == galatasaray:
  63.             Tally[c][7] += 1
  64.            
  65. for i in xrange(8):
  66.     for j in xrange(8):
  67.         tmp = float(Tally[i][j])/(len(possiblePerms))
  68.         tmp = round(tmp,2)
  69.         Tally[i][j] = tmp
  70.        
  71. from pprint import pprint
  72. pprint(Tally)
  73. print len(possiblePerms)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement