Programming and Interview Puzzles Page1
Page 1Page 2Page 3Page 4Page 5Page 6Page 7Page 8Page 9

A person wanted to withdraw X rupees and Y paise from the bank. But cashier made a mistake and gave him Y rupees and X paise. Neither the person nor the cashier noticed that.

After spending 20 paise, the person counts the money. And to his surprise, he has double the amount he wanted to withdraw.

Find X and Y. (1 Rupee = 100 Paise)
Answer
As given, the person wanted to withdraw 100X + Y paise.
But he got 100Y + X paise.

After spending 20 paise, he has double the amount he wanted to withdraw. Hence, the equation is

2 * (100X + Y) = 100Y + X - 20

200X + 2Y = 100Y +X - 20

199X - 98Y = -20

98Y - 199X = 20


Now, we got one equation; but there are 2 variables. We have to apply little bit of logic over here. We know that if we interchange X & Y, amount gets double. So Y should be twice of X or one more than twice of X i.e. Y = 2X or Y = 2X+1

 

Case I : Y=2X
Solving two equations simultaneously
98Y - 199X = 20
Y - 2X = 0
We get X = - 20/3 & Y = - 40/2

Case II : Y=2X+1
Solving two equations simultaneously
98Y - 199X = 20
Y - 2X = 1
We get X = 26 & Y = 53

Now, its obvious that he wanted to withdraw Rs. 26.53



Submit
Answer Users
Answer (2) BrainVista
Answer

The game of Tic-Tac-Toe is being played between two players. Only the last mark to be placed in the game as shown.

Who will win the game, O or X? Can you tell which was the sixth mark and at which position? Do explain your answer.
At the Party:
1. There were 9 men and children.
2. There were 2 more women than children.
3. The number of different man-woman couples possible was 24. Note that if there were 7 men and 5 women, then there would have been 35 man-woman couples possible.

Also, of the three groups - men, women and children - at the party:
4. There were 4 of one group.
5. There were 6 of one group.
6. There were 8 of one group.
Exactly one of the above 6 statements is false.

Can you tell which one is false? Also, how many men, women and children are there at the party



Assume that both the players are intelligent enough.




Answer

O will win the game. The sixth mark was X in square 9.

The 7th mark must be placed in square 5 which is the win situation for both X and O. Hence, the 6th mark must be placed in a line already containing two of the opponents marks. There are two such possibilities - the 6th mark would have been either O in square 7 or X in square 9.

As we know both the players are intelligent enough, the 6th mark could not be O in square 7. Instead, he would have placed O in square 5 and would have won.

Hence, the sixth mark must be X placed in square 9. And the seventh mark will be O. Thus O will win the game.

Answer

Statement (4) is false. There are 3 men, 8 women and 6 children.

Assume that Statements (4), (5) and (6) are all true. Then, Statement (1) is false. But then Statement (2) and (3) both can not be true. Thus, contradictory to the fact that exactly one statement is false.

So Statement (4) or Statement (5) or Statement (6) is false. Also, Statements (1), (2) and (3) all are true.

From (1) and (2), there are 11 men and women. Then from (3), there are 2 possible cases - either there are 8 men and 3 women or there are 3 men and 8 women.

If there are 8 men and 3 women, then there is 1 child. Then Statements (4) and (5) both are false, which is not possible.

Hence, there are 3 men, 8 women and 6 children. Statement (4) is false.

There is a shortage of tubelights, bulbs and fans in a village - Kharghar. It is found that
 All houses do not have either tubelight or bulb or fan.
 exactly 19% of houses do not have just one of these.
 atleast 67% of houses do not have tubelights.
 atleast 83% of houses do not have bulbs.
 atleast 73% of houses do not have fans.
What percentage of houses do not have tubelight, bulb and fan?
Answer

42% houses do not have tubelight, bulb and fan.

Let's assume that there are 100 houses. Hence, there should be total 300 items i.e. 100 tubelights, 100 bulbs and 100 fans.

From the given data, we know that there is shortage of atleast (67+83+73) 223 items in every 100 houses.

Also, exactly 19 houses do not have just one item. It means that remaining 81 houses should account for the shortage of remaining (223-19) 204 items. If those remaining 81 houses do not have 2 items each, there would be a shortage of 162 items. But total of 204 items are short. Hence, atleast (204-162) 42 houses do not have all 3 items - tubelight, bulb and fan.

Thus, 42% houses do not have tubelight, bulb and fan.
Mr. Subramaniam rents a private car for Andheri-Colaba-Andheri trip. It costs him Rs. 300 everyday.

One day the car driver informed Mr. Subramaniam that there were two students from Bandra who wished to go from Bandra to Colaba and back to Bandra. Bandra is halfway between Andheri and Colaba. Mr. Subramaniam asked the driver to let the students travel with him.

On the first day when they came, Mr. Subramaniam said, "If you tell me the mathematically correct price you should pay individually for your portion of the trip, I will let you travel for free."

How much should the individual student pay for their journey?
Answer

The individual student should pay Rs. 50 for their journey.

Note that 3 persons are travelling between Bandra and Colaba.

The entire trip costs Rs. 300 to Mr. Subramanian. Hence, half of the trip costs Rs. 150.

For Andheri-Bandra-Andheri, only one person i.e. Mr. Subramaniam is travelling. Hence, he would pay Rs. 150.

For Bandra-Colaba-Bandra, three persons i.e Mr. Subramaniam and two students, are travelling. Hence, each student would pay Rs. 50.

Substitute digits for the letters to make the following Division true
O U T

-------------

S T E M | D E M I S E

| D M O C

-------------

T U I S

S T E M

----------

Z Z Z E

Z U M M

--------

I S T
Note that the leftmost letter can't be zero in any word. Also, there must be a one-to-one mapping between digits and letters. e.g. if you substitute 3 for the letter M, no other letter can be 3 and all other M in the puzzle must be
Answer

C=0, U=1, S=2, T=3, O=4, M=5, I=6, Z=7, E=8, D=9

It is obvious that U=1 (as U*STEM=STEM) and C=0 (as I-C=I).

S*O is a single digit and also S*T is a single digit. Hence, their values (O, S, T) must be 2, 3 or 4 (as they can not be 0 or 1 or greater than 4).

Consider, STEM*O=DMOC, where C=0. It means that M must be 5. Now, its simple. O=4, S=2, T=3, E=8, Z=7, I=6 and D=9.
O U T 4 1 3

------------- -------------

S T E M | D E M I S E 2 3 8 5 | 9 8 5 6 2 8

| D M O C | 9 5 4 0

------------- -------------

T U I S 3 1 6 2

S T E M 2 3 8 5

---------- ----------

Z Z Z E 7 7 7 8

Z U M M 7 1 5 5

-------- --------

I S T 6 2 3
Also, when arranged from 0 to 9, it spells CUSTOMIZED.
At what time after 4.00 p.m. is the minutes hand of a clock exactly aligned with the hour hand?

Answer

4:21:49.5

Assume that X minutes after 4.00 PM minute hand exactly aligns with and hour hand.

For every minute, minute hand travels 6 degrees.
Hence, for X minutes it will travel 6 * X degrees.

For every minute, hour hand travels 1/2 degrees.
Hence, for X minutes it will travel X/2 degrees.

At 4.00 PM, the angle between minute hand and hour hand is 120 degrees. Also, after X minutes, minute hand and hour hand are exactly aligned. So the angle with respect to 12 i.e. Vertical Plane will be same. Therefore,

6 * X = 120 + X/2
12 * X = 240 + X
11 * X = 240
X = 21.8182
X = 21 minutes 49.5 seconds

Hence, at 4:21:49.5 minute hand is exactly aligned with the hour hand.

A soldier looses his way in a thick jungle. At random he walks from his camp but mathematically in an interesting fashion.

First he walks one mile East then half mile to North. Then 1/4 mile to West, then 1/8 mile to South and so on making a loop.

Finally how far he is from his camp and in which direction?

Answer

The soldier is 0.8944 miles away from his camp towards East-North.

It is obvious that he is in East-North direction.

Distance travelled in North and South directions
= 1/2 - 1/8 + 1/32 - 1/128 + 1/512 - 1/2048 + and so on... (a geometric series with r = (-1/4) )

(1/2) * ( 1 - (-1/4)n )
= ---------------------------
( 1 - (-1/4) )

= 1 / ( 2 * ( 1 - (-1/4) ) )
= 2/5

Similarly in East and West directions
= 1 - 1/4 + 1/16 - 1/64 + 1/256 - and so on... (a geometric series with r = (-1/4) )

(1) * ( 1 - (-1/4)n )
= ---------------------------
( 1 - (-1/4) )

= 1 / ( ( 1- (-1/4) )
= 4/5

So the soldier is 4/5 miles away towards East and 2/5 miles away towards North. So using right angled triangle, soldier is 0.8944 miles away from his camp.

Raj has a jewel chest containing Rings, Pins and Ear-rings. The chest contains 26 pieces. Raj has 2 1/2 times as many rings as pins, and the number of pairs of earrings is 4 less than the number of rings.

How many earrings does Raj have?

Answer

12 earrings

Assume that there are R rings, P pins and E pair of ear-rings.

It is given that, he has 2 1/2 times as many rings as pins.
R = (5/2) * P or P = (2*R)/5

And, the number of pairs of earrings is 4 less than the number of rings.
E = R - 4 or R = E + 4

Also, there are total 26 pieces.
R + P + 2*E = 26
R + (2*R)/5 + 2*E = 26
5*R + 2*R + 10*E = 130
7*R + 10*E = 130
7*(E + 4) + 10*E = 130
7*E + 28 + 10*E = 130
17*E = 102
E = 6

Hence, there are 6 pairs of Ear-rings i.e. total 12 Ear-rings
How many ways are there of arranging the sixteen black or white pieces of a standard international chess set on the first two rows of the board?

Given that each pawn is identical and each rook, knight and bishop is identical to its pair.
Submitted

Answer

6,48,64,800 ways

There are total 16 pieces which can be arranged on 16 places in 16P16 = 16! ways.
(16! = 16 * 15 * 14 * 13 * 12 * ..... * 3 * 2 * 1)

But, there are some duplicate combinations because of identical pieces.
 There are 8 identical pawn, which can be arranged in 8P8 = 8! ways.
 Similarly there are 2 identical rooks, 2 identical knights and 2 identical bishops. Each can be arranged in 2P2 = 2! ways.
Hence, the require answer is
= (16!) / (8! * 2! * 2! * 2!)
= 6,48,64,800


A person with some money spends 1/3 for cloths, 1/5 of the remaining for food and 1/4 of the remaining for travel. He is left with Rs 100/-

How much did he have with him in the begining?

Answer

Rs. 250/-

Assume that initially he had Rs. X
He spent 1/3 for cloths =. (1/3) * X
Remaining money = (2/3) * X

He spent 1/5 of remaining money for food = (1/5) * (2/3) * X = (2/15) * X
Remaining money = (2/3) * X - (2/15) * X = (8/15) * X

Again, he spent 1/4 of remaining maoney for travel = (1/4) * (8/15) * X = (2/15) * X
Remaining money = (8/15) * X - (2/15) * X = (6/15) * X

But after spending for travel he is left with Rs. 100/- So
(6/15) * X = 100
X = 250

Grass in lawn grows equally thick and in a uniform rate. It takes 24 days for 70 cows and 60 days for 30 cows to eat the whole of the grass.

How many cows are needed to eat the grass in 96 days?
Answer

20 cows

g - grass at the beginning
r - rate at which grass grows, per day
y - rate at which one cow eats grass, per day
n - no of cows to eat the grass in 96 days

From given data,
g + 24*r = 70 * 24 * y ---------- A
g + 60*r = 30 * 60 * y ---------- B
g + 96*r = n * 96 * y ---------- C

Solving for (B-A),
(60 * r) - (24 * r) = (30 * 60 * y) - (70 * 24 * y)
36 * r = 120 * y ---------- D

Solving for (C-B),
(96 * r) - (60 * r) = (n * 96 * y) - (30 * 60 * y)
36 * r = (n * 96 - 30 * 60) * y
120 * y = (n * 96 - 30 * 60) * y [From D]
120 = (n * 96 - 1800)
n = 20

Hence, 20 cows are needed to eat the grass in 96 days.
There is a safe with a 5 digit number as the key. The 4th digit is 4 greater than the second digit, while the 3rd digit is 3 less than the 2nd digit. The 1st digit is thrice the last digit. There are 3 pairs whose sum is 11.

Find the number.
Answer

65292

As per given conditions, there are three possible combinations for 2nd, 3rd and 4th digits. They are (3, 0, 7) or (4, 1, 8) or (5, 2, 9)

It is given that there are 3 pairs whose sum is 11. All possible pairs are (2, 9), (3, 8), (4, 7), (5, 6). Now required number is 5 digit number and it contains 3 pairs of 11. So it must not be having 0 and 1 in it. Hence, the only possible combination for 2nd, 3rd and 4th digits is (5, 2, 9)

Also, 1st digit is thrice the last digit. The possible combinations are (3, 1), (6, 2) and (9, 3), out of which only (6, 2) with (5, 2, 9) gives 3 pairs of 11. Hence, the answer is 65292.
Four friends - Arjan, Bhuvan, Guran and Lakha were comparing the number of sheep that they owned.

It was found that Guran had ten more sheep than Lakha.

If Arjan gave one-third to Bhuvan, and Bhuvan gave a quarter of what he then held to Guran, who then passed on a fifth of his holding to Lakha, they would all have an equal number of sheep.

How many sheep did each of them possess? Give the minimal possible answer

Answer


Arjan, Bhuvan, Guran and Lakha had 90, 50, 55 and 45 sheep respectively.

Assume that Arjan, Bhuvan, Guran and Lakha had A, B, G and L sheep respectively. As it is given that at the end each would have an equal number of sheep, comparing the final numbers from the above table.

Arjan's sheep = Bhuvan's sheep
2A/3 = A/4 + 3B/4
8A = 3A + 9B
5A = 9B

Arjan's sheep = Guran's sheep
2A/3 = A/15 + B/5 + 4G/5
2A/3 = A/15 + A/9 + 4G/5 (as B=5A/9)
30A = 3A + 5A + 36G
22A = 36G
11A = 18G

Arjan's sheep = Lakha's sheep
2A/3 = A/60 + B/20 + G/5 + L
2A/3 = A/60 + A/36 + 11A/90 + L (as B=5A/9 and G=11A/18)
2A/3 = A/6 + L
A/2 = L
A = 2L

Also, it is given that Guran had ten more sheep than Lakha.
G = L + 10
11A/18 = A/2 + 10
A/9 = 10
A = 90 sheep

Thus, Arjan had 90 sheep, Bhuvan had 5A/9 i.e. 50 sheep, Guran had 11A/18 i.e. 55 sheep and Lakha had A/2 i.e. 45 sheep.
Consider a number 235, where last digit is the sum of first two digits i.e. 2 + 3 = 5.

How many such 3-digit numbers are there?

Answer

There are 45 different 3-digit numbers.

The last digit can not be 0.

If the last digit is 1, the only possible number is 101. (Note that 011 is not a 3-digit number)

If the last digit is 2, the possible numbers are 202 and 112.

If the last digit is 3, the possible numbers are 303, 213 and 123.

If the last digit is 4, the possible numbers are 404, 314, 224 and 134.

If the last digit is 5, the possible numbers are 505, 415, 325, 235 and 145.

Note the pattern here - If the last digit is 1, there is only one number. If the last digit is 2, there are two numbers. If the last digit is 3, there are three numbers. If the last digit is 4, there are four numbers. If the last digit is 5, there are five numbers. And so on.....

Thus, total numbers are
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 = 45

Altogether then, there are 45 different 3-digit numbers, where last digit is the sum of first two digits.

Find the smallest number such that if its rightmost digit is placed at its left end, the new number so formed is precisely 50% larger than the original number.
Answer

The answer is 285714.

If its rightmost digit is placed at its left end, then new number is 428571 which is 50% larger than the original number 285714.

The simplest way is to write a small program. And the other way is trial and error !!!
Two identical pack of cards A and B are shuffled throughly. One card is picked from A and shuffled with B. The top card from pack A is turned up. If this is the Queen of Hearts, what are the chances that the top card in B will be the King of Hearts?

Answer

52 / 2703

There are two cases to be considered.

CASE 1 : King of Hearts is drawn from Pack A and shuffled with Pack B

Probability of drawing King of Hearts from Pack A = 1/51 (as Queen of Hearts is not to be drawn)
Probability of having King of Hearts on the top of the Pack B = 2/53

So total probability of case 1 = (1/51) * (2/53) = 2 / (51 * 53)

CASE 2 : King of Hearts is not drawn from Pack A

Probability of not drawing King of Hearts from Pack A = 50/51 (as Queen of Hearts is not to be drawn)
Probability of having King of Hearts on the top of the Pack B = 1/53

So total probability of case 2 = (50/51) * (1/53) = 50 / (51 * 53)

Now adding both the probability, the required probability is
= 2 / (51 * 53) + 50 / (51 * 53)
= 52 / (51 * 53)
= 52 / 2703
= 0.0192378
There are 3 ants at 3 corners of a triangle, they randomly start moving towards another corner.

What is the probability that they don't collide?

Answer

Let's mark the corners of the triangle as A,B,C. There are total 8 ways in which ants can move.
1. A->B, B->C, C->A
2. A->B, B->C, C->B
3. A->B, B->A, C->A
4. A->B, B->A, C->B
5. A->C, C->B, B->A
6. A->C, C->B, B->C
7. A->C, C->A, B->A
8. A->C, C->A, B->C

Out of which, there are only two cases under which the ants won't collide :
 A->B, B->C, C->A
 A->C, C->B, B->A