Make depth first search for Knapsack non-recursive and more efficient. Solves all problems in reasonable time now.
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
#!/usr/bin/python3
|
||||
#!/usr/bin/pypy
|
||||
# -*- coding: utf-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_greedy(k)
|
||||
return knapsack.result_to_output_data(r)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user