Knapsack problem solver
Purpose of this project
This open-source project is a coding exercise for Kotlin and dynamic programming (DP) skills. The solver algorithm is a personal implementation of the DP algorithm for the 0-1 knapsack problem explained in Knapsack Problems.
Request & response format
The following JSON is a valid input example for the application. Note that all parameters are integers.
{"weights":[10,20,30],"values":[60,100,120],"capacity":50}
The following JSON is the response for the input example. status
atribute can have two values: ok
, when the instance is solved and failed
when the input is invalid.
{"status":"ok","optimal_solution":[2,3],"optimal_value":220}