79103831

Date: 2024-10-18 22:24:44
Score: 0.5
Natty:
Report link
$chunk_size = 10
@(1..100) | % { $c = @(); $i = 0 } { if ($i % $chunk_size -eq 0) { $c += ,@() }; $c[-1] += $_; $i++ } 
$c
$chunk_size = 10 # Set desired chunk size
@(1..100) | % `
    { # Initialize loop variables
        $c = @(); # Cumulating array of chunks
        $i = 0;   # Incrementing index
    } {
        if ($i % $chunk_size -eq 0) { # If the index is divisible by chunk size
            $c += ,@() # Add another chunk to the accumulator
        }
        $c[-1] += $_; # Add current element to the last chunk
        $i++          # Increment
    }
$c
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: posh