{
  "schemaVersion": 1,
  "slug": "pizza-comparison-calculator",
  "category": "everyday",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "b58c8a0b2bc2f1091c8cabcca407e1f4bc76f8f3d450fd1c043be720a084af06",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/pizza-comparison-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": "A = π × (d ÷ 2)^2; P_a = P ÷ A; Δ = (A_B ÷ A_A − 1) × 100",
    "vars": [
      [
        "A",
        "Pizza area (in²)"
      ],
      [
        "d",
        "Diameter (in)"
      ],
      [
        "P_a",
        "Price per in²"
      ],
      [
        "Δ",
        "Size advantage (%)"
      ]
    ],
    "note": "Lower price per area is better; slices needed = people × slices per person."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const areaA = Math.PI*Math.pow(diameterA/2, 2); const areaB = Math.PI*Math.pow(diameterB/2, 2); const perA = areaA > 0 ? priceA/areaA : 0; const perB = areaB > 0 ? priceB/areaB : 0; const slicesNeeded = people*slicesPerPerson; return { areaA, pricePerSqInA: perA, areaB, pricePerSqInB: perB, betterValue: perA < perB ? 'Pizza A' : perA > perB ? 'Pizza B' : 'Same value', sizeAdvantage: areaA > 0 ? (areaB/areaA-1)*100 : 0, slicesNeeded };",
    "inputs": [
      {
        "name": "priceA",
        "type": "number",
        "default": 12.99,
        "min": 0,
        "max": 1000,
        "step": 0.01
      },
      {
        "name": "diameterA",
        "type": "number",
        "default": 12,
        "min": 1,
        "max": 60,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "priceB",
        "type": "number",
        "default": 18.99,
        "min": 0,
        "max": 1000,
        "step": 0.01
      },
      {
        "name": "diameterB",
        "type": "number",
        "default": 16,
        "min": 1,
        "max": 60,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "people",
        "type": "number",
        "default": 4,
        "min": 1,
        "max": 50,
        "step": 1,
        "slider": true
      },
      {
        "name": "slicesPerPerson",
        "type": "number",
        "default": 3,
        "min": 1,
        "max": 12,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "areaA",
        "precision": 1,
        "unit": "sq in"
      },
      {
        "name": "pricePerSqInA",
        "precision": 4,
        "unit": "$"
      },
      {
        "name": "areaB",
        "precision": 1,
        "unit": "sq in"
      },
      {
        "name": "pricePerSqInB",
        "precision": 4,
        "unit": "$"
      },
      {
        "name": "betterValue",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "sizeAdvantage",
        "precision": 0,
        "unit": "%"
      },
      {
        "name": "slicesNeeded",
        "precision": 0,
        "unit": ""
      }
    ],
    "interpret": null
  }
}
