Skip to content

Commit 4d24580

Browse files
Hardvancclauss
andauthored
Add strict=True
Co-authored-by: Christian Clauss <[email protected]>
1 parent e09ef5f commit 4d24580

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: greedy_methods/fractional_knapsack.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def frac_knapsack(vl: list, wt: list, w: int, n: int) -> float:
4646
"""
4747

4848
# sort in descending order of value/weight ratio
49-
r = sorted(zip(vl, wt), key=lambda x: x[0] / x[1], reverse=True)
49+
r = sorted(zip(vl, wt), key=lambda x: x[0] / x[1], reverse=True, strict=True)
5050

5151
vl, wt = [i[0] for i in r], [i[1] for i in r] # unzip the list
5252
acc = list(accumulate(wt)) # cumulative sum of weights

0 commit comments

Comments
 (0)