my take on knapsack problem