{
  "schemaVersion": 1,
  "slug": "plant-spacing-calculator",
  "category": "gardening",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "70581a56960f0b99db68772d7497c1b13cf41142ad680dff7894004943dd02ff",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/plant-spacing-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": "N = ⌊W × 12 ÷ s_w⌋ × ⌊L × 12 ÷ s⌋",
    "vars": [
      [
        "N",
        "Total plants"
      ],
      [
        "W",
        "Bed width (ft)"
      ],
      [
        "L",
        "Bed length (ft)"
      ],
      [
        "s",
        "Plant spacing (in)"
      ],
      [
        "s_w",
        "Cross/row spacing (in)"
      ]
    ],
    "note": "Staggered layout: N × 1.15 (floored); 1 ft = 12 in."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const across = Math.floor(bedWidth*12/(layout === 'rows' ? rowSpacing : spacing)); const along = Math.floor(bedLength*12/spacing); const gridTotal = across*Math.max(0, along); let totalPlants = gridTotal; if (layout === 'staggered') totalPlants = Math.ceil(gridTotal*1.15); if (layout === 'rows') totalPlants = Math.floor(bedWidth*12/rowSpacing)*Math.floor(bedLength*12/spacing); const area = bedLength*bedWidth; return { area, plantsAcross: across, plantsAlong: along, totalPlants, plantsPerSqft: area > 0 ? totalPlants/area : 0, note: layout === 'rows' ? 'Rows leave walking space, which is easier to tend but uses more ground' : 'Ensure every plant can reach its mature spread without crowding its neighbour' };",
    "inputs": [
      {
        "name": "bedLength",
        "type": "number",
        "default": 8,
        "min": 0.5,
        "max": 500,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "bedWidth",
        "type": "number",
        "default": 4,
        "min": 0.5,
        "max": 500,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "spacing",
        "type": "number",
        "default": 12,
        "min": 1,
        "max": 120,
        "step": 1,
        "slider": true
      },
      {
        "name": "layout",
        "type": "select",
        "default": "grid",
        "options": [
          {
            "value": "grid"
          },
          {
            "value": "rows"
          },
          {
            "value": "staggered"
          }
        ]
      },
      {
        "name": "rowSpacing",
        "type": "number",
        "default": 18,
        "min": 1,
        "max": 120,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "area",
        "precision": 1,
        "unit": "sq ft"
      },
      {
        "name": "plantsAcross",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "plantsAlong",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "totalPlants",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "plantsPerSqft",
        "precision": 2,
        "unit": "pcs"
      },
      {
        "name": "note",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
