Page Contents

**Analyse the Pattern SOLUTION SSEC0010**

**Analyse the Pattern SOLUTION SSEC0010**

**Hey guys I hope your all doing great.**

**Let’s Discuss the Logic :**

Now what comes in your mind first after seeing the question. As *I know there are several pattern questions which are mostly related to matrix. Is this the same thing?lets find it out.*

Now if you see

S

S S

S S E

S S E C

S S E

S S

S

S

S S

S S E

S S E C

S S E ………………………..

the above pattern it looks so easy to print it using matrix but here this is not the case we have to print the ascii values of the letters.

If you read the question it ends with ** “[All alphabets are capital]” ** which means our first step towards this problem is solved we know we can use a function to take values in capital letters.

**HOLD ON!!** are we going in right direction because if we see the input value and output our theory falls apart.

Now if we see the input we can clearly see that **“2” ** is No. of Test Case and **“5”** & **“4” **are number of rows. We are still trying to figure out what the questions wants from us we are not even near to the LOGIC!.

As, the inputs are number our First theory fall apart which was taking “the pattern input using matrix and in UpperCase”. This is how it was going to be at the first place but now we see, Our **work is been made 80%** easier. How?

### So lets dive in with the 2 Theory,

Now as we already know the pattern and how it looks, is there a chance of change in pattern NO! right basically we are not even taking Pattern as an Input here **we are taking Row inputs. **

**Now **what we can do here is that we need to assign values to the letter as per ascii.

**If we choose Row 1** “Remember starting row value is 1 not 0”

Pattern: **S**

If we are choosing Row 1 what is the value of N? then. Yes your right it’s 1 only. Now if **n=1 which means Row 1.**

** What is the ASCII Value of Capital S?** Its 83

**Right!.**

**Now I hope this makes it clear how we are going to approach this ****question**** if you still have doubts comment down below.**

**This logic is very very simply explained keeping in mind that if its first time for someone.**

Let’s see few more Inputs and Outputs:

**if n= 6** *“Count the rows from the pattern to know”*

*Output: 83 83 “S S”*

* *

*Now *Lets make our own pattern and finish this Question with better understanding.

**Pattern: **

A

A B C

A B C D

A B C D E F G

A C G E H

A B C D

A B C

A B

A

*What a pattern isn’t it.*

*Now let’s solve this using our logic (2 theory)*

**Input :** n = 4

**Output :** 65 66 67 68 69 70 71 ” A B C D E F G”

**Input:** n = 5

**Output:** 65 67 71 69 72 “A C G E H“

I hope this logic will help you to write down your code Now in this question we are using test cases Remember to use that. *And we all know Speciality of Codechef is TestCases.*

*Still have doubts and if you find that this logic is wrong do let us know it will help many people.*

*Keep Coding Guys.*