Probabilty & Apt

Embed Size (px)

DESCRIPTION

interview

Citation preview

  • 5/25/2018 Probabilty & Apt

    1/29

    1.Puzzle:King Octopus has servants with six, seven, or eight legs. The servants with seven legsalways lie, but the servants with either six or eight legs always say the truth.

    One day, 4 servants met :

    The blue one says: Altogether we have ! legs"#

    the green one says: Altogether we have $ legs"#

    the yellow one says: Altogether we have % legs"#

    the red one says: Altogether we have & legs".

    'hat is the colour o( the servant that says the truth)

    This is very (amous logical pu**les.

    Solution:

    The green one is telling the truth.

    Lets assume that one of them is telling the truth and then try to prove that. Since the four are

    disagreeing then 3 must be lying.

    Lets say blue is telling the truth: so the blue one has either 6 or 8 legs. And each of the other octopus is

    lying hence has 7 legs. So our total legs becomes: 6 7 7 7 ! "7 legs or 8 7 7 7 ! "# legs.

    $ut since blue said altogether %e have "8 legs& %e 'no% he is lying.

    (f you follo% this same logic for all of them& you reali)e that only the *reen octopus can be telling the

    truth as the number of legs adds up.

    Puzzle:Three men + am, -am and aurie + are married to -arrie, /illy and Tina, but notnecessarily in the same order. am0s wi(e and /illy0s 1usband play -arrie and Tina0s husband at

    bridge.

    2o wi(e partners her husband and -am does not play bridge. 'ho is married to -am)

    Solution:

    +arrie is married to +am.

    Sam,s %ife and $illy,s -usband play +arrie and Tina,s husband at bridge.

    (t means that Sam is not married to either $illy or +arrie. Thus& Sam is married to Tina. As +am does

    not play bridge& $illy,s husband must be Laurie.

    -ence& +arrie is married to +am.

    Puzzle:3ou have bas5ets and each bas5et contains exactly 4 balls, each balls is o( the same

    si*e. 6ach ball is either red, blac5, yellow, or orange, and there is one o( each color in each

    bas5et.

    7( you were blind(olded, and lightly shoo5 each bas5et so that the balls would be randomly

    distributed, and then too5 8 ball (rom each bas5et, what chance is there that you would have

    exactly red balls)

    Solution:

  • 5/25/2018 Probabilty & Apt

    2/29

    There are 6/ different possible outcomes& and in # of these& e0actly " of the balls %ill be red. There is

    thus a slightly better than 1/2 chance 4#56/19 that e0actly " balls %ill be red.

    A other %ay to solve the problem is to loo' at it this %ay.

    There are 3 scenarios %here e0actly 3 balls are red:

    1 " 3

    ;< < =

    < = Those two ropes are not identical, they aren0t

    the same density nor the same length nor the same width?. 6ach rope burns in %= minutes. 1eactually wants to measure 4& mins. 1ow can he measure 4& mins using only these two ropes.

    1e can0t cut the one rope in hal( because the ropes are nonhomogeneous and he can0t be sure

    how long it will burn.

    Solution:

    -e %ill burn one of the rope at both the ends and the second rope at one end. After half an hour& the

    first one burns completely and at this point of time& he %ill burn the other end of the second rope so no%

    it %ill ta'e 1> mins more to completely burn. so total time is 31> i.e. />mins.

    Puzzle:3ou are on your way to visit your Brandma, who lives at the end o( the valley. 7t0s her

    anniversary, and you want to give her the ca5es you0ve made. /etween your house and her

    house, you have to cross & bridges, and as it goes in the land o( ma5e believe, there is a troll

    under every bridgeC 6ach troll, 9uite rightly, insists that you pay a troll toll. /e(ore you can cross

    their bridge, you have to give them hal( o( the ca5es you are carrying, but as they are 5ind trolls,

    they each give you bac5 a single ca5e.

    1ow many ca5es do you have to leave home with to ma5e sure that you arrive at Brandma0s

    with exactly ca5es)

    Solution:

  • 5/25/2018 Probabilty & Apt

    4/29

    2 Cakes

    -o%H

    At each bridge you are reBuired to give half of your ca'es& and you receive one bac'. Ihich leaves you

    %ith " ca'es after every bridge.

    This is very cool intervie% pu))le.Problem:One day, anta and banta were playing cards, but suddenly power went o((. anta

    randomly inverted position o( 8& cards out o( & cards>and shu((led it? and as5ed banta to divide

    the card in two piles with e9ual number o( cards (acing up. 7t was very dar5 in the room and

    banta could not see the cards, a(ter thin5ing a bit banta divided the cards in two piles and 9uite

    surprisingly on counting number o( cards (acing up in both the piles were e9ual.

    'hat do you thin5 banta must have done)

    2ote : 2umber o( cards in each pile need not be e9ual.

    Puzzle Solution:

    Just ta'e top 1> cards from the pile and reverse them& no% you %ill have t%o piles of 1> cards and 37

    cards and both of them %ill have same number of inverted cards.

    (nverted cards pu))le e0planation:

    Lets say there %ere n inverted cards initially in top 1> cards& obviously in remaining 37 cards number of

    inverted cards %ill be 1>Fn& as total 1> inverted cards.

    Co% on reversing the 1> cards number of inverted cards %ould become 1> ; n and number of inverted

    cards %ill become same in the t%o piles.Problem:

    3ou have = /lue balls and 8= Ded balls in a bag. 3ou put your hand in the bag and ta5e o(( two

    at a time. 7( they0re o( the same color, you add a /lue ball to the bag. 7( they0re o( di((erent colors,

    you add a Ded ball to the bag. 'hat will be the color o( the last ball le(t in the bag)

    2ote: Assume you have a big supply o( /lue and Ded balls (or this purpose. 'hen you ta5e the

    two balls out, you don0t put them bac5 in, so the number o( balls in the bag 5eeps decreasing.

    Once you tac5le that, what i( there are = blue balls and 88 red balls to start with)

    Solution:

    There can be 3 possible cases ta'ing off " balls from bag.

    a (f %e ta'e off 1

  • 5/25/2018 Probabilty & Apt

    5/29

    1 " $lue& 1

  • 5/25/2018 Probabilty & Apt

    6/29

    +riminal should open door number ".

    -o%H

    Lets assume statement on the first door is true then second statement %ill also be true4as there %ill be

    a lady in one door and a tiger in other door& but as %e already 'no% that only one statement can be

    true& so first statement can not be true.

    Co% if first statement is false& it implies these possible scenarios

    Ooor 1 Ooor "

    Tiger Tiger

    Lady Lady

    Tiger Lady

    $ut as second statement is true& so it means behind one of the door there is a lady and in other door

    there is a tiger so options %ith both lady and both tigers are ruled out and only third option remains

    valid& thus the criminal should choose door number ".

    roblem:A horse rider went a mile in & minutes with the wind and returned in $ minutes against

    the wind. 1ow (ast could he ride a mile i( there was no wind)

    Solution:

    Dost of us %ill proceed li'e that if a rider goes a mile in " minutes %ith the %ind& and returns against the

    %ind in 3 minutes& that " and 3 eBual >& should give a correct average& so that time ta'en should be t%o

    and half minutes. Ie find this ans%er to be incorrect& because the %ind has helped him for only "

    minutes& %hile it has %or'ed adversely for 3 minutes.(f he could ride a mile in " minutes %ith the %ind& it

    is clear that he could go a 1.> mile 3 minutes& and 1 mile in 3 minutes against the %ind.

    Therefore ".> miles in 6 minutes gives his actual speed& because the %ind helped him ust as much as

    it has retarded him& so his actual speed for a single mile %ithout any %ind %ould be 4".>56 ! >51"

    miles5sec

    Puzzle:There are 8== statements.

    8stone says : at least one is wrong.

    ndone says : at least two are wrong.

    rdone says : at least three are wrong.

    4thone says : at least (our are wrong.

    and so on.

    8==thone says : at least 8== are wrong.

    1ow many statements are actually wrong and how many actually right )

    Solution:1thstatement is definitely %rong because it says at least 1 are %rong.$ut if that is correct& then 1 statement itself cannot be right.!G 1thstatement is %rong and!G 1ststatement is correct.

    ##thstatement cannot be correct because if it %ere correct&then t%o statements %ould become correct 41stand ##thitself.$ut ##thstatement says that atleast ## are %rong.!G ##this %rong and

  • 5/25/2018 Probabilty & Apt

    7/29

    !G "ndis correct.

    calculating so onK

    > statements are right 4the first > ones

    remaining > statements are %rong.

    roblem: An engineer goes to a ban5 with a chec5 o( E== and as5s the cashier Bive me some

    onedollar bills, ten times as many twos and the balance in (ivesC".

    'hat will the cashier do)

    Solution:

    The smallest amount of oneFdollar and t%oFdollar bills the cashier may give to the old man is 1P1

    1P" ! "1.

    -e must give the old man a multiple of "1 i.e. "1 or /" or 63 or 8/ or 1> or 1"6 or 1/7 or 168 or 187

    %ithout e0ceeding ". Nut of all these numbers only 1> can be added to a multiple of > to sum up to

    ma'e " altogether.

    So he must give the balance of #> in fiveFdollar bills.

    Therefore& the cashier must give > oneFdollar bills& > t%oFdollar bills and 1# fiveFdollar bills.

    Problem:3ou are standing be(ore two doors. One o( the path leads to heaven and the other one

    leads to hell. There are two guardians, one by each door. 3ou 5now one o( them always tells the

    truth and the other always lies, but you don0t 5now who is the honest one and who is the liar.

    3ou can only as5 one 9uestion to one o( them in order to (ind the way to heaven. 'hat is the

    9uestion)

    This is one o( the classic pu**les as5ed in 7n(osys interview.

    Solution:

    The Buestion you should as' is Q(f ( as' the other guard about %hich side leads to heaven& %hat %ould

    he ans%erH. (t should be fairly easy to see that irrespective of %hom do you as' this Buestion& you %ill

    al%ays get an ans%er %hich leads to hell. So you can chose the other path to continue your ourney to

    heaven.

    This idea %as famously used in the 1#86 film Labyrinth.

    -ere is the e0planation if it is yet not clear.

    Let us assume that the left door leads to heaven.

    (f you as' the guard %hich spea's truth about %hich path leads to heaven& as he spea's al%ays the

    truth& he

    %ould say Qleft. Co% that the liar & %hen he is as'ed %hat Qthe other guard 4truth teller %ould ans%er&

    he %ould definitely say Qright.

    Similarly& if you as' the liar about %hich path leads to heaven& he %ould say Qright. As the truth teller

    spea's nothing but the truth& he %ould say Qright %hen he is as'ed %hat Qthe other guard4 liar %ould

  • 5/25/2018 Probabilty & Apt

    8/29

    ans%er. So in any case& you %ould end up having the path to hell as an ans%er. So you can chose the

    other path as a %ay to heaven.

    Problem:3ou are blind(olded and 8= coins are place in (ront o( you on table. 3ou are allowed to

    touch the coins, but can0t tell which way up they are by (eel. 3ou are told that there are & coins

    head up, and & coins tails up but not which ones are which. 1ow do you ma5e two piles o( coins

    each with the same number o( heads up) 3ou can (lip the coins any number o( times.

    Solution:

    Da'e " piles %ith eBual number of coins. Co%& flip all the coins in one of the pile.

    -o% this %ill %or'H lets ta'e an e0ample.

    So initially there are > heads& so suppose you divide it in " piles.

    +ase:

    P1 : H H T T T

    P2 : H H H T T

    Now when P1 will be flipped

    P1 : T T H H H

    P1(Heads) = P2(Heads)

    Another case:

    P1 : H T T T T

    P2 : H H H H TNow when P1 will be flipped

    P1 : H H H H T

    P1(Heads) = P2(Heads)

    Problem:

    There are 8 caves arranged in a circle. There is a thie( in one o( the caves. 6ach day the the

    thie( can move to any one o( adFacent cave or can stay in smae cave in which he was staying the

    previous day. And each day, cops are allowed to enter any two caves o( their choice.

    'hat is the minimum number o( days to guarantee in which cops can catch the thie()

    Note:

    Thief may or may not move to adacent cave.

    http://www.crazyforcode.com/wp-content/uploads/2013/09/13-caves-and-a-thief-puzzle-150x150.png
  • 5/25/2018 Probabilty & Apt

    9/29

    +ops can chec' any t%o caves& not necessarily be adacent.

    Solution:

    Lets assume the thief is in cave +1 and going cloc'%ise and cops start searching from cave +13 and

    +1" on your first day.

    +ave +13 and +11 on second day&

    +13 and +1 on third day and so on till +13 and +1 on 1"th day.So basically the aim is to chec' +13 everyday so that if thief tries to go anti cloc'%ise you immediately

    catch it and if goes cloc'%ise cops %ill catch him in ma0imum 1" days 4this include the case %here he

    remains in +ave +1.

    Problem:

    Two trains enter a tunnel == miles long, traveling at 8== mph at the same time (rom opposite

    directions. As soon as they enter the tunnel a supersonic bee (lying at 8=== mph starts (rom one

    train and heads toward the other one. As soon as it reaches the other one it turns around and

    heads bac5 toward the (irst, going bac5 and (orth between the trains until the trains collide in a

    (iery explosion in the middle o( the tunnel. 1ow (ar did the bee travel)

    Solution:

    This pu))le is a little tric'y one. Nne,s thin'ing about solving this problem goes li'e this Qo'& so i ust

    need to sum up the distances that the bee travelsK but then you Buic'ly reali)e that its a difficult 4not

    impossible summation.

    The tunnel is " miles long. The trains meet in the middle traveling at 1 mph& so it ta'es them an

    hour to reach the middle. The bee is traveling 1 mph for an hour 4since its flying the %hole time the

    trains are racing to%ard one another ; so basically the bee goes 1 miles.

    Problem:

    A bad 5ing has a cellar o( 8=== bottles o( delight(ul and very expensive wine. A neighboring9ueen plots to 5ill the bad 5ing and sends a servant to poison the wine. ;ortunately >or say

    un(ortunately? the bad 5ing0s guards catch the servant a(ter he has only poisoned one bottle.

    Alas, the guards don0t 5now which bottle but 5now that the poison is so strong that even i(

    diluted 8==,=== times it would still 5ill the 5ing. ;urthermore, it ta5es one month to have an

    e((ect. The bad 5ing decides he will get some o( the prisoners in his vast dungeons to drin5 the

    wine. /eing a clever bad 5ing he 5nows he needs to murder no more than 8= prisoners +

    believing he can (ob o(( such a low death rate + and will still be able to drin5 the rest o( the wine

    >GGG bottles? at his anniversary party in & wee5s time. 6xplain what is in mind o( the 5ing, how

    will he be able to do so ) >o( course he has less then 8=== prisoners in his prisons?

    Solution:Thin' in terms of binary numbers. 4no% don,t read the solution& give a try.

    http://www.crazyforcode.com/wp-content/uploads/2013/09/king-wine-bottle-350x250.jpg
  • 5/25/2018 Probabilty & Apt

    10/29

    Cumber the bottles 1 to 1 and %rite the number in binary format.

    bottle 1 ! 1 41 digit binary

    bottle " ! 1

    bottle > ! 111111

    bottle 1 ! 111111

    Co% ta'e 1 prisoners and number them 1 to 1& no% let prisoner 1 ta'e a sip from every bottle that

    has a 1 in its least significant bit. Let prisoner 1 ta'e a sip from every bottle %ith a 1 in its most

    significant bit. etc.

    prisoner ! 1 # 8 7 6 > / 3 " 1

    bottle #"/ ! 1 1 1 1 1 1

    Eor instance& bottle no. #"/ %ould be sipped by 1&8&>&/ and 3. That %ay if bottle no. #"/ %as the

    poisoned one& only those prisoners %ould die.

    After four %ee's& line the prisoners up in their bit order and read each living prisoner as a bit and each

    dead prisoner as a 1 bit. The number that you get is the bottle of %ine that %as poisoned.

    1 is less than 1"/ 4"1. (f there %ere 1"/ or more bottles of %ine it %ould ta'e more than 1

    prisoners.

    Problem:;our glasses are placed on the corners o( a s9uare table. ome o( the glasses are upright >up?

    and some upsidedown >down?. A blind(olded person is seated next to the table and is re9uired

    to rearrange the glasses so that they are all up or all down, either arrangement being

    acceptable, which will be signalled by the ringing o( a bell. The glasses may be rearranged in

    turns subFect to the (ollowing rules. Any two glasses may be inspected in one turn and a(ter

    (eeling their orientation the person may reverse the orientation o( either, neither or both glasses.

    A(ter each turn the table is rotated through a random angle. The pu**le is to devise an algorithm

    which allows the blind(olded person to ensure that all glasses have the same orientation >either

    up or down? in a (inite number o( turns. The algorithm must be nonstochastic i.e. it must not

    depend on luc5.

    Solution:

    http://www.crazyforcode.com/wp-content/uploads/2013/09/Four_tumblers-240x300.jpg
  • 5/25/2018 Probabilty & Apt

    11/29

    On the first turn choose a diagonally opposite pair of glasses and turn both glasses

    up.

    On the second turn choose two adjacent glasses. At least one will be up as a result of

    the previous step. If the other is down, turn it up as well. If the bell does not ring then

    there are now three glasses up and one down(3U and 1!.

    On the third turn choose a diagonally opposite pair of glasses. If one is down, turn itup and the bell will ring. If both are up, turn one down. "here are now two glasses

    down, and they #ust be adjacent.

    On the fourth turn choose two adjacent glasses and reverse both. If both were in the

    sa#e orientation then the bell will ring. Otherwise there are now two glasses down

    and they #ust be diagonally opposite.

    On the fifth turn choose a diagonally opposite pair of glasses and reverse both. "he

    bell will ring for sure.

    Problem:

    A bag contains >x? one rupee coins and >y? &= paise coins. One coin is ta5en (rom the bag and

    put away. 7( a coin is now ta5en at random (rom the bag, what is the probability that it is a one

    rupee coin)

    Answers:

    +ase (: Let the first coin removed be one rupee coin Nne rupee coins left ! 40 ; 1 Eifty paise coins left

    ! y. Rrobability of getting a one rupee coin in the first and second dra% ! 0540 y P 40 ; 1540 ; 1 y

    +ase ((: Let the first coin removed be fifty paise coin Nne rupee coins left ! 0 Eifty paise coins left ! y ;

    1. Rrobability of getting a fifty paise coin in the first and one rupee coin in second dra%

    ! y 5 40 y P 0 5 40 y ; 1

    Total probability ! sum of these t%o ! 0540 y after simplification9.Problem:

    A candidate is selected (or interview (or posts.The number o( candidates (or the (irst, second

    and third posts are ,4 and respectively. 'hat is the probability o( getting at least one post)

    Solution:

    The probability the candidate does not get an offer from the first intervie% is "53. The probability she

    doesn,t get an offer from the second is 35/& and the probability she doesn,t get an offer from the third is

    15".

    So the probability she does not get an offer at all is "53 53/ 15"!15/. -ere %e are assuming

    4unrealistically independence.

    Thus the probability she gets at least one offer is 35/.

    Ie made the totally unreasonable assumption that ob offers are given at random& that if there are 3

    people intervie%ed& e0actly one& chosen at random& %ill get an offer. That,s not Buite the %ay the %orld

    %or's

    Problem:

    ;our prisoners are arrested (or a crime, but the Fail is (ull and the Failer has nowhere to put them.

    1e eventually comes up with the solution o( giving them a pu**le so i( they succeed they can go

    (ree but i( they (ail they are executed.

    The Failer puts three o( the men sitting in a line. The (ourth man is put behind a screen >or in a

  • 5/25/2018 Probabilty & Apt

    12/29

    separate room?. 1e gives all (our men party hats. The Failer explains that there are two blac5 and

    two white hats# that each prisoner is wearing one o( the hats# and that each o( the prisoners is

    only to see the hats in (ront o( them but not on themselves or behind. The (ourth man behind the

    screen can0t see or be seen by any other prisoner. 2o communication between the prisoners is

    allowed.

    7( any prisoner can (igure out and say to the Failer what color hat he has on his head all (ourprisoners go (ree. 7( any prisoner suggests an incorrect answer, all (our prisoners are executed.

    The pu**le is to (ind how the prisoners can escape, regardless o( how the Failer distributes the

    hats.

    Solution:

    Rrisoner A and $ are in the same situation ; they have no information to help them determine their hat

    colour so they can,t ans%er. + and O realise this.

    Rrisoner O can see both $ and +,s hats. (f $ and + had the same colour hat then this %ould let O 'no%

    that he must have the other colour.

    Ihen the time is nearly up& or maybe before& + realises that O isn,t going to ans%er because he can,t.

    + realises that his hat must be different to $,s other%ise O %ould have ans%ered. + therefore

    concludes that he has a blac' hat because he can see $,s %hite one.

    Problem:

    Two old (riends, Hac5 and /ill, meet a(ter a long time.

    Hac5: 1ey, how are you man)

    /ill: 2ot bad, got married and 7 have three 5ids now.

    Hac5: That0s awesome. 1ow old are they)

    /ill: The product o( their ages is $ and the sum o( their ages is the same as your birth date.

    Hac5: -oolI /ut 7 still don0t 5now.

    /ill: Jy eldest 5id Fust started ta5ing piano lessons.Hac5: Oh now 7 get it.

    1ow old are /ill0s 5ids)

    http://www.crazyforcode.com/wp-content/uploads/2013/08/hatpuzzle.jpg
  • 5/25/2018 Probabilty & Apt

    13/29

    Solution:

    This is a very good logical problem. To do it& first %rite do%n all the real possibilities that the number on

    that building might have been. Assuming integer ages one get get the follo%ing %hich eBual 7" %hen

    multiplied:

    "& "& 18 ; sum ! """& /& # ; sum ! 1>

    "& 6& 6 ; sum ! 1/

    "& 3& 1" ; sum ! 17

    3& /& 6 ; sum ! 13

    3& 3& 8 ; sum ! 1/

    1& 8& # ; sum ! 18

    1& 3& "/ ; sum ! "8

    1& /& 18 ; sum ! "3

    1& "& 36 ; sum ! 3#

    1& 6& 1" ; sum ! 1#

    The sum of their ages is the same as your birth date. That could be anything from 1 to 31 but the fact

    that Jac' %as unable to find out the ages& it means there are t%o or more combinations %ith the same

    sum. Erom the choices above& only t%o of them are possible no%. Eor any other number& the ans%er is

    uniBue and the Jac' %ould have 'no%n after the second clue. So he as'ed for a third clue. The clue

    that the eldest 'id ust started ta'ing piano lessons is really ust saying that there is an Qoldest&

    meaning that the younger t%o are not t%ins.

    "& 6& 6 ; sum4"& 6& 6 ! 1/3& 3& 8 ; sum43& 3& 8 ! 1/

    -ence& the ans%er is that the elder is 8 years old& and the younger t%o are both 3 years old.

    The ans%er is 3, 3 and 8.

    Problem:

    ou have two Fars, &= red marbles and &= blue marbles. 3ou need to place all the marbles into

    the Fars such that when you blindly pic5 one marble out o( one Far, you maximi*e the chances

    that it will be red. 'hen pic5ing, you0ll (irst randomly pic5 a Far, and then randomly pic5 a marble

    out o( that Far. 3ou can arrange the marbles however you li5e, but each marble must be in a Far.

    Answer:

    Say %e put all the red marbles into JA< A and all the blue ones into JA< $. then our chances for

    pic'ing a red one are:

    15" chance %e pic' JA< A >5> chance %e pic' a red marble

    15" chance %e pic' JA< $ 5> chance %e pic' a red marble

    ou %ould try different combinations& such as "> of each colored marble in a ar or putting all red

    marbles in one ar and all the blue in the other. ou %ould still end up %ith a chance of >2.

    Ihat if you put a single red marble in one ar and the rest of the marbles in the other arH This %ay& you

    are guaranteed at least a >2 chance of getting a red marble 4since one marble pic'ed at random&

  • 5/25/2018 Probabilty & Apt

    14/29

    doesn,t leave any room for choice. Co% that you have /# red marbles left in the other ar& you have a

    nearly even chance of pic'ing a red marble 4/# out of ##.

    So the ma0imum probability %ill be :

    ar A : 415"1 ! 15" 4selecting the ar A ! 15"& red marble from ar A ! 151

    ar $ : 415"4/#5## ! 4selecting the ar $ ! 15"& red marble from ar $ ! /#5##Total probability ! 7/5## 4U35/

    Problem:

    1ow many s9uares are on a chess board)

    (f you thought the ans%er is 6/& thin' again

    -o% about all the sBuares that are formed by combining smaller sBuares on the chess board 4"P"& 3P3&

    /P/ sBuares and so onH

    A 1P1 sBuare can be placed on the chess board in 8 hori)ontal and 8 vertical positions& thus ma'ing a

    total of 8 0 8 ! 6/ sBuares. Let,s consider a "P" sBuare. There are 7 hori)ontal positions and 7 vertical

    positions in %hich a "P" sBuare can be placed. IhyH $ecause pic'ing " adacent sBuares from a total

    of 8 sBuares on a side can only be done in 7 %ays. So %e have 7 0 7 ! /# "P" sBuares. Similarly& for

    the 3P3 sBuares& %e have 6 0 6 ! 36 possible sBuares. So here,s a brea' do%n.

    1P1 8 0 8 ! 6/ sBuares

    "P" 7 0 7 ! /# sBuares

    3P3 6 0 6 ! 36 sBuares

    /P/ > 0 > ! "> sBuares

    >P> / 0 / ! 16 sBuares

    6P6 3 0 3 ! # sBuares

    7P7 " 0 " ! / sBuares

    8P8 1P1 ! 1 sBuare

    1" "" 3" . . . n "

    Total ! 6/ /# 36 "> 16 # / 1 ! 20sBuares

    http://www.crazyforcode.com/wp-content/uploads/2013/07/chess-board-puzzle.jpg
  • 5/25/2018 Probabilty & Apt

    15/29

    Problem:

    This is the classical pu**le as5ed in microso(t interview

    A duc5, pursued by a (ox, escapes to the center o( a per(ectly circular pond. The (ox cannot

    swim, and the duc5 cannot ta5e (light (rom the water. The (ox is (our times (aster than the duc5.

    Assuming the (ox and duc5 pursue optimum strategies, is it possible (or the duc5 to reach theedge o( the pond and (ly away without being eaten) 7( so, how)

    Solution:

    Erom the speed of the fo0 it is obvious that duc' cannot simply s%im to the opposite side of the fo0 to

    escape.

    Eo0 can travel /r in the time duc' covers r distance. Since fo0 have to travel half of the circumference

    Rir and Rir V /r

    So ho% could the duc' ma'e life most difficult for the fo0H (f the duc' ust tries to s%im along a radius&

    the fo0 could ust sit along that radius and the duc' %ould continue to be trapped.

    At a distance of r5/ from the center of the pond& the circumference of the pond is e0actly four times the

    circumference of the duc',s path.

    Let the duc' rotate around the pond in a circle of radius r5/. Co% fo0 and duc' %ill ta'e e0act same time

    to ma'e a full circle. Co% reduce the radius the duc' is circling by a very small amount 4Oelta. Co% the

    Eo0 %ill lag behind& he cannot stay at a position as %ell.

    Say& the duc' circles the pond at a distance r5/ ; e& %here e is an infinitesimal amount. So as the duc'

    continues to s%im along this radius& it %ould slo%ly gain some distance over the fo0. Nnce the duc' is

    able to gain 18 degrees over the fo0& the duc' %ould have to cover a distance of 3r5/ e to reach the

    edge of the pond. (n the mean%hile& the fo0 %ould have to cover half the circumference of the pond 4i.e

    the 18 degrees. At that point&

    4pi r G / 43r5/ e

    So time ta'en to travel 3r5/ is Buic'er than 3.1/r at four times the speed.4.1/r distance is left

    The duc' %ould be able to ma'e it to land and fly a%ay.

    http://www.crazyforcode.com/wp-content/uploads/2013/07/duck-fox.jpg
  • 5/25/2018 Probabilty & Apt

    16/29

    Problem:

    3ou0ve got someone wor5ing (or you (or seven days and a gold bar to pay him. The gold bar is

    segmented into seven connected pieces. 3ou must give them a piece o( gold at the end o( every

    day. 'hat and where are the (ewest number o( cuts to the bar o( gold that will allow you to pay

    him 8$th each day)

    Solution:

    Lets split the chain as&

    Oay 1: *ive A 41

    Oay ": *et bac' A& give $ 4F1& "

    Oay 3: *ive A 41

    Oay /:*et bac' A and $& give + 4F"&F1&/

    Oay >:*ive A 41

    Oay 6:*et bac' A& give $ 4F1&"

    Oay 7:*ive A 41

    Problem:

    Sailor +at needs to bring a %olf& a goat& and a cabbage across the river. The boat is tiny and can only

    carry one passenger at a time. (f he leaves the %olf and the goat alone together& the %olf %ill eat the

    goat. (f he leaves the goat and the cabbage alone together& the goat %ill eat the cabbage.

    -o% can he bring all three safely across the riverH

    Solution:

    The tric' to this pu))le is that you can 'eep %olf and cabbage together. So the solution %ould be

    The sailor %ill start %ith the goat. -e %ill go to the other side of the river %ith the goat. -e %ill 'eep goat

    there and %ill return bac' and %ill ta'e cabbage %ith him on the ne0t turn. Ihen he reaches the other

    side he %ill 'eep the cabbage there and %ill ta'e goat bac' %ith him.

    http://www.crazyforcode.com/wp-content/uploads/2013/07/river-crossing.jpghttp://www.crazyforcode.com/wp-content/uploads/2013/07/gold-bar-cut.pnghttp://www.crazyforcode.com/wp-content/uploads/2013/07/gold-bar.png
  • 5/25/2018 Probabilty & Apt

    17/29

    Co% %e %ill ta'e %olf and %ill 'eep the %olf at the other side of the river along %ith the cabbage. -e %ill

    return bac' and %ill ta'e goat along %ith him. This %ay they all %ill cross the river.

    Rroblem:

    ou have ! balls. One o( them is de(ective and weighs less than others. 3ou have a balance to

    measure balls against each other. 7n weighing, how do you (ind the de(ective one)

    Solution:

    Oefective ball is light

    Da'e three *roups *1 ; 3 balls *" ; 3 balls *3 ; " balls

    Eirst %eightF *1 and *" if *1 ! *" then defective ball in *3 &

    %eigh the the " balls in *3 if @WXAL then 3rd ball of *3 is defective

    else %hichever lighter in 1st or "nd is defective ball

    else if *1 V *" defective ball in *1

    %eigh 1 and " ball of *1 if @WXAL then 3rd ball of *1 is defective

    else %hichever lighter in 1st or "nd is defective ball

    else if *1 G *" defective in *"

    Again in 1 comparison %e can find the odd ball.

    So by follo%ing above steps in " steps& lighter ball can be find out.

    Problem:

    There are 8== prisoners are in solitary cells, unable to see, spea5 or communicate in any waywith each other. There0s a central living room with one light bulb, the bulb is initially o((. 2o

    prisoner can see the light bulb (rom his own cell. 6veryday, the warden pic5s a prisoner at

    random, and that prisoner goes to the central living room. 'hile there, the prisoner can toggle

    the bulb i( he wishes. Also, the prisoner has the option o( asserting the claim that all 8==

    prisoners have been to the living room. 7( this assertion is (alse >that is, some prisoners still

    haven0t been to the living room?, all 8== prisoners will be shot (or their stupidity. 1owever, i( it is

    indeed true, all prisoners are set (ree. Thus, the assertion should only be made i( the prisoner is

    8==L certain o( its validity.

    /e(ore the random pic5ing begins, the prisoners are allowed to get together to discuss a plan.

    'hat plan should they agree on, so that eventually, someone will ma5e a correct assertion)

    http://www.crazyforcode.com/wp-content/uploads/2013/07/8-ball-puzzle.jpg
  • 5/25/2018 Probabilty & Apt

    18/29

    Solution:

    (n evaluation of the problem& there is no limit on the number of times that a prisoner can go into the cell&

    ho%ever the prisoners need a %ay to communicate %ith each other on %ho %hen into the cell.

    Therefore one person is chosen as the counter.

    @very time any prisoner is selected other than counter person & they follo% these steps. (f they have

    never turned on the light bulb before and the light bulb is off& they turn it on. (f not& they don,t do

    anything 4simple as that.

    Co% if +ounter person is selected and the light bulb is already on& he adds one to his count and turns

    off the bulb. (f the bulb is off& he ust sits and do nothing. The day his count reaches ##& he calls the

    %arden and tells him Q@very prisoner has been in the special room at least once.

    Problem:

    ou have two sand timers with you. One can measure $ minutes and the other sand timer can

    measure 88 minutes. This means that it ta5es $ minutes (or the sand timer to completely empty

    the sand (rom one portion to the other.

    3ou have to measure 8& minutes using both the timers. 1ow will you measure it )

    Solution:

    Dathematically

    http://www.crazyforcode.com/wp-content/uploads/2013/07/sand-timer.jpghttp://www.crazyforcode.com/wp-content/uploads/2013/07/light-bulb-100-prisoner-350x250.jpg
  • 5/25/2018 Probabilty & Apt

    19/29

    7 Dinutes Sand Timer Einished.

    Time

  • 5/25/2018 Probabilty & Apt

    20/29

    see the scenario again.

    1st son half of the horses 4185"!#

    "nd son one third of horses 41853!6

    3rd son one ninth of horses 4185#!"

    So in total 17 horses %ill get distributed among the three sons and the traveling mathematician %ill ta'e

    his horse and leave.

    Problem :

    3ou are given a choice o( three doors by an Angel. 3ou can choose only one o( the doors among

    the three. Out o( these three doors two contains nothing and one has a Fac5pot.

    A(ter you choose one o( the doors angel reveals one o( the other two doors behind which there

    is a nothing. Angel gives you an opportunity to change the door or you can stic5 with your

    chosen door.

    3ou don0t 5now behind which door we have nothing. hould you switch or it doesn0t matter)

    Soltuion:

    ou choose one of the door. So probability of getting the ac'pot ; 153.

    Let,s say that the ac'pot is in Ooor no 1 and you choose Ooor no 1. So the angel %ill either open door

    no " or door no 3. Let,s loo' at the sample space of this Ru))le.

    +ase FG Ooor1 Ooor" Ooor3+ase 1 : Jac'pot Cothing Cothing

    +ase " : Cothing Jac'pot Cothing

    +ase 3 : Cothing Cothing Jac'pot

    !ant to keep "our #uess:

    Let,s suppose that you guessed correctly. Then it ma'es no difference %hat the game sho% host does&

    the other door is al%ays the %rong door. So in that case& by 'eeping your choice& the probability that

    you %in is 153 0 1 ! 153.

    $ut let,s suppose you guessed incorrectly. (n that case& the remaining door is guaranteed to be the

    correct door. Thus& by 'eeping your choice& the probability of %inning is "53 0 ! .

    our total chances of %inning by 'eeping your guess is: 153 ! 153.

    !ant to $han#e "our #uess:

    Again& let,s suppose that you guessed correctly. $y changing your guess the probability that you %in is

    153 0 ! .

    $ut let,s suppose you guessed incorrectly. Again& this means that the remaining door mustbe the

    correct one. Therefore by changing your choice& the probability of %inning is "53 0 1 ! "53.

    our total chances of %inning by changing your guess is: "53 ! "53.

    Problem:

    This problem is also called Helly /eans problem. This is the most commonly as5ed interview

  • 5/25/2018 Probabilty & Apt

    21/29

    pu**le.

    3ou have Fars that are all mislabeled. One Far contains Apple, another contains Oranges and

    the third Far contains a mixture o( both Apple and Oranges.

    3ou are allowed to pic5 as many (ruits as you want (rom each Far to (ix the labels on the Fars.'hat is the minimum number o( (ruits that you have to pic5 and (rom which Fars to correctly

    label them)

    abels on Fars are as (ollows:

    Solution:

    Let,s ta'e a scenario. Suppose you pic' from ar labelled as Apple and Nranges and you got Apple from

    it. That means that ar should be Apple as it is incorrectly labelled. So it has to be Apple ar.

    Co% the ar labelled Nranges has to be Di0ed as it cannot be the Nranges ar as they are %rongly

    labelled and the ar labelled Apple has to be Nranges.

    Similar scenario applies if it,s a Nranges ta'en out from the ar labelled as Apple and Nranges. So you

    need to pic' ust one fruit from the ar labelled as Apple and Nranges to correctly label the ars.

    Problem:

    A person dies& and he arrives at the gate to heaven. There are 3 doors in the heaven. Nne of the door

    leads to heaven& second one leads to a 1Fday stay at hell and then bac' to the gate and the third one

    leads to a " day stay at hell and then bac' to the gate. @very time the person is bac' at the gate& the 3

    doors are reshuffled. -o% long %ill it ta'e the person to reach heavenH

    http://www.crazyforcode.com/wp-content/uploads/2013/07/Three_mislabeled_jars.jpg
  • 5/25/2018 Probabilty & Apt

    22/29

    Solution:

    According to probability 8 o( the time, the door to heaven will be chosen, so 8 o( the time it

    will ta5e = days. 8 o( the time, the 8day door is chosen, o( those, the right door will be chosen

    the next day. imilarly, 8 o( the time, the day door is chosen, o( those, the right door will be

    chosen a(ter the days.

    So lets say it %ill ta'e C days. 153 of the cases are done in days as before. 153 of the cases are 1C.

    153 are " C.

    C ! 153 153 41 C 153 4" CC ! 1 "C53

    Therefore& C53 ! 1 M C ! 3.

    So it %ill ta'e on average 3 days to reach to heaven.

    Problem:

    3ou are in a room with switches which correspond to bulbs in another room and you don0t

    5now which switch corresponds to which bulb. 3ou can only enter to the room with the bulbs

    and bac5 once. 3ou can 2OT use any external e9uipment >power supplies, resistors, etc.?. 1ow

    do you (ind out which bulb corresponds to which switch)

    Solution:

    $efore reading the ans%er if you are interested in a $lueH

    +lue: Light $ulbs get hot %hen they,re on.

    http://www.crazyforcode.com/wp-content/uploads/2013/07/3-bulbs-3-switches.jpghttp://www.crazyforcode.com/wp-content/uploads/2013/07/heaven-door.jpeg
  • 5/25/2018 Probabilty & Apt

    23/29

    +lue didn,t help you

    -ere is the solution for you.

    S%itch on s%itches 1 ? "& %ait a minute and s%itch off number ".

    @nter the room. Ihichever bulb is on is %ired to s%itch 1& %hichever is off and hot is %ired to s%itch

    number "& and the third is %ired to s%itch 3.

    Problem:

    There are & horses and & lanes. 3ou have no idea about which horse is better than other.

    ;ind in minimum possible races, the (irst three (astest running horses.

    Solution:

    Ie %ill have > races %ith all "> horses

    Let the results be

    u1&u"&u3&u/&u>

    v1&v"&v3&v/&v>

    01&0"&03&0/&0>

    y1&y"&y3&y/&y>

    )1&)"&)3&)/&)>

    Ior' through a process of elimination:

    Ihere u1 faster than u" & u" faster than u3 etc and

    Ie need to consider only the follo%ing set of horses

    u1&u"&u3

    v1&v"&v3

    01&0"&03

    y1&y"&y3

    )1&)"&)3

  • 5/25/2018 Probabilty & Apt

    24/29

    Ie get u1 as the fastest horse

    Ie can ignore y1&y"&y3&)1&)" and )3 automatically since those can not be in the top 3.

    Co% %e left %ith

    u"&u3&

    v1&v"&v3&01&0"&03&

  • 5/25/2018 Probabilty & Apt

    25/29

    Answer:

    very simple. -alf the couples have boys first& and stop. The rest have a girl. Nf those& half have a boy

    second& and so on.

    So suppose there are C couples. There %ill be C boys.

    15" have a boy and stop: girls

    15/ have a girl& then a boy: C5/ girls

    158 have " girls& then a boy: "C58 girls

    1516 have 3 girls& then a boy: 3C516 girls

    153" have / girls& then a boy: /C53" girls

    K

    Total: C boys and

    1C "C 3C /C

    ; ; ; K ! UC

    Therefore& the proportion of boys to girls %ill be pretty close to 1:1

    %uestion:

    Three ants are sitting at the three corners o( an e9uilateral triangle. 6ach ant starts randomly

    pic5s a direction and starts to move along the edge o( the triangle. 'hat is the probability that

    none o( the ants collide)

    Answer:

    So let,s thin' this through. The ants can only avoid a collision if they all decide to move in the same

    direction 4either cloc'%ise or antiFcloc'%ise. (f the ants do not pic' the same direction& there %ill

    definitely be a collision. @ach ant has the option to either move cloc'%ise or antiFcloc'%ise. There is aone in t%o chance that an ant decides to pic' a particular direction. Xsing simple probability

    calculations& %e can determine the probability of no collision.

    http://www.crazyforcode.com/wp-content/uploads/2013/06/ants-triangle.jpeghttp://www.crazyforcode.com/wp-content/uploads/2013/07/boys-girls-puzzle.jpg
  • 5/25/2018 Probabilty & Apt

    26/29

    R4Co collision ! R4All ants go in a cloc'%ise direction R4 All ants go in an antiFcloc'%ise

    direction ! .> .> .> .> .> .> ! 0&2'

    Problem:

    ou are given " eggs. ou have access to a 1Fstorey building. @ggs can be very hard or very fragile

    means it may brea' if dropped from the first floor or may not even brea' if dropped from 1 th

    floor.$oth eggs are identical. ou need to figure out the highest floor of a 1Fstorey building an eggcan be dropped %ithout brea'ing.

    Co% the Buestion is ho% many drops you need to ma'e. ou are allo%ed to brea' " eggs in the

    process.

    Answer:

    Let 0 be the ans%er %e %ant& the number of drops reBuired.

    So if the first egg brea's ma0imum %e can have 0F1 drops and so %e must al%ays put the first egg fromheight 0. So %e have determined that for a given 0 %e must drop the first ball from 0 height. And no% if

    the first drop of the first egg doesn,t brea's %e can have 0F" drops for the second egg if the first egg

    brea's in the second drop.

    Ta'ing an e0ample& lets say 16 is my ans%er. That ( need 16 drops to find out the ans%er. Lets see

    %hether %e can find out the height in 16 drops. Eirst %e drop from height 16&and if it brea's %e try all

    floors from 1 to 1>.(f the egg don,t brea' then %e have left 1> drops& so %e %ill drop it from 161>1

    !3"nd floor. The reason being if it brea's at 3"nd floor %e can try all the floors from 17 to 31 in 1/ drops

    4total of 16 drops. Co% if it did not brea' then %e have left 13 drops. and %e can figure out %hether %e

    can find out %hether %e can figure out the floor in 16 drops.

    Lets ta'e the case %ith 16 as the ans%er

    1 1> 16 if brea's at 16 chec's from 1 to 1> in 1> drops

    1 1/ 31 if brea's at 31 chec's from 17 to 3 in 1/ drops

    1 13 /> K..

    1 1" >8

    1 11 7

    1 1 81

    1 # #1

    1 8 1 Ie can easily do in the end as %e have enough drops to accomplish the tas'

    http://www.crazyforcode.com/wp-content/uploads/2013/06/2-eggs-100-floors.png
  • 5/25/2018 Probabilty & Apt

    27/29

    Co% finding out the optimal one %e can see that %e could have done it in either 1> or 1/ drops only but

    ho% can %e find the optimal one. Erom the above table %e can see that the optimal one %ill be needing

    linear trials in the last step.

    So %e could %rite it as

    41p 414pF1 414pF" KKK 41 G! 1.

    Let 1p!B %hich is the ans%er %e are loo'ing for

    B 4B15" G!1

    Solving for 1 you get B!1/.

    So the ans%er is: 1/

    Orop first orb from floors 1/& "7& 3#& >& 6& 6#& 77& 8/& #& #>& ##& 1K 4i.e. move up 1/ then 13& then

    1" floors& etc until it brea's 4or doesn,t at 1

    roblem:The riddle is Cine ((T students %ere sitting in a classroom. Their professor %anted them to

    test. Ce0t day the professor told all of his # students that he has # hats& The hats either red or blac'

    color. -e also added that he has at least one hat %ith red color and the no. of blac' hats is greater than

    the no. of red hats. The professor 'eeps those hats on their heads and as' them tell me ho% many red

    and blac' hats the professor haveH Nbviously students can not tal' to each other or no %ritten

    communication& or loo'ing into each other eyesM no such stupid options and no tric's.

    Rrofessor goes out and comes bac' after " minutes but nobody %as able to ans%er the Buestion. So

    he gave them 1 more minuets but the result %as the same. So he decides to give them final >

    minutes. Ihen he comes everybody %as able to ans%er him correctly.So %hat is the ans%erH and %hyH

    Answer:

    After first interval of $% #inutes &

    'ets assu#e that their is 1 hat of red color and hats of blac) color. "he student with red

    hat on his head can see all blac) hats, so he )nows that he #ust be wearing a red hat.

    *ow we )now that after first interval nobody was able to answer the prof that #eans our

    assu#ption is wrong. +o there can not be 1 red and blac) hats.

    After second interval of 1% #inutes &

    Assu#e that their are $ hats of red color and hats of blac) color. "he students with red

    hat on their head can see all blac) hats and 1 red hat, so they )now that they #ust be

    wearing a red hat.

    *ow we )now that after second interval nobody was able to answer the prof that #eans

    our assu#ption is again wrong. +o there can not be $ red and blac) hats.

    After third interval of final - #inutes &

    *ow assu#e that their is 3 hats of red color and hats of blac) color. "he students with

    red hat on their head can see all blac) hats and $ red hats, so they )now that they #ust

    be wearing a red hat.

    *ow we )now that this ti#e everybody was able to answer the prof that #eans our

    assu#ption is right.+o there are 3 red hats and blac) hats.*ow as everybody gave the

    answer so there can be a doubt that only those 3 students )now about it how everybody

    ca#e to )now /

  • 5/25/2018 Probabilty & Apt

    28/29

    "hen here is what i thin), the professor gave the# 0I*A' - #inutes to answer, so other

    guys will thin) that the professor epects the answer after 3rd interval (according to prof it

    #ust be solved after 3 intervals!, so this is the clue for others.

    Problem :

    -o% to measure e0actly / gallon of %ater from 3 gallon and > gallon ars& *iven& you have unlimited

    %ater supply from a running tap.

    4 allon water measure pu!!le

    Solution:

    Step 1. Eill 3 gallon ar %ith %ater. 4 >p ; & 3p ; 3

    Step ". Rour all its %ater into > gallon ar. 4>p ; 3& 3p ;

    Step 3. Eill 3 gallon ar again. 4 >p ; 3& 3p ; 3

    Step /. Rour its %ater into > gallon ar untill it is full. Co% you %ill have e0actly 1 gallon %ater remaining

    in 3 gallon ar. 4>p ; >& 3p ; 1

    Step >. @mpty > gallon ar& pour 1 gallon %ater from 3 gallon ar into it. Co% > gallon ar has e0actly 1

    gallon of %ater. 4>p ; 1& 3p ;

    Step 6. Eill 3 gallon ar again and pour all its %ater into > gallon ar,thus > gallon ar %ill have e0actly /

    gallon of %ater. 4>p ; /& 3p ;

    Ie are done

    Problem:

    Ie have 1 identical bottles of identical pills 4each bottle contain hundred of pills. Nut of 1 bottles #

    have 1 gram of pills but 1 bottle has pills of %eight of 1.1 gram. *iven a measurement scale& ho% %ould

    you find the heavy bottleH ou can use the scale only once.

    Answer:

    Eirst& arrange the bottles on shelf and no% ta'e& 1 pill from the first bottle& " pills from the second bottle&

    3 pills from the third bottle& and so on. (deally you %ould have 414115"!>> pills %eighing >> grams&%hen you put the entire pile of pills on the %eighing scale.The deviation from >> g %ould tell you %hich

    bottle contains the heavy pills.

    http://www.crazyforcode.com/wp-content/uploads/2013/06/water-measure.jpeg
  • 5/25/2018 Probabilty & Apt

    29/29

    (f it is .1 gram more& it is 1st bottle %hich has heavy pill& if it is ." more& gram "nd bottle has heavy pills&

    if it is .3 more& gram 3rd bottle has heavy pills.

    roblem:This solution has a limitation that information is partially passed and there needs some trustlevel.

    Salary of A: i

    Salary of $:

    Salary of +: '

    Salary of O: l

    A passes to $ 4i a %here a is a number that A 'no%s $ ta'es this a passes to + 4i a b. +

    ta'es this and passes to O 4i ' a b c. O ta'es this and passes to A 4i ' l a b c

    d

    Co% one after another they remove their constants.

    @0: A no% passes to $: i ' l b c d 4-e has removed a

    $ passes to + after removing of his constant 4b.

    Thus Einally O gets 0 y ) u d. -e ta'es a%ay his constant and no% he has i ' l.

    So the average is:4i ' l 5 /.

    Let us 'no% if you 'no% any other solution.