Вы находитесь на странице: 1из 7

I had used Einstein's LR problem to illustrate the method......

why don't you post a question and we can apply the method in that...... Here we go.. Eight students-A,B,C,D,E,F,G,H-went to for different places among Resort,Beach,Hotel and Cinema, such that each place is visited by to students each. Each student visited exactly one place.After their return, their teacher asked them about the place visited by each of them.Following were their answers.. (i) A said, " I didnt go with C or D and went to the Resort or the Cinema". (ii) B said, " I didnt go with E or G and went to the Hotel or the Cinema". (iii) C said, " I didnt go with F or D and went to the Resort or the Beach". (iv) D said, " I didnt go with B or H and went to the Beach or the Hotel". (v) E said, " I went with C or B or D or F or H and went to the Beach or the Cinema". (vi) F said, " I didnt go with A or G and went to the Resort or the Cinema". (vii) G said, " I went with B or D or E or F or H and went to the Beach or the Hotel". (viii) H said, " I didnt go with C or A and went to the Resort or the Beach". 1. Who among the following went with A? a)E b)B c)G d)H 2. Which place dis F visit? a)The Resort b)The Cinema c)The Hotel d) Cant be determined 3. E went with______and visited the _____. a) C, Beach b) F,cinema c)D,Beach d)G,Beach 4.If only D and H lied about the places visited by them, then with whom did D visit the place of his choice. a)H b)F c)G d)Cant be determined
It's not over.it's not end yet.Picture abhi baki hai...

QuoteReply . Like . Share


5

akhil_tiwari
Reply #205 01:36 PM, 04 Jun '12

By gawd, both VA gods (tanveer sir and spectra) in one thread? Double bonanza for mortals like us. If sirs (plural of 'sir'. Right? Wrong?) say may I join? Dash it! I have joined. AT :cheers:

The only disability in life is a bad attitude. Get rid of it!

QuoteReply . Like . Share


5

naga25french
Reply #206 03:38 PM, 04 Jun '12

Here we go..Eight students-A,B,C,D,E,F,G,H-went to for different places among Resort,Beach,Hotel and Cinema, such that each place is visited by to students each. Each student visited exactly one place.After their return, their teacher asked them about the place visited by each of them.Following were their answers.. I will say how will I solve this one . List out the possible pair for each student . A - B,E,F,G,H ( A says he didnt go with C or D .. so he can go with B,E,F,G,H ) Apply the same logic for others B - A,C,D,F,H C - A,B,E,G,H D - A,C,E,F,G E - C,B,D,F,H F - B,C,D,E,H G - B,D,E,F,H H - B,D,E,F,G Now take A alone into consideration : he can go with B,E,F,G,H But E,F,G,H cant go with A (refer above list ) So now problem becomes simpler. A-B B-A C - A,B,E,G,H D - A,C,E,F,G E - C,B,D,F,H F - B,C,D,E,H G - B,D,E,F,H H - B,D,E,F,G * red ones are ruled out Now take C - E, F and G are possible partner . But G is ruled out . Take G - D,E,F,H are possible partner . But E and F ruled out . By solving this way you can get other three pairs . (leaving it to you to solve)

Places : See A and B statement A - went to the Resort or the Cinema B - went to the Hotel or the Cinema SO they both can go to Cinema Hope this helps

The Standard Problem in simple writing goes like this:


* You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical. * You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking. * Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process

If you are one of the people who likes to solve a puzzle before seeing the answer you must quit the blog now and come back later for checking the answer. Now that this is a Google interview question I am taking the normal "Interview-Style" of solving a problem. Simply saying thinking aloud through the solution from worst to the best correcting the flows optimizing the solution or taking the 5-minute hard thinking acting pause to a problem, which you know already and just want to make your interviewer think that you are a challenge lover.

Solution
Drop the first egg from 50.If it breaks you can try the same approach for a 50-storey building (1 to 49) and try it from 25th floor. If it did not break try at 75th floor. And use linear search with the remaining portion of storey we need to test. For example if the first egg breaks at 50 we need to try all possibilities from 1 to 49. Now this looks a feasible solution. In computer student's jargon do a binary search with first egg and linear search with the second one. Best case is log (100) and worst is 50.

Now the optimal solution for the problem is that you figure out that you will eventually end up with a linear search because you have no way of deciding the highest floor with only one egg (If you broke one egg and you have to find the answer among 10 all you can do is start from the lowest to the highest and the worst is the total number of

floors). So the whole question grinds up to how to make use of the first egg to reduce the linear testing of the egg.

(For strict computer science students, well this problem can be solved using binary search on the number of drops needed to find the highest floor.) Now let x be the answer we want, the number of drops required. So if the first egg breaks maximum we can have x-1 drops and so we must always put the first egg from height x. So we have determined that for a given x we must drop the first ball from x height. And now if the first drop of the first egg doesnt breaks we can have x-2 drops for the second egg if the first egg breaks in the second drop. Taking an example, lets say 16 is my answer. That I need 16 drops to find out the answer. Lets see whether we can find out the height in 16 drops. First we drop from height 16,and if it breaks we try all floors from 1 to 15.If the egg dont break then we have left 15 drops, so we will drop it from 16+15+1 =32nd floor. The reason being if it breaks at 32nd floor we can try all the floors from 17 to 31 in 14 drops (total of 16 drops). Now if it did not break then we have left 13 drops. and we can figure out whether we can find out whether we can figure out the floor in 16 drops. Lets take the case with 16 as the answer 1 1 1 1 1 1 1 1 + + + + + + + + 15 16 14 31 13 45 12 58 11 70 10 81 9 91 8 100 if breaks at 16 checks from 1 to 15 in 15 drops if breaks at 31 checks from 17 to 30 in 14 drops .....

We can easily do in the end as we have enough drops to accomplish the task

Now finding out the optimal one we can see that we could have done it in either 15 or 14 drops only but how can we find the optimal one. From the above table we can see that the optimal one will be needing 0 linear trials in the last step. So we could write it as (1+p) + (1+(p-1))+ (1+(p-2)) + .........+ (1+0) >= 100. Let 1+p=q which is the answer we are looking for q (q+1)/2 >=100 Solving for 100 you get q=14. So the answer is: 14

Drop first orb from floors 14, 27, 39, 50, 60, 69, 77, 84, 90, 95, 99, 100... (i.e. move up 14 then 13, then 12 floors, etc) until it breaks (or doesn't at 100).

2. A camel has 3000 banans, he has to take those from A to B and B is 1000 miles away from A The camel can take 1000 bananas with him at a time and for every mile it needs one banana to eat... What max no of bananas can it take to B...
Camel will need 5 bananas to transfer all the bananas 1 mile away... 5 as for 1st 1000 he'll go n come back then for another 1000 he'll go n come back but for last 1000 he'll only go as nothing will be left behind... For second mile too it'll take 5 bananas... Now it'll require 5 bananas per mile for total banana count > 2000 and for banana count < 2000 it'll eat 3 bananas... and for < 1000 it'll eat 1 banana.... so 1st 1000 bananas will be finished in 1000/5 = 200 Miles next 1000 in 1000/3 = 334 Miles... Finaly he'll have 1000 bananas and 466 miles to go... At B camel will have 534 bananas

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 Labels: Microsoft Interview Puzzle

24 comments:
pai said... Simple- Divide the coins in half by quantity (easy to count coins while blindfolded) Then, flip all the coins in one pile over.

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

Вам также может понравиться