Computer Science, asked by navyashrees, 11 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.

Answers

Answered by annu2283
0
  1. 2-28: (5-)9+(@)5+5 7-()14
Answered by kushwahakuldeep321
7

Answer:

Explanation:

#Input_for_start_&_Galaxy_one_by_one

n=int(input())

r1=""

r2=""

r3=""

if 3 <= n <= 10**5:

   

   for i in range(3):

       

       

       for j in range(n):

           if i==0:

               r1+=input().replace(" ","")

           if i==1:

               r2+=input().replace(" ","")        

           if i==2:

               r3+=input().replace(" ","")                            

else:

   print("Not within range")  

 

#Main_solution  

   

def starcounter(a): #count number of "*"

   cnt=0

   for i in a:

       if i=="*":

           cnt+=1

   return cnt    

   

   

def nospacestar(line):#Divide_connected_star by 3

       n=3

       os=[]

       out = [(line[i:i+n]) for i in range(0, len(line), n)]  

       for k in out:

           os.append(k)

       return os

       

       

       

def final(rw,rw1,rw2): #final_method

   o = []

   arr=[]

   

   o=rw.replace("#","#$").split("$") #replace "#" with dollor & split graph

   o1=rw1.replace("#","#$").split("$")

   o2=rw2.replace("#","#$").split("$")

   

   ind=0

   

   #Adjustment loop for no space or connected Graph

   

   for a ,b,c in zip(o, o1,o2):

       if len(a.replace(".","").replace("#",""))>3:

           del o[ind]

           b2=nospacestar(a)

           for i in reversed(b2):

               o.insert(ind,i)    

       if len(b.replace(".","").replace("#",""))>3:

           del o1[ind]

           b2=nospacestar(b)

           for i in reversed(b2):

               o1.insert(ind,i)  

       if len(c.replace(".","").replace("#",""))>3:

           del o2[ind]

           b2=nospacestar(c)

           for i in reversed(b2):

               o2.insert(ind,i)    

       ind+=1    

   

   #Counting Number of star to match with vowels

   for a ,b,c in zip(o, o1,o2):

       cnt=cnt1=cnt2=0

       

       cnt+=starcounter(a);

       cnt1+=starcounter(b);

       cnt2+=starcounter(c);

       p=str(cnt)+str(cnt1)+str(cnt2)

       

       if p=="132":

           

           arr.append("A")

       elif p=="333":

           arr.append("E")

           

       elif p=="313":

           arr.append("I")

       elif p=="323":

           arr.append("O")

       elif p=="223":

           arr.append("U")

       try:    

           if a[-1]=="#":

               arr.append("#")

       except:

           pass

           

   done="".join(arr)

   

   return done

#r1=*.*#***#***#***.*.#***#

#r2=*.*#*.*#.*.#******#***#

#r3=***#***#***#****.*#***#

a=final(r1,r2,r3)

print(a)    #print_output

"""

Input=

18

*

.

*

#

*

*

*

#

*

*

*

#

*

*

*

.

*

.

*

.

*

#

*

.

*

#

.

*

.

#

*

*

*

*

*

*

*

*

*

#

*

*

*

#

*

*

*

#

*

*

*

*

.

*

Output=

U#O#I#EA

       

       

       

   

   

Similar questions