Skip to content

Commit 31017ca

Browse files
authored
Update fractional_cover_problem.py
1 parent 32b02e3 commit 31017ca

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: greedy_methods/fractional_cover_problem.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ class Item:
88
weight: int
99
value: int
1010

11-
def __eq__(self, other: "Item") -> bool:
11+
def __eq__(self, other: object) -> bool:
1212
"""
1313
Compare two Item objects for equality based on weight and value attributes.
1414
1515
Args:
16-
other (Item): Another Item object to compare with.
16+
other (object): Another object to compare with.
1717
1818
Returns:
1919
bool: True if the objects are equal, False otherwise.
@@ -28,7 +28,7 @@ def __eq__(self, other: "Item") -> bool:
2828
False
2929
"""
3030
if not isinstance(other, Item):
31-
return NotImplemented
31+
return False # Return False for non-Item objects
3232
return self.weight == other.weight and self.value == other.value
3333

3434

@@ -106,3 +106,4 @@ def fractional_cover(items: list[Item], capacity: int) -> float:
106106
print("All tests passed")
107107
else:
108108
print(f"{result} test(s) failed")
109+

0 commit comments

Comments
 (0)