DEV Community

Discussion on: Daily Challenge #104 - Matrixify

Collapse
 
qm3ster profile image
Mihail Malo

What should the output for n other than 1, 2, 5, 10, 25 and 50 be?

Collapse
 
stanciudragosioan profile image
StanciuDragosIoan

It should build n columns. Regardless if there is some remainder or not, the remainder should just be put in a column of itself (which will contain less elements compaired to the other).

Collapse
 
qm3ster profile image
Mihail Malo

You mean a row? A row where only m<n out of n columns are populated?

Thread Thread
 
stanciudragosioan profile image
StanciuDragosIoan

Hi, the function should build columns, say you have only 9 indexes and build 3 columns:

Say array is [0,1,2,3,4,5,6,7,8]

Your columns will be:

0 3 6
1 4 7
2 5 8

That's the output in the console, of course the 'columns' can be simple arrays, but the elements have to be pushed onto them like this.

Also, if instead of 9 items you have say 11 -> [0,1,2,3,4,5,6,7,8,9,10], your output will be similar but the last column will be incomplete:

0 3 6 9
1 4 7 10
2 5 8

Hope this clarifies it a bit.

Thanks for reaching out =).