{
  "schemaVersion": 1,
  "slug": "pizza-size-calculator",
  "category": "cooking",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "5df5328e1230e6a4a845c0e34f80496d223b09be70994cb9772c3a3e7fc0f038",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/pizza-size-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; r = A₂ ÷ A₁; P_a = P ÷ A",
    "vars": [
      [
        "A",
        "Pizza area (in²)"
      ],
      [
        "d",
        "Diameter (in)"
      ],
      [
        "r",
        "Area ratio (2 vs 1)"
      ],
      [
        "P_a",
        "Price per area"
      ]
    ],
    "note": "The pizza with the lower price per area wins."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const a1 = Math.PI*Math.pow(diameter1/2,2), a2 = Math.PI*Math.pow(diameter2/2,2); const p1 = a1>0 ? price1/a1 : 0, p2 = a2>0 ? price2/a2 : 0; return { area1: a1, area2: a2, areaRatio: a1>0 ? a2/a1 : 0, pricePerArea1: p1, pricePerArea2: p2, betterValue: p1 <= p2 ? 'Pizza 1' : 'Pizza 2' };",
    "inputs": [
      {
        "name": "diameter1",
        "type": "number",
        "default": 12,
        "min": 1,
        "max": 40,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "price1",
        "type": "number",
        "default": 12,
        "min": 0,
        "max": 10000,
        "step": 0.5
      },
      {
        "name": "diameter2",
        "type": "number",
        "default": 18,
        "min": 1,
        "max": 40,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "price2",
        "type": "number",
        "default": 20,
        "min": 0,
        "max": 10000,
        "step": 0.5
      }
    ],
    "outputs": [
      {
        "name": "area1",
        "precision": 1,
        "unit": "in²"
      },
      {
        "name": "area2",
        "precision": 1,
        "unit": "in²"
      },
      {
        "name": "areaRatio",
        "precision": 2,
        "unit": "x"
      },
      {
        "name": "pricePerArea1",
        "precision": 4,
        "unit": "$"
      },
      {
        "name": "pricePerArea2",
        "precision": 4,
        "unit": "$"
      },
      {
        "name": "betterValue",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
