PeteCake 字典和最小值

def cakes(recipe, available):
# TODO: insert code
count = []
for item in recipe:
if item not in available:
return 0
else:
count.append(int(available[item]/recipe[item]))
return min(count)

 

 

还可以

def cakes(recipe, available): return min(available.get(k, 0)/recipe[k] for k in recipe)

posted on 2017-07-07 11:04  run_qin  阅读(138)  评论(0编辑  收藏  举报

导航