Kapsack iterative implementation