补全缩进 def pack_using_bags(order): bags_cnt = [0] * len(bag_sizes) total_volume = 0 for i in range(order["数量"]): volume = order["长"] * order["宽"] * order["高"] #遍历订单尺寸 while volume > 0: packed = False for j
时间: 2024-03-19 17:42:53 浏览: 74
in range(len(bag_sizes)): if bags_cnt[j] < order["数量"] and bag_sizes[j] >= volume: bags_cnt[j] += 1 total_volume += volume packed = True break if not packed: return False volume = order["长"] * order["宽"] * order["高"] - total_volume return True
相关问题
# 用袋打包 def pack_using_bags(order): bags_cnt = [0] * len(bag_sizes) total_volume = 0 for i in range(order["数量"]): volume = order["长"] * order["宽"] * order["高"] #遍历订单尺寸 while volume > 0: packed = False for j, bag_size in enumerate(bag_sizes): #遍历袋子尺寸 if (bag_size[0] >= order["长"]) and (bag_size[1] >= order["宽"]) and (bag_size[2] >=order["高"]): bags_cnt[j] += 1 total_volume += bag_size[0] * bag_size[1] * bag_size[2] packed = True break if not packed: break volume -= bag_size[0] * bag_size[1] * bag_size[2] return bags_cnt, total_volume补全上述代码缩进
def pack_using_bags(order):
bags_cnt = [0] * len(bag_sizes)
total_volume = 0
for i in range(order["数量"]):
volume = order["长"] * order["宽"] * order["高"] # 遍历订单尺寸
while volume > 0:
packed = False
for j, bag_size in enumerate(bag_sizes): # 遍历袋子尺寸
if (bag_size[0] >= order["长"]) and (bag_size[1] >= order["宽"]) and (bag_size[2] >= order["高"]):
bags_cnt[j] += 1
total_volume += bag_size[0] * bag_size[1] * bag_size[2]
packed = True
break
if not packed:
break
volume -= bag_size[0] * bag_size[1] * bag_size[2]
return bags_cnt, total_volume
阅读全文