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
|
567 Discussions
|
Please Login in order to post a comment
matrix = [list(i) for i in zip(*matrix)] matrix = sum(matrix, []) string = "".join(matrix)
pattern = "[A-Za-z0-9][^A-Za-z0-9]+[A-Za-z0-9]"
betweens = re.findall(pattern, string) for substr in betweens: string = string.replace(substr[1:-1], ' ', 1)
print(string)
this is my code, I replace positive lookbehind and positivei lookahead condition into \b meta string.
my program is in Process but it passes all the tests, does it mean it is wrong ?
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 = []
for _ in range(n): matrix_item = input() matrix.append(matrix_item)
try these code decoded_script = re.sub(r'(?<=\w)([^\w]+)(?=\w)', ' ', decoded_script)
print(decoded_script)