I am trying to wrap my head around the following:
We have the following example array: var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
We have user input N
as a parameter.
For the sake of this example, let's assume that N = 3
.
After that, let's define the var blockSize = 2 * N
The example array arr
then has to be split into chunks like these:
[0, 0, 0, 1, 2, 3], [1, 2, 3, 4, 5, 6], [4, 5, 6, 7, 8, 9], [7, 8, 9, 10, 11, 12], [10, 11, 12, 0, 0 ,0]
Note that this is a perfect example where numbers get split perfectly because of the parameter we gave. I need this to be working even with cases, where it won't be so perfect. In that case, zeros should be added to the end of the last chunk to have it properly sized (N*2).