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.
- Prepare
- Python
- Regex and Parsing
- Matrix Script
- Discussions
Matrix Script
Matrix Script
Sort by
recency
|
604 Discussions
|
Please Login in order to post a comment
!/bin/python3
import math import os import random import re import sys
first_multiple_input = input().rstrip().split()
n = int(first_multiple_input[0])
m = int(first_multiple_input[1])
matrix = [] pattern = r"(?<=[A-Za-z0-9])[^A-Za-z0-9]+(?=[A-Za-z0-9])" for _ in range(n): matrix_item = input() matrix.append(matrix_item) zipped = list(zip(*matrix)) final = "".join(ch for tup in zipped for ch in tup)
output = re.sub(pattern," ",final) print(output)