knapsack code with images