Skip to content

Commit 322eda5

Browse files
committed
change knapsack Fitness to compare Volume last
1 parent 514b80b commit 322eda5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ch09/knapsackTests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,10 @@ def __init__(self, totalWeight, totalVolume, totalValue):
254254

255255
def __gt__(self, other):
256256
if self.TotalValue != other.TotalValue:
257-
return self.TotalValue > other.TotalValue
257+
return self.TotalValue > other.TotalValue
258258
if self.TotalWeight != other.TotalWeight:
259259
return self.TotalWeight < other.TotalWeight
260-
return self.TotalValue < other.TotalValue
260+
return self.TotalVolume < other.TotalVolume
261261

262262
def __str__(self):
263263
return "wt: {:0.2f} vol: {:0.2f} value: {}".format(

0 commit comments

Comments
 (0)