Naive implementation of a Knapsack algorithm