Solving the knapsack problem