{
  "schemaVersion": 1,
  "slug": "seed-spacing-calculator",
  "category": "gardening",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "9143293fe5964b6e77ab3a2990233cbb463d7d04ecf2e17747336118fddaa374",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/seed-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": "F = ⌊12L÷d_f⌋×r; S = ⌈⌊12L÷d_s⌋×r÷(g÷100)⌉; X = max(0, ⌊12L÷d_s⌋×r − F)",
    "vars": [
      [
        "L",
        "Row length (ft)"
      ],
      [
        "d_f",
        "Final spacing (in)"
      ],
      [
        "d_s",
        "Sowing spacing (in)"
      ],
      [
        "r",
        "Number of rows"
      ],
      [
        "g",
        "Germination rate (%)"
      ],
      [
        "F",
        "Final number of plants"
      ],
      [
        "S",
        "Seeds sown to offset germination losses"
      ],
      [
        "X",
        "Seedlings removed by thinning"
      ]
    ],
    "note": "Final plants = floor(row length×12÷final spacing)×rows. Target seed count is the larger of sow-spacing positions and final plant count, adjusted upward by germination percentage; expected thinning uses the estimated germinated count. Actual emergence varies."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const plantsPerRow=Math.floor(rowLength*12/finalSpacing);const finalPlants=plantsPerRow*rows;const targetSeeds=Math.max(Math.ceil(rowLength*12/sowSpacing)*rows,finalPlants);const seedsSown=Math.ceil(targetSeeds/(germination/100));const expectedGerminated=seedsSown*germination/100;const totalRowLength=rowLength*rows;return{finalPlants,seedsSown,thinning:Math.max(0,Math.floor(expectedGerminated-finalPlants)),seedPerFoot:totalRowLength>0?seedsSown/totalRowLength:0};",
    "inputs": [
      {
        "name": "rowLength",
        "type": "number",
        "default": 20,
        "min": 0.5,
        "max": 1000,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "finalSpacing",
        "type": "number",
        "default": 4,
        "min": 0.5,
        "max": 60,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "sowSpacing",
        "type": "number",
        "default": 1,
        "min": 0.25,
        "max": 12,
        "step": 0.25,
        "slider": true
      },
      {
        "name": "germination",
        "type": "number",
        "default": 80,
        "min": 1,
        "max": 100,
        "step": 1,
        "slider": true
      },
      {
        "name": "rows",
        "type": "number",
        "default": 1,
        "min": 1,
        "max": 100,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "finalPlants",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "seedsSown",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "thinning",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "seedPerFoot",
        "precision": 2,
        "unit": "pcs"
      }
    ],
    "interpret": null
  }
}
