knapsack
knapsack copied to clipboard
failing test
I think there's an issue with the algorithm - see provided test
Indeed. This implementation doesn't appear to solve the knapsack problem at all. It simply fills the knapsack with the biggest item it can until there's not enough capacity for the remaining items. The possibility of smaller items being optimal is what makes this problem NP-Complete.