Skip to content

calc_profit always returns an int #2090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions greedy_method/greedy_knapsack.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
Calculate the maximum profit that the shopkeeper can make given maxmum weight that can
be carried.
"""
from typing import Union


def calc_profit(profit: list, weight: list, max_weight: int) -> Union[str, int]:
def calc_profit(profit: list, weight: list, max_weight: int) -> int:
"""
Function description is as follows-
:param profit: Take a list of profits
Expand Down
4 changes: 3 additions & 1 deletion greedy_method/test_knapsack.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ def test_unequal_list_length(self):
# profit = [10, 20, 30, 40, 50]
# weight = [2, 4, 6, 8, 10, 12]
# max_weight = 100
self.assertRaisesRegex(IndexError, "The length of profit and weight must be same.")
self.assertRaisesRegex(
IndexError, "The length of profit and weight must be same."
)


if __name__ == "__main__":
Expand Down