module.exports = { slug: "bakers-percentage", title: "Baker's percentage", deck_category: "cooking", description: "Converts a list of baker's percentages (relative to flour weight) into actual ingredient weights.", inputs: [ { name: "flour_weight_g", type: "number", unit: "g", required: true, description: "Total flour weight, the 100% reference", min: 0 }, { name: "ingredients", type: "array", required: true, description: "List of {name, percent} entries, percent relative to flour_weight_g" } ], outputs: [ { name: "weights", unit: null, description: "Ingredient list with computed weight in grams" } ], steps: [ "In baker's percentage, flour is always 100% and every other ingredient's percentage is relative to the flour weight, not the total dough weight.", "For each ingredient: weight_g = flour_weight_g * percent / 100.", "Round every computed weight to 1 decimal place." ], constants: [], sources: [ { kind: "edition_page", value: "Figoni PI. How Baking Works: Exploring the Fundamentals of Baking Science, 3rd edition, chapter on formula and percentage systems.", title: "Baker's percentage (formula percentage) method", publisher: "Wiley", retrieved_utc: "2026-09-30T20:00:00Z", note: "Standard professional baking method: every ingredient is expressed as a percentage of total flour weight, which is fixed at 100%." } ], disclaimer: null, questionText(inputs) { const items = inputs.ingredients.map((i) => `${i.name} at ${i.percent}%`).join(", "); return `For a baker's percentage formula with ${inputs.flour_weight_g} g of flour and ${items}, what are the ingredient weights?`; }, run(inputs) { const { flour_weight_g, ingredients } = inputs; if (typeof flour_weight_g !== "number" || flour_weight_g <= 0) throw new Error("flour_weight_g must be a positive number"); if (!Array.isArray(ingredients) || ingredients.length === 0) throw new Error("ingredients must be a non-empty array"); const weights = ingredients.map((ing) => { if (typeof ing.name !== "string" || typeof ing.percent !== "number") { throw new Error("each ingredient needs name (string) and percent (number)"); } const w = Math.round(flour_weight_g * (ing.percent / 100) * 10) / 10; return { name: ing.name, weight_g: w }; }); const answer = weights.map((w) => `${w.weight_g} g ${w.name}`).join(", "); return { answer, values: { weights } }; }, examples: [ { name: "worked example", inputs: { flour_weight_g: 1000, ingredients: [ { name: "water", percent: 65 }, { name: "salt", percent: 2 }, { name: "yeast", percent: 1 } ] }, expected: { answer: "650 g water, 20 g salt, 10 g yeast" }, check: "1000*0.65=650. 1000*0.02=20. 1000*0.01=10." }, { name: "test vector: smaller batch with decimal result", inputs: { flour_weight_g: 500, ingredients: [ { name: "water", percent: 68 }, { name: "salt", percent: 1.8 } ] }, expected: { answer: "340 g water, 9 g salt" }, check: "500*0.68=340. 500*0.018=9." } ] };