Knapsack NP-complete implementation