Fractional Knapsack in Python
The program does not solve the problem:

&gt;&gt;&gt; get_optimal_value(1, (1, 1, 1, 1), (1, 1, 1, 1))
2.0


Here we have a knapsack with capacity 1, and four kinds of item, each with weight 1 and value 1. So all ways of filling the knapsack have value 1.