Skip to content
DeepForgeby svx
All problems
EasyLinear Algebrala-155

Vectorize Column-Major

Problem

Flatten matrix A into a single list in column-major (Fortran) order.

Columns are concatenated from left to right, and entries within a column from top to bottom.

Hint

Loop over columns first, then rows, unlike row-major flattening.

Test cases

case 1
in: [[[1,2],[3,4]]]
expected: [1,3,2,4]
case 2
in: [[[1,2,3]]]
expected: [1,2,3]
case 3
in: [[[1],[2],[3]]]
expected: [1,2,3]
case 4
in: [[[1,2],[3,4],[5,6]]]
expected: [1,3,5,2,4,6]
Starter codePython
def vectorize_column_major(A):
    # Your code here
    pass

4 test cases · run your code against them in the editor