Knapsack problem/Unbounded/Python dynamic programming: Difference between revisions

m (→‎Ancillary module: Fixed typo (independant→ independent))
imported>Katsumi
Line 6:
===Brute force, single size attribute===
A brute-force solution for items with only one 'size' attribute would look like the following and would not scale:
<syntaxhighlight lang="python">
<lang python>from operator import itemgetter as iget
from itertools import product
from random import shuffle
Line 418 ⟶ 419:
Size = makesize('wt vol')
x,y = Size(*[1,2]), Size(*[3,4])
</syntaxhighlight>
</lang>
Anonymous user