three characters(#,*,.) represents a constellation of stars and galaxies in space.each galaxy is demarcated by # characters.there can be one or more stars in a given galaxy.stars can only be in shape of vowels( a,e,i,o,u).a constellation of * in the shape of the vowels is a star.a star is contained in a 3×3 block.stars can be overlapping .that dot(.) character denotes empty space.want code in C
Answers
Answer:
Python 3
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