Add example problem.

This commit is contained in:
2019-12-10 07:02:58 -05:00
parent 4a7034225d
commit bb9678a493
3 changed files with 7 additions and 2 deletions

4
knapsack/dp_3 Normal file
View File

@@ -0,0 +1,4 @@
3 10
45 5
48 8
35 3

View File

@@ -97,6 +97,7 @@ def solve_knapsack_depth_first_search(knapsack):
# Take current item.
max_value = get_max_value(index, capacity)
print(max_value)
item = knapsack.items[index]
# print("max_value: {}".format(max_value))
max_value_not = get_max_value(index + 1, capacity)

View File

@@ -7,8 +7,8 @@ import knapsack
def solve_it(input_data):
# Modify this code to run your optimization algorithm
k = knapsack.input_data_to_knapsack(input_data)
r = knapsack.solve_knapsack_dynamic(k)
# r = knapsack.solve_knapsack_depth_first_search(k)
# r = knapsack.solve_knapsack_dynamic(k)
r = knapsack.solve_knapsack_depth_first_search(k)
# r = knapsack.solve_knapsack_greedy(k)
return knapsack.result_to_output_data(r)