I have my code:
def knapsack(weights, prices, capacity):
n=len(weights)
your code goes here
if n==0:
return 0
if capacity == 0:
return 0
t=[0]
for i in range(len(weights)):
if weights[i] <= capacity: t.append(knapsack( weights[0:i] + weights[(i+1): n ], prices[0:i] + prices[(i+1): n ] , capacity-weights[i] ) + weights[i] )
return max(t)
stressTesting = False
Which runs on my computer just fine but all I get is Execution timed out! error