weight=[20,10,26,15]
_list = zip(weight, range(0, len(weight)))
capacity =70
_list.sort(key=lambda item:item[0])
print _list
_list_load = []
def load(item):
global capacity
capacity = capacity -item[0]
if capacity >0:
_list_load.append(True)
else:
_list_load.append(False)
map(lambda item:load(item), _list)
print _list_load
_list_3 = zip(_list, _list_load)
print _list_3
_list_4 = filter(lambda item:item[1], _list_3)
print _list_4
时间: 2024-10-11 11:18:14