DL Info
DL Info
1)def trierpardatedefin(E):
L = E[:]
n = len(L)
for i in range(n):
min = i
for j in range(i + 1, n):
if L[j][1] < L[min][1]:
min = j
L[i], L[min] = L[min], L[i]
return L
execution:[(1, 4), (3, 5), (0, 6), (5, 7), (3, 8), (5, 9), (6, 10), (8, 11), (8,
12), (2, 13), (12, 14)]
2)def selection_demandes(L):
F = []
s = 0
for i in L:
debut, fin = i
if debut >= s:
F.append((debut, fin))
s = fin
return F
execution:[(1, 4), (5, 7), (8, 11), (12, 14)]
exercice 1:
def glouton(L, n):
B = []
S = []
while len(B) < n:
max = -1
index = -1
for j in range(len(L)):
if j not in S and (j-1 not in S) and (j+1 not in S):
if L[j] > max:
max = L[j]
index = j
if index != -1:
B.append(L[index])
S.append(index)
return B
execution:[20, 19, 16, 15, 14]
exercice 4:
1)def Monnaie(somme_a_rendre, systeme_monnaie):
rendu = []
return rendu
2)somme_a_rendre = 49
systeme_monnaie = (50, 20, 10, 5, 2, 1)
execution:[20,20,5,2,2]