{
  "schemaVersion": 1,
  "slug": "party-favor-calculator",
  "category": "party",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "4dc2c27591b406aab5ea6b2793a1845ba91ed80517485b70e6976b1d388c245b",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/party-favor-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "F = max(0, G − C) + k C; F_s = ceil(F × (1 + p ÷ 100)); cost = F_s × c",
    "vars": [
      [
        "G",
        "Total guests"
      ],
      [
        "C",
        "Children"
      ],
      [
        "k",
        "Favors per child"
      ],
      [
        "p",
        "Spare percentage"
      ],
      [
        "c",
        "Cost per favor"
      ]
    ],
    "note": "Children are a subset of guests (C ≤ G); adult favors = G − C; child favors = C × favors per child; spares are rounded up."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "if(children>guests)return{favorsNeeded:null,favorsWithSpares:null,totalCost:null,costPerGuest:null,adultFavors:null,childFavors:null,__error:'inputError'};const adults=guests-children,childF=children*favorsPerChild,favors=adults+childF,withSpares=Math.ceil(favors*(1+sparePct/100));return{favorsNeeded:favors,favorsWithSpares:withSpares,totalCost:withSpares*costPerFavor,costPerGuest:guests>0?withSpares*costPerFavor/guests:0,adultFavors:adults,childFavors:childF}",
    "inputs": [
      {
        "name": "guests",
        "type": "number",
        "default": 25,
        "min": 1,
        "max": 500,
        "step": 1,
        "slider": true
      },
      {
        "name": "children",
        "type": "number",
        "default": 10,
        "min": 0,
        "max": 500,
        "step": 1,
        "slider": true
      },
      {
        "name": "favorsPerChild",
        "type": "number",
        "default": 2,
        "min": 0,
        "max": 10,
        "step": 1,
        "slider": true
      },
      {
        "name": "costPerFavor",
        "type": "number",
        "default": 2.5,
        "min": 0,
        "max": 500,
        "step": 0.01
      },
      {
        "name": "sparePct",
        "type": "number",
        "default": 10,
        "min": 0,
        "max": 100,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "favorsNeeded",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "favorsWithSpares",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "totalCost",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "costPerGuest",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "adultFavors",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "childFavors",
        "precision": 0,
        "unit": ""
      }
    ],
    "interpret": null
  }
}
