{
  "schemaVersion": 1,
  "slug": "staircase-calculator",
  "category": "construction",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "c48aa8a134f4ab74d6b1c7047c5559e5e4661a51e6036dc5d494f844c894b8d5",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/staircase-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": "R = ceil(H ÷ r₀); r = H ÷ R; G = (R − 1) × t; reference = (r ≤ 7.75) and (t ≥ 10)",
    "vars": [
      [
        "H",
        "total rise (in)"
      ],
      [
        "r₀",
        "target riser (in)"
      ],
      [
        "R",
        "risers"
      ],
      [
        "r",
        "actual riser (in)"
      ],
      [
        "t",
        "tread depth (in)"
      ],
      [
        "G",
        "total run (in)"
      ]
    ],
    "note": "Risers = ceiling(total rise ÷ target); actual riser = total rise ÷ risers; treads = risers − 1; total run = treads × depth. Reference checks are not code approval."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const risers=Math.max(1,Math.ceil(totalRise/desiredRiser)); const actualRiser=totalRise/risers; const treads=Math.max(1,risers-1); const totalRun=treads*treadDepth; const ok=actualRiser<=7.75 && treadDepth>=10; return {risers,treads,actualRiser,totalRun,totalRunFeet:totalRun/12,codeCheck:ok ? \"Meets the calculator reference\" : \"Outside the calculator reference\"};",
    "inputs": [
      {
        "name": "totalRise",
        "type": "number",
        "default": 108,
        "min": 10,
        "max": 400,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "desiredRiser",
        "type": "number",
        "default": 7,
        "min": 5,
        "max": 8,
        "step": 0.25,
        "slider": true
      },
      {
        "name": "treadDepth",
        "type": "number",
        "default": 10,
        "min": 9,
        "max": 16,
        "step": 0.25,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "risers",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "treads",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "actualRiser",
        "precision": 2,
        "unit": "in"
      },
      {
        "name": "totalRun",
        "precision": 1,
        "unit": "in"
      },
      {
        "name": "totalRunFeet",
        "precision": 1,
        "unit": "ft"
      },
      {
        "name": "codeCheck",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
