Add example problem.
This commit is contained in:
4
knapsack/dp_3
Normal file
4
knapsack/dp_3
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
3 10
|
||||||
|
45 5
|
||||||
|
48 8
|
||||||
|
35 3
|
||||||
@@ -97,6 +97,7 @@ def solve_knapsack_depth_first_search(knapsack):
|
|||||||
|
|
||||||
# Take current item.
|
# Take current item.
|
||||||
max_value = get_max_value(index, capacity)
|
max_value = get_max_value(index, capacity)
|
||||||
|
print(max_value)
|
||||||
item = knapsack.items[index]
|
item = knapsack.items[index]
|
||||||
# print("max_value: {}".format(max_value))
|
# print("max_value: {}".format(max_value))
|
||||||
max_value_not = get_max_value(index + 1, capacity)
|
max_value_not = get_max_value(index + 1, capacity)
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import knapsack
|
|||||||
def solve_it(input_data):
|
def solve_it(input_data):
|
||||||
# Modify this code to run your optimization algorithm
|
# Modify this code to run your optimization algorithm
|
||||||
k = knapsack.input_data_to_knapsack(input_data)
|
k = knapsack.input_data_to_knapsack(input_data)
|
||||||
r = knapsack.solve_knapsack_dynamic(k)
|
# r = knapsack.solve_knapsack_dynamic(k)
|
||||||
# r = knapsack.solve_knapsack_depth_first_search(k)
|
r = knapsack.solve_knapsack_depth_first_search(k)
|
||||||
# r = knapsack.solve_knapsack_greedy(k)
|
# r = knapsack.solve_knapsack_greedy(k)
|
||||||
return knapsack.result_to_output_data(r)
|
return knapsack.result_to_output_data(r)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user