T: / Corrigés des challenges / Python
sort avec reverse ou non et parcours d’un tableau.
def place_occupee(sac,objets):
solution = 0
objets.sort(reverse = True)
for i in range(0,10):
if (solution + objets[i]) > sac:
break
solution += objets[i]
objets.sort()
for i in range(0,10):
if (solution + objets[i]) > sac:
break
solution += objets[i]
return solution
Other content to discover