You are viewing a single comment's thread. Return to all comments →
import re
first_multiple_input = input().rstrip().split()
n = int(first_multiple_input[0]) m = int(first_multiple_input[1])
matrix = []
for _ in range(n): matrix_item = input() matrix.append(matrix_item[:m])
text = ''.join(matrix) assigned_text=[]
for i in range(m): for j in range(i,len(text),m): assigned_text.append(text[j])
print(re.sub(r'(?<=[0-9a-zA-Z])[!,@,#,$,%,&,\s]+(?=[0-9a-zA-Z])',' ',''.join(assigned_text)))
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 →
import re
first_multiple_input = input().rstrip().split()
n = int(first_multiple_input[0]) m = int(first_multiple_input[1])
matrix = []
for _ in range(n): matrix_item = input() matrix.append(matrix_item[:m])
text = ''.join(matrix) assigned_text=[]
for i in range(m): for j in range(i,len(text),m): assigned_text.append(text[j])
print(re.sub(r'(?<=[0-9a-zA-Z])[!,@,#,$,%,&,\s]+(?=[0-9a-zA-Z])',' ',''.join(assigned_text)))