Pete, the baker

1
2
3
4
5
6
7
8
9
function cakes(recipe, available) {
var cakes=Number.MAX_VALUE;
for(ing in recipe){
if(recipe.hasOwnProperty(ing)){
cakes=Math.min(ing in available ? Math.floor(available[ing]/recipe[ing]) : 0,cakes);
}
}
return cakes;
}