Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.08 KB | None | 0 0
  1. import random
  2.  
  3.  
  4.  
  5. bestTeamA = []
  6. bestTotaalA = 0
  7.  
  8. bestTeamB = []
  9. bestTotaalB = 0
  10.  
  11. bestBerekening = 1000000000
  12.  
  13. players = {
  14.     "angelo" : 9,
  15.     "brent" : 7,
  16.     "lino" : 9,
  17.     "vince" : 9,
  18.     "dimi" : 8,
  19.     "keanu la" : 5,
  20.     "keanu cl" : 6,
  21.     "remi" : 3,
  22.     "mathias": 2,
  23.     "jellis" : 6
  24. }
  25.  
  26.  
  27. while True:
  28.     TeamA = []
  29.     totaalA = 0
  30.  
  31.     TeamB = []
  32.     totaalB = 0
  33.  
  34.     #########TeamA###############################
  35.     for i in range(5):
  36.         while True:
  37.             ding = random.sample(list((players)),1)
  38.             if ding[0] not in TeamA and ding[0] not in TeamB:
  39.                 TeamA.append(ding[0])
  40.                 totaalA += players[ding[0]]
  41.                 break
  42.    ######Debug###############
  43.    #print(TeamA)
  44.     ###########################
  45.  
  46.  
  47.     #############TeamB####################
  48.     for i in range(5):
  49.         while True:
  50.             ding = random.sample(list((players)),1)
  51.             if ding[0] not in TeamB and ding[0] not in TeamA:
  52.                 TeamB.append(ding[0])
  53.                 totaalB += players[ding[0]]
  54.                 break
  55.     #########Debug###########
  56.     #print(TeamB)
  57.     ###########################
  58.  
  59.     if totaalA > totaalB:
  60.         berekening = totaalA - totaalB
  61.         if bestBerekening > berekening:
  62.             bestBerekening = berekening
  63.             bestTeamA = TeamA
  64.             bestTeamB = TeamB
  65.             bestTotaalA = totaalA
  66.             bestTotaalB = totaalB
  67.  
  68.     elif totaalB > totaalA:
  69.         berekening = totaalB - totaalA
  70.         if bestBerekening > berekening:
  71.             bestBerekening = berekening
  72.             bestTeamA = TeamA
  73.             bestTeamB = TeamB
  74.             bestTotaalA = totaalA
  75.             bestTotaalB = totaalB
  76.     else:
  77.         berekening = 0
  78.         if bestBerekening > berekening:
  79.             bestBerekening = berekening
  80.             bestTeamA = TeamA
  81.             bestTeamB = TeamB
  82.             bestTotaalA = totaalA
  83.             bestTotaalB = totaalB
  84.  
  85.         break
  86.  
  87.  
  88. print("einde")
  89. print(bestTeamA ,":",totaalA)
  90. print(bestTeamB,":",totaalB)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement