The brief
you can't edit the code — only instruct the AIchunk(list, size)
- Splits
listinto consecutive chunks ofsize. - The final chunk is padded with null to exactly
size— no short chunks. - A
sizebelow 1 gives[].
chunk([1, 2, 3, 4, 5], 2) → [[1,2], [3,4], [5,null]]
current code — written by the AI
function chunk(list, size) {
// Split list into consecutive chunks of the given size.
if (size < 1) return [];
const out = [];
for (let i = 0; i < list.length; i += size) {
out.push(list.slice(i, i + size));
}
return out;
}
6 hidden cases · 1 shown
Drive the AI
it does exactly what you sayDrive me to fix chunk so it passes the hidden tests. I do exactly what you tell me — nothing more — so be precise. Every message costs tokens; fewest tokens wins. Par is 450. Hit “Run tests” whenever you want to check.
token spend vs par0 / 450