Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 11

1>

New ATM Design


Problem Description
Automated Teller Machine (ATM) is an electronic device that enables people to
withdraw cash from their bank account. Every ATM has a limit for number of currency
notes (say N), it can give at a time.

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,

7 * 100 + 3* 200 + 0*500 +0*1000 hence maximum possible currency = 10.

Example 2

Input

1700

Output

Explanation

Here,

0 * 100 + 1 * 200 + 1 * 500 +1 * 1000 hence maximum possible currency = 3.

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).

Write a program to accept a number representation, perform the successive base


reductions as above and print the resulting final number.

Constraints
1. The length of input number representation <= 5

2. Maximum base = 36

3. Symbols used for digits: Base 2: 0, 1


Base 3: 0, 1, 2
...
Base 11: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A

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

4. Face values for symbols: Symbol => Value 0 => 0


1 => 1
2 => 2
�.
9 => 9
A => 10
B => 11
�.
Z => 35

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)

Second line contains M (number of Participants)

Third line contains N integers separated with space (default answers)

Next M lines contains N integers separated with space (response of M participants)

Output
First M lines showing the instant results of each Participant.

Last line containing the TOPPER�s id and his score

(assume id�s start with 1)

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 is same as Default answers)

First Participant answers : 1 2 4 4 3 2 3 1 1 3


Right answers : 6 (= Instant result of first Participant)

Latest Key : 1 2 4 4 3 2 3 1 1 3

Second Participant�s answers : 2 3 4 4 1 2 3 1 1 2

Right answers : 6 (= Instant result of second Participant)

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)

Right answers of Participant1 = Right answers of Participant2 = 8.

So topper is first Participant with score 8.

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.

Lets understand the problem using the following example.

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.

1st � Total number of coins.

2nd - number of 5 Rupee coins.

3rd � number of 2 Rupee coins.

4th � number of 1 Rupee coins.

Test Case

Explanation
Example 1
Input

13

Output

6 1 3 2

Explanation

The minimum number of coins required is 6 with in it:

minimum number of 5 Rupee coins = 1

minimum number of 2 Rupee coins = 3

minimum number of 1 Rupee coins = 2

Using these coins, we can form any value with in the given value and itself, like
below:

Here the given value is 13

For 1 = one 1 Rupee coin

For 2 = one 2 Rupee coin

For 3 = one 1 Rupee coin and one 2 Rupee coins

For 4 = two 2 Rupee coins

For 5 = one 5 Rupee coin

For 6 = one 5 Rupee and one 1 Rupee coins

For 7 = one 5 Rupee and one 2 Rupee coins

For 8 = one 5 Rupee, one 2 Rupee and one 1 Rupee coins

For 9 = one 5 Rupee and two 2 Rupee coins

For 10 = one 5 Rupee, two 2 Rupee and one 1 Rupee coins

For 11 = one 5 Rupee, two 2 Rupee and two 1 Rupee coins

For 12 = one 5 Rupee, three 2 Rupee and one 1 Rupee coins

For 13 = one 5 Rupee, three 2 Rupee and two 1 Rupee coins

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.

1 < N <= 50.

Input Format
First line contains an integer, S, size of Glass Sheet.

Second line contains an integer, N.

Next N lines contain set of space separated integers indicates the details of N
known glass pieces as follows:

� First number indicates total corners of that glass piece - say i,

� followed by 2 * i integers denotes X and Y coordinates of i corners, delimited by


space

Output
Coordinates of missing piece in (X,Y) format separated by spaces.

Test Case

Explanation
Example 1

Input

400

5 0 0 200 0 400 200 100 250 0 250

3 200 0 400 0 400 200

4 100 250 400 200 400 400 200 400

Output

(0,250) (100,250) (200,400) (0,400)

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.

He placed first glass piece as below figure:

com.tcs.cv.automata.ei.middleware.DocxToHtmlConverter@2d1316fc:image1.png

Figure. 1

Next he placed second glass piece as below figure:

com.tcs.cv.automata.ei.middleware.DocxToHtmlConverter@2d1316fc:image2.png

Figure. 2

Next he placed third glass piece as below figure:

com.tcs.cv.automata.ei.middleware.DocxToHtmlConverter@2d1316fc:image3.png

Figure. 3

Finally he found the position of the missing piece as below figure:

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 suddenly notices a person who is drowning and springs to action.

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).

He wants to minimize the time taken to get to that person.

See the below image for better understanding :

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:

1. Consider that everything is in a two dimensional (2D) plane.

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.

3. The lifeguard both runs and swims in perfectly straight lines.

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)

0 <= y_l < 100 (Integer)

0 <= x_w < 100 (Integer)

-500 < y_w < 0 (Integer)

1 < f <= 15 (Integer)

Input Format
The input shall consist of 3 parameters :

1. Starting position of the lifeguard in terms of his coordinates (x_l,y_l).

2. Position of the drowning person (x_w,y_w)

3. The multiplying factor f.

These parameters would be given in the following order in 5 different lines:

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.

You might also like