Best riddles

logicmath

There are n coins in a line. (Assume n is even). Two players take turns to take a coin from one of the ends of the line until there are no more coins left. The player with the larger amount of money wins. Would you rather go first or second? Does it matter? Assume that you go first, describe an algorithm to compute the maximum amount of money you can win. Note that the strategy to pick maximum of two corners may not work. In the following example, first player looses the game when he/she uses strategy to pick maximum of two corners. Example 18 20 15 30 10 14 First Player picks 18, now row of coins is 20 15 30 10 14 Second player picks 20, now row of coins is 15 30 10 14 First Player picks 15, now row of coins is 30 10 14 Second player picks 30, now row of coins is 10 14 First Player picks 14, now row of coins is 10 Second player picks 10, game over. The total value collected by second player is more (20 + 30 + 10) compared to first player (18 + 15 + 14). So the second player wins.
Going first will guarantee that you will not lose. By following the strategy below, you will always win the game (or get a possible tie). (1) Count the sum of all coins that are odd-numbered. (Call this X) (2) Count the sum of all coins that are even-numbered. (Call this Y) (3) If X > Y, take the left-most coin first. Choose all odd-numbered coins in subsequent moves. (4) If X < Y, take the right-most coin first. Choose all even-numbered coins in subsequent moves. (5) If X == Y, you will guarantee to get a tie if you stick with taking only even-numbered/odd-numbered coins. You might be wondering how you can always choose odd-numbered/even-numbered coins. Let me illustrate this using an example where you have 6 coins: Example 18 20 15 30 10 14 Sum of odd coins = 18 + 15 + 10 = 43 Sum of even coins = 20 + 30 + 14 = 64. Since the sum of even coins is more, the first player decides to collect all even coins. He first picks 14, now the other player can only pick a coin (10 or 18). Whichever is picked the other player, the first player again gets an opportunity to pick an even coin and block all even coins.
72.18 %
60 votes
logiccleanstory

One day a really rich old man with two sons died. In his will he said that he would give one of his sons all of his fortune. He gave each of his sons a horse and said they would compete in a horse race from Los Angeles to Sacramento, but the son whose horse came in second would get the money. So one day they started the race. After one whole day they had only ridden one mile. At night they decided they should stop at a hotel. While they were booking in they told their problem to the wise old clerk, who made a suggestion. The next day the two brothers rode as fast as they could. What did the clerk suggest that they do?
The clerk told them to swap horses. The father said that whoever's horse crossed the finish line second would get the money. He didn't say that the owner of the horse had to be on it.
72.17 %
98 votes
logicmathstory

The owner of a banana plantation has a camel. He wants to transport his 3000 bananas to the market, which is located after the desert. The distance between his banana plantation and the market is about 1000 kilometer. So he decided to take his camel to carry the bananas. The camel can carry at the maximum of 1000 bananas at a time, and it eats one banana for every kilometer it travels. What is the most bananas you can bring over to your destination?
First of all, the brute-force approach does not work. If the Camel starts by picking up the 1000 bananas and try to reach point B, then he will eat up all the 1000 bananas on the way and there will be no bananas left for him to return to point A. So we have to take an approach that the Camel drops the bananas in between and then returns to point A to pick up bananas again. Since there are 3000 bananas and the Camel can only carry 1000 bananas, he will have to make 3 trips to carry them all to any point in between. When bananas are reduced to 2000 then the Camel can shift them to another point in 2 trips and when the number of bananas left are <= 1000, then he should not return and only move forward. In the first part, P1, to shift the bananas by 1Km, the Camel will have to Move forward with 1000 bananas – Will eat up 1 banana in the way forward Leave 998 banana after 1 km and return with 1 banana – will eat up 1 banana in the way back Pick up the next 1000 bananas and move forward – Will eat up 1 banana in the way forward Leave 998 banana after 1 km and return with 1 banana – will eat up 1 banana in the way back Will carry the last 1000 bananas from point a and move forward – will eat up 1 banana Note: After point 5 the Camel does not need to return to point A again. So to shift 3000 bananas by 1km, the Camel will eat up 5 bananas. After moving to 200 km the Camel would have eaten up 1000 bananas and is now left with 2000 bananas. Now in the Part P2, the Camel needs to do the following to shift the Bananas by 1km. Move forward with 1000 bananas – Will eat up 1 banana in the way forward Leave 998 banana after 1 km and return with 1 banana – will eat up this 1 banana in the way back Pick up the next 1000 bananas and move forward – Will eat up 1 banana in the way forward Note: After point 3 the Camel does not need to return to the starting point of P2. So to shift 2000 bananas by 1km, the Camel will eat up 3 bananas. After moving to 333 km the camel would have eaten up 1000 bananas and is now left with the last 1000 bananas. The Camel will actually be able to cover 333.33 km, I have ignored the decimal part because it will not make a difference in this example. Hence the length of part P2 is 333 Km. Now, for the last part, P3, the Camel only has to move forward. He has already covered 533 (200+333) out of 1000 km in Parts P1 & P2. Now he has to cover only 467 km and he has 1000 bananas. He will eat up 467 bananas on the way forward, and at point B the Camel will be left with only 533 Bananas.
72.17 %
98 votes