Knapsack Problem/Python: Difference between revisions

m
Line 37:
print "The weight to carry is %4.1f and the volume used is %5.3f" % (best.weight, best.volume)</lang>
 
===General Brute-Force Solution===
Requires Python V.2.6+
 
This handles a varying number of items
<lang python>from itertools import product, izip
from collections import namedtuple
Anonymous user