diff --git a/u11/knapsack.py b/u11/knapsack.py index 0382440..735579e 100644 --- a/u11/knapsack.py +++ b/u11/knapsack.py @@ -33,10 +33,10 @@ def maximum_value_with_items(maximum_weight, items): for currW,(currV, vibir) in stav.items(): NEwW = currW + w - if NEwW <= maximum_weight: - NewV = currV + v - if NewV > Novystav.get(NEwW, (0, []))[0]: - Novystav[NEwW] = (NewV, vibir + [item]) + if NEwW <= maximum_weight: + NewV = currV + v + if NewV > Novystav.get(NEwW, (0, []))[0]: + Novystav[NEwW] = (NewV, vibir + [item]) stav = Novystav