Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 322eda5

Browse files
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

Lines changed: 2 additions & 2 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /