hacker rank python (matrix script)
MATRIX SCRIPT
//HARDEST IN THE SOLUTIONS
import re
import sys
nm = input().split()
n = int(nm[0])
m = int(nm[1])
matrix = []
for _ in range(n):
matrix_item = input()
matrix.append(matrix_item)
string = ""
for i in range(m):
string += "".join(matrix[j][i] for j in range(n))
res = re.sub(r"(?<=\w)[!@#$%&\s]+(?=\w)",r" ",string)
sys.stdout.write(res)
Comments