Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- bestTeamA = []
- bestTotaalA = 0
- bestTeamB = []
- bestTotaalB = 0
- bestBerekening = 1000000000
- players = {
- "angelo" : 9,
- "brent" : 7,
- "lino" : 9,
- "vince" : 9,
- "dimi" : 8,
- "keanu la" : 5,
- "keanu cl" : 6,
- "remi" : 3,
- "mathias": 2,
- "jellis" : 6
- }
- while True:
- TeamA = []
- totaalA = 0
- TeamB = []
- totaalB = 0
- #########TeamA###############################
- for i in range(5):
- while True:
- ding = random.sample(list((players)),1)
- if ding[0] not in TeamA and ding[0] not in TeamB:
- TeamA.append(ding[0])
- totaalA += players[ding[0]]
- break
- ######Debug###############
- #print(TeamA)
- ###########################
- #############TeamB####################
- for i in range(5):
- while True:
- ding = random.sample(list((players)),1)
- if ding[0] not in TeamB and ding[0] not in TeamA:
- TeamB.append(ding[0])
- totaalB += players[ding[0]]
- break
- #########Debug###########
- #print(TeamB)
- ###########################
- if totaalA > totaalB:
- berekening = totaalA - totaalB
- if bestBerekening > berekening:
- bestBerekening = berekening
- bestTeamA = TeamA
- bestTeamB = TeamB
- bestTotaalA = totaalA
- bestTotaalB = totaalB
- elif totaalB > totaalA:
- berekening = totaalB - totaalA
- if bestBerekening > berekening:
- bestBerekening = berekening
- bestTeamA = TeamA
- bestTeamB = TeamB
- bestTotaalA = totaalA
- bestTotaalB = totaalB
- else:
- berekening = 0
- if bestBerekening > berekening:
- bestBerekening = berekening
- bestTeamA = TeamA
- bestTeamB = TeamB
- bestTotaalA = totaalA
- bestTotaalB = totaalB
- break
- print("einde")
- print(bestTeamA ,":",totaalA)
- print(bestTeamB,":",totaalB)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement