mirror of
https://github.com/onyx-and-iris/grokking-algorithms.git
synced 2024-11-15 17:30:52 +00:00
no need to pass W, it's global.
This commit is contained in:
parent
ec899f2a73
commit
85481bd3d3
@ -18,7 +18,7 @@ class Item:
|
||||
weight: int
|
||||
|
||||
|
||||
def dynamic(W, items, n):
|
||||
def dynamic(items, n):
|
||||
# create table and zero fill it (required for calculations)
|
||||
table = [[0 for _ in range(W + 1)] for _ in range(n + 1)]
|
||||
|
||||
@ -53,6 +53,6 @@ def format_and_print(table):
|
||||
|
||||
items = [Item("Guitar", 1500, 1), Item("Stereo", 3000, 4), Item("Laptop", 2000, 3)]
|
||||
W = 4
|
||||
greatest_value = dynamic(W, items, len(items))
|
||||
greatest_value = dynamic(items, len(items))
|
||||
|
||||
print(greatest_value)
|
||||
|
Loading…
Reference in New Issue
Block a user