You are viewing a single comment's thread. Return to all comments →
from re import sub n, m = map(int, input().split()) matrix = [""] * m line = "" pattern = r"[a-zA-Z0-9][^a-zA-Z0-9]+[a-zA-Z0-9]" for _ in range(n): line = input() for i in range(m): matrix[i] += line[i] def replace(match): return f"{match.group(0)[0]} {match.group(0)[-1]}" print(sub(pattern, replace, "".join(matrix)))
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 →