TCS Codevita Pre-qualifier Round which was held on 15th August 2020 by TCS to filter out the candidates that suits there company as Software Engineers. The level of this Coding Round was medium and not that easy. Every candidate has to solve atleast one question to be qualified for the next round. **The coding round comprised of good set of questions which are as follows :**

**Question 1: String Pair**

**Problem Description**

One person hands over the list of digits to Mr. String, But Mr. String understands only strings. Within strings also he understands only vowels. Mr. String needs your help to find the total number of pairs which add up to a certain digit D.The rules to calculate digit D are as follow :-

Take all digits and convert them into their textual representation.

Next, sum up the number of vowels i.e. {a, e, i, o, u} from all textual representation.

This sum is digit D

Now, once digit D is known find out all unordered pairs of numbers in input whose sum is equal to D. Refer example section for better understanding.

**Constraints**

1 <= N <= 100

1 <= value of each element in second line of input <= 100

Number 100, if and when it appears in input should be converted to textual representation as hundred and not as one hundred. Hence number of vowels in number 100 should be 2 and not 4

**Input**

First line contains an integer N which represents number of elements to be processed as input

Second line contains N numbers separated by space

**Output**

Lower case representation of textual representation of number of pairs in input that sum up to digit D

Note: – (If the count exceeds 100 print “greater 100”)

**Examples**

Input :51 2 3 4 5

Output :one

Input :37 4 2

Output :zero

**Question 2: Elections**

**Problem Description**

Elections are going on, and there are two candidates A and B, contesting with each other. There is a queue of voters and in this queue some of them are supporters of A and some of them are supporters of B. Many of them are neutral. The fate of the election will be decided on which side the neutral voters vote. Supporters of A and supporters of B make attempt to win the votes of neutral voters.

The way this can be done is explained below:

1. The voter queue is denoted by three characters, viz {-, A, B}. The – denotes neutral candidate, A denotes supporter of candidate A and B denotes supporter of candidate B.

2. Supporters of A can only move towards the left side of the queue.

3. Supporters of B can only move towards the right side of the queue.

4. Since time is critical, supporters of both A and B will move simultaneously.

5. They both will try and influence the neutral voters by moving in their direction in the queue. If supporter of A reaches the neutral voter before supporter of B reaches him, then that neutral voter will become a supporter of candidate A.

6. Similarly, if supporter of B reaches the neutral voter before supporter of A reaches him, then that neutral voter will become a supporter of candidate B.

7. Finally, if both reach at the same time, the voter will remain neutral. A neutral vote cannot decide the outcome of the election.

8. If finally, the queue has more votes for candidate A, then A wins the election. If B has more votes, then B wins that election. If both have equal votes, then it will be a coalition government.

Refer Examples section for understanding the dynamics of how the supporters influence the neutral voters.

Your task is to find the outcome of the election.

Note: There are no test cases where all votes are neutral.

**Input**

First line contains an integer which is length of queue of voters.

Second line contains characters {-, A, B}, in which denotes

· A = voter who is supporter of candidate A

· B = voter who is supporter of candidate B

· – = neutral voter

**Output**

Print candidate with maximum number of votes. If they have equal number of votes, print “Coalition government“.

**Examples**

14Input :–AB–AB—A–

AOutput :

4Input :

A—

AOutput :

**Question 3: Moving Average**

**Problem Description**

A stock price is dynamic. Its value can change multiple times in a fraction of a second or remain unchanged for several minutes. Analyzing the dynamics of stock price change can provide an indication for forth coming uptrend or downtrend in that stock. One such indicator is simple moving averages. Now, Harry wants to analyze the price trend of the stock on the basis of moving averages (MA).

Let’s consider a moving average of 2-day and 4-day respectively. A 2-day moving average is calculated by taking average of closing price of 2 consecutive days. A 4-day moving average is calculated by taking average of closing price of 4 consecutive days. Now, according to experts whenever a faster moving average curve (2-day MA) cuts the slower moving average (4-day MA) from below, then it is an indication of uptrend in the stock. Similarly, whenever a faster moving averages curve (2-day MA) cuts the slower moving average curve (4-day MA) from above, then it is an indication of downtrend in the stock.

Help Harry in computing the number of uptrends and downtrends in the given time for which the data is provided.

In this graph, there are three lines indicating stock closing price, moving average of two days and four days .Now we can see that between 13th and 15th there is an intersection. It is known as downtrend when moving average of fewer days is cutting downwards the more days moving average and vice versa.

Note1 – There will be no day1 moving average for 2-day MA. Similarly there will be no day1, day2, day3 moving average for 4-day MA. In general there will be no X-1, X-2, Y-1, Y-2, etc day point for X-day and Y-day moving average curve.

Note2 – All the computation has to be accurate up to 6 digits after the decimal point.

**Input**

First line contains two space separated integers which are the moving average days X and Y.

Second-line contains an integer N denoting number of stock prices.

Third line contains N space separated decimal values denoting the closing price of the stock for N days.

**Output**

Print the total number of times the stock will give uptrend or downtrend.

**Examples**

3 5Input :11

4.55 5.4 5.65 5.4 5.2 4.85 4.95 5.05 4.9 4.9 4.95

3Output :

2 4Input :14

69.849998 72.900002 74.449997 77.300003 75.050003 74.349998 75.449997 76.300003 74 69.349998 65.349998 67.349998 67.599998 68.449997

4Output :

**Question 4: Jogging Ground**

**Problem Description**

There are 4 circular grounds of equal sizes. Their circumferences do not intersect. The radius and the distance of the center of each circle from the leftmost circle’s center are given.

There are 4 joggers who can start at the same time from any of the points designated as { a, b, c, d } on the circumference of all the four circles as shown in the diagram below. All 4 joggers jog in different grounds along the circumference of that ground. They could jog in either clockwise (left to right) or anticlockwise (right to left) direction. Finally they may also jog at different speeds.

Given starting position, direction of jogging and speed of jogging of all the 4 joggers, find the summation of length of 3 segments between the four joggers at a given point in time since the start of the jog.

**Input**

First line contains 4 integers each denoting the following

R denotes the radius of all four circles

D1 denotes the distance centre of the second circle from left to the centre of the leftmost circle

D2 denotes the distance centre of the third circle from left to the centre of the leftmost circle

D3 denotes the distance centre of the last circle from left to the centre of the leftmost circle

Second line contains 4 space separated integers denoting the angle with point a of each of the 4 circles where 0 degree indicates point a itself, 90 degree indicates point b, 180 degree indicates point c and 270 degree indicates point d.

Third line contains 4 space separated integers denoting the velocity in degrees per second.

Fourth line contains 4 space separated integers denoting the direction of running for joggers (0=clockwise and 1=anticlockwise).

Fifth Line contains integer N denoting the time in seconds since the start of the jog.

**Output**

Print the summation of length of 3 segments between the four joggers after N seconds, rounded to the nearest integer.

**Examples**

10 25 50 75Input :0 0 0 0

1 1 1 1

1 1 1 1

90

75Output :

10 25 50 75Input :0 0 0 0

1 2 3 4

0 0 0 0

90

91Output :

**Question 5: Zoo Design**

**Problem Description**

Aman is a rich businessman who want to build a zoo. He wants to make enclosures for terrestrial and aquatic animals. Terrestrial animals will be of two types, namely herbivorous and carnivorous animals. So there will be three different enclosures.

Herbivores like Elephant, Deer are prime attractions. Similarly, Lion and Tiger are prime attractions amongst carnivores. Finally, Dolphins and Shark are prime attractions amongst aquatics for tourists.

Aman being a savvy businessman realizes that in order to minimize the cost of building the zoo without compromising on the attractions, he has to decide how much area to allocate to each animal type. Each animal type requires a certain area to thrive in. This in turn impacts the area allocation, which in turn has cost implications.

Your task is to help Aman workout the mathematics such that the zoo building cost is minimized subject to the following constraints:

Zoo needs to have minimum of X herbivores, Y carnivores and Z aquatic animals

Different types of animals will need different minimum area to thrive in

For animals of a given type, the minimum area required is the same

There is also a maximum limit for the overall area allocated for each animal type

Cost of fencing etc. is included in cost of enclosure

Exclude the essentials like pathways for tourists, from area and cost calculations

Consider all areas in square meters and cost in Rupees.

**Input**

First line contains three space separated integers denoting the cost per square meter of building the enclosure for each type of animals viz. herbivorous, carnivorous and aquatic respectively

Second line contains three space separated integers denoting the maximum area that can be allocated to each type of animal viz. herbivorous, carnivorous and aquatic respectively

Next three lines, each will contain two space separated integers M and N, for each type of animal viz. herbivorous, carnivorous and aquatic respectively, where M denotes minimum number of animals of that type and N denotes minimum area required for that animal type

Last line contains an integer which represents the total area of land on which the zoo needs to be built

**Output**

Single integer containing the minimum cost required to build the zoo.

**Examples**

10000 1000 1500Input :250 250 300

5 5

15 5

10 10

500

837500Output :

**Explanation**

·The cost of constructing the enclosure for herbivores is high. However, since we need to accommodate 5 herbivores as per given constraints, a 25 sq. meter land will need to allocated for the herbivores.

·Since the cost of constructing the enclosure for carnivores is cheapest we are able to allocate them the maximum limit that we can allocate. Thus we are allocating 250 sq. meters for carnivores.

·The remaining 225 sq. meters can thus be allocated to aquatics without violating any constraint.

·Thus the minimum cost of constructing the zoo adhering to all constraints is (25 * 10000 + 250 * 1000 + 225 * 1500) = 837500

**Example 2**

100 1000 1500Input :250 250 300

5 5

15 5

10 10

500

325000Output :

**Explanation**

·Since the cost of constructing the enclosure for herbivores is cheapest we are able to allocate them the maximum limit that we can allocate. Thus we are allocating 250 sq. meters for herbivores.

·The cost of constructing the enclosure for aquatics is high. However, since we need to accommodate 10 aquatics as per given constraints, a 100 sq. meter land will need to allocated for the aquatic animals.

·The remaining 150 sq. meters can thus be allocated to carnivores without violating any constraint.

·Thus the minimum cost of constructing the zoo adhering to all constraints is (250 * 100 + 150 * 1000 + 100 * 1500) = 325000

## Recommended Posts:

- TCS Interview Experience | Set 9 (Off-Campus through CodeVita)
- TCS Interview Experience | Set 10 (Off-Campus through CodeVita)
- TCS Interview Experience | Set 11 (On-Campus through CodeVita)
- TCS Interview Experience | Set 12 (Off-Campus through CodeVita)
- TCS Interview Experience 2018 (Off-Campus, through Codevita)
- TCS (off campus) through Codevita
- TCS off campus drive through Codevita
- TCS Interview Experience | (Off-Campus through CodeVita)
- TCS Codevita Interview Experience
- TCS Interview Experience through CodeVita
- TCS Interview Experience: Off-Campus Interview through Codevita
- TCS Interview Experience - (Off-campus through Codevita 2018)
- TCS Codevita 7 2018 Interview Experience
- TCS CodeVita Interview | Digital vs Ninja profile
- TCS CodeVita 2018 Interview Experience
- TCS Codevita Season 8 Interview 2019-Noida
- TCS Codevita Interview -2019
- TCS Codevita Interview Experience
- TCS Codevita Interview Experience 2019
- TCS Codevita Interview Experience 2019

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.