1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| def sommeTitanSanté(list_of_name):
sommeTitanSanté=sum([seq[name]["Titan Santé"] for name in list_of_name])
return sommeTitanSanté
def sommeTitanDegats(list_of_name):
sommeTitanDegats=sum([seq[name]["Titan Degats"] for name in list_of_name])
return sommeTitanDegats
def sommeTitanArmure(list_of_name):
sommeTitanArmure=sum([seq[name]["Titan Armure"] for name in list_of_name])
return sommeTitanArmure
def comb(m, lst):
if m == 0: return [[]]
return [[x] + suffix for i, x in enumerate(lst)
for suffix in comb(m - 1, lst[i + 1:])]
# Définitions des dictionnaires
Relique1= {'Titan Santé':5,'Titan Degats':7,'Titan Armure':2}
Relique2= {'Titan Santé':1,'Titan Degats':3,'Titan Armure':3}
Relique3= {'Titan Santé':2,'Titan Degats':2,'Titan Armure':4}
seq={"Relique1":Relique1, "Relique2":Relique2,"Relique3":Relique3}
for i in seq:
names=list(seq)
combinaisons = comb(2, names)
totauxTitanSanté = [ sommeTitanSanté(c) for c in combinaisons ]
totauxTitanDegats = [ sommeTitanDegats(c) for c in combinaisons ]
totauxTitanArmure = [ sommeTitanArmure(c) for c in combinaisons ]
resultat=sorted(zip( totauxTitanSanté,totauxTitanDegats,totauxTitanArmure, combinaisons) ,reverse=True)
print(resultat)
#Mise en forme des résultats
for a, b, c, d in resultat:
print("La combinaison",d,'\n', "Titan Santé=",a,'\n',"TitanDegats=",b,'\n',"Titan Armure=",c,'\n') |
Partager