Transpose and Flatten

Sort by

recency

|

324 Discussions

|

  • + 0 comments

    import numpy N, M = list(map(int, input().strip().split())) my_array = numpy.array([input().strip().split()[:M] for _ in range(N)], dtype=int) print(numpy.transpose(my_array)) print(numpy.sort(numpy.transpose(my_array).flatten()))

  • + 0 comments

    import numpy import numpy as np

    n, m = map(int, input().strip().split()) matrix = np.array([input().strip().split() for _ in range(n)], dtype=int) transpose = np.transpose(matrix) flatten = matrix.flatten() print(transpose) print(flatten)

  • + 0 comments

    import numpy n,m = input().split() og=numpy.array([[s for s in map(int,input().split())] for _ in range(int(n))]) print(numpy.transpose(og)) print(og.flatten())

  • + 0 comments
    import numpy as np
    
    n, m = map(int, input().split())
    matrix = np.array([list(map(int, input().split())) for _ in range(n)])
    print(np.transpose(matrix))
    print(matrix.flatten())
    
  • + 0 comments

    import numpy as np

    n,m = input().split() arr = [] for i in range(int(n)): num = list(map(int, input().split())) arr.append(num) myarr = np.array(arr) print(np.transpose(myarr)) print(myarr.flatten())