Computer Science, asked by sumukhsubramanyahk, 7 months ago

Three characters { #, *, . } represents a constellation of stars and galaxies in space. Each galaxy is demarcated by # characters. There can be one or many stars in a given galaxy. Stars can only be in shape of vowels { A, E, I, O, U } . A collection of * in the shape of the vowels is a star. A star is contained in a 3x3 block. Stars cannot be overlapping. The dot(.) character denotes empty space. Given 3xN matrix comprising of { #, *, . } character, find the galaxy and stars within them. Note: Please pay attention to how vowel A is denoted in a 3x3 block in the examples section below. Constraints 3 <= N <= 10^5 Input Input consists of single integer N denoting number of columns. Output Output contains vowels (stars) in order of their occurrence within the given galaxy. Galaxy itself is represented by # character. Time Limit 1 Examples Example 1 Input 18 * . * # * * * # * * * # * * * . * . * . * # * . * # . * . # * * * * * * * * * # * * * # * * * # * * * * . * Output U#O#I#EA Explanation As it can be seen that the stars make the image of the alphabets U, O, I, E and A respectively. com.tcs.cv.automata.ei.middleware.DocxToHtmlConverter@1aefe2ea:image1.png Example 2 Input 12 * . * # . * * * # . * . * . * # . . * . # * * * * * * # . * * * # * . * Output U#I#A Explanation As it can be seen that the stars make the image of the alphabet U, I and A. com.tcs.cv.automata.ei.middleware.DocxToHtmlConverter@1aefe2ea:image1.png

Answers

Answered by riddhibht99
2

Answer:

n = int(input())

p = []

d = {20:"U",10:"O",101:"I",0:"E",111:"A"}

for i in range(3):

p.append(input())

l = []

for i in range(n):

if p[0][i] == '#':

 l.append('#')

else:

 c = 0

 for j in range(3):

  if p[j][i] == '.':

   c+=1

 l.append(c)

if 3 in l:

n = n - l.count(3)

q = "".join("".join([str(i) for i in l]).split("3"))

else:

q = "".join([str(i) for i in l])

i,h = 0,[]

while i < n:

if q[i] == "#":

 h.append("#")

 i+=1

else:

 h.append(int(str(q[i])+str(q[i+1])+str(q[i+2])))

 i+=3

for i in h:

if i == "#":

 print("#",end="")

else:

 print(d[i],end="")

Explanation:

Similar questions