71% found this document useful (7 votes)
16K views

Wipro PRP

The document describes a problem to write a function that takes two string inputs - an incomplete word and a string of possible complete words separated by colons. The function should return the possible complete words that match the incomplete word, with any missing character replaced. It provides an example where the incomplete word is "Fi_er", the possible words are "Fever:filer:Filter: Fixer:fiber:fibre:tailor:offer", and the correct output is "FILER:FIXER FIBER". It also describes the requirements that the output words be uppercase and in the same order as the possible words input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
71% found this document useful (7 votes)
16K views

Wipro PRP

The document describes a problem to write a function that takes two string inputs - an incomplete word and a string of possible complete words separated by colons. The function should return the possible complete words that match the incomplete word, with any missing character replaced. It provides an example where the incomplete word is "Fi_er", the possible words are "Fever:filer:Filter: Fixer:fiber:fibre:tailor:offer", and the correct output is "FILER:FIXER FIBER". It also describes the requirements that the output words be uppercase and in the same order as the possible words input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 82

IDENTIFY POSSIBLE WORDS: Identify possible words: Detective Bakshi while solving a case stumbled upon a letter

which had many words whose one character was missing ie. one character in the word was replaced by an
underscore. For e.g. “Fi_ er”. He also found thin strips of paper which had a group of words separated by colons,
for e.g. “Fever:filer:Filter: Fixer:fiber:fibre:tailor:offer”. He could figure out that the word whose one character
was missing was one of the possible words from the thin strips of paper. Detective Bakshi has approached you (a
computer programmer) asking for help in identifying the possible words for each incomplete word.

You are expected to write a function to identify the set of possible words.

The function identity PossibleWords takes two strings as input, where input1 contains the incomplete word, and
input2 is the string containing a set of words separated by colons

The function is expected to find all the possible words from input2 that can replace the incomplete word input1,
and then return the final output string in the format specified below See below examples carefully to understand
the format of input1, input2 and output

Example1: input1= "Fi_er” input2=”Fever:filer:Filter: Fixer:fiber:fibre:tailor:offer” output= "FILER:FIXER FIBER”


Note that-

● Output string should contain the set of all possible words that can replace the incomplete word in input1

● all words in the output string should be stored in UPPER-CASE

● all words in the output string should appear in the order in which they appeared in input2, i.e. in the above
example we have FILER followed by FIXER followed by FIBER.

● While searching for input1 in input2, the case of the letters are ignored, i.e Fi er matches with filer as well as
Fixer as well as "fiber”.

● IMPORTANT: If none of the words in input2 are possible candidates to replace input1, the output string should
be “ERROR-009”.

using System;

public class Program

public static void Main()

string input1=Console.ReadLine();

string input2=Console.ReadLine();

input1=input1.ToUpper();

input2=input2.ToUpper();

String word="", res="";

int i,j;

String[] words = input2.Split(':');

for(i=0;i<words.Length;i++)

word = words[i];

if(input1.Length==word.Length)
{

for(j=0;j<input1.Length;j++)

if((input1[j]!='_')&&(input1[j]!=word[j]))

break;

if(j==input1.Length)

res=res + word+":";

Console.WriteLine(res.Length==0?"ERROR-009":res.Substring(0,res.Length-1));

ALTERNATE ADD SUM Given a number N (1<=N<=10000), and an option opt=1 or 2, find the result as per below
rules, If opt=1, Result= N-(N-1)+(N-2) - (N-3) +(N-4) ......till 1 If opt=2 Result= N+(N-1)- (N-2) + (N-3) - (N-4)..... till 1
Example1: IfN = 6, and opt=1 Result =6-5+4-3+2-1=3 Example2 If N = 6, and opt=2 Result =6+5-4+3-2+1= 9 The
function prototype should be as belowint AddSub(int N, int opt);

Code:

using System;

public class Program

public static void Main()

int N=Int32.Parse(Console.ReadLine());

int opt=Int32.Parse(Console.ReadLine());

int sum=0;

sum+=N;

N=N-1;
if(opt==2)

if(N%2==0)

while(N>0)

if(N%2==0)

sum+=N;

else

sum-=N;

N--;

else

while(N>0)

if(N%2==0)

sum-=N;

else

sum+=N;

N--;

else

if(N%2==0)

while(N>0)

if(N%2==0)

sum-=N;

else
sum+=N;

N--;

else

while(N>0)

if(N%2==0)

sum+=N;

else

sum-=N;

N--;

Console.WriteLine(sum);

FIND SUMEET SUM (Model-1) Given 5 input numbers, Sumeet has to find the sum of the smallest numbers that
can be produced using 2 digits from each of the above 5 numbers. Understanding Question: We are given five
numbers and we have to find the smallest 2-digit numbers from given five numbers i.e., For example take a
number 54110. We have to find the smallest 2-digit number that can be formed. In the first Iteration we will get 0
as the smallest number when considered as 1-digit number but we need 2-digit number so in another iteration
we’ll get 1 as smallest number so from this the smallest 2-digit number that can be formed from given number
54110 is 01.

In the similar manner we’re given 5 numbers and we have to find the smallest 2-digit number from all those
inputs given and we’ve to find the sum of all smallest 2-digit numbers acquired.

Explaining Given Test Case 1:

Input1 – 23792 – From these the smallest number that can be formed is 22.

Input2 – 37221 – From these the smallest number that can be formed is 12.

Input3 – 10270 – From these the smallest number that can be formed is 00.

Input4 – 73391 – From these the smallest number that can be formed is 13.

Input5 – 12005 – From these the smallest number that can be formed is 00.

The second part of our task is to find the sum of all these smallest 2-digit numbers and the result is 47.

Explaining Given Test Case 2:


Input1 – 26674 – From these the smallest number that can be formed is 24.

Input2 – 105 – From these the smallest number that can be formed is 01.

Input3 – 37943 – From these the smallest number that can be formed is 33.

Input4 – 95278 – From these the smallest number that can be formed is 25.

Input5 – 27845 – From these the smallest number that can be formed is 24.

The second part of our task is to find sum of all these smallest 2-digit numbers and the result is 107.

using System;

public class Program

public static void Main()

int input1=Convert.ToInt32(Console.ReadLine());

int input2=Convert.ToInt32(Console.ReadLine());

int input3=Convert.ToInt32(Console.ReadLine());

string x=input1.ToString();

string y=input2.ToString();

string z=input3.ToString();

char[] ch1=x.ToCharArray();

Array.Sort(ch1);

char[] ch2=y.ToCharArray();

Array.Sort(ch2);

char[] ch3=z.ToCharArray();

Array.Sort(ch3);

int l1=ch1.Length;

int l2=ch2.Length;

int l3=ch3.Length;

string a=Convert.ToString(ch1[l1-1])+Convert.ToString(ch1[l1-2]);

string b=Convert.ToString(ch2[l2-1])+Convert.ToString(ch2[l2-2]);

string c=Convert.ToString(ch3[l3-1])+Convert.ToString(ch3[l3-2]);

int num1=Int32.Parse(a);

Console.WriteLine(num1);

int num2=Int32.Parse(b);

Console.WriteLine(num2);
int num3=Int32.Parse(c);

Console.WriteLine(num3);

int sum=0;

sum=num1+num2+num3;

Console.WriteLine(sum);

FIND SUMEET SUM (Model-2) FindSumeetSum: Sum of smallest 3- digit numbers from given 5 numbers Given 5
input numbers, Sumeet has to find the sum of the smallest numbers that can be produced using 3 digits from each
of the above 5 numbers

Example-1 If the 5 input numbers are 23792,37221,10270,73391 and 12005 The smallest numbers that can be
produced using 3 digits from each of these are 223,122,001,133 and 001 respectively, and the sum of these
smallest numbers will be 480. Therefore, the expected result is 480

Example-2 If the 5 input numbers are 26674,105,37943,95278 and 27845, The smallest numbers that can be
produced using 3 digits from each of these are 246,015,334,257 and 245 respectively, and the sum of these
smallest numbers will be 1097. Therefore, the expected result is 1097.

NOTE- All the given 5 numbers will be >=100 and <=99999 Function prototype is as belowInt findSumeetSum(int
input1,int input2,int input3,int input4,int input5)

using System;

public class Program

public static void Main()

int input1=Convert.ToInt32(Console.ReadLine());

int input2=Convert.ToInt32(Console.ReadLine());

int input3=Convert.ToInt32(Console.ReadLine());

int input4=Convert.ToInt32(Console.ReadLine());

int input5=Convert.ToInt32(Console.ReadLine());

string x=input1.ToString();

string y=input2.ToString();

string z=input3.ToString();
string a=input4.ToString();

string b=input5.ToString();

char[] ch1=x.ToCharArray();

Array.Sort(ch1);

char[] ch2=y.ToCharArray();

Array.Sort(ch2);

char[] ch3=z.ToCharArray();

Array.Sort(ch3);

char[] ch4=a.ToCharArray();

Array.Sort(ch4);

char[] ch5=b.ToCharArray();

Array.Sort(ch5);

string c=Convert.ToString(ch1[0])+Convert.ToString(ch1[1])+Convert.ToString(ch1[2]);

string d=Convert.ToString(ch2[0])+Convert.ToString(ch2[1])+Convert.ToString(ch2[2]);

string e=Convert.ToString(ch3[0])+Convert.ToString(ch3[1])+Convert.ToString(ch3[2]);

string f=Convert.ToString(ch4[0])+Convert.ToString(ch4[1])+Convert.ToString(ch4[2]);

string g=Convert.ToString(ch5[0])+Convert.ToString(ch5[1])+Convert.ToString(ch5[2]);

int num1=Int32.Parse(c);

int num2=Int32.Parse(d);

int num3=Int32.Parse(e);

int num4=Int32.Parse(f);

int num5=Int32.Parse(g);

int sum=0;

sum=num1+num2+num3+num4+num5;

Console.WriteLine(sum);

//26674,105,37943,95278 and 27845

FIND SUMEET SUM (Model-3) FindSumeetSum: Sum of largest 3-digit numbers from given 5 numbers Given 5
input numbers, Sumeet has to find the sum of the largest numbers that can be produced using 3 digits from each
of the above 5 numbers.
Example-1 If the 5 input numbers are 23792,37221,10270,73391 and 12005, The largest numbers that can be
produced using 3 digits from each of these are 973,732,721,973 and 521 respectively and the sum of these largest
numbers will be 3920. Therefore, the expected result is 3920.

Example-2 If the 5 input numbers are 26674,105,37943,95278 and 27845 The largest numbers that can be
produced using 3 digits from each of these are 766,510,974,987 and 875 respectively and the sum of these largest
numbers will be 4112. Therefore, the expected result is 4112.

NOTE:- All the given 5 numbers will be >=100 and <=99999 Function prototype is as below – Int
findSumeetSum(int input1,int input2,int input3,int input4,int input5)

using System;

public class Program

public static void Main()

int input1=Convert.ToInt32(Console.ReadLine());

int input2=Convert.ToInt32(Console.ReadLine());

int input3=Convert.ToInt32(Console.ReadLine());

int input4=Convert.ToInt32(Console.ReadLine());

int input5=Convert.ToInt32(Console.ReadLine());

string x=input1.ToString();

int l1=x.Length;

string y=input2.ToString();

int l2=y.Length;

string z=input3.ToString();

int l3=z.Length;

string a=input4.ToString();

int l4=a.Length;

string b=input5.ToString();

int l5=b.Length;

char[] ch1=x.ToCharArray();

Array.Sort(ch1);

char[] ch2=y.ToCharArray();

Array.Sort(ch2);

char[] ch3=z.ToCharArray();

Array.Sort(ch3);
char[] ch4=a.ToCharArray();

Array.Sort(ch4);

char[] ch5=b.ToCharArray();

Array.Sort(ch5);

string c=Convert.ToString(ch1[l1-1])+Convert.ToString(ch1[l1-2])+Convert.ToString(ch1[l1-3]);

string d=Convert.ToString(ch2[l2-1])+Convert.ToString(ch2[l2-2])+Convert.ToString(ch2[l2-3]);

string e=Convert.ToString(ch3[l3-1])+Convert.ToString(ch3[l3-2])+Convert.ToString(ch3[l3-3]);

string f=Convert.ToString(ch4[l4-1])+Convert.ToString(ch4[l4-2])+Convert.ToString(ch4[l4-3]);

string g=Convert.ToString(ch5[l5-1])+Convert.ToString(ch5[l5-2])+Convert.ToString(ch5[l5-3]);

int num1=Int32.Parse(c);

int num2=Int32.Parse(d);

int num3=Int32.Parse(e);

int num4=Int32.Parse(f);

int num5=Int32.Parse(g);

int sum=0;

sum=num1+num2+num3+num4+num5;

Console.WriteLine(sum);

//26674,105,37943,95278 and 27845

//4112

ENCODED TWO STRINGS (Model-1)

You are provided with TWO words. You are expected to split each word into THREE parts each, and create a
password using the below rule –

Password = first part of word 2 + first part of word1 + third part of word1 + third part of word 2 For splitting a
given word into three parts the below approach should be used If word= "ABC", then part1-A part2=B and part3-C
If word= "ABCD", then part1=A part2=BC and part 3=D

If word= "ABCDE" then part1=A part2=BCD and part3=E

If word= "ABCDEF", then part1=AB part2=CD and part3=EF

If word= "ABCDEFG", then part1 AB part2-DCDE and part3-FG

If word "ABCDEFGH", then part1 AB part2-COEF and part3=GH and so on

i.e.,

1) If the length of the given word can be equally divided into three parts, then each part gets the same number of
letters (as seen in above examples of "ABC" and "ABCDEF")
2) If the length of the given word cannot be equally divided into three parts, then the center part i.e., part2 gets
the extra number of characters (as seen in rest of the above examples)

Let us now look at the below examples

Example 1:

input1="WIPRO"

input 2="TECHNOLOGIES" Output should be "TECHWOGIES"

Explanation - The three parts of WIPRO will be "W", "IPR" and "O"

The three parts of TECHNOLOGIES will be "TECH", "NOLO" and "GIES"

So, Password = First part of word 2 + First part of word 1+ Third part of word 1 + Third part of word2 =TECH + W +
O + GIES = TECHWOGIES

Example 2: input="MACHINE" input 2="LEARNING" Output should be "LEMANENG"

Explanation –

The three parts of MACHINE will be "MA", "CHI" and "NE"

The three parts of LEARNING will be "LE", "ARNI", and "NG"

So, Password = First part of word 2 + First part of word 1+ Third part of word 1 + Third part of word2

= LE + MA + NE + NG = LEMANENG

using System;

public class Program

public static void Main()

string str1=Console.ReadLine();

string str2=Console.ReadLine();

int l1=str1.Length;

int l2=str2.Length;

string[,] res=new String[2,3];

string[] words={str1,str2};

string password="";

for(int i=0;i<2;i++)

int l=words[i].Length;

res[i,0]=words[i].Substring(0,l/3);

res[i,1]=words[i].Substring(l/3,l-l/3);
res[i,2]=words[i].Substring(l-l/3);

password=res[1,0]+res[0,0]+res[0,2]+res[1,2];

Console.WriteLine(password);

ENCODED TWO STRINGS (Model-2)

You are provided with TWO words. You are expected to split each word into THREE parts each, and create a
password using the below rule – Password = Second part of word 1+ Second part of word 2 + First part of word 2
For splitting a given word into three parts the below approach should be used If word= "ABC",

then part1-A part2=B

and part3-C If word= "ABCD",

then part1=A part2=BC and part 3=D

If word= "ABCDE" then part1=A part2=BCD and part3=E If word= "ABCDEF",

then part1=AB part2=CD and part3=EF If word= "ABCDEFG",

then part1 AB part2-DCDE and part3-FG If word "ABCDEFGH",

then part1 AB part2-COEF and part3=GH and so on i.e., 1)

If the length of the given word can be equally divided into three parts, then each part gets the same number of
letters (as seen in above examples of "ABC" and "ABCDEF")

2) If the length of the given word cannot be equally divided into three parts, then the center part i.e., part2 gets
the extra number of characters (as seen in rest of the above examples) Let us now look at the below examples

Example 1:

input1="WIPRO" input 2="TECHNOLOGIES" Output should be "IPRNOLOTECH"

Explanation - The three parts of WIPRO will be "W", "IPR" and "O"

The three parts of TECHNOLOGIES will be "TECH", "NOLO" and "GIES"

So, Password = Second part of word 1+ Second part of word 2 + First part of word 2 = IPR + NOLO + TECH =
IPRNOLOTECH

Example 2:

input="MACHINE" input 2="LEARNING" Output should be "CHIARNILE"

Explanation - The three parts of MACHINE will be "MA", "CHI" and "NE"

The three parts of LEARNING will be "LE", "ARNI", and "NG"

So, Password = Second part of word 1+ Second part of word 2 + First part of word 2 = LE + MA + NE + NG =
LEMANENG

using System;
public class Program

public static void Main()

string str1=Console.ReadLine();

string str2=Console.ReadLine();

int l1=str1.Length;

int l2=str2.Length;

string[,] res=new String[2,3];

string[] words={str1,str2};

string password="";

for(int i=0;i<2;i++)

int l=words[i].Length;

res[i,0]=words[i].Substring(0,l/3);

res[i,1]=words[i].Substring(l/3,(l-l/3)-l/3);

res[i,2]=words[i].Substring(l-l/3);

password=res[0,1]+res[1,1]+res[1,0];

Console.WriteLine(password);

ENCODED TWO STRINGS (Model-3)

Example 1: input1="WIPRO"

input 2="TECHNOLOGIES"

Output should be "PGIESWITECH"

Explanation - The three parts of WIPRO will be "WI", "P" and "RO"

The three parts of TECHNOLOGIES will be "TECH", "NOLO" and "GIES"

So, Password = Second part of word1+ Third part of word 2 + First part of word1 + First part of word 2 =P + GIES +
WI + TECH = PGIESWITECH

Example 2:
input="MACHINE"

input 2="LEARNING"

Output should be "CHIINGMALEA"

Explanation - The three parts of MACHINE will be "MA", "CHI" and "NE"

The three parts of LEARNING will be "LEA", "RN", and "ING"

So, Password = Second part of word1+ Third part of word 2 + First part of word1 + First part of word 2 = CHI + ING
+ MA + LEA = CHIINGMALEA

Code:

using System;

//input1="WIPRO" input 2="TECHNOLOGIES"

//Output should be "IPRNOLOTECH"

//input1="MACHINE" input 2="LEARNING"

//Output should be "CHIARNILE"

public class Program

public static void Main()

string str1=Console.ReadLine();

string str2=Console.ReadLine();

int l1=str1.Length;

int l2=str2.Length;

string[,] res=new String[2,3];

string[] words={str1,str2};

string password="";

for(int i=0;i<2;i++)

int len = words[i].Length;

if(len%3==0 || len%3==1)

res[i,0] = words[i].Substring(0, len/3);

res[i,1] = words[i].Substring(len/3, (len-len/3)-len/3);

res[i,2] = words[i].Substring(len-len/3);
}

else

res[i,0] = words[i].Substring(0, len/3+1);

res[i,1] = words[i].Substring(len/3+1, len/3);

res[i,2] = words[i].Substring(len-len/3-1);

for(int a=0;a<2;a++)

for(int b=0;b<3;b++)

Console.WriteLine(res[a,b]);

password=(res[0,1]+res[1,2]+res[0,0]+res[1,0]);

Console.WriteLine(password);

ENCODED TWO STRINGS (Model-4)

Example 1:

input1="WIPRO"

input 2="TECHNOLOGIES"

Output should be "GIESPNOLOWI"

Explanation - The three parts of WIPRO will be "WI", "P" and "RO"

The three parts of TECHNOLOGIES will be "TECH", "NOLO" and "GIES"

So, Password = Third part of word2 + Second part of word1 + Second part of word2 + First part of word1

= GIES + P + NOLO + WI

= GIESPNOLOWI

Example 2:

input="MACHINE"

Input 2="LEARNING"

Output should be "INGCHIRNMA"


Explanation - The three parts of MACHINE will be "MA", "CHI" and "NE"

The three parts of LEARNING will be "LEA", "RN", and "ING"

So, Password = Third part of word2 + Second part of word1 + Second part of word2 + First part of word1

= ING + CHI + RN + MA

= INGCHIRNMA

using System;

//: input="MACHINE" input 2="LEARNING"

//Output should be "INGCHIRNMA"

//input1="WIPRO" input 2="TECHNOLOGIES"

//Output should be "GIESPNOLOWI"

public class Program

public static void Main()

string str1=Console.ReadLine();

string str2=Console.ReadLine();

int l1=str1.Length;

int l2=str2.Length;

string[,] res=new String[2,3];

string[] words={str1,str2};

string password="";

for(int i=0;i<2;i++)

int len = words[i].Length;

if(len%3==0 || len%3==1)

res[i,0] = words[i].Substring(0, len/3);

res[i,1] = words[i].Substring(len/3, (len-len/3)-len/3);

res[i,2] = words[i].Substring(len-len/3);

else

{
res[i,0] = words[i].Substring(0, len/3+1);

res[i,1] = words[i].Substring(len/3+1, len/3);

res[i,2] = words[i].Substring(len-len/3-1);

for(int a=0;a<2;a++)

for(int b=0;b<3;b++)

Console.WriteLine(res[a,b]);

password=(res[1,2]+res[0,1]+res[1,1]+res[0,0]);

Console.WriteLine(password);

ENCODED TWO STRINGS (Model-5)

Example 1:

input1="WIPRO"

input 2="TECHNOLOGIES"

Output should be "TECHWIROGIES"

Explanation –

The three parts of WIPRO will be "WI", "P" and "RO"

The three parts of TECHNOLOGIES will be "TECH", "NOLO" and "GIES"

So, Password = First part of word2 + First part of word1 + Third part of word1 + Third part of word2

= TECH + WI + RO + GIES

= TECHWIROGIES

Example 2:

input="MACHINE"

input 2="LEARNING"

Output should be "LEAMANEING"

Explanation –
The three parts of MACHINE will be "MA", "CHI" and "NE"

The three parts of LEARNING will be "LEA", "RN", and "ING"

So, Password = First part of word2 + First part of word1 + Third part of word1 + Third part of word2

= LEA + MA + NE + ING

= LEAMANEING

using System;

//input1="WIPRO" input 2="TECHNOLOGIES"

//Output should be "TECHWIROGIES"

//input1="MACHINE" input 2="LEARNING"

//Output should be ""LEAMANEING"

public class Program

public static void Main()

string str1=Console.ReadLine();

string str2=Console.ReadLine();

int l1=str1.Length;

int l2=str2.Length;

string[,] res=new String[2,3];

string[] words={str1,str2};

string password="";

for(int i=0;i<2;i++)

int len = words[i].Length;

if(len%3==0 || len%3==1)

res[i,0] = words[i].Substring(0, len/3);

res[i,1] = words[i].Substring(len/3, (len-len/3)-len/3);

res[i,2] = words[i].Substring(len-len/3);

else

{
res[i,0] = words[i].Substring(0, len/3+1);

res[i,1] = words[i].Substring(len/3+1, len/3);

res[i,2] = words[i].Substring(len-len/3-1);

for(int a=0;a<2;a++)

for(int b=0;b<3;b++)

Console.WriteLine(res[a,b]);

password=(res[1,0]+res[0,0]+res[0,2]+res[1,2]);

Console.WriteLine(password);

FIND KEY (Model-1):

Find Key: You are provided with 3 numbers :

input1, input2 and input3.

Each of these are 4 digits numbers within >=1000 and <=9999 i.e.,

1000<=input1<=9999 1000<=input2<=9999 1000<=input3<=9999

You are expected to find the key using below formula:

Key = Sum of Largest digits of each number + Sum of Second Largest digits of each number

For Example,

input1=3521, input2=2452 input3=1352

Key = (5+5+5) + (3+4+3) = 25

using System;

public class Program

public static void Main()


{

int input1=Convert.ToInt32(Console.ReadLine());

int input2=Convert.ToInt32(Console.ReadLine());

int input3=Convert.ToInt32(Console.ReadLine());

string str1=input1.ToString();

string str2=input2.ToString();

string str3=input3.ToString();

char[] ch1=str1.ToCharArray();

Array.Sort(ch1);

char[] ch2=str2.ToCharArray();

Array.Sort(ch2);

char[] ch3=str3.ToCharArray();

Array.Sort(ch3);

String L1=Convert.ToString(ch1[ch1.Length-1]);

String L2=Convert.ToString(ch2[ch2.Length-1]);

String L3=Convert.ToString(ch3[ch3.Length-1]);

String l1=Convert.ToString(ch1[ch1.Length-2]);

String l2=Convert.ToString(ch2[ch2.Length-2]);

String l3=Convert.ToString(ch3[ch3.Length-2]);

int
key=Convert.ToInt32(L1)+Convert.ToInt32(L2)+Convert.ToInt32(L3)+Convert.ToInt32(l1)+Convert.ToInt32(l2)+Con
vert.ToInt32(l3);

Console.WriteLine(key);

FIND KEY (Model-2):

You are provided with 3 numbers input1,input2,input3.

Each of these are four digit numbers within the range >=1000 and <=9999

i.e 1000<=input1<=9999 1000<=input2<=9999 1000<=input3<=9999

you are expected to find the key using the below formula

Key=

[smallest digit in the thousands place of all three numbers]

[LARGEST digit in the hundreds place of all the three numbers]

[smallest digit in the tens place of all three numbers]


[LARGEST digit in the units place of all three numbers]

for e.g if input1=3521,input2=2452,input3=1352,then Key=[1][5][2][2]=1522

using System;

public class Program

public static void Main()

int input1=Convert.ToInt32(Console.ReadLine());

int input2=Convert.ToInt32(Console.ReadLine());

int input3=Convert.ToInt32(Console.ReadLine());

int th1=input1/1000;

int h1=(input1/100)%10;

int t1=(input1/10)%10;

int u1=input1%10;

int th2=input2/1000;

int h2=(input2/100)%10;

int t2=(input2/10)%10;

int u2=input2%10;

int th3=input3/1000;

int h3=(input3/100)%10;

int t3=(input3/10)%10;

int u3=input3%10;

int minth=Math.Min(Math.Min(th1,th2),th3);

int maxh=Math.Max(Math.Max(h1,h2),h3);

int mint=Math.Min(Math.Min(t1,t2),t3);

int maxu=Math.Max(Math.Max(u1,u2),u3);

int key=minth*1000+maxh*100+mint*10+maxu;

Console.WriteLine(key);

}
FIND KEY (Model-3):

You are provided with 3 numbers input1,input2,input3.

Each of these are four digit numbers within the range >=1000 and <=9999

i.e 1000<=input1<=9999 1000<=input2<=9999 1000<=input3<=9999

you are expected to find the key using the below formula

Key=[LARGEST digit in the thousands place of all three numbers][smallest digit in the hundreds place of all the
three numbers]

[LARGEST digit in the tens place of all three numbers]

[smallest digit in the units place of all three numbers]

for e.g if input1=3521,input2=2452,input3=1352,then Key=[3][3][5][1]=3351

using System;

public class Program

public static void Main()

int input1=Convert.ToInt32(Console.ReadLine());

int input2=Convert.ToInt32(Console.ReadLine());

int input3=Convert.ToInt32(Console.ReadLine());

int th1=input1/1000;

int h1=(input1/100)%10;

int t1=(input1/10)%10;

int u1=input1%10;

int th2=input2/1000;

int h2=(input2/100)%10;

int t2=(input2/10)%10;

int u2=input2%10;

int th3=input3/1000;

int h3=(input3/100)%10;

int t3=(input3/10)%10;

int u3=input3%10;
int minth=Math.Max(Math.Max(th1,th2),th3);

int maxh=Math.Min(Math.Min(h1,h2),h3);

int mint=Math.Max(Math.Max(t1,t2),t3);

int maxu=Math.Min(Math.Min(u1,u2),u3);

int key=minth*1000+maxh*100+mint*10+maxu;

Console.WriteLine(key);

TRAVERSE ARRAY AND FIND KEY (Model-1)

Mohan has received an array of numbers The numbers in this array are special because each number consists of
two parts -a “KEY” part and a “NEXT ADDRESS” part For example, if the number in the array is 411, the leftmost
digit in the number is “4” is the “KEY part and all the remaining digits in number be “11 form the “NEXT ADDRESS
part. Mohan’s task is to start from the first array element, pick the “KEY”part go to the “NEXT ADDRESS array
element pick Its “KEY” part, go to the “NEXT ADDRESS array element, pick its “KEY part, and continue this cycle
the encounters a negative number While traversing through the array in this fashion, we need to perform an
alternate addition and subtraction of the KEYS. The result of alternate addition and subtraction of all the keys is
the expected final result. Note that we should stop traversing (traveling) through the array when a negative
number is encountered

(See Examples 1 and 2 below) Important: If the array does NOT contain any negative number, the result should be
the largest number in the array (See Example 3 below) Help Mohan by writing the code to find the FINAL Result.
Input1 represents the array of numbers, and input2 represents the number of elements in the array.

Example 1 – If the array input 1 is 74 -56 15 71 92 23 and input2 is 6 First array element = 74

Here, KEY = 7 NEXT_ADDRESS – 4 4 th array element = 92

(NOTE THAT ARRAY ELEMENT ADDRESS STARTS FROM 0, SO 4th element is 92)

Here, KEY = 9 NEXT ADDRESS = 2 2 nd array element 15

Here, KEY = 1, NEXT ADDRESS = 5 5 th array element – 23

Here KEY = 2 NEXT ADDRESS = 3 3 rd array element 71

Here, KEY 7, NEXT ADDRESS =1 1 st array element =-56

Here, KEY = 5 NEXT ADDRESS -STOP (because we have reached a negative number).

FINAL RESULT = Alternatively Add and Subtract the keys = 7+9-1+ 2-7+5= 15

using System;

public class Program

public static void Main()


{

int input2=Convert.ToInt32(Console.ReadLine());

int[] input1={74,-56,15,71,92,23};

int i, flag=0;

int max =int.MinValue;

for(i=0;i<input2;i++)

if(input1[i]<0)

flag=1;

if(input1[i]>max)

max=input1[i];

if(flag==0)

Console.WriteLine(max);

int sign=-1, res=0, key, digits, power;

i=0;

while(i<input2 && flag==1)

if(input1[i]<0)

flag=0;

input1[i]*=-1;

digits = (int)(Math.Log10(input1[i])+1);

power = (int)(Math.Pow(10, digits-1));

key = (int)input1[i]/power;

if(i==0)

res = key;

else

res = res + key*(sign=sign*-1);

i = input1[i]%power;

Console.WriteLine(res);

}
}

TRAVERSE ARRAY AND FIND KEY (Model-2)

Example 1-

1 the array input1 is{ 47,-65,51,17,29,32}

and input2 is 6

First array element 47 Here, KEY 7,NEXT ADDRESS = 4

4th array element 29 (NOTE THAT ARRAY ELEMENT ADDRESS STARTS FROM 0, So 4th element is 29)

Here, KEY 9 NEXT ADDRESS= 2 2nd array element = 51

Here, KEY 1 NEXT ADDRESS = 5 5th array element = 32

Here, KEY 2 NEXT ADDRESS=3 3rd array element 17

Here KEY 7 NEXT ADDRESS = 1 1st array element = -65

Here, KEY=5 NEXT ADDRESS - STOP (because we have reached a negative number) FINAL RESULT = Alternately
subhead and Add the key 7-9+1-2+7-5=1

Example 2 - If the array s {47,65,51,17,29,-32} and input2 is 6

First array element 47 Here KEY 7 NEXT ADDRESS=4 4th array element is 29

Here, KEY 9 NEXT ADDRESS =2 2nd may element is 51

Here KEY 1 NEXT ADDRESS=5 5th array element – 32

Here, KEY- 2 NEXT_ADDRESS-STOP (because we have reached a negative number)

FINAL RESULT Animatedly Subtract and Add the key =7-9+1-2=-3

Example 3 - the array is 47 65 51 12 29 32 54 and input2 is 7

Here we see that the array does NOT contain any negative number, so the result should be calculated as the
smallest number in the array FINAL RESULT 12

using System;

public class Program

public static void Main()

int input2=Convert.ToInt32(Console.ReadLine());

int[] input1={47,65,51,12,29,32,54};

int flag=0,k=0,key,add;

int[] a=new int[input2];

for(int i=0;i<input2;i++)

{
if(input1[i]<0)

flag=1;

break;

if(flag==0)

Array.Sort(input1);

Console.WriteLine(input1[0]);

else

key=input1[0]%10;

a[k++]=key;

input1[0]=input1[0]/10;

add=input1[0];

while(input1[add]>0)

key=input1[add]%10;

a[k++]=key;

input1[add]=input1[add]/10;

add=input1[add];

a[k++]=-(input1[add]%10);

int sum=0;

for(int i=0;i<k;i++)

if(i%2==0)

sum+=a[i];

else

sum-=a[i];

Console.WriteLine(sum);
}

FIND PASSWORD (Model-1)

password=(Number of unstable numbers*10)+Number of stable numbers


For example: If input1=12,input2=1313,input3=122,input4=678 and input5=898 ,

we see that there are THREE stable numbers i.e 12,1313 and 678 and TWO unstable numbers i.e 122 and 898

so,the password should be=(Number of Unstable numbers*10)+Number of stable numbers=

(2*10)+3=23

using System;

public class Program

public static void Main()

int input1=Convert.ToInt32(Console.ReadLine());

int input2=Convert.ToInt32(Console.ReadLine());

int input3=Convert.ToInt32(Console.ReadLine());

int input4=Convert.ToInt32(Console.ReadLine());

int input5=Convert.ToInt32(Console.ReadLine());

int[] num={input1,input2,input3,input4,input5};

int stable=0, unstable=0, i, j;

for(i=0;i<5;i++)

int[] freq = new int[10]; //frequencies of all the digits

int temp=num[i];

int maxf=0;

while(temp!=0)

int r = temp%10;

freq[r]++;

temp/=10;

if(freq[r]>maxf)

maxf=freq[r];
}

for(j=0;j<10;j++)

if(freq[j]!=0 && freq[j]!=maxf)

break;

if(j==10)

stable++;

else

unstable++;

Console.WriteLine(unstable*10 + stable);

FIND PASSWORD (Model-2)

password=(Number of stable numbers*10)+Number of unstable numbers


For example: If input1=12,input2=1313,input3=122,input4=678 and input5=898 , we see that there are THREE
stable numbers i.e 12,1313 and 678 and

TWO unstable numbers i.e 122 and 898

so,the password should be=(Number of stable numbers*10)+Number of Unstable numbers=(3*10)+1=32

using System;

public class Program

public static void Main()

int input1=Convert.ToInt32(Console.ReadLine());

int input2=Convert.ToInt32(Console.ReadLine());

int input3=Convert.ToInt32(Console.ReadLine());

int input4=Convert.ToInt32(Console.ReadLine());

int input5=Convert.ToInt32(Console.ReadLine());

int[] num={input1,input2,input3,input4,input5};

int stable=0, unstable=0, i, j;


for(i=0;i<5;i++)

int[] freq = new int[10]; //frequencies of all the digits

int temp=num[i];

int maxf=0;

while(temp!=0)

int r = temp%10;

freq[r]++;

temp/=10;

if(freq[r]>maxf)

maxf=freq[r];

for(j=0;j<10;j++)

if(freq[j]!=0 && freq[j]!=maxf)

break;

if(j==10)

stable++;

else

unstable++;

Console.WriteLine(stable*10 + unstable);

FIND PASSWORD MODEL-3

Password=Maximum of all stable numbers+Minimum of all Unstable numbers


For example:

If input1=12,input2=1313,input3=122,input4=678 and input5=898 ,

we see that there are THREE stable numbers i.e 12,1313 and 678 and

TWO unstable numbers i.e 122 and 898 s

o,the password should be=Maximum of all stable numbers+Minimum of all Unstable numbers=1313+122=1435
using System;

//12,1313,122,678,898

//password should be=Maximum of all stable numbers+Minimum of all Unstable

//numbers=1313+122=1435

public class Program

public static void Main()

int input1=Convert.ToInt32(Console.ReadLine());

int input2=Convert.ToInt32(Console.ReadLine());

int input3=Convert.ToInt32(Console.ReadLine());

int input4=Convert.ToInt32(Console.ReadLine());

int input5=Convert.ToInt32(Console.ReadLine());

int[] num={input1,input2,input3,input4,input5};

int[] Stable=new int[5];

int[] Unstable=new int[5];

int stable=0, unstable=0, i, j;

for(i=0;i<5;i++)

int[] freq = new int[10]; //frequencies of all the digits

int temp=num[i];

int maxf=0;

while(temp!=0)

int r = temp%10;

freq[r]++;

temp/=10;

if(freq[r]>maxf)

maxf=freq[r];

for(j=0;j<10;j++)

if(freq[j]!=0 && freq[j]!=maxf)


break;

if(j==10)

Stable[stable]=num[i];

stable++;

else

Unstable[unstable]=num[i];

unstable++;

Array.Sort(Stable);

Array.Sort(Unstable);

int maxstable=Stable[4];

int minunstable=Unstable[unstable+1];

int sum=maxstable+minunstable;

Console.WriteLine(sum);

/*for(int l=0;l<5;l++)

Console.WriteLine(Stable[l]);

*/

FIND PASSWORD MODEL-4

Password=sum of all stable numbers - sum of all Unstable numbers


If input1=12,input2=1313,input3=122,input4=678 and input5=898 ,

we see that there are THREE stable numbers 12,1313 and 678

and TWO unstable numbers 122 and 898

So, the password should be=sum of all stable numbers – sum of all Unstable numbers=983

using System;
//the Password should be=Sum of all stable numbers - Sum of all Unstable

//input=12,1313,122,678,898

//result=983

public class Program

public static void Main()

int input1=Convert.ToInt32(Console.ReadLine());

int input2=Convert.ToInt32(Console.ReadLine());

int input3=Convert.ToInt32(Console.ReadLine());

int input4=Convert.ToInt32(Console.ReadLine());

int input5=Convert.ToInt32(Console.ReadLine());

int[] num={input1,input2,input3,input4,input5};

int stable=0, unstable=0, i, j;

int sums=0;

int sumu=0;

for(i=0;i<5;i++)

int[] freq = new int[10]; //frequencies of all the digits

int temp=num[i];

int maxf=0;

while(temp!=0)

int r = temp%10;

freq[r]++;

temp/=10;

if(freq[r]>maxf)

maxf=freq[r];

for(j=0;j<10;j++)

if(freq[j]!=0 && freq[j]!=maxf)

break;
}

if(j==10)

stable++;

sums=sums+num[i];

else

unstable++;

sumu=sumu+num[i];

Console.WriteLine(sums-sumu);

FIND PASSWORD MODEL-5

Password=Maximum of all stable numbers - Minimum of all Unstable numbers


If input1=12,input2=1313,input3=122,input4=678 and input5=898 ,

we see that there are THREE stable numbers 12,1313 and 678 and

TWO unstable numbers 122 and 898

So, the Password should be=Maximum of all stable numbers - Minimum of all Unstable numbers=1313-122=1191

using System;

//12,1313,122,678,898 result=1191

//Password=Maximum of all stable numbers - Minimum of all Unstable numbers

public class Program

public static void Main()

int input1=Convert.ToInt32(Console.ReadLine());

int input2=Convert.ToInt32(Console.ReadLine());

int input3=Convert.ToInt32(Console.ReadLine());

int input4=Convert.ToInt32(Console.ReadLine());
int input5=Convert.ToInt32(Console.ReadLine());

int[] num={input1,input2,input3,input4,input5};

int[] Stable=new int[5];

int[] Unstable=new int[5];

int stable=0, unstable=0, i, j;

for(i=0;i<5;i++)

int[] freq = new int[10]; //frequencies of all the digits

int temp=num[i];

int maxf=0;

while(temp!=0)

int r = temp%10;

freq[r]++;

temp/=10;

if(freq[r]>maxf)

maxf=freq[r];

for(j=0;j<10;j++)

if(freq[j]!=0 && freq[j]!=maxf)

break;

if(j==10)

Stable[stable]=num[i];

stable++;

else

Unstable[unstable]=num[i];

unstable++;

}
Array.Sort(Stable);

Array.Sort(Unstable);

int maxstable=Stable[4];

int minunstable=Unstable[unstable+1];

Console.WriteLine((maxstable-minunstable));

/*for(int l=0;l<5;l++)

Console.WriteLine(Stable[l]);

*/

FIND PASSWORD MODEL-6

Password=Maximum of all Unstable numbers - Minimum of all Unstable


numbers
If input1=12,input2=1313,input3=122,input4=678 and input5=898 ,

we see that there are THREE stable numbers 12,1313 and 678

and TWO unstable numbers 122 and 898

So, the Password should be=Maximum of all Unstable numbers - Minimum of all Unstable numbers=898-122=776

using System;

//12,1313,122,678,898

//Password should be=Maximum of all Unstable numbers - Minimum of all Unstable

//Result=(numbers=898-122=776)

public class Program

public static void Main()

int input1=Convert.ToInt32(Console.ReadLine());

int input2=Convert.ToInt32(Console.ReadLine());

int input3=Convert.ToInt32(Console.ReadLine());

int input4=Convert.ToInt32(Console.ReadLine());

int input5=Convert.ToInt32(Console.ReadLine());

int[] num={input1,input2,input3,input4,input5};
int[] Stable=new int[5];

int[] Unstable=new int[5];

int stable=0, unstable=0, i, j;

for(i=0;i<5;i++)

int[] freq = new int[10]; //frequencies of all the digits

int temp=num[i];

int maxf=0;

while(temp!=0)

int r = temp%10;

freq[r]++;

temp/=10;

if(freq[r]>maxf)

maxf=freq[r];

for(j=0;j<10;j++)

if(freq[j]!=0 && freq[j]!=maxf)

break;

if(j==10)

Stable[stable]=num[i];

stable++;

else

Unstable[unstable]=num[i];

unstable++;

Array.Sort(Unstable);

int maxunstable=Unstable[4];
int minunstable=Unstable[unstable+1];

int result=maxunstable-minunstable;

Console.WriteLine(result);

FIND PASSWORD MODEL-7

Password=sum of all Unstable numbers


If input1=12,input2=1313,input3=122,input4=678 and input5=898 ,

we see that there are THREE stable numbers 12,1313 and 678

and TWO unstable numbers 122 and 898 So,

the Password should be=sum of all Unstable numbers=898+122=1020

using System;

//12,1313,122,678,898

//Password should be=Sum of all Unstable numbers

//Result=(numbers=898-122=1020)

public class Program

public static void Main()

int input1=Convert.ToInt32(Console.ReadLine());

int input2=Convert.ToInt32(Console.ReadLine());

int input3=Convert.ToInt32(Console.ReadLine());

int input4=Convert.ToInt32(Console.ReadLine());

int input5=Convert.ToInt32(Console.ReadLine());

int[] num={input1,input2,input3,input4,input5};

int sum=0;

int[] Unstable=new int[5];

int stable=0, unstable=0, i, j;

for(i=0;i<5;i++)

int[] freq = new int[10]; //frequencies of all the digits

int temp=num[i];

int maxf=0;
while(temp!=0)

int r = temp%10;

freq[r]++;

temp/=10;

if(freq[r]>maxf)

maxf=freq[r];

for(j=0;j<10;j++)

if(freq[j]!=0 && freq[j]!=maxf)

break;

if(j==10)

stable++;

else

sum=sum+num[i];

unstable++;

Console.WriteLine(sum);

FIND PASSWORD MODULE-9

Password=Maximum of all stable numbers + Minimum of all stable numbers


If input1=12,input2=1313,input3=122,input4=678 and input5=898 ,

we see that there are THREE stable numbers 12,1313 and 678

and TWO unstable numbers 122 and 898

So, the Password should be=Maximum of all stable numbers + Minimum of all stable numbers=1313 + 12=1325

using System;
//12,1313,122,678,898

//Password should be=Maximum of all stable numbers + Minimum of all stable

//Result=1313-12=1325

public class Program

public static void Main()

int input1=Convert.ToInt32(Console.ReadLine());

int input2=Convert.ToInt32(Console.ReadLine());

int input3=Convert.ToInt32(Console.ReadLine());

int input4=Convert.ToInt32(Console.ReadLine());

int input5=Convert.ToInt32(Console.ReadLine());

int[] num={input1,input2,input3,input4,input5};

int[] Stable=new int[5];

int[] Unstable=new int[5];

int stable=0, unstable=0, i, j;

for(i=0;i<5;i++)

int[] freq = new int[10]; //frequencies of all the digits

int temp=num[i];

int maxf=0;

while(temp!=0)

int r = temp%10;

freq[r]++;

temp/=10;

if(freq[r]>maxf)

maxf=freq[r];

for(j=0;j<10;j++)

if(freq[j]!=0 && freq[j]!=maxf)

break;

}
if(j==10)

Stable[stable]=num[i];

stable++;

else

unstable++;

Array.Sort(Stable);

int maxstable=Stable[4];

int minstable=Stable[stable-1];

int result=maxstable+minstable;

Console.WriteLine(result);

PERSONS AND TOKENS (Model-1)

Example 1: Input1 = 10

Input2 = {“Rajesh", “ Abdul", “Rahul”, “Priya”, “Sanjay", "Nidhi”, “Varun”, “Varsha”, “Basil”, “Asif”}

Input3 = {99, 46, 39, 102, 45, 521, 65, 4, 47, 741}

Expected output "Basil:Abdul: Sanjay"

Example 2:

Input1= 7

Input2 = ["aa", "bb", "cc", "dd", "ee", "gg"]

Inpul 3={9,89,5,0,6,65,4}

Expected output = "ee:cc:gg"

using System;

//Input1= 7

//Input = ["aa", "bb", "cc", "dd", "ee", "gg"]

//Inpul 3={9,89,5,0,6,65,4}
//Expected output = "ee:cc:gg"

//Input1 = 10

//Input2 = {“Rajesh", “ Abdul", “Rahul”, “Priya”, “Sanjay", "Nidhi”, “Varun”, “Varsha”, “Basil”, “Asif”}

//Input3 = {99, 46, 39, 102, 45, 521, 65, 4, 47, 741}

//Expected output "Basil:Abdul: Sanjay"

public class Program

public static void Main()

int input1=Int32.Parse(Console.ReadLine());

string[] input2=new
string[]{"Rajesh","Abdul","Rahul","Priya","Sanjay","Nidhi","Varun","Varsha","Basil","Asif"};

int[] input3={99, 46, 39, 102, 45, 521, 65, 4, 47, 741};

int i,x=0,y=0,z=0,flag=0;

int[] a=new int[input1];

for(int m=0;m<input1;m++)

a[m]=input3[m];

Array.Sort(a);

for(i=0;i<input1-2;i++)

if(a[i+1]-a[i]==1 && a[i+2]-a[i+1]==1)

flag=1;

x=a[i+2];

y=a[i+1];

z=a[i];

break;

if(flag==0)
{

Console.WriteLine("NONE");

int fi=0,si=0,ti=0;

for(i=0;i<input1;i++)

if(x==input3[i])

{fi=i;}

if(y==input3[i])

{si=i;}

if(z==input3[i])

{ ti=i;}

Console.Write(input2[fi]+":"+input2[si]+":"+input2[ti]);

PERSONS AND TOKENS (Model-2)

Example 1: Input1 = 10

Input2 = {“Rajesh","Abdul”, "Rahul”, "Priya","Sanjay", "Nidhi", “Varun" ,”Varsha”, “Basil", “Asif”)

Input3 = {99,46,39,102,45,521,65,4,47,741}

Expected output = "Sanjay:Abdul:Basil"

Example 2:

Input1= 17

Input2={“aa","bb",” cc”,” dd”, "ee”, “ff”,”gg")

Input3 = {9,89,5,0,6,65,4}

Expected output ="gg:cc:ee "

Example 3:

Input1 = 4

Input2 = {"Priya", "Soumya" ,"Sam”, “Vidya”}

Input3 = {9,76,8,23}

Expected output = "NONE"

using System;
//Input1= 7

//Input = ["aa", "bb", "cc", "dd", "ee", "gg"]

//Inpul 3={9,89,5,0,6,65,4}

//Expected output = "ee:cc:gg"

//Input1 = 10

//Input2 = {“Rajesh", “ Abdul", “Rahul”, “Priya”, “Sanjay", "Nidhi”, “Varun”, “Varsha”, “Basil”, “Asif”}

//Input3 = {99, 46, 39, 102, 45, 521, 65, 4, 47, 741}

//Expected output "Basil:Abdul: Sanjay"

public class Program

public static void Main()

int input1=Int32.Parse(Console.ReadLine());

string[] input2=new
string[]{"Rajesh","Abdul","Rahul","Priya","Sanjay","Nidhi","Varun","Varsha","Basil","Asif"};

int[] input3={99, 46, 39, 102, 45, 521, 65, 4, 47, 741};

int i,x=0,y=0,z=0,flag=0;

int[] a=new int[input1];

for(int m=0;m<input1;m++)

a[m]=input3[m];

Array.Sort(a);

for(i=0;i<input1-2;i++)

if(a[i+1]-a[i]==1 && a[i+2]-a[i+1]==1)

flag=1;

x=a[i];

y=a[i+1];

z=a[i+2];

break;
}

if(flag==0)

Console.WriteLine("NONE");

int fi=0,si=0,ti=0;

for(i=0;i<input1;i++)

if(x==input3[i])

{fi=i;}

if(y==input3[i])

{si=i;}

if(z==input3[i])

{ ti=i;}

Console.Write(input2[fi]+":"+input2[si]+":"+input2[ti]);

USER ID GENERATION MODULE-1

Let us see a few examples

Example-1 - If the participant's details are as below

First Name = Ray

Last Name =Roy

PIN = 560037

N= 6

Step1 - Length of Last_Name is less than the Length of First_Name, so the Smaler Name is “Roy” and the Longer
Name is “Rajiv”

Step2 - The user id will be = Last Letter of the smaller name +Entre word in the longer name + Digit at position N in
the PIN when traversing the PIN from left to right +Digit at position N in the PIN when traversing the PIN from
right to left

=Last Letter of “Roy”+ Entre word in Rajiv+ 6th Digit of Pin from left + 6th Digit of PIN from right

=y+ Rajiv+7+5
Therefore, user-id=yRajiv75

Step3 -Toggle the alphabet in the user-id. So,user-id = YrAJIV75

using System;

/*Rajiv

Roy

560037

YrAJIV75

*/

public class Program

public static void Main()

string input1=Console.ReadLine();

string input2=Console.ReadLine();

string input3=Console.ReadLine();

string input4=Console.ReadLine();

int s1=input1.Length;

int s2=input2.Length;

String longer="";

String smaller="";

String output1="";

if(s1==s2)

if(input1.CompareTo(input2)>0)

longer=input1;

smaller=input2;

else

longer=input2;

smaller=input1;

}
}

if(s1>s2)

longer=input1;

smaller=input2;

else if(s1<s2)

longer=input2;

smaller=input1;

String pin=input3+"";

String output=smaller[(smaller.Length-1)]+longer+pin[(Int32.Parse(input4)-1)]+pin[(pin.Length-
Int32.Parse(input4))];

for(int i=0;i<output.Length;i++)

if(Char.IsLower(output[i]))

output1+=Char.ToUpper(output[i]);

else

output1+=Char.ToLower(output[i]);

Console.WriteLine(output1);

USER ID GENERATION MODEL-3

Example-1 –

If the participant's details are as below –

First Name Rajiv

Last Name = Roy

PIN = 560037
N=6

Step1 - Length of Last Name is less than the Length of First Name, so the Smaller Name is "Roy and the Longer Name
is "Rajiv“ Step2 - The user-id will be

= Last Letter of the longer name + Entire word of the smaller name + Digit at position N in the PIN when traversing
the PIN from left to right + Digit at position N in the PIN when traversing the PIN from right to left

= Last Letter of “Rajiv” + Entire word of “Roy” + 6th Digit of pin from left + 6th Digit of pin from right

= v + Roy + 7 + 5

Therefore, user-id = vRoy75

Step3 -Toggle the alphabets in the user-id = VrOY75

using System;

/*

Rajiv

Roy

560037

VrOY75

*/

public class Program

public static void Main()

string input1=Console.ReadLine();

string input2=Console.ReadLine();

string input3=Console.ReadLine();

string input4=Console.ReadLine();

int s1=input1.Length;

int s2=input2.Length;

String longer="";

String smaller="";

String output1="";

if(s1==s2)

if(input1.CompareTo(input2)>0)
{

longer=input1;

smaller=input2;

else

longer=input2;

smaller=input1;

if(s1>s2)

longer=input1;

smaller=input2;

else if(s1<s2)

longer=input2;

smaller=input1;

String pin=input3+"";

String output=Convert.ToString(longer[longer.Length-1])+smaller+pin[(Int32.Parse(input4)-
1)]+pin[(pin.Length-Int32.Parse(input4))];

for(int i=0;i<output.Length;i++)

if(Char.IsLower(output[i]))

output1+=Char.ToUpper(output[i]);

else

output1+=Char.ToLower(output[i]);

}
}

Console.WriteLine(output1);

ENCODED THREE STRINGS (Model-1)

Anand was assigned the task of coming up with an encoding mechanism for any given three strings. He has come
up with the following plan. Step ONE: Given any three strings, break each string into 3 parts each. For example- if
the three strings are below:

Input 1: “John”

Input 2: “Johny”

Input 3: “Janardhan”

“John” should be split into “J”, “oh”, “n,” as the FRONT, MIDDLE and END part, respectively.

“Johny” should be split into “Jo”, “h”, “ny” as the FRONT, MIDDLE and END, respectively.

“Janardhan” should be split into “Jan”, “ard”, “han” as the FRONT, MIDDLE and END part, respectively.

Step TWO:

Concatenate (join) the FRONT, MIDDLE and END parts of the string as per the below specified concatenation –
rule to from three Output strings.

Output1: FRONT part of input 1 + FRONT part of input 2 + FRONT part of input 3

Output2: MIDDLE part of input1 + MIDDLE part of input2 + MIDDLE part of input3

Output3: END part of the input1 + END part of input2 + END part of input3

For example, for the above example input strings:

Output1 = “J” + “Jo” + “Jan” = “JJoJan”

Output2 = “oh” + “h” + “ard” = “ohhard”

Output3 = “n” + “ny” + “han” = “nnyhan”

Step THREE: Process the resulting output strings based on the output-processing rule. After the above two steps, we
will now have three output strings. Further processing is required only for the third output string as per below rule-

“Toggle the case of each character in the string”, i.e., in the third output string, all lower-case characters should be
made upper-case and vice versa.

For example, for the above example strings,

output3 is “nnyhan”, so after applying the toggle rule.

Output3 should become “NNYHAN”.

Final Result – The three output strings after applying the above three steps i.e.

for the above example.

Output1 = “JJoJan”

Output2= “ohhard’

Output3 = “NNYHAN” Help Anand to write a program that would do the above.
using System;

public class Program

public static void Main()

string input1=Console.ReadLine();

string input2=Console.ReadLine();

string input3=Console.ReadLine();

String frnt1="",mid1="",end1="";

String frnt2="",mid2="",end2="";

String frnt3="",mid3="",end3="";

String output1="",output2="",output3="";

int len1=input1.Length;

int len2=input2.Length;

int len3=input3.Length;

if(len1==input1.Length){

if(len1%3==0)

frnt1=input1.Substring(0, (len1/3));

mid1=input1.Substring((len1/3), (len1/3));

end1=input1.Substring(2*(len1/3));

else if((len1-1)%3==0)

frnt1=input1.Substring(0, (len1/3));

mid1=input1.Substring((len1/3), ((len1/3)+1));

end1=input1.Substring(((2*(len1/3))+1));

else if((len1-2)%3==0)

frnt1=input1.Substring(0, ((len1/3)+1));

mid1=input1.Substring(((len1/3)+1), (len1/3));

end1=input1.Substring(((2*(len1/3))+1));
}

if(len2==input2.Length){

if(len2%3==0)

frnt2=input2.Substring(0, (len2/3));

mid2=input2.Substring((len2/3), (len2/3));

end2=input2.Substring(2*(len2/3));

else if((len2-1)%3==0)

frnt2=input2.Substring(0, (len2/3));

mid2=input2.Substring((len2/3), (len2/3+1));

end2=input2.Substring(((2*(len2/3))+1));

else if((len2-2)%3==0)

frnt2=input2.Substring(0, ((len2/3)+1));

mid2=input2.Substring(((len2/3)+1), (len2/3));

end2=input2.Substring(((2*(len2/3))+1));

if(len3==input3.Length){

if(len3%3==0)

frnt3=input3.Substring(0, (len3/3));

mid3=input3.Substring((len3/3), (len3/3));

end3=input3.Substring(2*(len3/3));

else if((len3-1)%3==0)

frnt3=input3.Substring(0, (len3/3));

mid3=input3.Substring((len3/3), (len3/3+1));

end3=input3.Substring(((2*(len3/3))+1));
}

else if((len3-2)%3==0)

frnt3=input3.Substring(0, ((len3/3)+1));

mid3=input3.Substring(((len3/3)+1), (len3/3));

end3=input3.Substring(((2*(len3/3))+1));

output1=frnt1+frnt2+frnt3;

output2=mid1+mid2+mid3;

output3=end1+end2+end3;

int l=output3.Length;

char[] arr=new char[l];

for(int i=0;i<l;i++)

if(Char.IsUpper(output3[i]))

arr[i]=Char.ToLower(output3[i]);

else

arr[i]=Char.ToUpper(output3[i]);

string str=new string(arr);

Console.WriteLine(output1);

Console.WriteLine(output2);

Console.WriteLine(str);

ENCODE THREE STRING MODEL-2

Step ONE: Given any three strings, break each string into 3 parts each. For example- if the three strings are below:
Input 1: “John”

Input 2: “Johny”
Input 3: “Janardhan”

“John” should be split into “J”, “oh”, “n,” as the FRONT, MIDDLE and END part, respectively.

“Johny” should be split into “Jo”, “h”, “ny” as the FRONT, MIDDLE and END, respectively.

“Janardhan” should be split into “Jan”, “ard”, “han” as the FRONT, MIDDLE and END part, respectively.

Step TWO: Concatenate (join) the FRONT, MIDDLE and END parts of the string as per the below specified
concatenation – rule to from three Output strings.

Output1: FRONT part of input 1 + MIDDLE part of input 2 + END part of input 3

Output2: MIDDLE part of input1 + END part of input2 + FRONT part of input3

Output3: END part of the input1 + FRONT part of input2 + MIDDLE part of input3

For example, for the above example input strings:

Output1 = “J” + “h” + “han” = “Jhhan”

Output2 = “oh” + “ny” + “Jan” = “ohnyJan”

Output3= “n” + “Jo” + “ard” += “nJoard”

Final Result – The three output strings after applying the above three steps i.e. for the above example.

Output1 = “Jnhan”

Output2= “ohnyJan’

Output3 = “NjOARD”

using System;

public class Program

public static void Main()

string input1=Console.ReadLine();

string input2=Console.ReadLine();

string input3=Console.ReadLine();

String frnt1="",mid1="",end1="";

String frnt2="",mid2="",end2="";

String frnt3="",mid3="",end3="";

String output1="",output2="",output3="";

int len1=input1.Length;

int len2=input2.Length;
int len3=input3.Length;

if(len1==input1.Length){

if(len1%3==0)

frnt1=input1.Substring(0, (len1/3));

mid1=input1.Substring((len1/3), (len1/3));

end1=input1.Substring(2*(len1/3));

else if((len1-1)%3==0)

frnt1=input1.Substring(0, (len1/3));

mid1=input1.Substring((len1/3), ((len1/3)+1));

end1=input1.Substring(((2*(len1/3))+1));

else if((len1-2)%3==0)

frnt1=input1.Substring(0, ((len1/3)+1));

mid1=input1.Substring(((len1/3)+1), (len1/3));

end1=input1.Substring(((2*(len1/3))+1));

if(len2==input2.Length){

if(len2%3==0)

frnt2=input2.Substring(0, (len2/3));

mid2=input2.Substring((len2/3), (len2/3));

end2=input2.Substring(2*(len2/3));

else if((len2-1)%3==0)

frnt2=input2.Substring(0, (len2/3));

mid2=input2.Substring((len2/3), (len2/3+1));

end2=input2.Substring(((2*(len2/3))+1));

}
else if((len2-2)%3==0)

frnt2=input2.Substring(0, ((len2/3)+1));

mid2=input2.Substring(((len2/3)+1), (len2/3));

end2=input2.Substring(((2*(len2/3))+1));

if(len3==input3.Length){

if(len3%3==0)

frnt3=input3.Substring(0, (len3/3));

mid3=input3.Substring((len3/3), (len3/3));

end3=input3.Substring(2*(len3/3));

else if((len3-1)%3==0)

frnt3=input3.Substring(0, (len3/3));

mid3=input3.Substring((len3/3), (len3/3+1));

end3=input3.Substring(((2*(len3/3))+1));

else if((len3-2)%3==0)

frnt3=input3.Substring(0, ((len3/3)+1));

mid3=input3.Substring(((len3/3)+1), (len3/3));

end3=input3.Substring(((2*(len3/3))+1));

output1=frnt1+mid2+end3;

output2=mid1+end2+frnt3;

output3=end1+frnt2+mid3;

int l=output3.Length;

char[] arr=new char[l];

for(int i=0;i<l;i++)

{
if(Char.IsUpper(output3[i]))

arr[i]=Char.ToLower(output3[i]);

else

arr[i]=Char.ToUpper(output3[i]);

string str=new string(arr);

Console.WriteLine(output1);

Console.WriteLine(output2);

Console.WriteLine(str);

ENCODE THREE STRING MODEL-3

Step ONE: Given any three strings, break each string into 3 parts each. For example- if the three strings are below:
Input 1: “John”

Input 2: “Johny”

Input 3: “Janardhan”

“John” should be split into “J”, “oh”, “n,” as the FRONT, MIDDLE and END part,

respectively. “Johny” should be split into “Jo”, “h”, “ny” as the FRONT, MIDDLE and END, respectively.

“Janardhan” should be split into “Jan”, “ard”, “han” as the FRONT, MIDDLE and END part, respectively.

Step TWO: Concatenate (join) the FRONT, MIDDLE and END parts of the string as per the below specified
concatenation – rule to from three Output strings.

Output1: FRONT part of input 1 + END part of input 2 + MIDDLE part of input 3

Output2: MIDDLE part of input1 + FRONT part of input2 + END part of input3

Output3: END part of the input1 + MIDDLE part of input2 + FRONT part of input3

For example, for the above example input strings:

Output1 = “J” + “nh” + “ard” = “Jnyard”

Output2 = “oh” + “Jo” + “han” = “ohJohan”

Output3= “n” + “h” + “Jan” += “nhJan”

Final Result – The three output strings after applying the above three steps i.e.

for the above example.


Output1 = “Jnyard”

Output2= “ohJohan’

Output3 = “NHjAN”

using System;

public class Program

public static void Main()

string input1=Console.ReadLine();

string input2=Console.ReadLine();

string input3=Console.ReadLine();

String frnt1="",mid1="",end1="";

String frnt2="",mid2="",end2="";

String frnt3="",mid3="",end3="";

String output1="",output2="",output3="";

int len1=input1.Length;

int len2=input2.Length;

int len3=input3.Length;

if(len1==input1.Length){

if(len1%3==0)

frnt1=input1.Substring(0, (len1/3));

mid1=input1.Substring((len1/3), (len1/3));

end1=input1.Substring(2*(len1/3));

else if((len1-1)%3==0)

frnt1=input1.Substring(0, (len1/3));

mid1=input1.Substring((len1/3), ((len1/3)+1));

end1=input1.Substring(((2*(len1/3))+1));

else if((len1-2)%3==0)

{
frnt1=input1.Substring(0, ((len1/3)+1));

mid1=input1.Substring(((len1/3)+1), (len1/3));

end1=input1.Substring(((2*(len1/3))+1));

if(len2==input2.Length){

if(len2%3==0)

frnt2=input2.Substring(0, (len2/3));

mid2=input2.Substring((len2/3), (len2/3));

end2=input2.Substring(2*(len2/3));

else if((len2-1)%3==0)

frnt2=input2.Substring(0, (len2/3));

mid2=input2.Substring((len2/3), (len2/3+1));

end2=input2.Substring(((2*(len2/3))+1));

else if((len2-2)%3==0)

frnt2=input2.Substring(0, ((len2/3)+1));

mid2=input2.Substring(((len2/3)+1), (len2/3));

end2=input2.Substring(((2*(len2/3))+1));

if(len3==input3.Length){

if(len3%3==0)

frnt3=input3.Substring(0, (len3/3));

mid3=input3.Substring((len3/3), (len3/3));

end3=input3.Substring(2*(len3/3));

else if((len3-1)%3==0)

{
frnt3=input3.Substring(0, (len3/3));

mid3=input3.Substring((len3/3), (len3/3+1));

end3=input3.Substring(((2*(len3/3))+1));

else if((len3-2)%3==0)

frnt3=input3.Substring(0, ((len3/3)+1));

mid3=input3.Substring(((len3/3)+1), (len3/3));

end3=input3.Substring(((2*(len3/3))+1));

output1=frnt1+end2+mid3;

output2=mid1+frnt2+end3;

output3=end1+mid2+frnt3;

int l=output3.Length;

char[] arr=new char[l];

for(int i=0;i<l;i++)

if(Char.IsUpper(output3[i]))

arr[i]=Char.ToLower(output3[i]);

else

arr[i]=Char.ToUpper(output3[i]);

string str=new string(arr);

Console.WriteLine(output1);

Console.WriteLine(output2);

Console.WriteLine(str);

ENCODE THREE STRING MODEL-4


Step ONE: Given any three strings, break each string into 3 parts each.

For example- if the three strings are below:

Input 1: “John”

Input 2: “Johny”

Input 3: “Janardhan”

“John” should be split into “J”, “oh”, “n,” as the FRONT, MIDDLE and END part, respectively.

“Johny” should be split into “J”, “ohn”, “y” as the FRONT, MIDDLE and END, respectively.

“Janardhan” should be split into “Jan”, “ard”, “han” as the FRONT, MIDDLE and END part, respectively.

Step TWO: Concatenate (join) the FRONT, MIDDLE and END parts of the string as per the below specified
concatenation – rule to from three Output strings.

Output1: FRONT part of input 1 + MIDDLE part of input 2 + END part of input 3

Output2: MIDDLE part of input1 + END part of input2 + FRONT part of input3

Output3: END part of the input1 + FRONT part of input2 + MIDDLE part of input3

For example, for the above example input strings:

Output1 = “J” + “ohn” + “han” = “Johnhan”

Output2 = “oh” + “y” + “Jan” = “ohyJan”

Output3= “n” + “J” + “ard” += “nJard”

Final Result – The three output strings after applying the above three steps i.e. for the above example.

Output1 = “Johnhan”

Output2= “ohyJan’

Output3 = “NjARD”

using System;

public class Program

public static void Main()

string input1=Console.ReadLine();

string input2=Console.ReadLine();

string input3=Console.ReadLine();

String frnt1="",mid1="",end1="";

String frnt2="",mid2="",end2="";

String frnt3="",mid3="",end3="";

String output1="",output2="",output3="";
int len1=input1.Length;

int len2=input2.Length;

int len3=input3.Length;

if(len1==input1.Length){

if(len1%3==0)

frnt1=input1.Substring(0, (len1/3));

mid1=input1.Substring((len1/3), (len1/3));

end1=input1.Substring(2*(len1/3));

else if((len1-1)%3==0)

frnt1=input1.Substring(0, (len1/3));

mid1=input1.Substring((len1/3), ((len1/3)+1));

end1=input1.Substring(((2*(len1/3))+1));

else if((len1-2)%3==0)

frnt1=input1.Substring(0, ((len1/3)+1));

mid1=input1.Substring(((len1/3)+1), (len1/3));

end1=input1.Substring(((2*(len1/3))+1));

if(len2==input2.Length){

if(len2%3==0)

frnt2=input2.Substring(0, (len2/3));

mid2=input2.Substring((len2/3), (len2/3));

end2=input2.Substring(2*(len2/3));

else if((len2-1)%3==0)

frnt2=input2.Substring(0, (len2/3));

mid2=input2.Substring((len2/3), (len2/3+1));
end2=input2.Substring(((2*(len2/3))+1));

else if((len2-2)%3==0)

frnt2=input2.Substring(0, (len2/3));

mid2=input2.Substring((len2/3), (len2/3+len2%3));

end2=input2.Substring(((2*(len2/3))+1));

if(len3==input3.Length){

if(len3%3==0)

frnt3=input3.Substring(0, (len3/3));

mid3=input3.Substring((len3/3), (len3/3));

end3=input3.Substring(2*(len3/3));

else if((len3-1)%3==0)

frnt3=input3.Substring(0, (len3/3));

mid3=input3.Substring((len3/3), (len3/3+1));

end3=input3.Substring(((2*(len3/3))+1));

else if((len3-2)%3==0)

frnt3=input3.Substring(0, ((len3/3)+1));

mid3=input3.Substring(((len3/3)+1), (len3/3));

end3=input3.Substring(((2*(len3/3))+1));

output1=frnt1+mid2+end3;

output2=mid1+end2+frnt3;

output3=end1+frnt2+mid3;

int l=output3.Length;

char[] arr=new char[l];


for(int i=0;i<l;i++)

if(Char.IsUpper(output3[i]))

arr[i]=Char.ToLower(output3[i]);

else

arr[i]=Char.ToUpper(output3[i]);

string str=new string(arr);

Console.WriteLine(output1);

Console.WriteLine(output2);

Console.WriteLine(str);

LARGEST POSSIBLE PALINDROME

NOTE 1: if all the characters in the word are already sufficient to form a palindrome, then the number of characters
that have to be removed from the word should be 0.

For e.g the word is "Magma", then the result should be 0

NOTE 2: if all the characters in the word are different and cannot form a palindrome, then the number of characters
that have to be removed from the word should be -1

For e.g the word is “Victory” then the result should be -1

NOTE 3: Ignore the case of the letters white doing the check

i.e "Template” or “template" or “TEMplate” or “TEmPLAte” or “TEMPLATE” should all give the same result which is 3

NOTE 4: You can assume that the given word will be a single word with no spaces and only alphabet characters.

using System;

public class Program

public static void Main()

String input1=Console.ReadLine();
input1=input1.ToLower();

int[] h=new int[26];

for(int i=0;i<input1.Length;i++)

h[(int)input1[i]-97]++;

int c=0;

for(int i=0;i<26;i++)

if(h[i]%2==1)

c++;

if(c==0 || c==1)

Console.WriteLine(0);

else if(c==input1.Length)

Console.WriteLine(-1);

else

Console.WriteLine(c-1);

WEIGHT OF HILL PATTERNS

Example1 –

Given, the total levels(total rows) in the hill pattern = 5 (input1)

the weight of the head level (first row) = 10(input2)

the weight increments of each subsequent level = 2(input3)

Then, The total weight of the hill pattern will be calculated as

= 10 + (12+10+12) + (14+12+14+12+14) + (16+14+16+14+16+14+16) + (18+16+18+16+18+16+18+16+18)


= 10 + 34 + 66 + 106 + 154

= 370

Example2 –

Given, the total levels in the hill pattern = 4(input1)

the weight of the head level = 1(input2)

the weight increments of each subsequent level = 5(input3)

Then, Total weight of the hill pattern will be

= 1 + (6+1+6) + (11+6+11+6+11) + (16+11+16+11+16+11+16)

= 1 + 13 + 45 + 97

= 156

using System;

public class Program

public static void Main()

int r=Int32.Parse(Console.ReadLine());

int a=Int32.Parse(Console.ReadLine());

int k=Int32.Parse(Console.ReadLine());

int j=2,s=a;

for(int i=1;i<r;i++)

s+=(a*i)+(a+k)*j;

j+=1;

a+=k;

Console.WriteLine(s);

JUMBLED WORD

Example1:

input1="PROJECT BASED LEARNING"


input2=1

Expected output="POETCJR BSDEA LANNGIRE"

Example2:

input1="PROJECT BASED LEARNING"

input2=2

Expected output="POETRJC BSDAE LANNERIG"

Example3: input1="WIPRO LIMITED"

input2=1

Expected output="WPORI LMTDEII"

Example4:

input1="WIPRO LIMITED"

input2=2

Expected output="WPOIR LMTDIIE"

using System;

public class Program

public static void Main()

string input1="PROJECT BASED LEARNING";

int input2=Int32.Parse(Console.ReadLine());

string[] s=input1.Split(' ');

string s1="",res="",even="",odd="";

for(int i=0;i<s.Length;i++)

s1=s[i];

even="";

odd="";

for(int j=0;j<s1.Length;j++)

if(j%2==0)

even+=s1[j];

}
else

odd+=s1[j];

if(input2==1)

char[] arr=odd.ToCharArray();

Array.Reverse(arr);

string sk=new string(arr);

res+=even+sk+" ";

}//POETRJC BSDAE LANNERIG

else

res+=even+odd+" ";

Console.WriteLine(res);

FIX THE FORMULA

Sample Input/Output-1

Input1= we8+you2-7to/*32

Output=2

Explanation: Here the operators are [+,-,/,*] and the numbers are [8,2,7,3,2] Thus we would be getting 8+2=>10-
7=>3/3=>1*2=>2

Final answer is 2.

Sample Input/Output-2

Input1= i*-t5s-t8h1e4birds

Output=35

Explanation: Here the operators are [+,-,-] and the numbers are [5,8,1,4] Thus we would be getting 5*8=>40-1=>39-
4=>35

Final answer is 35.


using System;

public class Program

public static void Main()

string input1=Console.ReadLine();

int len=input1.Length;

int[] d=new int[len];

char[] c=new char[len];

int k1=0,k2=0;

for(int i=0;i<len;i++)

if(!Char.IsLetter(input1[i]))

if(Char.IsDigit(input1[i]))

d[k1++]=Int32.Parse(Convert.ToString(input1[i]));

else

c[k2++]=input1[i];

int res=d[0],k=1;

for(int i=0;i<k2;i++)

if(c[i]=='+')

res+=d[k];

else if(c[i]=='-')

{
res-=d[k];

else if(c[i]=='*')

res*=d[k];

else

res/=d[k];

k++;

Console.WriteLine(res);

FORM THE WORDS

Example-1

Input1 = ww:ii:pp:rr:oo

Output= WIPRO Explanation

Word1 is ww, both are same hence take w

Word2 is ii, both are same hence take i

Word3 is pp, both are same hence take p

Word4 is rr, both are same hence take r

Word5 is oo,

both are same hence take o Hence the output is WIPRO

Example-2

Input1= zx:za:ee

Output=BYE

using System;

public class Program

{
public static void Main()

string input1=Console.ReadLine();

String[] s=input1.Split(':');

String s1="",res="";

int x,len=s.Length;

for(int i=0;i<len;i++)

s1=s[i];

if(((int)s1[0])-((int)s1[1])==0)

res+=s1[0];

else if(((int)s1[0])-((int)s1[1])>0)

x=((int)s1[0])-((int)s1[1]);

res+=((char)(96+x));

else

x=((int)s1[1])-((int)s1[0]);

res+=((char)(96+x));

Console.WriteLine(res.ToUpper());

TWO DIGIT REDUCED SUBTRACTED FORM

For eg if the input number is 6928,

its RSF can be found by concatenating the difference between (6 and 9), (9 and 2) and (2 and 8) as shown below –
Difference between 6 and 9 is 3

Difference between 9 and 2 is 7


Difference between 2 and 8 is 6

So, the “Reduced Subtracted Form(RSF)” of 6928 = 376

The resultant RSF (376) is not a two-digit number, so we must continue finding its “Reduced Subtracted Form(RSF)”

Difference between 3 and 7 is 4

Difference between 7 and 6 is 1

So, the “Reduced Subtracted Form(RSF)” of 376 = 41

The resultant RSF (41) is two-digit number, so we have reached the “two-digit Reduced Subtracted Form”.

Therefore, the two-digit RSF of 6928 = 41

If input1 = 5271

Expected output = 21

Explanation: RSF of 5271 = (5-2)(2-7)(7-1)=356

RSF of 356=(3-5)(5-6)=21

using System;

public class Program

public static void Main()

int input1=Int32.Parse(Console.ReadLine());

while(input1>=100)

int x=input1,l=0;

while(input1>0)

input1=input1/10;

l++;

int[] a=new int[l];

int i=l-1;

while(x>0)

a[i]=x%10;

x=x/10;

i--;
}

for(int j=0;j<l-1;j++)

input1=input1*10+Math.Abs(a[j]-a[j+1]);

Console.WriteLine(input1);

MATCHING THE WORD

Example 1:

Input1: {arc, nep, tis}

Input2: {sit, car, pen}

Input3: 3 Output: 120

Example 2:

Input1: {cnhul, estl, rakeb, ahev}

Input2: {lets, have, lunch, break}

Input3: 4 Output: 2031

using System;

public class Program

public static void Main()

int input3=Int32.Parse(Console.ReadLine());

string[] input1=new string[input3];;

string[] input2=new string[input3];

for(int a=0;a<input3;a++)

input1[a]=Console.ReadLine();

for(int a=0;a<input3;a++)

{
input2[a]=Console.ReadLine();

String res="";

for(int i=0;i<input3;i++)

char[] t1 = input1[i].ToCharArray();

char[] t2 = input2[i].ToCharArray();

//sorting

Array.Sort(t1);

Array.Sort(t2);

input1[i]= new String(t1);

input2[i]= new String(t2);

for(int i=0;i<input3;i++)

for(int j=0;j<input3;j++)

if(input1[i].Equals(input2[j]))

res=res+j;

break;

Console.WriteLine(Int32.Parse(res));

ONE DIGIT REDUCED SUBTRACTED FORM

using System;

public class Program

public static void Main()


{

int input1=Int32.Parse(Console.ReadLine());

while(input1>=10)

int x=input1,l=0;

while(input1>0)

input1=input1/10;

l++;

int[] a=new int[l];

int i=l-1;

while(x>0)

a[i]=x%10;

x=x/10;

i--;

for(int j=0;j<l-1;j++)

input1=input1*10+Math.Abs(a[j]-a[j+1]);

Console.WriteLine(input1);

PROCESS TWO WORDS

Input1=Today is a nice day

Input2=41

Output=cein daydoT

using System;

using System.Text;

public class Program


{

public static void Main()

string input1=Console.ReadLine();

int input2=Int32.Parse(Console.ReadLine());

int nu1=input2/10;

int nu2=input2%10;

string[] s=input1.Split(' ');

string s1=s[nu1-1];

char[] arr=s1.ToCharArray();

Array.Reverse(arr);

String sr1=new String(arr);

string s2=s[nu2-1];

char[] arr1=s2.ToCharArray();

Array.Reverse(arr1);

string sr2=new string(arr1);

int l1=s1.Length;

int l2=s2.Length;

string r1=s1.Substring(l1/2)+sr1.Substring(l1/2);

string r2=s2.Substring(l2/2)+sr2.Substring(l2/2);

Console.WriteLine(r1+" "+r2);

GENERATE SERIES AND FIND Nth ELEMENT

using System;

//1,3,6,8,11,13,16,18,21,23,,26,28,31,33,36,38,41

public class Program

public static void Main()

int input1=Int32.Parse(Console.ReadLine());

int input2=Int32.Parse(Console.ReadLine());

int input3=Int32.Parse(Console.ReadLine());
int input4=Int32.Parse(Console.ReadLine());

int gap1 = (input2 - input1);

int gap2 = (input3 - input2);

int output = input1;

for (int i = 1; i < input4; i++)

if (i % 2 == 1)

output += gap1;

else

output += gap2;

Console.WriteLine(output);

EATRY JOINT

using System;

public class Program

public static void Main()

int[,] input1={{0,2},{2,3},{2,2},{5,2}};

int input2=Int32.Parse(Console.ReadLine());

int time=input1[0,1];

String se="c0-";

int count=1;

String le="";

for(int i=1;i<input2;i++)

if(time<=input1[i,0])

time=time+input1[i,1];
se=se+"c"+i+"-";

count++;

else

le=le+"c"+i+"-";

String ans="";

if(count==input2)

ans="served";

else

se=se.Substring(0,se.Length-1);

if(le.Length>0)

le=le.Substring(0,le.Length-1);

ans=se+":"+le;

Console.WriteLine(ans);

FIND PRIME VOWELS

using System;

public class Program

static String[] word = {"zero", "one", "two", "three","four", "five", "six", "seven","eight","nine"};

public static void Main()

int input1=Int32.Parse(Console.ReadLine());

int num=1,count=0,j;
while(count<input1)

num=num+1;

for(j=2;j<=num;j++)

if(num%j==0)

break;

if(j==num)

count++;

int n=num;

int[] digits = new int[10];

String s="",w="";

int dc = 0;

do

digits[dc] = n % 10;

n = n/10;

dc++;

} while (n != 0);

for (int i = dc - 1; i >= 0; i--)

s+=word[digits[i]] + " ";

for(int i = 0; i < s.Length; i++)

if(s[i]== 'a' || s[i]== 'e' || s[i]== 'i' || s[i]== 'o' || s[i]=='u')

if(Char.IsLetter(s[i])){

w += s[i];

}
w=w+w.Length;

Console.WriteLine(w);

IDENTIFY POSSIBLE WORDS

Example1:

input1= "Fi_er”

input2=”Fever:filer:Filter: Fixer:fiber:fibre:tailor:offer”

output= "FILER:FIXER FIBER”

using System;

public class Program

public static void Main()

string input1=Console.ReadLine();

string input2=Console.ReadLine();

input1=input1.ToUpper();

input2=input2.ToUpper();

String word="", res="";

int i,j;

String[] words = input2.Split(':');

for(i=0;i<words.Length;i++)

word = words[i];

if(input1.Length==word.Length)

for(j=0;j<input1.Length;j++)

if((input1[j]!='_')&&(input1[j]!=word[j]))

break;

}
}

if(j==input1.Length)

res=res + word+":";

Console.WriteLine(res.Length==0?"ERROR-009":res.Substring(0,res.Length-1));

ALTERNATE ADD SUM

Given a number N (1<=N<=10000), and an option opt=1 or 2, find the result as per below rules,

If opt=1, Result= N-(N-1)+(N-2) - (N-3) +(N-4) ......till 1

If opt=2 Result= N+(N-1)- (N-2) + (N-3) - (N-4)..... till 1

Example1: IfN = 6, and opt=1 Result =6-5+4-3+2-1=3 Example2 If N = 6, and opt=2

Result =6+5-4+3-2+1= 9

The function prototype should be as belowint AddSub(int N, int opt);

using System;

public class Program

public static void Main()

int N=Int32.Parse(Console.ReadLine());

int opt=Int32.Parse(Console.ReadLine());

int sum=0;

sum+=N;

N=N-1;

if(opt==2)

if(N%2==0)

while(N>0)

{
if(N%2==0)

sum+=N;

else

sum-=N;

N--;

else

while(N>0)

if(N%2==0)

sum-=N;

else

sum+=N;

N--;

else

if(N%2==0)

while(N>0)

if(N%2==0)

sum-=N;

else

sum+=N;

N--;

else

{
while(N>0)

if(N%2==0)

sum+=N;

else

sum-=N;

N--;

Console.WriteLine(sum);

PLACE THE ALPHABETS

using System;

//input1={10,5,70,1};

//output cbda

public class Program

public static void Main()

int[] input1={10,5,70,1};

int[] sorted_input=(int[])input1.Clone();

Array.Sort(sorted_input);

char[] result=new char[input1.Length];

int[] index=new int[input1.Length];

int ind;int o=0;

foreach(int i in input1)

ind=Array.IndexOf(sorted_input,i);

//Console.WriteLine(ind+1);

result[o]=(char)(ind+1+96);

o++;
}

Console.WriteLine(result);

You might also like