Showing posts with label Puzzles. Show all posts
Showing posts with label Puzzles. Show all posts

Saturday, May 2, 2009

Puzzle: Circular Table, Pile of Quarters and 2 Players


Puzzle: There is a huge pile of quarters and a circular table. There are two people to play a game of placing the quarters down on the table alternately without any overlap. The one who can't put down a quarter loses. Assuming that the pile of quarters is non-exhaustive what will be your winning strategy? Whether you would like to start or let your partner start?

Solution: The winning strategy here will be to find a way where you always end up getting a
section of free space on the table to place down the quarter in your hand. That's fine, but how can one always ensure free space on the table? The table is circular and hence due to symmetry every place on the table (except for the centre) will have its own corresponding counterpart right opposite to it on the other side of the centre.

Got the answer now? Since the centre of the table is the only exception (not having a
symmetrically opposite area) here and any other area on the table can always be guaranteed to have a directly opposite area where the centre of the table will be right in the middle of the two.

For winning the game you got to start first and place the quarter exactly in the centre of
the table. From now on, any area your parter chooses to put down the quarter in their hand, will have its corresponding symmetrically opposite area on the other side of the centre of the table where you can place the quarter on your turn.

This will guarantee that you never fall short of free space on the table as this way you would be occupying the last usable (free) section of the table and consequently your partner will be the one failing to find a free area on the table to place the quarter on. How long/soon that happens, will depend upon the size of the quarters and that of the table.

Liked the article? Subscribe to this blog for regular updates. Wanna follow it to tell the world that you enjoy GeekExplains? Please find the 'Followers' widget in the rightmost sidebar.



Share/Save/Bookmark


Saturday, July 5, 2008

Puzzle: 2 crystal balls, 100 storey building, find no. of drops required?


Puzzle: There are two identical crystal balls and one needs to find out which is the maximum floor in a 100 storey building from where the balls can fall before they break. In the most efficient way, what will be the maximum number of drops required to find the right floor in any possible scenario? The balls are allowed to be broken (if required) while finding the right floor.

Solution:
The maximum drops required will be 14 to find the right floor considering all possible scenarios.

The approach should be to drop the first crystal ball from a floor and if it breaks then try dropping the second crystal ball (of course until it breaks) from the floor next to the previously tested floor until one less than that floor from where the first crystal ball broke when dropped.

In the most efficient way, the maximum number of trials needed should be kept to the minimum possible. We have a maximum of 100 floors, so we need to divide these floors in such a way that the sum of the number of trials consumed by first crystal ball and that of the second crystal ball (if the first breaks) remains the minimum. For this to happen we need to reduce the difference between the previously tested floor and the next floor to test the first ball from every time by 1 as the first balls has already been dropped by those many times. Confused? Let's try to understand it this way: Suppose we drop the first ball from the Nth floor for the first time then we'll require a maximum of N drops if the first ball breaks as in this case the second ball will be tried from floor #1 to floor #(N-1). If the first ball doesn't break then we'll have to select the next floor to test the drop of the first ball from. This can't be more than (N-i) from the previously tested floor where i = 1 ... N-1 for every subsequent step in this order only. Reason being, if we test the first ball from a higher floor and if the ball breaks then we may require to test the second ball more number of times and hence the maximum attempts may exceed N in this case. Similarly, if we test the first ball from a lower floor then we'll require to test the first ball more than N times if it doesn't break at all.

Obviously this N will of course be dependent upon the maximum number of floors which is 100 in our case. Putting N = 14, we will require the first ball test from floor #14, #(14 + 14 - 1 = 27), #(27 + 14 - 2 = 39), #(39 + 14 - 3 = 50), #(50 + 14 - 4 = 60), #(60 + 14 - 5 = 69), #(69 + 14 - 6 = 77), #(77 + 14 - 7 = 84), #(84 + 14 - 8 = 90), #(90 + 14 - 9 = 95), #(95 + 14 - 10 = 99), and finally from #100. The test will continue until we reach #100 OR the first ball breaks in which case the second crystal ball will be used for the floors lying between the floor where the first ball breaks and the previously tested floor.

I doubt if there is any easy formula to find out this number N, but we can certainly reach this by using a heuristic approach. As we move on we consume trials at every stage and this should always be kept in mind. This is the reason why we can't keep the difference between the previously tested floor and the next floor to test from as constant for the first crystal ball drop.

For N = 14, if the first ball doesn't break at all then we need to try a maximum of 12 times and if it breaks the very first time itself then we may require to try a maximum of 14 times (1 by the first ball from floor #14 and a maximum of 13 by the second ball from floor #1 ... #13). Similarly, if the first ball breaks at floor #27 then maximum attempts required will again be 14 (2 by first ... [from floor #14 and from floor #27] plus 12 by second [from floor #15 ... floor #26]). And and so on. Thus we see that in this case if the first ball breaks at any of the floors then we need a maximum of 14 attempts to figure out the correct floor and if it doesn't break at all then we'll done with a maximum of 12 attempts only.



Share/Save/Bookmark


Puzzle: Deck of 52 cards, two players, who will win?


Puzzle: The rules of a card game (having 52 cards) played between two peole are:- they will turn over two cards at a time. If both the cards are Black they will go the first player's pile and if both are Red they they will go to the second player's pile. If one is Red and one Black then both the cards will simply be discarded.

The process of turning over two cards at a time is repeated till all the 52 cards are exhausted. Whoever is having more number of cards in their pile wins the game. In case of tie the first player is declared winner. What's the chance of second player winning the game?

Solution: Zero ... yeah you read it right. Second player will never win the game. We can have only the following possibilities:-

  • If, All the pairs are perfectly matched - 13 Black pairs and 13 Red pairs and hence a tie and therefore First Player wins the game.
  • Else If, 12 pairs are matched - If we get 12 matched Black pairs then we'll have 12 matched Red pairs as well as if the rest two pairs are also matched then it'll be same as the above case. Okay... so in this scenario both the mixed pairs will be discarded and it'll be tie again and hence First Player wins in this case as well.
  • Else If, 11 pairs are matched - we'll have 4 mixed and hence discarded pairs and 11 matched pairs each for both Red and Black... again a tie and First Player wins the game.
  • Else If, 10 pairs are matched... tie and First player wins.
  • Else If, 9 pairs are matched... tie and First Player wins.
  • ... and so on.
Thus we that irrespective of how mixed the deck of cards is... it'll always be a tie and hence the First Player will always emerge as the winner.



Share/Save/Bookmark


Wednesday, June 11, 2008

Puzzle: Avg Salary without disclosing the salaries


Puzzle: How can three co-workers know the average of their salaries without disclosing their own salaries to each other?

Solution: Let's say the three co-workers are A, B, and C and their individual salaries are Sa, Sb, and Sc respectively. For knowing the average of their salaries without disclosing their own salaries to each other, they follow these steps:-

  • A adds a random amount, say Ra to his own salary and gives that to B (B won't be able to know A's salary as he has added a random amount known to him only). In this case, B will receive the figure (Sa + Ra) from A.
  • B does the same and gives the final amount to C (without showing that to A). Now C will get the figure (Sa + Ra + Sb + Rb).
  • C does the same and gives the final figure to A (without showing it to B). Now, A will receive the figure (Sa + Ra + Sb + Rb + Sc + Rc).
  • Now A subtracts his random amount and gives the final figure to B (without showing that to C). B will now receive the figure (Sa + Sb + Rb + Sc + Rc).
  • B subtracts his random amount and gives the final figure to C (without showing it to A). C will receive the figure (Sa + Sb + Sc + Rc).
  • C subtracts his random amount and then the figure becomes (Sa + Sb + Sc). It's shown to everyone and by they get to know the average simply by dividing this figure by 3. Cool... isn't it?

It's important to note here that at every stage (except the very last where C subtracts his random amount), only two co-workers communicating each other should know the fugures and not the third one.

We can apply the same technique to know the average of more than 3 people as well. We just need to remember that at every stage only two people should share the figures and rest other should not be communicated that. What are you waiting for? Find the average salary of your team. No one needs to disclose his/her own salary, so it'll be good fun :-)



Share/Save/Bookmark


Puzzle: What's the no. of trailing zeroes in 100!


Puzzle: What's the number of trailing zeroes in 100!

Solution: FYI - 100! = 1 * 2 * 3 * .... * 99 * 100

Approach: 1 trailing zero will be produced by every different 10 as a factor in the product. One 10 will be produced by one 5 and one 2. Since, number of 2s will always be more than number of 5s in the overall product, so we'll go by counting the occurrences of 5s to compute the number of occurrences of 10s as factors. Similarly, counting the occurrences of 5*5 = 25 will give us the total number of occurrences of 100s in the product... we need to calculate this as one 100 will contribute 2 zeroes at the end of the product. 1 out of these 2 zeroes would have already been counted by calculating the number of occurrences of 10s and the second zero will be counted by calculating the number of occurrences of 100s. Right? We don't need to continue the same way for finding the occurrences of 1000s as all such cases would have already been counted either by counting the occurrences of 10s or by counting the occurrences of 100s. Okay... let's try to understand this. One possible combination of factors which can produce 1000 is (25, 40). But, we have already counted the occurrences of 25 and that of 5. So, this pair is already covered. We can easily see the same happening for any other possible combination of factors which can produce 1000. So, the rule of thumb is that we continue counting the occurrences of 5, 5*5, ... till it exceeds the number whose factorial is being counted for trailing zeroes.

Answer: Hence, the number of trailing 0s in 100! = ceil(100, 5) + ceil(100, 25) = 20 + 4 = 24. Here, the ceil function gives the total number of occurrences of the second operand in the factorial of the first operand.



Share/Save/Bookmark


Monday, June 9, 2008

Puzzle: Probability of sitting on one's own seat?


Puzzle: 100 passengers are waiting to board a flight having 100 seats. Each of them is having a ticket with a particular seat number which is same as their number in the queue. Unfortunately the first person in the queue is little crazy and he can occupy any random seat. Now, all other passengers will see if their seat is occupied by that crazy guy or not? If not, then they will be seated on their own seat numbers otherwise they will also look for a free random seat to sit on. This continues. What's the probability that the 100th person gets his own seat to sit on?


Solution: The crazy guy can occupy any seat randomly, hence the probability of him occupying his own seat = 1/2 (and not 1/100 as there will only be two cases - either he sits on his propely allocated seat or not... rest of the 99 seats can be viewed as only one case here). Similarly, the probability of the second person in the queue getting his own seat is again 1/2 as either the crazy guy would have occupied his seat or not.... and this continues. For any other person in the queue, his eat will either be occupied either by the crazy guy (or some other guy as that guy's seat was already occupied) or free for him to sit on. So, a seat will either be Free to sit on OR Occupied. That's it. Only two cases.


Hence, the probability of the 100th person occupying his own seat is also 1/2 only. Irrespective of which seat the crazy guy sits on, all the other passengers will have only two possible choices - either their own seat or any other random seat. The key here is to visualize all the random choices as only only one case. Confused? You can take an example of 3-4 passengers and probably that can help you understanding the underlying idea.



Share/Save/Bookmark


Puzzle: 13 Red, 15 Green, and 17 Blue Chameleons



Puzzle: There are 13 Red, 15 Green, and 17 Blue Chameleons at some point of time. Whenever two Chameleons of the different colors meet both of them change their color to the third color. Is it ever possible for all Chameleons to become of the same color? Why?


Solution: Initial differences between the number of Chameleons of different colors are as follows:-


nC(r) ~ nC(g) = 2

nC(g) ~ nC(b) = 2

nC(r) ~ nC(b) = 4


Whenever two Chameleons of different colors meet, both of them convert to Chameleons of the third color i.e., the number of Chameleons of the two colors (they were before meeting) decreases by 1 whereas the number of Chameleons of the third color (they turn into after meeting) increases by 2.


Let's try to see how the difference between the number of Chameleons of different colors change once they start meeting. For example, if C(r) and C(g) meet ... then nC(r) ~ nC(g) will remain 2 only as net change will be 0. nC(g) ~ nC(b) = 2 + 1 = 3 as nC(b) increases by 2 whereas nC(g) decreases by 1 in this case. Similarly, nC(r) ~ nC(b) = 4 + 1 = 5. If we proceed like this then ultimately nC(r) will become 0 and nC(g) will remain 2, but the difference will still be 2 only. Now, we will start making C(g) and C(b) meet, but then they will start producing C(r) and ultimately nC(g) will become 0, but we'll have few nC(r) which will not be same as nC(b) and this continues... Irrespective of what combination you follow, you'll always end up being in a similar situation.


Thus, we can easily observe that the difference between Chameleons of two different colors is never going to be 0 and in absence of such a scenario we can't get all the Chameleons turning into one single color.



Share/Save/Bookmark


Puzzle: How many hens for 6 eggs in 6 days?


Puzzle: If a hen and a half lay an egg and a half in a day and a half then how many hens will it take to lay six eggs in six days?

Answer: A simple one...right? Only 1.5 hens will be needed in this case.

Since, 1.5 eggs in 1.5 days require 1.5 hens
=> 1 egg in 1.5 days will require 1.5/1.5 = 1 hen
=> 1 egg in 1 day will require 1 * 1.5 = 1.5 hens
=> 6 eggs in 1 day will require 1.5 * 6 hens
=> 6 eggs in 6 days will require 1.5 * 6 / 6 = 1.5 hens



Share/Save/Bookmark


Wednesday, May 28, 2008

Puzzle: 15 pirates, 100 Coins - how to distribute?


Puzzle: There are fifteen pirates all ranked by their years of service i.e., Pirate 15 is having 15 years of service, Pirate 14 is having 14 years of service, and so on. They find 100 gold coins. To divide these coins they agree on the condition which says "The most senior pirate will propose a way of distributing the coins, and then all the pirates (including the one who proposed) will vote and if he gets at least 50% votes then everyone will accept that proposal otherwise he'll be forced to leave the place without any coin. The next senior most will follow the same... and so on until a proposal gets approved."


Considering that all the pirates are able enough to see which proposal will ensure them the maximum gain. Their prefernces will be in the order to stay alive first, maximize the number of gold coins, and if at all there are equal outcomes in two situations then to have fewer number of pirates left with them.


After thinking for a while, the most senior pirate proposes a solution, which maximizes his share of gold coins, and others also accept that as none could think of any better alternative. What plan did the most senior pirate suggest?


Solution: The key here is to think about the pirates who the most senior pirate needs to take care of while proposing a plan. Okay... what will be the least number of pirates left to divide the gold coins among themselves? The least number will 1 when all other pirates get their plans dumped and hence leave the place. Now, if there is only 1 pirate left then he'll obviously get his own vote which will ensure 100% vote for him and he'll take home all the 100 coins.


Similarly, if there are only 2 pirates left then pirate 2 will be the most senior among them and he'll 50% vote by his own vote only and hence will take home all 100 coins. So, in this case pirate 1 won't get any coins.


If there are 3 pirates then the pirate 3 being the most senior may offer only 1 gold coin to pirate 1 to ensure his vote and will safely take home the rest 99 coins. Pirate 1 knows that if he dumps the plan proposed by pirate 3 then pirate 3 will leave the place and pirate 2 being the senior most will take home all 100 coins. So, pirate 1 will have no ther choice but to accept the plan prposed by pirate 3 in this case.


If there are 4 pirates then pirate 4 being the senior most pirate requires one more vote to ensure 50%. He knows that in case there are only 3 pirates left then pirate 2 gets 0 coins, so he'll offer 1 gold coin to pirate 2 and pirate 2 will have no other option but to accept it. Pirate 4 will take home 99 coins.


If there are 5 pirates then pirate 5 being the senior most requires 2 votes except his own vote to ensure 50%+. So, he will offer 1 coin to pirate 3 and 1 coin to pirate 1, which pirate 3 and pirate 1 will have to accept because in absence of pirate 5, pirate 4 will become the senior most and in that case pirate 1 and pirate 3 will get nothing. So, pirate 5 will take home 98 gold coins.


Similarly, if there are 15 pirates then pirate 15 being the most senior requires 7 other votes except his own vote to ensure 50%+ and hence he'll offer 1 coin each to all the pirates who won't get anything in absence of pirate 15. These pirates will be pirate 13, pirate 11, pirate 9, pirate 7, pirate 5, pirate 3 and pirate 1. All these seven pirates will accept the plan proposed by pirate 15 because they know that if he leaves and pirate 14 becomes the senior most then they'll go home with 0 coins :-)



Share/Save/Bookmark


Probability of seeing a car in 5 minutes - Puzzle


Puzzle: If the probability of observing a car on a highway in 20 minutes time is 609/625 then what is the probability of observing a car in 5 minutes time on the same highway (considering all the factors involved to be uniform)?

Solution: Probability of seeing a car in 20 minutes = 609/625
=> Probability of not seeing a car in 20 minutes = 1 - 609/625 = 16/625
=> (Probability of not seeing a car in 5 minutes)^4 = 16/625
=> Probability of not seeing a car in 5 minutes = (16/625)^(1/4)
=> Probability of not seeing a car in 5 minutes = 2/5

Hence, the Probability of seeing a car in 5 minutes = 1 - 2/5 = 3/5



Share/Save/Bookmark


Monday, May 26, 2008

Train, Tunnel, and Man. How faster is the train running?


Puzzle: A man has entered into a tunnel and has crossed only 1/4 of it while it hears a whistle from a train behind him. He turns and runs towards the train with the same speed and he could barely get out of tunnel before the train (running with a constant speed) could hit him at the entrance of the tunnel. Had he moved in the same direction with the same speed then also he could have crossed the tunnel before the train could have hit him at the exit of the tunnel. Assume that the speed of the man is uniform, he takes zero time to turn back, and instantly gets his speed while turning back. How faster is the train moving as compared to the man?



Solution: Let the speed of the train be X and that of the man be Y. Let the length of the tunnel be T and the distance of the train from the entrance of the tunnel at the time the man turned back is E.



Now, we can easily form two euqations with the given data. One, The man covered T/4 distance and the train covered E distance in the same time, hence


E/X = (T/4)/Y

=> X/Y = E/(T/4)

=> X/Y = 4E/T ..... (i)


Two, The man could have covered 3T/4 distance and the train could have covered E + T in the same time, hence


(E+T)/X = (3T/4)/Y

=> X/Y = (E+T)/(3T/4)

=> X/Y = 4(E+T)/3T ..... (ii)


Comparing (i) & (ii), we get


4E/T = 4(E+T)/3T

=> E = (E+T)/3

=> 3E = E + T

=> T = 2E


putting this value in equation (i), we get


X/Y = 4E/2E

=> X/Y = 2


That means the train is running twice as fast as the man.




Share/Save/Bookmark


Friday, May 23, 2008

Rope Bridge, Torch, Four People - Puzzle


Puzzle: Four people need to cross a rope bridge, which is strong enough to support only two people at a time. First person takes 1 minute to cross the bridge, Second person takes 2 minutes, Third person takes 5 minutes, and the Fourth person takes 10 minutes to cross the bridge. They have a torch which has battery left only for 17 minutes and the bridge can not be crossed without light. How will they manage to cross the bridge?



Solution: Let's say the four people as P, Q, R, and S. Based on the info we have, let's consider P takes 1 minute, Q takes 2 minutes, R takes 5 minutes, and S takes 10 minutes to cross the bridge.

Now, they can manage to cross the bridge in time if they follow the below steps:-
  • Step #1: P and Q cross the river. Total time taken so far = 2 minutes
  • Step #2: Q comes back. Total time taken so far = 2 + 2 = 4 minutes
  • Step #3: R and S cross the river. Total time takes so far = 4 + 10 = 14 minutes
  • Step #4: P comes back (he's at the other end). Total time so far = 14 + 1 = 15 minutes
  • Step #5: P & Q cross the river. Total time taken so far = 15 + 2 = 17 minutes

We can have another valid solution similar to the above in case P comes back instead of Q in Step #2:-
  • Step #1: P and Q cross the river. Total time = 2 minutes
  • Step #2: P comes back. Total time = 2 + 1 = 3 minutes
  • Step #3: R and S cross the river. Total time = 3 + 10 = 13 minutes
  • Step #4: Q comes back. Total time = 13 + 2 = 15 minutes
  • Step #5: P and Q cross the river. Total time = 15 + 2 = 17 minutes



Share/Save/Bookmark


Wednesday, May 21, 2008

What is the age of the oldest child who plays Piano?


Puzzle: Two freinds (say A & B) see each other after a very long time, say 20 years. After a brief conversation, A finds that B is married and having 3 children. When inquired about the age of the children B replies to A "The product of their ages is 72 and the sum of their ages is same as the number on that building (pointing to a building)". A tries to think for a while and then says "Oh... I couldn't find the ages". Then B promptly realizes something and responds "The oldest plays Piono". Now A smiles and says that his oldest child is also of the same age. How old is the oldest child of A (or B)? Consider that all the ages are natural numbers only.



Solution: The only concrete piece of info we have here is that the product of three natural numbers is 72. We can think of all such triplets in not more than few minutes. But, this info is not sufficient. A can see the number on the bulding that means he know the sum and still couldn't find the triplet. Therefore, there would be more than one triplet for the same sum. Otherwise A would have easily found the correct triplet and in turn the age of the children. Right?



B's reponse brings up only one point that the highest of the correct triplet is unique and then only he can say that the oldest child plays piano.



Good. We have enough info now. We just need to write down the triplets now and the answer will be quite apparent then. The triplets satisfying the first info (product being 72) are: (1, 1, 72 -> Sum = 74), (1, 2, 36 -> Sum = 39), (1, 3, 24 -> Sum = 28), (1, 4, 18 -> Sum = 23), (1, 6, 12 -> Sum = 19), (1, 8, 9 -> Sum = 18), (2, 2, 18 -> Sum = 22), (2, 3, 12 -> Sum = 17), (2, 4, 9 -> Sum = 15), (2, 6, 6 -> Sum = 14), (3, 3, 8 -> Sum = 14), and (3, 4, 6 -> Sum = 13).



You can easily see that there are two triplets with the same 'sum'. Hence, the building next to A & B has this number '14'. These triplets are (2, 6, 6) and (3, 3, 8).



Now, the info 'the oldest' eliminates the triplet (2, 6, 6) as in this case the highest number has two occurrences and hence A would not be having a single 'oldest child'. Instead he would have been having twins in that case :-)



So, the only choice left is (3, 3, 8) and hence the oldest child of A (or B as both are of the same age) is 8 years old.




Share/Save/Bookmark


Saturday, May 17, 2008

3 litres and 5 litres containers puzzle


Puzzle: You have two container - one can contain exactly 3 litres of water and the other can contain exactly 5 litres of water. How many minimum steps will you take to get exactly 4 litres of water without using any other container? You can assume the availability of sufficient quantity of water.


Solution: Find below the steps:-

  • Step #1: fill the 5 litres container (3L - 0, 5L - 5)
  • Step #2: fill the 3 litres container with the filled 5 litres container (3L - 3, 5L - 2)
  • Step #3: empty the just filled 3 litres container (3L -0, 5L - 2)
  • Step #4: transfer the 2 litres of water left in 5 litres container into 3 litres container (3L - 2, 5L - 0)
  • Step #5: fill the 5 litres container (3L - 2, 5L - 5)
  • Step #6: fill the 3 litres container (having 2L currently) using just filled 5 litres container (3L - 3, 5L - 4)
So in a minimum of 6 steps you get exactly 4L of water in the 5 litres container.



Share/Save/Bookmark