Professional Documents
Culture Documents
Tcs Question
Tcs Question
A bank wants to design an ATM for school students. The unique feature of this ATM
would be that it would always give maximum number of currency notes possible, to
make the students happy. Available denomination of currency notes in the ATM are
100, 200, 500, 1000
Constraints
N<100
Input Format
First Line provides an integer, N
Second Line provides an integer denoting the amount you want to withdraw (in
multiples of 100)
Third Line provides an integer denoting the available currency note of Rs 100 in
the ATM
Fourth Line provides an integer denoting the available currency note of Rs 200 in
the ATM
Fifth Line provides an integer denoting the available currency note of Rs 500 in
the ATM
Sixth Line provides an integer denoting the available currency note of Rs 1000 in
the ATM
Output
One line containing the maximum number of currency note possible for the desired
withdrawal amount. Output should be 0 (zero) if transaction is not possible, for
example if sufficient fund is not available in the ATM.
Test Case
Explanation
Example 1
Input
10
1300
10
10
10
10
Output
10
Explanation
Here,
Example 2
Input
1700
Output
Explanation
Here,
2>
Iterate Base
Problem Description
Given a number representation, we can identify the base that would result in a
least value for the representation. Consider the following examples:
1. For the number representation 11, the least possible base is 2 and hence the
least possible value is 3 in base 10.
2. For 17, the least possible base is 8 and the least possible value is 15 in base
10.
3. For 1729, the least possible base in 10 and the least possible value is 1729 in
base 10.
Consider doing this base reduction iteratively till a fixed point is reached as
shown in the following example: Let's start with number representation 72. The
least possible value of 72 is in base 8 and is 58 (represented in base 10).
Iterating, the least possible value of 58 is in base 9 and is 53 (base 10). In the
next iteration, 53 (in base 6) becomes 33. Then, 33 (base 4) gives 15; 15 (base 6)
gives 11; 11 (base 2) gives 3. Finally, 3 remains 3 (in bases 4 and above).
Constraints
1. The length of input number representation <= 5
2. Maximum base = 36
Base 36: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O,
P, Q, R, S, T, U, V, W, X, Y, Z
Input Format
One line containing a number representation (See Examples section for better
understanding)
Output
The final number representation that results from iteratively performing base
reductions in the manner illustrated above
Test Case
Explanation
Example 1
Input
25
Output
Explanation
Starting with 25, we have the following transitions: 25 -> base 6 => 17 -> base 8
=> 15 -> base 6 => 11 -> base 2 => 3, which is the fixed point
Example 2
Input
TCS
Output
17900
Explanation
Starting with TCS, TCS -> base 30 => 29*30^2+12*30+28=26488 -> base 9 =>
2*9^4+6*9^3+4*9^2+8*9+8=17900 -> base 10 => 17900, which is the fixed point
3>
Market Survey
Problem Description
Market Research firm is carrying out a survey regarding popular brands. The person
who has the best pulse of the survey population will be rewarded by the firm.
The survey comprises of N questions was taken by M participants, not at the same
time but one after the other. Clearly, there is no correct answer since it is a
survey of brands. Each question can have only four options (1,2,3,4). Most expected
answers to different questions is used as a template to measure brand popularity.
Think of this as a default answer sheet where the question paper is the Survey.
'0' represents no answer to a question. Thus it means that the participant has
skipped answering that question.
Right Answer:
For a particular question, the highly chosen option till that point of time is
treated as the correct answer. If multiple options have the same count, then out of
those options the one which was chosen recently is treated as the right answer.
Score of a Participant:
One point will be awarded for each right answer. No negative points for wrong
answers.
Instant Result:
This is shared to the Participant instantly after completion of his/her exam. (this
is equal to number of right answers)
Final Result:
Only the final top scorer(TOPPER) is announced along with his score.
Note:
At the end of all M Participants completing the exam, the final right answers gets
decided.
Based on these answers score of each candidate gets recalculated and the one with
highest score is the TOPPER!!!
If more than one Participant gets the top score then the one among them who
attempted the exam first, is treated as TOPPER.
Constraints
1 <= N,M <= 1000
Input Format
First line contains N (number of questions)
Output
First M lines showing the instant results of each Participant.
Test Case
Explanation
Example 1
Input
10
1 2 3 4 1 2 3 4 1 2
1 2 4 4 3 2 3 1 1 3
2 3 4 4 1 2 3 1 1 2
Output
1 8
Explanation
Number of questions = 10
Number of Participants = 2
Default answers : 1 2 3 4 1 2 3 4 1 2
Latest Key : 1 2 4 4 3 2 3 1 1 3
Latest Key : 1 2 4 4 1 2 3 1 1 2
Final key : 1 2 4 4 1 2 3 1 1 2
(Final Key is same as Latest Key at the end of all Participants completing the
exam)
4>
Coins Required
Problem Description
Find minimum number of coins required to form any value between 1 to N, both
inclusive. Cumulative value of coins should not exceed N. Coin denominations are 1
Rupee, 2 Rupee and 5 Rupee.
Consider value of N is 13, then the minimum number of coins required to formulate
any value between 1 and 13, is 6. One 5 Rupee, three 2 Rupee and two 1 Rupee coins
are required to realize any value between 1 and 13. Hence this is the answer.
However, if one takes two 5 Rupee coins, one 2 rupee coin and two 1 rupee coin,
then too all values between 1 and 13 are achieved. But since the cumulative value
of all coins equals 14, i.e., exceeds 13, this is not the answer.
Constraints
0 < n < 100000
Input Format
A single integer value.
Output
Four space separated integer values.
Test Case
Explanation
Example 1
Input
13
Output
6 1 3 2
Explanation
Using these coins, we can form any value with in the given value and itself, like
below:
5>
Glass Piece
Problem Description
A square glass sheet of size 'S' cm fell down and broken down into N+1 pieces.
A man collected the broken pieces and he is trying to arrange the pieces to get the
original shape. He found that exactly one piece is missing. To find the exact
position of the missing piece, he noted down all (x,y) coordinates of each broken
piece. Please help him to find the coordinates of the missing piece.
Note 1 : The input order of corners of known glass pieces are in the clockwise
direction starting from the corner having least X value. If more than one corners
having the same least X value, then start from the corner having least X and least
Y value.
Note 2 : The corners of missing glass piece should output in the clockwise
direction starting from the corner having least X value. If more than one corners
have same least X value, then start from the corner having least X and least Y
value.
Constraints
1 < S <= 1000.
Input Format
First line contains an integer, S, size of Glass Sheet.
Next N lines contain set of space separated integers indicates the details of N
known glass pieces as follows:
Output
Coordinates of missing piece in (X,Y) format separated by spaces.
Test Case
Explanation
Example 1
Input
400
Output
Explanation
The size of the square glass plate is 400 cm * 400 cm. The glass plate broke into 4
pieces and he got 3 pieces.
com.tcs.cv.automata.ei.middleware.DocxToHtmlConverter@2d1316fc:image1.png
Figure. 1
com.tcs.cv.automata.ei.middleware.DocxToHtmlConverter@2d1316fc:image2.png
Figure. 2
com.tcs.cv.automata.ei.middleware.DocxToHtmlConverter@2d1316fc:image3.png
Figure. 3
com.tcs.cv.automata.ei.middleware.DocxToHtmlConverter@2d1316fc:image4.png
Figure. 4
6>
Lifeguard Prob
Problem Description
A life guard is sitting on a beach on a lookout for potential emergencies.
He runs up to the sea with a speed f*V km/hr, then he swims straight to the person
at the rate V km/hr (both in straight lines and where f is a multiplying factor as
humans run much faster than they can swim).
com.tcs.cv.automata.ei.middleware.DocxToHtmlConverter@7452c059:image1.png
Since the lifeguard runs faster, it will save some more time to run a longer
distance rather than going straight and thus swimming a long distance.
However, this comes with the trade-off that running longer can actually mean going
a longer distance thus taking more time.
Thus, it can be logically inferred that, there must exist a spot on the Beach-Sea
Interface where, if the lifeguard directly runs to from his starting location, and
then swims directly to the drowning person, it'll take the least time.
Given the starting location , the location of the drowning person and the
multiplying factor f, find the optimized spot for fastest time.
Assumptions/Problem Explanation:
The x axis represents the Beach-Sea interface, positive Y axis is towards land and
negative Y-axis towards sea (See image above).
2. The Y-axis along with origin is at some arbitrary location to the left of both
the lifeguard and the drowning person. Since the origin point remains the same for
both of them and the staring locations are given relative to the origin , its
actual location does not matter. The only thing to note is, the origin and Y axis
is to the left of both of them, so beach is always in 1st quadrant and sea in 4th.
Thus, the positions of lifeguard and the drowning person are given as their (x,y)
co-ordinates. (7,5) means the person is 7 units on the axis and 5 units on the
positive y axis, and hence on the beach. Similarly, (7,-5) means the person is 7
units on the axis and 5 units on the negative Y axis, and hence in sea.
4. With regards to everything explained above, your task is to find a point on the
Beach-Sea Interface (X -axis) (x_optimized,0) to where if the lifeguard runs
directly from his starting position and then swims directly from the point to the
drowning person, it'll take the least amount of time.
5. All calculations must be done upto 6 decimal points accuracy and the output must
be upto 6 decimal points as well.
Constraints
0 <= x_l < 100 (Integer)
Input Format
The input shall consist of 3 parameters :
x_l
y_l
x_w
y_w
f
Output
Output must be a single number, x_optimized, as described above. The output must be
having accuracy to 6 decimal places. That is, 1 should be represented as 1.000000
Test Case
Explanation
Example 1
Input
-1
1.2
Output
1.000000
Lastly, display the coordinates of missing glass piece in the clockwise direction
starting from the corner (0,250), as output.