Set the decision and its input
In this fictional offer, a block covers ten units. Two workspaces consume six and four. Pooling gives ten units and one block; rounding each workspace separately gives one plus one, two blocks. The same usage records do not imply the same billed quantity.
| Case | Input JSON |
|---|---|
| Base test | {"scope":"per-workspace","workspaceUnits":[6,4]} |
Run the supplied comparison
The comparison is about the external billing function before any internal allocation. Keep the quotation scope, workspace amounts and computed blocks together; dividing two billed blocks among departments does not turn them into one.
| Path | Output JSON |
|---|---|
| Faulty path | {"scope":"per-workspace","blocks":1} |
| Required path | {"scope":"per-workspace","blocks":2} |
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(!['pooled','per-workspace'].includes(i.scope)||!i.workspaceUnits.every(x=>smallWhole(x,1000000)))return {held:true};
const pooled=Math.ceil(i.workspaceUnits.reduce((a,b)=>a+b,0)/10);
const separate=i.workspaceUnits.reduce((a,b)=>a+Math.ceil(b/10),0);
return {scope:i.scope,blocks:corrected?(i.scope==='pooled'?pooled:separate):pooled};
};
const cases=[{"input":{"scope":"per-workspace","workspaceUnits":[6,4]},"corrected":false,"expected":{"scope":"per-workspace","blocks":1}},{"input":{"scope":"per-workspace","workspaceUnits":[6,4]},"corrected":true,"expected":{"scope":"per-workspace","blocks":2}},{"input":{"scope":"pooled","workspaceUnits":[6,4]},"corrected":true,"expected":{"scope":"pooled","blocks":1}},{"input":{"scope":"per-workspace","workspaceUnits":[0,0]},"corrected":true,"expected":{"scope":"per-workspace","blocks":0}},{"input":{"scope":null,"workspaceUnits":[6,4]},"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
Explicit pooling accepts one block. Two unused workspaces consume zero under the supplied zero-use rule. Unknown aggregation scope is held.
- Identify aggregation scope
- Round at that scope
- Retain billed blocks separately
Hold a missing pooling rule instead of averaging workspace usage.
| Condition | Input JSON | Expected output JSON |
|---|---|---|
| declared pooling | {"scope":"pooled","workspaceUnits":[6,4]} | {"scope":"pooled","blocks":1} |
| empty usage | {"scope":"per-workspace","workspaceUnits":[0,0]} | {"scope":"per-workspace","blocks":0} |
| scope unspecified | {"scope":null,"workspaceUnits":[6,4]} | {"held":true} |
What count belongs to the base per-workspace offer?
Show the worked answer
Two. Six rounds to one block and four rounds to another. The one-block pooled result belongs to a different stated contract.