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.
import sys
import re
p = re.compile(r'(?<=\w)([\$#\%\s]+)(?=\w)')
dem = sys.stdin.readline().split();
r = int(dem[0])
c = int(dem[1])
rows = [l for l in sys.stdin]
text = "";
for i in range(c):
for j in range(r):
text = text+rows[j][i]
print(p.sub(' ',text))
Cookie support is required to access HackerRank
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 sys import re p = re.compile(r'(?<=\w)([\$#\%\s]+)(?=\w)') dem = sys.stdin.readline().split(); r = int(dem[0]) c = int(dem[1]) rows = [l for l in sys.stdin] text = ""; for i in range(c): for j in range(r): text = text+rows[j][i] print(p.sub(' ',text))