Anonymous user
Knapsack problem/Unbounded/Python dynamic programming: Difference between revisions
Knapsack problem/Unbounded/Python dynamic programming (view source)
Revision as of 14:59, 22 August 2023
, 8 months ago→Dynamic Programming Solution
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">
from itertools import product
from random import shuffle
Line 418 ⟶ 419:
Size = makesize('wt vol')
x,y = Size(*[1,2]), Size(*[3,4])
</syntaxhighlight>
|