Transpose and Flatten

  • + 0 comments

    With the help of regEx :

    import sys, re, numpy
    
    
    entry = sys.stdin.read().replace(' ', '').splitlines()[1:]
    
    my_array = []
    for i in range(len(entry)):
       my_array.append([int(i) for i in re.findall(r"\d", entry[i])])
    
    my_array = numpy.array(my_array)
    print(numpy.transpose(my_array), my_array.flatten(), sep='\n')