{
  "schemaVersion": 1,
  "slug": "halloween-candy-calculator",
  "category": "party",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "bc8d98027b2270a23d7bcbade850e64d1bda19ae49cb086fd686d71480ebaf11",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/halloween-candy-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": "P = floor(60H/m)×p×K",
    "vars": [
      [
        "H",
        "Hours trick-or-treating"
      ],
      [
        "m",
        "Minutes per house"
      ],
      [
        "p",
        "Candy pieces per house"
      ],
      [
        "K",
        "Number of kids"
      ],
      [
        "P",
        "Total candy pieces"
      ]
    ],
    "note": "Pieces eaten = round(P×eating%/100); pounds = P×11/453.592; calories = 45 per piece."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const houses = minutesPerHouse > 0 ? Math.floor(hours*60/minutesPerHouse) : 0; const perKid = houses*piecesPerHouse; const total = perKid*kids; const eaten = Math.round(total*eatingPct/100); const weight = total*11/453.592; return { housesVisited: houses, totalPieces: total, piecesPerKid: perKid, piecesEatenTonight: eaten, leftoverPieces: total - eaten, poundsOfCandy: weight, calories: total*45 };",
    "inputs": [
      {
        "name": "kids",
        "type": "number",
        "default": 2,
        "min": 1,
        "max": 20,
        "step": 1,
        "slider": true
      },
      {
        "name": "hours",
        "type": "number",
        "default": 2,
        "min": 0.5,
        "max": 8,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "minutesPerHouse",
        "type": "number",
        "default": 1.5,
        "min": 0.2,
        "max": 15,
        "step": 0.1,
        "slider": true
      },
      {
        "name": "piecesPerHouse",
        "type": "number",
        "default": 2,
        "min": 1,
        "max": 20,
        "step": 1,
        "slider": true
      },
      {
        "name": "eatingPct",
        "type": "number",
        "default": 20,
        "min": 0,
        "max": 100,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "housesVisited",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "totalPieces",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "piecesPerKid",
        "precision": 1,
        "unit": ""
      },
      {
        "name": "piecesEatenTonight",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "leftoverPieces",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "poundsOfCandy",
        "precision": 2,
        "unit": "lb"
      },
      {
        "name": "calories",
        "precision": 0,
        "unit": ""
      }
    ],
    "interpret": null
  }
}
