Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Most Efficient Cutting by ssk8
from itertools import permutations
def most_efficient_cutting(bom):
total_waste = sum(bom) + 6000
for combo in permutations(bom):
current, waste = 0, 0
for cut in combo:
if current + cut > 6000:
waste += 6000 - current
current = cut
elif current + cut == 6000:
current = 0
else:
current += cut
waste += (6000 - current)%6000
if waste < total_waste:
total_waste = waste
return total_waste
July 20, 2018