Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
2nd solution in Clear category for Most Efficient Cutting by tarasenkoa
def most_efficient_cutting(bom):
from itertools import permutations
TOO_MUCH = -1
def cutting(cuts, wastes):
rod = 6000
wasted = 0
for cut in cuts:
if cut > rod:
wasted += rod
rod = 6000
rod -= cut
if wastes and wasted > min(wastes):
return TOO_MUCH
return wasted + rod
wastes = []
for cuts in permutations(bom):
wasted = cutting(cuts, wastes)
if wasted == 0:
return 0
if wasted == TOO_MUCH:
continue
wastes.append(wasted)
return min(wastes)
July 13, 2018
Comments: