komentarze

This commit is contained in:
neerka 2024-04-04 14:18:38 +02:00
parent 6ab8c4af87
commit bfe9b967b1

View File

@ -37,13 +37,13 @@ def knapsack(dostepne, cap, mode):
plecak = items
return
if mode in [1, 2] and waga >= cap: # alfa cięcie
if mode in [1, 2] and waga >= cap: # alfa cięcie part 1
return
if mode in [2] and max_val >= val + ograniczenie(dostepne[i:], cap-waga): # beta cięcie
return
if waga + dostepne[i].waga <= cap:
if waga + dostepne[i].waga <= cap: # alfa cięcie part 2
temp = items[:]
temp.append(dostepne[i])
rekurencja(i+1, waga + dostepne[i].waga, val + dostepne[i].wartosc, temp)