Computer Science, asked by yashwanthvardhan456, 4 months ago


Nandini has a complex matrix script. The matrix script is a N X M grid of strings. It consists of alphanumeric characters and symbols (!,@,#,$,%,&). To
decode the script, Nandini needs to read each column and select only the alphanumeric characters and connect them. She reads the column from top
to bottom and starts reading from the leftmost column. If there are symbols in the decoded script, then Nandini removes them for better
readability. Alphanumeric characters consist of: [A-Z, a-z, and 0-9].
Input Format
The first line contains space-separated integers N (rows) and M (columns) respectively.
The next N lines contain the row elements of the matrix script separated by space.
Output Format
Print the decoded matrix script.
Sample Input:
73
Tsi
h % x
i i #$
SM#
$a &
#t%
ir!
Output:
ThisisMatrix
Select the Language for this assignment Python 3​

Answers

Answered by abhishekkumarcs19
1

Answer:

import re

 

(N,M) = map(int, raw_input().strip().split())

 

matrix = []

 

for i in range(N):

   matrix.append(raw_input())

 

phrase = ""

 

for j in range(M):

   for i in range(N):

       phrase += str(matrix[i][j])

 

# # phrase = "q"+str(phrase)+"q"

# print phrase

print re.sub(r'\b[^a-zA-Z0-9]+\b', r' ', phrase)

Explanation:

Answered by nikhil18bce7144
0

Answer:

a,b=map(int,input().split())

l=[]

for i in range(a):

 x=list(map(str,input().split()))

 l.append(x)

for i in range(b):

 for j in range(a):

   if l[j][i].isalnum():

     print(l[j][i],end="")

Explanation:

Similar questions