STUD.com
← Objectives

Compute · Transform · Data & Research

Compute the bill under a linear, 2-part, or 3-part tariff

I give a usage volume and a tariff schedule and get the exact amount owed, with the right block selected and overage applied only above included units.

You receive: A pure function computing {blockIndex, platformFee, unitCharge, overageCharge, total} from a block schedule and a usage figure, graded on hidden input->output cases.

Part of Choose Business Model

What's verified: STUD verifies the billing function selects the correct block (the first block, ascending by included units, whose bound covers the usage; above the top bound the top block applies) and computes the fee, per-unit, and overage charges exactly against hidden usage cases. STUD does NOT verify that the tariff is well designed or that the usage figure is what a real customer would consume.

Opens soon

Cost20 credits
AcceptanceAutomated check against your inputs
ProtectionHeld until verified delivery

This objective is verified and ready. It opens soon, once sign-in and payments are live.

Deliverable interface

The exact vocabulary the automated check enforces: keys, tokens, entry points, and worked examples. Generated from the verification source.

{
 "constants": {},
 "entryName": "compute_tariff_bill",
 "expectNote": "expect is the comparison-space value (your return value goes through normalize first when one is published)",
 "hiddenCaseCount": 16,
 "hiddenCaseNames": [
  "hd_boundary_exact_block1",
  "hd_boundary_just_above",
  "hd_boundary_exact_top",
  "hd_twopart_above_top",
  "hd_linear_above_top",
  "hd_threepart_single_block_overage",
  "hd_unsorted_blocks",
  "hd_omitted_optional_cells",
  "gen0",
  "gen1",
  "gen2",
  "gen3",
  "gen4",
  "gen5",
  "gen6",
  "gen7"
 ],
 "inputKeys": [
  "blocks",
  "fee",
  "overageRate",
  "tariffType",
  "unitRate",
  "upTo",
  "usage"
 ],
 "normalizeSource": "def _normalize_tariff_bill_for_usage(r):\n    if not isinstance(r, dict):\n        return repr(r)\n    try:\n        return {\"blockIndex\": int(round(float(r[\"blockIndex\"]))),\n                \"platformFee\": round(float(r[\"platformFee\"]), 2),\n                \"unitCharge\": round(float(r[\"unitCharge\"]), 2),\n                \"overageCharge\": round(float(r[\"overageCharge\"]), 2),\n                \"total\": round(float(r[\"total\"]), 2)}\n    except Exception:\n        return repr(r)\n",
 "returnShapes": [
  [
   "blockIndex",
   "overageCharge",
   "platformFee",
   "total",
   "unitCharge"
  ]
 ],
 "signature": "def compute_tariff_bill(inp):",
 "submission": "python exposing the entry function; inp is one input object; graded on held-out cases",
 "tier": "calculator",
 "visibleCases": [
  {
   "expect": {
    "blockIndex": 1,
    "overageCharge": 0,
    "platformFee": 35000,
    "total": 35000,
    "unitCharge": 0
   },
   "input": {
    "blocks": [
     {
      "fee": 35000,
      "overageRate": 0.45,
      "unitRate": 0,
      "upTo": 100000
     },
     {
      "fee": 75000,
      "overageRate": 0.4,
      "unitRate": 0,
      "upTo": 250000
     },
     {
      "fee": 125000,
      "overageRate": 0.35,
      "unitRate": 0,
      "upTo": 500000
     }
    ],
    "tariffType": "three_part",
    "usage": 90000
   },
   "name": "threepart_block1_within"
  },
  {
   "expect": {
    "blockIndex": 2,
    "overageCharge": 0,
    "platformFee": 75000,
    "total": 75000,
    "unitCharge": 0
   },
   "input": {
    "blocks": [
     {
      "fee": 35000,
      "overageRate": 0.45,
      "unitRate": 0,
      "upTo": 100000
     },
     {
      "fee": 75000,
      "overageRate": 0.4,
      "unitRate": 0,
      "upTo": 250000
     },
     {
      "fee": 125000,
      "overageRate": 0.35,
      "unitRate": 0,
      "upTo": 500000
     }
    ],
    "tariffType": "three_part",
    "usage": 120000
   },
   "name": "threepart_block2_within"
  },
  {
   "expect": {
    "blockIndex": 3,
    "overageCharge": 35000,
    "platformFee": 125000,
    "total": 160000,
    "unitCharge": 0
   },
   "input": {
    "blocks": [
     {
      "fee": 35000,
      "overageRate": 0.45,
      "unitRate": 0,
      "upTo": 100000
     },
     {
      "fee": 75000,
      "overageRate": 0.4,
      "unitRate": 0,
      "upTo": 250000
     },
     {
      "fee": 125000,
      "overageRate": 0.35,
      "unitRate": 0,
      "upTo": 500000
     }
    ],
    "tariffType": "three_part",
    "usage": 600000
   },
   "name": "threepart_overage"
  },
  {
   "expect": {
    "blockIndex": 1,
    "overageCharge": 0,
    "platformFee": 20000,
    "total": 35000,
    "unitCharge": 15000
   },
   "input": {
    "blocks": [
     {
      "fee": 20000,
      "overageRate": 0,
      "unitRate": 0.3,
      "upTo": 100000
     }
    ],
    "tariffType": "two_part",
    "usage": 50000
   },
   "name": "twopart_book"
  },
  {
   "expect": {
    "blockIndex": 1,
    "overageCharge": 0,
    "platformFee": 0,
    "total": 20000,
    "unitCharge": 20000
   },
   "input": {
    "blocks": [
     {
      "fee": 0,
      "overageRate": 0,
      "unitRate": 0.25,
      "upTo": 100000
     }
    ],
    "tariffType": "linear",
    "usage": 80000
   },
   "name": "linear_single_block"
  }
 ],
 "vocabulary": [
  "blockIndex",
  "blocks",
  "fee",
  "linear",
  "overageCharge",
  "overageRate",
  "platformFee",
  "tariffType",
  "three_part",
  "total",
  "two_part",
  "unitCharge",
  "unitRate",
  "unknown tariffType: ",
  "upTo",
  "usage"
 ]
}

Get early access to STUD the day it goes live.