# Constellation Problem(TCS CodeVita)

## Constellation Problem

Constellation Problem is one of the problem that was asked in previous year TCS CodeVita Exam. If you using C++ or Java you have to use the concept of HashMap or STL for solving the particular problem, in case you prefer to code in Python, try to use dictionaries for solving the problem. Here in this article we have tried to explain the problem using C++ Code ## Constellation Problem(TCS CodeVita)

### Problem Description

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 the 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 3×3 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 3×3 block in the examples section below.

Constraints

• 3 <= N <= 10^5

Input

• Input consists of a single integer N denoting the number of columns.

Output

• The output contains vowels (stars) in order of their occurrence within the given galaxy. The galaxy itself is represented by the # character.

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.

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.

Possible solution:

Input:

12

* . * # . * * * # . * .

* . * # . . * . # * * *

* * * # . * * * # * . *

## Solution for Constellation Problem

`#include<bits/stdc++.h>using namespace std; int main(){    int n;cin>>n;    char co[n];    for(int i=0;i<3;i++)    {        for(int j=0;j<n;j++)        cin>>co[i][j];    }    for(int i=0;i<n-2;i++)    {        if(co[i]=='#') {cout<<"#";continue;}        if(co[i]=='.' && co[i+1]=='*' && co[i+2]=='.')        {            if(co[i]=='*' && co[i+1]=='*' && co[i+2]=='*')            if(co[i]=='*' and co[i+1]=='.' and co[i+2]=='*')            cout<<"A";i+=2;continue;        }        if(co[i]=='*' and co[i+1]=='*' and co[i+2]=='*')        {            if (co[i]=='*' and co[i+1]=='*' and co[i+2]=='*')            {                if (co[i]=='*' and co[i+1]=='*' and co[i+2]=='*')                {cout<<"E";i+=2;continue;}            }            else if(co[i]=='.' and co[i+1]=='*' and co[i+2]=='.')            {                 if (co[i]=='*' and co[i+1]=='*' and co[i+2]=='*')                 {cout<<"I";i+=2;continue;}            }            else if(co[i]=='*' and co[i+1]=='.' and co[i+2]=='*')            {                if(co[i]=='*' and co[i+1]=='*' and co[i+2]=='*')                {cout<<"O";i+=2;continue;}            }        }        if(co[i]=='*' and co[i+1]=='.' and co[i+2]=='*')        if(co[i]=='*' and co[i+1]=='.' and co[i+2]=='*')        if(co[i]=='*' and co[i+1]=='*' and co[i+2]=='*')        {cout<<"U";i+=2;continue;}    }}`
`n=int(input())co=[]for i in range(3):co.append(list(input().split()))i=0while i<n-2:    if co[i]=='#':        print("#",end="")        i+=1        continue    if co[i]=='.' and co[i+1]=='*' and co[i+2]=='.':        if co[i]=='*' and co[i+1]=='*' and co[i+2]=='*':            if co[i]=='*' and co[i+1]=='.' and co[i+2]=='*':                print('A',end="")    if co[i]=='*' and co[i+1]=='*' and co[i+2]=='*':        if co[i]=='*' and co[i+1]=='*' and co[i+2]=='*':            if co[i]=='*' and co[i+1]=='*' and co[i+2]=='*':                print('E',end="")                i+=3                continue        elif co[i]=='.' and co[i+1]=='*' and co[i+2]=='.':            if co[i]=='*' and co[i+1]=='*' and co[i+2]=='*':                print('I',end="")                i+=3                continue        elif co[i]=='*' and co[i+1]=='.' and co[i+2]=='*':            if co[i]=='*' and co[i+1]=='*' and co[i+2]=='*':                print('O',end="")                i+=3                continue    if co[i]=='*' and co[i+1]=='.' and co[i+2]=='*':        if co[i]=='*' and co[i+1]=='.' and co[i+2]=='*':            if co[i]=='*' and co[i+1]=='*' and co[i+2]=='*':                print('U',end="")                i+=3                continue    i+=1`