We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#!/bin/python3importre# Read the matrix dimensionsfirst_multiple_input=input().rstrip().split()n=int(first_multiple_input[0])#Numberofrowsm=int(first_multiple_input[1])#Numberofcolumns# Read the matrixmatrix=[]for_inrange(n):matrix_item=input()matrix.append(matrix_item)# Transpose the matrix to read columns as rowsdecoded_script=''.join([matrix[i][j]forjinrange(m)foriinrange(n)])# Replace non-alphanumeric characters between alphanumeric characters with a single spacecleaned_script=re.sub(r'(?<=\w)[^\w]+(?=\w)',' ',decoded_script)# Print the cleaned decoded scriptprint(cleaned_script)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Matrix Script
You are viewing a single comment's thread. Return to all comments →