Set the decision and its input
The fictional offer allows five operations per second and one thousand per month. Demand is twenty in one second and one hundred in the month. Monthly demand fits, but the burst does not. Overall fit requires both under this supplied buying rule.
| Case | Input JSON |
|---|---|
| Base test | {"perSecond":5,"perMonth":1000,"oneSecondDemand":20,"monthDemand":100} |
Run the supplied comparison
This is a limit comparison, not an invented retry or queue feature. Whether operations may wait is a separate supplied business condition; no automatic delay is assumed to rescue an immediate task.
| Path | Output JSON |
|---|---|
| Faulty path | {"monthFits":true,"burstFits":false,"overallFits":true} |
| Required path | {"monthFits":true,"burstFits":false,"overallFits":false} |
import assert from 'node:assert/strict';
const smallWhole=(x,max)=>Number.isSafeInteger(x)&&x>=0&&x<=max;
const run=function run(i,corrected=true){
if(![i.perSecond,i.perMonth,i.oneSecondDemand,i.monthDemand].every(x=>smallWhole(x,1000000)))return {held:true};
const monthFits=i.monthDemand<=i.perMonth,burstFits=i.oneSecondDemand<=i.perSecond;
return {monthFits,burstFits,overallFits:corrected?monthFits&&burstFits:monthFits};
};
const cases=[{"input":{"perSecond":5,"perMonth":1000,"oneSecondDemand":20,"monthDemand":100},"corrected":false,"expected":{"monthFits":true,"burstFits":false,"overallFits":true}},{"input":{"perSecond":5,"perMonth":1000,"oneSecondDemand":20,"monthDemand":100},"corrected":true,"expected":{"monthFits":true,"burstFits":false,"overallFits":false}},{"input":{"perSecond":5,"perMonth":1000,"oneSecondDemand":5,"monthDemand":1000},"corrected":true,"expected":{"monthFits":true,"burstFits":true,"overallFits":true}},{"input":{"perSecond":null,"perMonth":1000,"oneSecondDemand":20,"monthDemand":100},"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
Exactly five per second and one thousand per month fit the inclusive limits. An unknown burst allowance prevents the combined decision.
- Read both time scales
- Compare each demand separately
- Require both for immediate fit
An unstated burst limit remains unknown.
| Condition | Input JSON | Expected output JSON |
|---|---|---|
| both exact limits | {"perSecond":5,"perMonth":1000,"oneSecondDemand":5,"monthDemand":1000} | {"monthFits":true,"burstFits":true,"overallFits":true} |
| unknown burst allowance | {"perSecond":null,"perMonth":1000,"oneSecondDemand":20,"monthDemand":100} | {"held":true} |
Can the base offer be marked suitable from the monthly count alone?
Show the worked answer
No. One hundred fits one thousand, but twenty exceeds five in the required second. Record the burst failure separately.