Improved readability (#1615)

* improved readability

* further readability improvements

* removed csv file and added f
This commit is contained in:
GeorgeChambi
2019-12-07 05:39:59 +00:00
committed by Christian Clauss
parent 938dd0bbb5
commit 9eb50cc223
21 changed files with 44 additions and 50 deletions

View File

@ -81,13 +81,13 @@ def knapsack_with_example_solution(W: int, wt: list, val: list):
raise ValueError(
"The number of weights must be the "
"same as the number of values.\nBut "
"got {} weights and {} values".format(num_items, len(val))
f"got {num_items} weights and {len(val)} values"
)
for i in range(num_items):
if not isinstance(wt[i], int):
raise TypeError(
"All weights must be integers but "
"got weight of type {} at index {}".format(type(wt[i]), i)
f"got weight of type {type(wt[i])} at index {i}"
)
optimal_val, dp_table = knapsack(W, wt, val, num_items)