Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
11-liner: recursive and fast when elements repeated solution in Creative category for Most Efficient Cutting by przemyslaw.daniel
def most_efficient_cutting(data, rest=6000):
if not data: return rest
result, visited, mec = [], set(), most_efficient_cutting
for i in range(len(data)):
if data[i] in visited: continue
visited |= {data[i]}
if data[i] > rest:
result += [rest+mec(data, 6000)]
else:
result += [mec(data[:i]+data[i+1:], rest-data[i])]
return min(result)
Oct. 8, 2017
Comments: