def cakes(recipe, available):
# your code
num_list = {}
if set(recipe.keys()) <= set(available.keys()):
# for i in recipe.keys():
# if i in available.keys():
# num_list[i] = available.get(i) // recipe.get(i)
# else:
# return 0
# return min(num_list.values())
return min([ available.get(i) // recipe.get(i) if i in available.keys() else 0 for i in recipe.keys() ])
else:
return 0
def cakes(recipe, available):
result = []
for i in recipe:
if i not in available.keys():
return 0
else:
result.append(available[i] // recipe[i])
return min(result)
def cakes(recipe, available):
# your code
if set(recipe.keys()).issubset(set(available.keys())):
return 0
else:
return min([available[k]//recipe[k] for k in recipe.keys()])
def cakes(recipe, available):
# your code
return min([available[k]//recipe[k] for k in recipe.keys()]) if set(recipe.keys()).issubset(set(available.keys())) else 0
def cakes(recipe, available):
return min(available.get(i)//v for i, v in recipe.items()) if len(set(available.keys()) & set(recipe.keys())) == len(recipe) else 0
def cakes(recipe, available):
##如果recipe的keys包含available的所有key,则开始判断数量
if set(recipe.keys()).issubset(set(available.keys())):
return min([available.get(i)//recipe.get(i) for i in recipe.keys()])
##双斜杠表示取整除
else:
return 0