Set the decision and its input
The fictional tariff uses accounting credits, not a real supplier price. Under marginal pricing, the first ten units cost two credits each and excess units one. Under whole-band pricing, every unit costs one once quantity exceeds ten. Twelve units produce twenty-two and twelve respectively. The rule must be named before comparing totals.
| Case | Input JSON |
|---|---|
| Base test | {"units":12,"rule":"marginal"} |
Run the supplied comparison
The program evaluates the quoted function rather than guessing from the phrase “volume rate”. At ten units both functions yield twenty. At eleven they diverge to twenty-one and eleven, which gives a useful demonstration case.
| Path | Output JSON |
|---|---|
| Faulty path | {"quotedRule":"marginal","fictionalCredits":12} |
| Required path | {"quotedRule":"marginal","fictionalCredits":22} |
import assert from 'node:assert/strict';
const run=function run(i,corrected=true){
if(!Number.isInteger(i.units)||i.units<0||!['marginal','whole-band'].includes(i.rule))return {held:true};
const marginal=Math.min(i.units,10)*2+Math.max(i.units-10,0);
const whole=i.units*(i.units>10?1:2);
return {quotedRule:i.rule,fictionalCredits:corrected?(i.rule==='marginal'?marginal:whole):whole};
};
const cases=[{"input":{"units":12,"rule":"marginal"},"corrected":false,"expected":{"quotedRule":"marginal","fictionalCredits":12}},{"input":{"units":12,"rule":"marginal"},"corrected":true,"expected":{"quotedRule":"marginal","fictionalCredits":22}},{"input":{"units":10,"rule":"marginal"},"corrected":true,"expected":{"quotedRule":"marginal","fictionalCredits":20}},{"input":{"units":11,"rule":"marginal"},"corrected":true,"expected":{"quotedRule":"marginal","fictionalCredits":21}},{"input":{"units":11,"rule":"whole-band"},"corrected":true,"expected":{"quotedRule":"whole-band","fictionalCredits":11}},{"input":{"units":12,"rule":null},"corrected":true,"expected":{"held":true}}];
for(const test of cases){const actual=await run(test.input,test.corrected);assert.deepEqual(actual,test.expected);console.log(actual);}
Choose from the boundary evidence
A quotation lacking the piecewise rule remains held even if one total happens to agree. The ten-unit match alone cannot distinguish the tariffs.
- Read the piecewise function
- Run threshold and first excess
- Compare using the stated rule
Do not infer a tariff from one coincident total.
| Condition | Input JSON | Expected output JSON |
|---|---|---|
| ten-unit tie | {"units":10,"rule":"marginal"} | {"quotedRule":"marginal","fictionalCredits":20} |
| first excess unit | {"units":11,"rule":"marginal"} | {"quotedRule":"marginal","fictionalCredits":21} |
| whole-band first excess | {"units":11,"rule":"whole-band"} | {"quotedRule":"whole-band","fictionalCredits":11} |
| unstated billing rule | {"units":12,"rule":null} | {"held":true} |
Does a matching total at ten establish marginal pricing?
Show the worked answer
No. Both yield twenty there. At eleven, marginal gives twenty-one while whole-band gives eleven; obtain the stated rule and retain both tests.