def cakes(recipe, available):
d = [False for recipe_key in recipe.keys() if recipe_key not in available.keys()]
if d:
return 0
else:
return min([available[recipe_key]/recipe[recipe_key] for recipe_key in recipe.keys()])
def cakes(recipe, available): return min(available.get(k, 0)/recipe[k] for k in recipe)

原文:http://www.cnblogs.com/dreamyu/p/7605857.html