classic puzzle

http://classic-puzzles.blogspot.in/

Fox and Duck Interview Puzzle
A number of different versions of the puzzle are available. For this post we are using the Fox and the Duck version. A duck, pursued by a fox, escapes to the center of a perfectly circular pond. The fox cannot swim, and the duck cannot take flight from the water. The fox is four times faster than the duck. Assuming the fox and duck pursue optimum strategies, is it possible for the duck to reach the edge of the pond and fly away without being eaten? If so, how?

From : IndiaDiscuss.com Interview Questions and Puzzles

Solution:
This is not a simple mathematical puzzle to solve like normal common problems. Fox in this puzzle is too fast and clever for any normal and simple strategy.

From the speed of the fox it is obvious that duck cannot simply swim to the opposite side of the fox to escape. Pi*R/4 < R.

Let V be the speed of Duck and 4V speed of fox.

Now we need to find out the position from where duck can swim to the shore in time less then Pi*R/4V. Pi = 3.14.

To keep things simple we will take the distance from center for the duck to escape when the fox is on the exact opposite side of the pond to be R/4.
So duck can swim in 3R/4V which is less than Pi*R/4V.

Now the next challenge is how we can make sure the clever fox will be on the opposite side. Here is the tricky part.

Let the duck rotate around the pond in a circle of radius R/4. Now fox and duck will take exact same time to make a full circle. Now reduce the radius the duck is circling by a very small amount (Delta). Now the Fox will lag behind, he cannot stay at a position as well. Now in due time duck will get to a position we wanted, 3/4*R distance away from shore where fox is on the exact opposite side of the pond. From there duck can swim safely to shore and fly away.
Posted by SSP  at 5:19 AM  4 comments:
Wednesday, November 9, 2011
Interview Puzzles and Answers
River Crossing Puzzle

Four people need to cross a rickety rope bridge to get back to their camp at night. Unfortunately, they only have one flashlight and it only has enough light left for seventeen minutes. The bridge is too dangerous to cross without a flashlight, and it’s only strong enough to support two people at any given time. Each of the campers walks at a different speed. One can cross the bridge in 1 minute, another in 2 minutes, the third in 5 minutes, and the slow poke takes 10 minutes to cross. How do the campers make it across in 17 minutes?

Solution: Send 1 and 2 first, 1 comes back, send 5 and 10, 2 comes back, send 2 and 1 to the other side.

3 Baskets Puzzle

There are three baskets labeled Orange , Apple, Oracle/Apple. And all of them have wrong labels.How to find the correct label by checking only one basket

Solution:
Open the Orange/Apple basket. If we get Apple then basket labeled as Orange will be “Orange/Apple” basket.
Posted by SSP  at 11:22 AM  4 comments:
Thursday, November 3, 2011
25 Horses Puzzle
This is a classic puzzle which can look simple.
Given 25 horses, find the best 3 horses with minimum number of races. Each race can have only 5 horses. You don’t have a timer.
Now the challange is how we can do it in 7 races.

Solution

We will have 5 races with all 25 horses
Let the results be
a1,a2,a3,a4,a5
b1,b2,b3,b4,b5
c1,c2,c3,c4,c5
d1,d2,d3,d4,d5
e1,e2,e3,e4,e5

Where a1 faster than a2 , a2 faster than a3 etc and

We need to consider only the following set of horses

a1,a2,a3,
b1,b2,b3,
c1,c2,c3,
d1,d2,d3,
e1,e2,e3,

Race 6
We race a1,b1,c1,d1 abd e1
Let speed(a1)>speed(b1)>speed(c1)>speed(d1)>speed(e1)

We get a1 as the fastest horse
We can ignore d1,d2,d3,e1,e2 and e3

a2,a3,
b1,b2,b3,
c1,c2,c3,

Race 7

Race a2,a3,b1,b2 and c1
The first and second will be second and third of the whole set
Posted by SSP  at 11:11 AM  6 comments:
Labels: Infosys Interview Puzzle
Friday, May 2, 2008
Door Toggling Puzzle Or 100 Doors Puzzle
This is a very common interview puzzle. The problem is very simple if you understand it. So the point to note is, do not arrive at the solution so “fast”, if you are asked this puzzle in an interview and if you are not planning to show any acquaintance with this puzzle.

Problem goes like this :
There are N doors in a row numbered from 1 to N. Initially all are closed.
Then you make N passes by the N doors. In pass 1 you toggle the all the doors (1,2,3,4….)starting from the first door. In the second pass you toggle every second door(2,4,6,8,…). In the third pass you toggle all third doors(3,6,9…).Similarly you make N passes.

Question is what is the state of door k after N passes.

This is a simple but requires clear mathematical Logic.
Normally asked version has N=100.
Posted by SSP  at 10:52 PM  71 comments:
Labels: Amazon Interview Puzzle, Infosys Interview Puzzle
Saturday, April 21, 2007
Sum of hats Puzzle
The problem is taken from here :
Description goes like this :
There are 3 people Abel,Bill and Clark.Three of them have numbers written on their hats.One can only see the numbers written on others hats and can not see the number written on his own hat. Sum of numbers on any two 2 hats is equal to the number on the third hat.Now the following event occurs
1. Abel was asked about the number on his hat.He replied “Don’t Know”
2. Bill was asked about the number on his hat.He also replied “Don’t Know”
3. Clark was asked about the number on his hat.He also replied “Don’t Know”a
4. Abel was asked again ,to which he repplied “50”

Now the question is how did he know it.And what are the numbers on other people’s hats.

Posted by SSP  at 11:50 AM  21 comments:
Wednesday, December 27, 2006
Microsoft Interview Question : Polar Bear

One of the most asked and well known microsoft interview question is that of the walking bear.The question is still asked because a lot of people have either not heard of it or most of them don’t know the correct solution yet.

If a bear walks one mile south, turns left and walks one mile to the east and then turns left again and walks one mile north and arrives at its original position, what is the color of the bear.

Well,from the very framing of the question it is evident that we r talking about the poles,and all polar bears are white.You can also very well argue that any bear or man walking the same path will reach the same starting position if he is at north
pole.The question can also be extended and that’s what we are interested in.

The question is how many such points exists on the surface of the globe.
Well,whats your answer,is it one or infinity
Posted by SSP  at 12:06 AM  18 comments:
Labels: Microsoft Interview Puzzle
Wednesday, December 20, 2006
Microsoft Puzzle : Coins on the Table

This is not one of the classic Microsoft puzzle. I recently heard from a friend. I am listing the problem below.

There is a table on which a number of coins are placed. You also know that there are as many coins with Head up as many coins with Tail up. Now you have to divide the coins (number of coins is even) into two equal piles such that number of coins with Heads up and Tails up in either piles be the same. The catch is you are blind folded and you cannot determine the sides (for sure) if you are blinded
Posted by SSP  at 9:25 PM  24 comments:
Labels: Microsoft Interview Puzzle
Monday, December 18, 2006
Solution to the Shopkeeper Problem
I don’t think I need to post the solution as Christophe has already solved all of them in no time.

Problem 1: One Side Only (Simple)

This is simply the numbers 2^0,2^1,2^2 ….. that is 1,2,4,8,16 ……….
So for making 1000 kg we need up to
1, 2, 4, 8, 16, 32, 64, 128, 512.

Problem 2: Both Sides (Medium)

For this answer is 3^0,3^1,3^2 …. That is 1,3,9,27,81,243,729

Problem 3: Incremental (Hard)

This is exactly a problem solved by Gray code.

Gray codes are named after the Frank Gray who patented their use for shaft encoders in 1953
A Gray code represents each number in the sequence of integers {0…2^N-1} as a binary string of length N in an order such that adjacent integers have Gray code representations that differ in only one bit position. Marching through the integer sequence therefore requires flipping just one bit at a time.

Example (N=3): The binary coding of {0…7} is {000, 001, 010, 011,
100, 101, 110, 111}, while one Gray coding is {000, 001, 011, 010,
110, 111, 101, 100}.

For this answer we need as many blocks as per Solution to Problem 1.
For easy understanding let me describe the case where the packets range from 1 to 7 which can be easily extended to 1 – 125 range.
Now if we want to make packets of all weights from 1 to & we will do the following

001 We measure 1kg,using 1kg block.
011 We measure 3kg by placing 2 kg block also
010 We remove 1kg block and measure 2 kg.
110 We add 4kg weight and measure 6kg weight …
………….

Now we can see answer to our problem is Gray code of 7 bits. Now our range is 1 to 125 and not 1 to 127.This can be solved by using appropriate Gray code making the following numbers falling to the end of the sequence you are starting with
1111 110
1111 111
Posted by SSP  at 10:48 PM  2 comments:
Labels: Microsoft Interview Puzzle
Friday, December 15, 2006
Job Interview Puzzle: 3 Classic Weighing puzzles :Simple Medium and Hard

In this post I want to describe about a series of puzzles called weighing puzzles. These puzzle vary in hardness from simple to extremely mathematical involving either expertise in some fields or extreme ingenuity. Either you know it or you figure out it using extreme intelligence. So here is the chance for some people to burn your grey cells.

I am putting forward three puzzles with varying range of hardness. Sometimes you may feel the hardest one is very easy for you have already come across the theory, but I still made it the hardest for the people who will be solving it with out knowing the theory behind it, giving them an option to figure out a small part in evolution of computational history.

There is a shopkeeper who wants to weigh things who has a common balance. He must be in a position to weigh things of all possible integral weighing units from 1 to a given maximum sum. The question will be either about how many weights you will need or how will you weigh.

Problem 1: One Side Only (Simple Interview Question for Phone Screening usually)

In this version of the problem shopkeeper can only place the weights in one side of the common balance. For example if shopkeeper has weights 1 and 3 then he can measure 1,3 and 4 only. Now the question is how many minimum weights and name the weights you will need to measure all weights from 1 to 1000. This is a fairly simple problem and very easy to prove also.

Problem 2: Both Sides (Medium:5 to 10 mins onsite interview question)

This is same as the first problem with the condition of placing weights on only side of the common balance being removed. You can place weights on both side and you need to measure all weights between 1 and 1000.For example if you have weights 1 and 3,now you can measure 1,3 and 4 like earlier case, and also you can measure 2,by placing 3 on one side and 1 on the side which contain the substance to be weighed. So question again is how many minimum weights and of what denominations you need to measure all weights from 1kg to 1000kg.

Problem 3: Incremental (Hard)
This is an altogether different one in the same scenario. You have to make 125 packets of sugar with first one weighing 1 kg, second 2 kg, third 3 kg etc …and 125th one weighing 125kg.You can only use one pan of the common balance for measurement for weighing sugar, the other pan had to be used for weights i.e. weights should be used for each weighing.
It has come into notice that moving weights into and out of the pan of the balance takes time and this time depends on the number on the number of weights that are moved. For example – If we need to measure 4 kg using weights 1 and 3 only, it will take twice as much time needed to measure 1 kg. Lets say we want to make sugar packets of weights 1,3,4 using weights 1 and 3 only. For this first we measure 1 kg, with 1 unit of time, we place 3 kg along with 1 kg and measure 4kg with again 1 unit of time, and finally we move 1kg out of pan to measure 3kg in 1 unit of time. So in 3 units of time we could measure 1,3 and 4kg using weights 1 and 3 only.

Now you have to make sugar packets of all weights from 1 to 125 in minimum time, in other words in minimum movement of weights. The question here is to find out the minimum number of weighs needed and the weight of each the weights used and the strategy to be followed for the creation of 125 packets of sugar.

Please post your solutions as comments.Solution will be posted soon in the blog.If any where its obfuscated or simple wrong pls feel free to correct.

Advertisements
This entry was posted in interview. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s