Saturday, May 5, 2007

Stock Price

Rushabh works for the Stock Exchange as a Share Broker. He primarily keeps his eyes on Shares related to IT companies.

One day he met his friend Parag, during lunch time. Parag asked him about the price of a single Share of Info Tech company.

Rushabh answered cryptically by giving following three clues:

  • if price of a Share is multiple of 5, then it is between $1 and $30
  • if price of a Share is not a multiple of 7, then it is between $31 and $50
  • if price of a Share is not a multiple of 10, then it is between $51 and $60
What is the price of a Share of Info Tech company?

Note that the price of a Share is a positive integer.
















Answer is 56.

Solution:
1. If muliple of 5 > 5,10,15,20,25
2. If not a muliple of 7 > 31,32,33,34,36,37,38,39,40,41,43,44,45,46,47,48
3. If not a muliple of 10 > 51,52,53,54,55,56,57,58,59

Let say, its multiple of 5, In this case, it won't be multiple of 7 as none of number in case 1 is divisible by 7, so case 1 and case 2 will contrdict. So can't be a multiple of 5. If can't be a multiple of 5 then also can't be a multiple of 10. so case 3 will hold true and then number will be anyone from case 3.
Now acc to case 2, if its not a multiple of 7, it anyone from case 2 numbers. So only 56 from case 3 fits as Its a multiple of 7 so case 2 won't apply.

For more such articles, Visit: http://www.pankajbatra.com

Sweets

Patricia loves Indian sweets. During her visit to the Indian Sweets Shop, she purchased three different types of sweets – Rasgulla, Gulab Jamun and Barfi.

She purchased as many pieces of each type of sweets as its price in dollar. Each of the three types of sweet cost a different amount per piece. She spent less than $100.

Rasgulla cost the most, Gulab Jamun cost less and Barfi cost the least per piece. Compared to Rasgulla, one of the other two types of sweet costs $ 5 less per piece.

If she paid an average of $ 7 for each piece of sweet, how many of each type did she purchase?











Patricia purchased 9 Rasgulla, 4 Gulab Jamun and 1 Barfi. She paid $ 98.

Assume that she purchased R pieces of Rasgulla. Also assume that P and Q are the number of pieces of other sweets.

It is given that - she purchased as many pieces of each type of sweets as its price in dollar and she paid an average of $ 7 for each piece of sweet. Hence,
7 * (R + P + Q) = R*R + P*P + Q*Q

Since the average price per piece is $ 7 and Rasgulla cost the most, per piece cost of Rasgulla should be more than $ 7.

Also, it is given that - Compared to Rasgulla, one of the other two types of sweet costs $ 5 less per piece.

Consider R = 8 and hence, P = 3
7 * (8 + 3 + Q) = 8*8 + 3*3 + Q*Q
7 * (11 + Q) = 64 + 9 + Q*Q
Q*Q – 7*Q – 4 = 0
For Q = 1, 2, 4, 5, 6, 7, above equation is not valid.

Consider R = 9 and hence, P = 4
7 * (9 + 4 + Q) = 9*9 + 4*4 + Q*Q
7 * (13 + Q) = 81 + 16 + Q*Q
Q*Q – 7*Q + 6 = 0
Q = 6 or Q = 1

Q can not be 6 as total cost (81 + 36 + 16 = 133) would be more than $ 100. Hence, Q=1.

For all other values of R, the total cost would be more than $ 100.

Thus, Patricia purchased 9 Rasgulla, 4 Gulab Jamun and 1 Barfi. She paid $ 98.

For more such articles, Visit: http://www.pankajbatra.com

Wednesday, May 2, 2007

Jars

The Problem:

You've got two jars, one of them fits exactly 7 liters, the other one fits exactly 4 liters. How could you get exactly 2 liters with these two jars? You have unlimited supply of water and you are allowed to spoil some water.





The Solution:

7 0 fill the 7 ltr jar completely
3 4 fill the 4 ltr jar using the 7 ltr one completely
3 0 empty the 4 ltr jar
0 3 fill all water from 7 ltr jar to 4 ltr water
7 3 fill the 7 ltr jar completely
6 4 fill 4 ltr jar from 7 ltr one completely
6 0 empty the 4 ltr jar
2 4 fill 4 ltr jar from 7 ltr one completely
2 0 empty the 4 ltr jar

Now you have exactly 2 ltrs in 7 ltr jar

For more such articles, Visit: http://www.pankajbatra.com

Thursday, April 26, 2007

One odd in 12 balls

The Problem:

You have 12 balls identical in size and appearance but 1 is an odd weight (could be either light or heavy).

You have a set scales (balance) which will give 3 possible readings: Left = Right, Left > Right or Left < Right (ie Left and Right have equal weight, Left is Heavier, or Left is Lighter).

You have only 3 chances to weigh the balls in any combination using the scales. Determine which ball is the odd one and if it's heavier or lighter than the rest. How do you do it?

The Solution:

Number the balls 1, 2, 3, ... 10, 11, 12

Start off with them in 3 groups: [1, 2, 3 and 4], [5, 6, 7 and 8] and [9,10,11 and 12]

Weigh 1, 2, 3 and 4 vs 5, 6, 7 and 8 with 3 possible outcomes:

1. If they balance then 9,10,11,12 have the odd ball, so weigh 6,7,8 vs 9,10,11 with 3 possible outcomes:

1a If 6,7,8 vs 9,10,11 balances, 12 is the odd ball. Weigh it against any other ball to determine if heavy or light.

1b If 9,10,11 is heavy then they contain a heavy ball. Weigh 9 vs 10, if balanced then 11 is the odd heavy ball, else the heavier of 9 or 10 is the odd heavy ball.

1b If 9,10,11 is light then they contain a light ball. Weigh 9 vs 10, if balanced then 11 is the odd light ball, else the lighter of 9 or 10 is the odd light ball.



2. If 5,6,7,8 > 1,2,3,4 then either 5,6,7,8 contains a heavy ball or 1,2,3,4 contains a light ball so weigh 1,2,5 vs 3,6,12 with 3 possible outcomes:

2a If 1,2,5 vs 3,6,12 balances, then either 4 is the odd light ball or 7 or 8 is the odd heavy ball. Weigh 7 vs 8, if they balance then 4 is the odd light ball, or the heaviest of 7 vs 8 is the odd heavy ball.

2b If 3,6,12 is heavy then either 6 is the odd heavy ball or 1 or 2 is the odd light ball. Weigh 1 vs 2, if balanced then 6 is the odd heavy ball, or the lighest of 1 vs 2 is the odd light ball.

2c If 3,6,12 is light then either 3 is light or 5 is heavy. Weigh 3 against any other ball, if balanced then 5 is the odd heavy ball else 3 is the odd light ball.



3. If 1,2,3,4 > 5,6,7,8 then either 1,2,3,4 contains a heavy ball or 5,6,7,8 contains a light ball so weigh 5,6,1 vs 7,2,12 with 3 possible outcomes:

3a If 5,6,1 vs 7,2,12 balances, then either 8 is the odd light ball or 3 or 4 is the odd heavy ball. Weigh 3 vs 4, if they balance then 8 is the odd light ball, or the heaviest of 3 vs 4 is the odd heavy ball.

3b If 7,2,12 is heavy then either 2 is the odd heavy ball or 5 or 6 is the odd light ball. Weigh 5 vs 6, if balanced then 2 is the odd heavy ball, or the lighest of 5 vs 6 is the odd light ball.

3c If 7,2,12 is light then either 7 is light or 1 is heavy. Weigh 7 against any other ball, if balanced then 1 is the odd heavy ball else 7 is the odd light ball.

For more such articles, Visit: http://www.pankajbatra.com

100 doors in a row

You have 100 doors in a row that are all initially closed. you make 100 passes by the doors starting with the first door every time. the first time through you visit every door and toggle the door (if the door is closed, you open it, if its open, you close it). the second time you only visit every 2nd door (door #2, #4, #6). the third time, every 3rd door (door #3, #6, #9), etc, until you only visit the 100th door.

for example, after the first pass every door is open. on the second pass you only visit the even doors (2,4,6,8...) so now the even doors are closed and the odd ones are opened. the third time through you will close door 3 (opened from the first pass), open door 6 (closed from the second pass), etc..

question: what state are the doors in after the last pass? which are open which are closed?





Solution: you can figure out that for any given door, say door #42, you will visit it for every divisor it has. so 42 has 1 & 42, 2 & 21, 3 & 14, 6 & 7. so on pass 1 i will open the door, pass 2 i will close it, pass 3 open, pass 6 close, pass 7 open, pass 14 close, pass 21 open, pass 42 close. for every pair of divisors the door will just end up back in its initial state. so you might think that every door will end up closed? well what about door #9. 9 has the divisors 1 & 9, 3 & 3. but 3 is repeated because 9 is a perfect square, so you will only visit door #9, on pass 1, 3, and 9... leaving it open at the end. only perfect square doors will be open at the end.

For more such articles, Visit: http://www.pankajbatra.com

Tuesday, April 24, 2007

Bulbs and Switches

There are three bulbs on 19th floor and there are three switches X, Y and Z on the ground floor. Each switch belongs to one bulbs, not necessarily in order. You can switch on or off as many times you want but you can go on 19th floor only once.

How will you find out which swich belongs to which bulb? Note that you are the only person over there. You can't go outside and can't use any tools.








Answer :
switch X on and leave for 5 minutes. The turn that on off. switch Y on then go up to 19th floor. X switches the lightbulb that is warm but off, Y the one that is lit and Z the cold lightbulb that is off. Pretty simple huh....

For more such articles, Visit: http://www.pankajbatra.com

Elevator

Question: A man lives on the twelfth floor of an apartment building. Every morning he takes the elevator down to the lobby and leaves the building. In the evening, he gets into the elevator, and, if there is someone else in the elevator -- or if it was raining that day -- he goes back to his floor directly. Otherwise, he goes to the tenth floor and walks up two flights of stairs to his apartment.

Answer: The man is a dwarf. He can't reach the upper elevator buttons, but he can ask people to push them for him. He can also push them with his umbrella.

For more such articles, Visit: http://www.pankajbatra.com