Fragen im Vorstellungsgespräch: Software engineer in New York, Vereinigte Staaten von Amerika
Fragen aus Vorstellungsgesprächen für software engineer, von Bewerbern geteilt
Top Vorstellungsgespräch-Fragen
A frog is at the bottom of a 30 meter well. Each day he summons enough energy for one 3 meter leap up the well. Exhausted, he then hangs there for the rest of the day. At night, while he is asleep, he slips 2 meters backwards. How many days does it take him to escape from the well? 567 Antwortentry to answer this question as seriously as u can 28 I agree -- it's 28...because on that morning, he'll be at 27 metres and he can jump to the top in one bound. Mehr Antworten anzeigen Answer: 28 Each day he makes it up another meter, and then on the twenty seventh day he can leap three meters and climb out. It's 29 - on the 28th day he can leap 3 meters and hang at the top (but he can't climb higher & out), and on the 29th day he'll leap and be out of the well at 31 meters. 27 At day 0, he jumps to 3m. At day 27, he jumps to 30m and gets out. 28. Each night he ends up/starts the next morning at the number of days he's been there (first night, he's at 1 foot, 2nd night he's at two feet). Hence, on the 28th day he jumps 3 feet to 30 feet. 28 days. At start of day 27, he jumps 3m to reach the top of the 30m well but has no energy left to climb out. At start of day 28, he jumps another 3m and entirely out of the well. Never....the frog would be dead by day 10 since nothing to eat or drink. 28 Saying 28 is too easy. What about the external (1) and internal factors (2): (1) there might be a heavy rain during the first night and the frog can easily float up or, ..., drown, at all; (2) the frog may decide it's sunday - let's have a rest and spare the energy for a bigger jump on the next day... 27 days Day 1 - It jumps 3 meters. 0 + 3 = 3. Then falls back 2 at night. 3 - 2 = 1 Day 2 - It jumps 3 meters. 1 + 3 = 4. Then falls back 2 at night. 4 - 2 = 2. ... Day 26 - It jumps 3 meters. 26 + 3 = 29. Then falls back 2 at night. 29 - 2 = 27. Day 27 - It jumps 3 meters. 27 + 3 = 30 This question is ambiguous whether if the frog is able to get out when it reaches the top or if it needs to exceed 30 meters to climb out. Assuming it doesn't die of starvation, the answer is 28 days.* start of day 1 (0 days elapsed): 0m --> 3m (then falls back 2m by start of day 2) start of day 2 (1 day elapsed): 1m --> 4m start of day 3 (2 days elapsed): 2m --> 5m ... start of day 28 (27 days elapsed): 27m --> 30m start of day 29 (28 days elapsed): 28m --> 31m In other words, 28 days will have elapsed before the frog can jump to a height exceeding 30m.* * This answer assumes the frog is not able to walk away after it hits 30m. I would assume it has no energy left to climb out based on the problem description. If the questioner disagrees with this assumption, then the answer is 27 days. Mehr Antworten anzeigen 28 27 ..... he will jump 3 meters this day to get out!!! The math certainly says 27, assuming he only needs to get to 30m to actually get out. its easy to forget that, as pointed out by Paul, he can jump at the beginning of the day, therefore he can reach 3 meters in 0 days. I like the out-of-the-box notions presented by HB and nic. Maybe croaking could get him some help from someone. Maybe he could get up in a well bucket. Why does he want to leave? -- maybe he has everything he needs there and is safe from predators. Why does he slip down? Can he stop that? I wonder what they're looking for in a question like that. I wonder if it really helps them choose good candidates. I wonder who's going to bother reading this. No math necessary. Frog is dead after a few days. 27!! as he will be out on the same day. it will be 28 if he spends the night as well. and c'mon, frog is not based on a binary system, that he wont have enough energy after the last 3 meter, he sure will be motivated enough to take the 3.000001 meteres on the last day to get out of the damn well. 27 days It is 28 assuming reaching 30 ft gets him out of the well, people saying 27 are making the error of assuming there is a day zero, when counting days as with years there is no 0. 28. 27 days to get to go to sleep on level 27. Next day outa da hole. Most frogs have to surface for air. After a short amount of time they will die without air unless they are in aerated water and can absorb through skin. So ask what species is the frog. Day 1: 0 + 3 = 3 - 2 = 1, D2: 1 + 3 = 4 -2 = 2, D3: 2 +3 = 5 - 2 = 3....D28: 27 + 3 = 30 -2 = 28, D29: 28 + 3 = Eaten by the bird that has been waiting for him.... Mehr Antworten anzeigen bllshit If Mr. Frog manages to make it up the wall another meter everyday then, on the 27th day, he can leap three meters and climb out, the answer would be 28 days... 28 days. As the frog slips 2 meters down every night by the 27th day he has climbed 27 meters. On 28th, the frog will start from the point of 27m which means start climbing 3 meters foward and this way he reaches his 30m to get out. 28days NB - he does 3m/day, but the result in the next morning b4 his next jump is 1m jump the previous day In the morning of day 26 b4 he jump, he has 5m left...meaning he has done 25m for 25days. On day 26, he jumps 3m, leaving him wit 2m to go but cos he sinks 2m overnight, the4 his resulting meters to go is 4m On day 27, he jumps 3m and left with 1m but sinking 2m more means the resulting meters to go is 3m On day 28, he complete his 30m and walk out from the well victorious provided no predator in the well and he didnt die of starvation 28 days... kermit the frog? How much water is in the well? Frogs need water to survive. What about food? 27th day How did the frog get in the well in the first place? What is motivating him to get up? How does he know he can get out? If the frog slips two meters every night for 27 nights he will be very sad and wont try anymore so he will never get out. Wait....I am this frog! x = number of days A = 30 meters x+2 = A x + 2 = 30 x=28 Mehr Antworten anzeigen Thirty days as he is only moving one meter a day. What kind of Frog is it? Is the well full of Water? My first thought is that the frog would not survive, Food and air seem the best bet for Frog-a-cide. Of course if the question is mathematical only in nature then you would have to follow the logic above x=number of days y=30 meters x+2=y x+2=30 x=28 Hey guys ... Its simple don't break your head.... 30 feet well OK 1 day 3 feet jump and sleeping and falling down to 2 feet.. So the frog can only climb up 1 feet per day... so on 26th day it was in 26 th feet and jumped and it reached to 29th feet and sleeping and falling down to 2 feet down.. so on 27th day it was in 27th feet jumped and it reached to 30 feet and went out of the well.. bec after reaching the 30th feet why the hell does the frog gonna sleep again. So it took 27 days for the frog to come out of the 30 feet well. Question created by me... so answered it....lolzzzzzzzzzzz Answer: Day 28 Day 1 - It jumps 3 meters. 0 + 3 = 3. Then falls back 2 at night. 3 - 2 = 1 Day 2 - It jumps 3 meters. 1 + 3 = 4. Then falls back 2 at night. 4 - 2 = 2. ... Day 26 - It jumps 3 meters. 25 + 3 = 28. Then falls back 2 at night. 28 - 2 = 26. Day 27 - It jumps 3 meters. 26 + 3 = 29 Then falls back 2 at night. 29 - 2 = 27. Day 28 - It jumps 3 meters. 27 + 3 = 30 Note: Assume after the first leap that his hind legs are exactly three meters up the well. His hind legs must clear the well for him to escape. Answer: Day 29 Remember that on Day 1 the frog ends at 1 meter, Day 2 the frog ends at 2 meters, ... So on Day 27, the frog end at 27 meters. On Day 28, the frog goes up to 30 meters, then back down to 28 meters. On Day 29 the frog finally makes it to 31 meters (out of the well). This will help if you are still not convinced: int height = 30; int curPos = 0; int days = 0; while(curPosheight){ break; } curPos -=2; if(curPos>height){ break; } } System.out.println(days); } ITS ONLY 10 DAYS. Because, if he waits 10 days, he will summon the strength to jump 30 meters in one jump to the top of the well. Ya'll can't think outside the box... Cool Mehr Antworten anzeigen I know this isn't the right answer but if u think VERY VERY logically, well, he doesn't. 30 days Day 1 -> Total distance Covered = 3-2 = 1m Day 27 -> 1*27 = 27 Day 28 -> 27+3 = 30 and the frog and he escapes 28 will be the final answer Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 Mehr Antworten anzeigen I will forever be indebted to the great Doctor Tebe for fixing my broken marriage after my husband left me for his mistress for 6 months. I never believed in spells until my friend introduced me to him. At first, I was skeptical about him because I heard a lots about false spell casters but I put my doubts behind me for i was desperate to get my husband back and I did according to what he instructed me to do. Now my husband is back just within 48 hours of contacting him. I'm living happily with my husband again after 6 months of divorce and I will not rest till he's known all over the world. He's also specialize in money spells, lottery spells, sickness spells E.T.C. Get connected with Doctor Tebe now, his email is drtebe1@gmail. com or WhatsApp on +2348140544262. Mehr Antworten anzeigen i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 Mehr Antworten anzeigen i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Just wanted to call out Paul for his fantastic service through my home buying process - from identifying the best rate through to obtaining approval and settlement. This was my first home purchase and I think it's fair to say that it would have been significantly more challenging without his help. Paul was on top of everything that needed to be done - going the extra bit in dealing with the bank and conveyance to ensure that the whole process was concluded smoothly. The best part was that Paul was always there to answer any questions and provide support, making life much simpler. Highly recommended! www.westernloanfinance.com Just wanted to call out Paul for his fantastic service through my home buying process - from identifying the best rate through to obtaining approval and settlement. This was my first home purchase and I think it's fair to say that it would have been significantly more challenging without his help. Paul was on top of everything that needed to be done - going the extra bit in dealing with the bank and conveyance to ensure that the whole process was concluded smoothly. The best part was that Paul was always there to answer any questions and provide support, making life much simpler. Highly recommended! www.westernloanfinance.com Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 Mehr Antworten anzeigen When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 Mehr Antworten anzeigen Just wanted to call out Paul for his fantastic service through my home buying process - from identifying the best rate through to obtaining approval and settlement. This was my first home purchase and I think it's fair to say that it would have been significantly more challenging without his help. Paul was on top of everything that needed to be done - going the extra bit in dealing with the bank and conveyance to ensure that the whole process was concluded smoothly. The best part was that Paul was always there to answer any questions and provide support, making life much simpler. Highly recommended! www.westernloanfinance.com When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Get your ex back from a real love spell caster with Dr Paul at his email at astoriashrine@ gmail com within 48 hours instantly. I am very happy for contacting Dr Paul who helped me get my ex husband back from another woman after 3 years of separation. I am very happy because I never believed in spell casting and contacting spell casters to solve my problem but after 3 years of separating from my husband being single, I had to contact Dr Paul after I read about him online and how he has been helping people. I am very glad I did. My husband came back to me within 48 hours, begged me and the kids who needed their father back with them and I am very happy. I found this man through testimonies that he can solve pregnancy and love problems that is why I contacted him to help me and within 48 hours my husband came back home and we are living happily together. His email is astoriashrine @ gmail com or Whats-app number on +2349051441669 Get your ex back from a real love spell caster with Dr Paul at his email at astoriashrine@ gmail com within 48 hours instantly. I am very happy for contacting Dr Paul who helped me get my ex husband back from another woman after 3 years of separation. I am very happy because I never believed in spell casting and contacting spell casters to solve my problem but after 3 years of separating from my husband being single, I had to contact Dr Paul after I read about him online and how he has been helping people. I am very glad I did. My husband came back to me within 48 hours, begged me and the kids who needed their father back with them and I am very happy. I found this man through testimonies that he can solve pregnancy and love problems that is why I contacted him to help me and within 48 hours my husband came back home and we are living happily together. His email is astoriashrine @ gmail com or Whats-app number on +2349051441669 Mehr Antworten anzeigen I will forever be indebted to the great Doctor ojoka for fixing my broken marriage after my husband left me for his mistress for 3 months. I never believed in spells until my friend introduced me to him. At first, I was skeptical about him because I heard a lots about false spell casters but I put my doubts behind me for i was desperate to get my husband back and I did according to what he instructed me to do. Now my husband is back just within 48 hours of contacting him. I'm living happily with my husband again after 6 months of divorce and I will not rest till he's known all over the world. He's also specialize in money spells, lottery spells, sickness spells E.T.C. Get connected with Doctor ojoka now, his email him drojokaspelltemple@gmail com or Whats App on +2348144172934 I will forever be indebted to the great Doctor ojoka for fixing my broken marriage after my husband left me for his mistress for 3 months. I never believed in spells until my friend introduced me to him. At first, I was skeptical about him because I heard a lots about false spell casters but I put my doubts behind me for i was desperate to get my husband back and I did according to what he instructed me to do. Now my husband is back just within 48 hours of contacting him. I'm living happily with my husband again after 6 months of divorce and I will not rest till he's known all over the world. He's also specialize in money spells, lottery spells, sickness spells E.T.C. Get connected with Doctor ojoka now, his email him drojokaspelltemple@gmail com or Whats App on +2348144172934 Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 Mehr Antworten anzeigen When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 Mehr Antworten anzeigen When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 Mehr Antworten anzeigen Mehr Antworten anzeigen My husband and I have been married for about 7 yrs now. We were happily married with two kids, a boy and a girl. 3 months ago, I started to notice some strange behavior from him and a few weeks later I found out that my husband is seeing someone. He started coming home late from work, he hardly care about me or the kids anymore, Sometimes he goes out and doesn't even come back home for about 2-3 days. I did all I could to rectify this problem but all to no avail. I became very worried and needed help. As I was browsing through the Internet one day, I came across a website that suggested that Dr sirdoma can help solve marital problems, restore broken relationships and so on. So, I felt I should give him a try. I contacted him and he did a spell for me. Two days later, my husband came to me and apologized for the wrongs he did and promise never to do it again. Ever since then, everything has returned back to normal. I and my family are living together happily again.. All thanks to Dr sirdoma . If you need a spell caster that can cast a spell that truly works, I suggest you contact him. He will not disappoint you. This is his nubmer ; +2347010313315 1)lotto spell 2)promotion spell 3)protection spell Mehr Antworten anzeigen Please if you are having issues with your relationship or marriages I advice you to contact Dr Charles he can help you as well. WhatSApp: +2348146708557 Mehr Antworten anzeigen I completely trusted Dr Paul totally from the time I spoke with him during the period my husband Left me after11 years of our marriage, He started the spell work on my husband, and gave me so much assurance and guaranteed me that he was going to bring my husband back to my feet in just 48 hours of the spell casting. I was so confident in his work and just as he said in the beginning, my husband is finally back to me again, yes he is back with all his hearts, Love, care, emotions and flowers and things are better now. I would have no hesitation to recommend this powerful spell caster to anybody who is in need of help.. E-mail; astoriashrine @ gmail com I completely trusted Dr Paul totally from the time I spoke with him during the period my husband Left me after11 years of our marriage, He started the spell work on my husband, and gave me so much assurance and guaranteed me that he was going to bring my husband back to my feet in just 48 hours of the spell casting. I was so confident in his work and just as he said in the beginning, my husband is finally back to me again, yes he is back with all his hearts, Love, care, emotions and flowers and things are better now. I would have no hesitation to recommend this powerful spell caster to anybody who is in need of help.. E-mail; astoriashrine @ gmail com I completely trusted Dr Paul totally from the time I spoke with him during the period my husband Left me after11 years of our marriage, He started the spell work on my husband, and gave me so much assurance and guaranteed me that he was going to bring my husband back to my feet in just 48 hours of the spell casting. I was so confident in his work and just as he said in the beginning, my husband is finally back to me again, yes he is back with all his hearts, Love, care, emotions and flowers and things are better now. I would have no hesitation to recommend this powerful spell caster to anybody who is in need of help.. E-mail; astoriashrine @ gmail com Mehr Antworten anzeigen I completely trusted Dr Paul totally from the time I spoke with him during the period my husband Left me after11 years of our marriage, He started the spell work on my husband, and gave me so much assurance and guaranteed me that he was going to bring my husband back to my feet in just 48 hours of the spell casting. I was so confident in his work and just as he said in the beginning, my husband is finally back to me again, yes he is back with all his hearts, Love, care, emotions and flowers and things are better now. I would have no hesitation to recommend this powerful spell caster to anybody who is in need of help.. E-mail; astoriashrine @ gmail com Mehr Antworten anzeigen Mehr Antworten anzeigen Einer oder mehrere Kommentare wurden entfernt. |
Out of 25 horses, pick the fastest 3 horses. In each race, only 5 horses can run at the same time. What is the minimum number of races required? 68 Antworten7 races. 6 races. After running 5 you have the 5 fastest horses out of 25. Run 1 more race of 5 horses to get the fastest 3. 8 races Mehr Antworten anzeigen The above answer is not right. The correct answer is 8 races. Sid's answer is incorrect. The correct answer is 7 races. 7 races. We run five races with five horses. The five winners race in a sixth race while the 4th and fith place finishers are eliminated from further consideration. The sixth race show horse is faster than all the horses that participated in the preliminary races where the 4th and 5th place horses participated and they are eliminated from further consideration. The other horses in the preliminary race where the 6th race show horse participated are also eliminated. The show horse in the preliminary race where the 6th race place horse participated is eliminated since there are at least three remaining horses that are faster. We are left with 6 horses. We know the winner of the 6th race is fastest overall, so that leaves five horses to enter a 7th race for the overall place and show. Seems to me the correct answer is five. Assuming that each horse's performance is timed, by running five races with five horses each, you'll know the speed of all 25 horses. The three with the shortest times are the three fastest horses. Most responses assume you need multiple rounds, but these responses seem to assume that the five horses that finish first in the first round are the fastest five overall. That may not be the case. Just because a horse beat its four competitors doesn't mean it's one of the five fastest overall ... just that it was faster than the four it competed against. Consider: 5 races will ensure that each horse runs once. In race #1, the margin of victory could be so insignificant that the difference between horse #1 and horse #5 is.05 seconds (with 2nd place .02 behind, 3rd place .03 behind, 4th place .04 behind). The horse that finishes in 5th place in race #1 could actually be the 5th fastest horse of the 25. You wont know this of course until all 25 horses have raced. Horse #5 from race #1 could be faster than the first place finishers in all other 4 races. Rank the top 5 fastest times. Odds are that they were not all from the same race. Maybe you race them one more time against each other to verify your ranking technique (and in the good spirit of a playoff.) This brings the total to 6. 5 (or 6) is a great, pat answer if you know all of the particulars. Unfortunately, most programming in the world of finance wants to make sure nothing is being missed. The interviewer wants to see how you think and how you code. If you had a timer, yeah, 5 races are what you need. Sort all 25 horses by time and voila, you have 1, 2, and 3. However, horses (loans, retirement funds, Investments) will perform differently over time, distance, endurance, phase of the moon, etc. The interviewer wants to hear the deep answer to see your thought process. When you are dealing in operations that take milliseconds, extra loops in order to be thorough are not a bad thing. How about 11 races - 5 horses in Race 1. Best 3 face horses 6 & 7. Best 3 face horses 8 & 9. Best 3 face horses 10 & 11. Rinse and repeat. Or 12 races - first round - 5 races of 5. (W)in, (P)lace, and (S)how in each go to second round (15 horses). second round - 3 races of 5. W, P, & S in each go to third round (9 horses). third round - a race of 5 and a race of four. W, P, & S in each go to fourth round (6 horses). fourth round - race 1 - W, P, & S from round 3, race 1 and W & P from round 3, race 2 fourth round - race 2 - W, P, & S from round 4, race 1 and S from round 3, race 2 Not pretty, but definite. I think 5 is the correct answer. Why?: The first requirement is to get the minimum races (no tournament). Secondly, It does not dictate how to get the time. It only conditions 5 horses per race. Which mean 25 / 5 = 5 races. Now, How to time: the timer can help to get the individual hoese race time. These days the time can be measures upto 0.000 (there fractions) which is good enough. Aslo there is no condtion to handle exceptions, so we can skip any exception. 12 RACES ARE REQUIRED -------------------------------------- In the worst case scenario the 'best three' can be from a single team of 5 horses. So 5 races in round one. Chose all the first three of each of the 5 races. 3 races of all the 15 horses which were the 3 winners of the first round. Chose the 9 horses which were winners in round two and have 2 races for the 9 winners[ 5 & 4 horses] you get 6 winners. 1 race of 5 horses, out of the 6 round three winners, keeping one standby 1 race of 4 horses of round four winners with the standby. This will give you the best 3 horses out of 25 So you need to have 5+3+2+1+1 = 12 races in order to get the best three horses. Answer 12 races required. Sometimes the 2nd and/or 3rd best athlete do not get selected if they are teamed in a race along with the best athlete. dynamitemike's answer is the one. A timer could be considered but the problem would be pointless if you had a time. Run 5 races, let's say, Hij denoting the j-th rose in the i-th race, 1 <= i <= 5, 1 <= j <= 5. Eliminate the last two, since there will be three or more horses faster than them for sure. We are left with 15 horses. Run a 6th race with the Hi1 (the 1st placed horses). Suppose the results are Ha1, Hb1, Hc1, Hd1 and He1. The fastest horse in this race (Ha1) is the fastest horse of them all. The last two (Hd1 and He1) can also be eliminated because there will be three or more horses faster than them for sure (at least the top 3 of the 6th race). At this point, we have 12 horses to consider. But the 2nd and 3rd places horses in the preliminary races of the two worst placed horses (Hd1, He1) in the 6th races (Hd2, Hd3, He2, He3) can also be eliminated since there will be at least three horses faster than them. We have only 8 horses left. What about the 2nd and 3rd places horses in the preliminary race of the 3rd placed horse (Hc1) of the 6th race? There will be at least three horses faster than them (Ha1, Hb1 and Hc1). They can be eliminated. We have 6 horses left. Following the same reasoning, the 3rd placed horse in the preliminary race of the 2nd placed horse (Hb1) of the 6th race can be eliminated because there will be at least three horses faster (Ha1, Hb1 and Hb2). We have 5 horses left, namely Ha2, Ha3, Hb1, Hb2 and Hc1. These horses will run in the 7th race and the top 2 will join Ha1 and they are the top 3 horses among the 25 initial. Note that the maximum numbers of races required is MAX = 1 + (H - R)/(R - T), if you have H horses, if you can use R horses per race and if you want the top T horses among all H. For H = 25, R = 5 and T = 3, MAX = 11 races. You get to this result simply through successive races eliminating the last two (R - T) and adding the same number of horses until all of them have raced. It is an exhaustive "brute force" approach. If we were looking for the fastest horse and could only use 2 horses at a race, the problem would actually be: "what is the minimum number of comparisons required to find the maximum value of an unordered set of N values?" A brute force approach would require N - 1 comparisons. In addition, another problem variation: given N^2 horses, if you can use N horses per race, then you only need N+1 races to find the fastest horse. Mehr Antworten anzeigen Do I have resource to metter the time of each horse in each race? Assuming I have it. So I need only 5 races. Assuming I don't have it, I need to understand I cannot eliminate the second and third horses, because they could be faster than the fisrt horse of another race. Assuming either I can have more than one race for each horse with the same performance, after the first five races I eliminate 10 horses. After the next 3 races, I eliminate more 6 horses. Now I have 8 races and 9 horses. For the next 2 races I eliminate more 3 horses (2 in the 1st and 1 in the 2nd). Now I have 10 races and 6 horses. In the 11th race with 5 horses I eliminate more 2 horses, having 11 races and 4 horses. In the last 12th race I find the better 3 horses in order. So, in my opinion I need 12 races to find the best 3 horses, assuming I don't have resource to metter each horse time in a race and assuming each horse run always the same lap time. dynamitemike & Isac Costa nailed it. Seven races are needed without using a timer. You can only eliminate two horses a race maximum. Fastest 3 out of 5. The goal is to eliminate 22 horses (25 down to 3). So 11 is the minimum number of races needed. You have to assume that it's possible each race to actually have the fastest three horses in the bunch. So eliminating more than two horses in any race means you are assuming something that may not be true. Another angle on this. Everyone gets the part about 5 races with 5 horses each. The key is to realize that it is possible that any of those 5 races could contain 0, 1, 2 or 3 of the best 3. The sixth race between the five heat winners can eliminate the two slowest ones. The seventh race is key. After six races, we already know who the fastest horse is, so you only need determine #2 and #3. The fastest horse rests and eats some oats. + Take 2nd and 3rd place finishers from the heat that was won by the fastest horse + Take 2nd place finisher from the heat won by the second fastest horse in the sixth race + Now race these three along with 2nd and 3rd place finishers from the second race and pick the two fastest horses to be #2 and #3. 1 race. You already have the 3 fastest. Win, place, show. No one said i couldn't rerun the same race. The answer has to be 12 For the reasons stated above, and the fact that horses do not race in a vacuum. They are influnced by the other horses in the race, things like drafting, setting the pace. There are frontrunners, and closers. A horse may only run fast enough to win. If they did run in a vacuum, 5 races and a stopwatch would be all you would need - I didn't see that a stopwatch was supplied in the question. None. The way the question is phrased, it doesn't even tell you what the requirement is. 6 is the answer. 1. Race 5 horses 2. Eliminate slowest 4 3. Add 4 horses, race again 4. Repeat steps 2 and 3 until all horses have competed, the winner of the 6th race is the fastest horse. This assumes that: a) the horses will performance identically in each race b) timing devices are not available Santosh K. Rao has the right idea and so the answer is 12. However, the only problem I have with his suggestion is that in the second last step, sitting out the one horse (because you can run only 5 at a time) will give it a competitive advantage as it has raced one less race than the winning 3 horses that it is about to compete against. But this aside, 12 is the right answer. If a timer is available then only 5 races. But if a timer is not available then 8 races. Divide the horses into 5 groups (Group A, B, C D and E). Races 1 to 5 are intra-group races. Race 6::: The fastest horse from each group runs this race. The winner of this race gets the gold medal. Race 7::: 4 horses from race 6 will remain the same. However, replace the winner of race 6 with the next-fastest horse in the same group as the winner of race 6 (we will have this information from the results of races 1-5). The winner of this race gets the silver medal. Race 8::: Same logic as race 7. Replace the winner of race 7 with the next fastest horse of the same group. The winner of this race gets the bronze medal. Mehr Antworten anzeigen I thought the answer was 9... then I read Debarshi's post... 8 is the right number. Nice I believe Issc's answer is correct and I will make it more clear by drawing a simple diagram. Lets map out the 25 horses on a grid: 1 2 3 4 5 ------------ 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5 Above is the grid, the 1-5th places for 5 races are listed as columns. The 6th race, which races the 1st place of each horse, is listed as a row at the very top. So now we have a ranking for each column. From here alone, we see that the fastest horse is in the top left corner: 1 Then, in addition, we will add the possible contenders for 2nd place: 1 2 1 Finally, we will add the contenders for 3rd place: 1 2 3 1 2 1 Every other number not in this triangle are not contenders for the top 3, and are thus eliminated. Knowing that the top left "1" is already the fastest, we put the other 5 horses into the 7th race to determine the 2nd and 3rd place. Hope this helps. Apparently I can't edit my post; I made a typo above, let me retype the wrong portion: From here alone, we see that the fastest horse is in the top left corner: 1 Then, in addition, we will add the possible contenders for 2nd place: 1 1 2 Finally, we will add the contenders for 3rd place: 1 1 1 2 2 3 Every other number not in this triangle are not contenders for the top 3, and are thus eliminated. Knowing that the top left "1" is already the fastest, we put the other 5 horses into the 7th race to determine the 2nd and 3rd place. Hope this helps. This question is about three things: (1) recognizing path dependence (performance is based on the environment) (2) evaluating your ability to reason critically (3) your ability to to question assumptions (do we have a stop watch? does it matter?) There is no "right" answer to this question, they want to see you come to the conclusion that the right answer depends on your assumptions and what you're trying to measure. If you have race times and assume path independence the answer is 5. If you have race times and assume the paths are not independent it's 8-ish. No race times + path independence is 11. Basically they're asking you how many scenarios you should use to price an exotic derivative, but putting it into a context where you can't fall back on "stock" answer(s). Definitely 7. Top 3 in each race (a,b,c,d,e) are in play after round 1, 15 horses. Five winners from round one race. This gives you the undisputed top horse (let's call this horse a1) and moving on to the next round are b1, c1 (2nd and 3rd place in race 6) and a2,a3,b2,b3,c2,c3 for a total of 9 horses. First overall is already confirmed so we only need to determine 2nd and 3rd places now, so our pool is 8. We then eliminate c2 and c3 because the best c1 could do is 3rd place. We also eliminate b3 since the best b2 can be is 3rd place. Now we have 6 horses remaining. Only the bottom 5 run in the last race and the top two placers fill out our top 3. All of this assumes these horses run the same speed each race, of course. If I have a way to time them, 5 races is the minimum. If I do not, then the answer is 7 races. We take the winner from each of the first 5 runs. The ones who place 4th & 5th in this race not only disqualifies them from being top 3, but also disqualifies everyone who ran with them in their first run. The 3rd place finisher in this race is the only possible placer from his first run. The second place finisher in this race is the possible second place overall and the one who took second in that race has the possibility of coming in third overall. The first place finisher from the scond run is first overall and does not need to race again, but the second and third place from that horse's first race might get 2nd & 3rd overall so they need to run again. After you figure who needs to run again, there are only 5 of them so only one race is needed to determine 2nd & 3rd place overall... these horses ar the second & third place from the first run with the first place overall winner. The horse who placed second in their second run and the horse who was second in THAT horse's first run, and the horse who placed third in the second run. Another way of putting it. Assume no timer: 1) 5 races: run all horses. We'll call the races heats A, B ,C, D, E (eliminate last 2 in each race) 2) 1 race: run all 5 of the 1st place horses (eliminate last 2) 3) 1 race: assume the fastest overall horse was from heat A (we'll cal it A1), the 2nd fastest was from heat B (we'll call it B1), and the 3rd fastest was from heat C (we'll call it C1). the only possible combinations of fastest horses is: -A1, B1, C1 -A1, B1, A2 -A1, B1, B2 -A1, A2, B1 -A1, A2, A3 Therefore A1 is the fastest horse. So you only need to race the remaining 5 horses. Conclusion: 7 races are necessary. Assuming we know the second and third place winners and not just the first place winners of the respective races, then 7 is the minimum amount of races required, as theparadox put it. If we only know the first place winners, then we need probably around 10. The correct answer has been posted. It's 11 races, and Mark's reasoning from Jan 11 is correct: In each race you can eliminate at most 2 horses. Can't beat logic! 12 is undoubtably the correct answer here. Just by following pure simple logic and mathematics. First you need to determine a model for the iteration: Take 1 heat of 5 horses. Suppose the top three finishers in this heat are the fastest three out of any of the other 4 heats (We're working with a total of 5 heats, each consisting of 5 horses). This 1st heat will yield the fastest three horses. The 4th horse does not matter, and never matters. Even if the 4th horse is faster than the 1st place finisher in the 2nd heat, you are still left with the top 3 horses in the 1st heat. The 4th place finisher is irrelevant in any heat. Now assume you have the slowest 5 horses in the 1st heat. Then no matter what, these horses will be weeded out in future heats against all the top three finishers of the other heats. So what we conclude here is that the top three horses in each heat are the only relevant horses considering the fact that we are looking for the fastest three horses. Once we know this, the problem is simply an iteration. Here it is: Run 5 races, select the top 3 of each heat. (We are left with 5 x 3 = 15 horses) Run 3 races, select the top 3 of each heat. (We are left with 3 x 3 = 9 horses) Run 2 races (one with 5 horses, one with 4 horses), select the top 3 of each heat. (We are left with 2 x 3 = 6 horses) Run 1 race, select the top 3 of this heat. One horse sat out during this race and must be tested against the top 3. (We are left with 4 horses) Run 1 race, select the top 3 of this heat. These are the 3 fastest horses. It took 12 races to determine this. Mehr Antworten anzeigen Most of you are making this harder than it has to be. You run five races and time each horse once. You compare their individual times (regardless of who they raced against directly )and pick the top three. 7 is correct. if you label the horses 1-25 and create groups of 1-5, 5-10, etc for the first 5 races and for simplicity the horses finish in numerical sequence for each heat. So horse 1, 6, 11, 16, & 21 won their heats. Race the winners and they also finish sequencially so horse #1 wins and it gets the gold. That means horse 11 is best case 3rd fasted and 12-25 are eliminated. Now the 2nd fasted horse can only be #2 or #6. If it's #2 then the 3rd fasted can only be #3 or #6 so that eliminates #4 & #5. Howver, if #6 is the 2nd fastest then the 3rd fastest can only be #2, #7, or #11. This eliminates #8, #9, & #10. After the conceptional eliminations, we are left with #2, #3, #6, #7, #11 for the seventh race. The top 2 join #1 in the winner's circle. Answer is 11 as posted multiple times... no assumptions should be made (timer, won a heat then you're faster than others etc.) In this case, each race of 5 horses would eliminate 2 from contention as being top 3. In order to eliminate 22 horses (25 - top 3), you would need 11 races. the question is not fully defined! instantaneous velocity? over a long or short race? do we include a running start? on that day or on average during the horses' lives? on what planet? what surface? what weather? with or without drugs? with or without a rider? what weight rider? how experienced? saddled? bridled? etc, etc, etc........... 7 is the right answer. Guys, who suggests 11 and 12 - please, try to understand the explanation first. I tried, and I got it finally. let's assume horses 1, 2 and 3 are the fastest. But we don't know it. 1) first 5 races 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 let's assume horses 4, 5, 9, 10, 14, 15, 19, 20, 24 and 25 are the slowest. They are eliminated first. We established already that first three horses in each race stay, cause they could be the fastest of all. 2) 6th race - we take only the fastest horses from all races, let's assume these are 1 6 11 16 21 1st horse we will make the fastest. Let's put it in the pocket. Let's assume the horses came in the order the are standing. First 1, second 6, third 11, forth 16, fifth 21. 3) the 7th race is the key!!! It's the most complicated race to organize. let's see: in this race we don't take the horses number 1(we know it's the fastest of all), we don't take the horses 17, 18, 22 and 23 - they are slower than the slowest horses 16 and 21. Horses number 12 and 13 are slower than 11, and logically, than 6 and 1. The same with the horse number 8: we know already that it is slower than 6, 7, and 1. The only horses which can possibly be faster than the 6 and 11 - are the horses number 2, 3 and 7. So, the 7th race is between 2 3 6 7 11 the first two in this race - are the second and third fastest of all. Looks like I can add a new perspective, the answer is 6. This is based on the wording of the question where they ask for the minimum number of races required to find out. They don't ask for the minimum number guaranteed to find out. So.... you run one race, and then you run the third place finisher in that race in the next five races against 4 new horses in each race. If the original third place finisher wins the next 5 races you have your answer in the minimum number of races. I don't want to guess the odds of this very remote scenario taking place but it is the minimum. Of course the "outside the box" answers might be passable, I especially like, "None. If I already chose the fastest three horses, they are the fastest." But mathematically, it's 7, assuming the horses always run at the same speed. Natalya did probably the best job explaining it, but I'll try a different tack (ha!). I encourage you to write this down and cross out the eliminated horses. Assume the 25 horses are named A-Y. Race 1: A B C D E Race 2: F G H I J Race 3: K L M N O Race 4: P Q R S T Race 5: U V W X Y So far, yes, the people saying you can only eliminate 2 horses per race are correct. We've only eliminated the slowest two in each heat thus far. Assume the left-most was the fastest and the right-most was the slowest. Now we race the winners: Race 6: A F K P U Now we've added a significant amount of information. Not only can we eliminate P and U, but we eliminate all of the horses that they defeated. We can also eliminate all of the horses that K defeated, but we can't eliminate K itself. For each of those horses, at least A, F, and K are faster. Lastly, we can also eliminate H, because we know for a fact that at least A, F, and G are faster. We know A is the absolute fastest, so that leaves: Race 7: B C F G K The winner and runner up have to be the second and third fastest, respectively. Let's look at this question backwards how many horses can be eliminated in each heat. Heats 1-5 you eliminate all horses that did not finish in 1-3 place. Heat 6 you run top horse from heats 1-5. You can eliminate three horses from the 4th and 5th place horses heats, plus the 2nd and 3rd place horses in the heat 6 3rd place finishers original heat, plus the 3rd place finisher in the heat 6 2nd place finishers original heat. The 6th race eliminates 9 horses. This leaves the horse that finished 1st & 1st who is in for sure and the following 5 horses to race again in heat 7: The two remaining horses from the winner's first heat, the heat 6 2nd place finisher and the horse that finished second to him in their first heat and the third place finisher in heat 6. Top two are combined with the 1st 1st horse for the answer. The Right Answer is SEVEN!! Think of the question "How many people defeated a Horse?" After the first round (which everyone agrees is a round of 5 races of 5 horses each) we get the following matrix ---------------------------- AFTER FIVE RACES ---------------------------- 0 0 0 0 0 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 Now when we play all the Winners of these races in one match (The First Row) interestingly these numbers change to the following. Note that if your team's Winner loses against one person (stands second) your entire team shifts one place down (The entire column's number increases by one). If your team member loses against 2 people then your entire team shifts down two places. (Increases by 2) ---------------------------- AFTER SIXTH RACE ---------------------------- 0 1 2 3 4 1 2 3 4 5 2 3 4 5 6 3 4 5 6 7 4 5 6 7 8 Now if a horse has been defeated more than 3 or more times that clearly indicates that there are at least 3 horses better than it and hence you that particular horse is eliminated That leaves us with the following. 0 1 2 1 2 2 You now need only one more race to decide who is the second and third. You already have found your Ace Horse ;) I could like to choose 8 races. race 1: A B C D E race 2: F G H I J race 3: K L M N O race 4: P Q R S T race 5: U V W X Y This is much same as others to drop the last 2 horses in each race. Drop: D E I J N O S T X Y Pick the fastest horses on race 1 to 5 race 6: A F K P U After race 6 I could drop 8 horses, Drop: H M P Q R U V W Remaining: A B C F G K L As A is the fastest from race 6, I could states H and M won't be the top 3 horses and A is the fastest. Combination of top 3 should be (AFK), (ABC), (AFG), (AKL), (ABF) and (ABK). Thus, my race 7 is to test if C is the third fastest of the horses above. race7: C F G K L If C is the fastest then I am done. If not, drop C. race8: B F G K L DONE ~~~~ Mehr Antworten anzeigen The answer is definitely 7. Read here for a very detailed and easy to understand explanation: http://www.programmerinterview.com/index.php/puzzles/25-horses-3-fastest-5-races-puzzle/ Hi. If all 3 fastest horses were in the same group for the initial race and the 2nd place horse from that group won race 7, the 3rd place horse could not be eliminated without racing. The answer is that 7 races are likely needed, but an 8th race might be needed. The chance of needing an 8th race is 3 and 1/3 percent. "daved18" You are the Winner!!!!!!! Using only the information given and nothing else you have correctly answered the question. That being said I really enjoyed reading all the other perspectives given. It really shows how many approaches there are to answering a question without being able to ask any. You need to make a determination of whether or not a horse's time is affected by the horses it races against. If not, the answer is of course 5. If so, then you can start looking at the other options listed above. 10 - The correct answer can only be 10. (Note: those who answered 12 are close, but they fail to conclude that, by racing the 3rd place horses together in separate heats, they can eliminate one unnecessary race.) By the way, the question asks for the fastest 3 horses – so we can assume nothing less than that the results must be exact. Some assumptions can be made: 1. The 3rd fastest horse in each race (other than those races of only 3rd place horses), could be the 3rd fastest overall , so it can never be fully eliminated. It is possible that it was forced to run all of its races against the fastest two horses. 2. The 3rd fastest horse in each race can never be the 1st or 2nd fastest horse, so you can eliminate all 3rd place horses by racing them together. Only the fastest of these 3rd place horses could ever be the third fastest overall - so in these races, only the fastest needs to be promoted. First heat (5 races – total = 5): Take the top 2 horses from each race and put them aside for the third heat (10 horses total). Second heat (1 race – total = 6): Race all 3rd place horses from the first heat. Only the fastest horse in this heat needs to be promoted. Third heat (2 races – total = 8) Race the 1st and 2nd place horses from the first heat. The top 3 horses from each race gets promoted (6 horses total). Fourth heat (1 race – total = 9) Race the two 3rd place horses from the third heat and the winner of the second heat (all 3rd place horses). The fastest of these horses could be the overall 3rd fastest, but it is the only one needs to get promoted. Fifth heat (1 race – total = 10) The two fastest horses from each race in the third heat, along with the winner of the fourth heat. Top three horses in this heat are the fastest three overall. Again, the answer is 10 – and it can only ever be 10. I made a mistake - the answer is 9. If you race the 2nd place horses from the first heat together (in the second heat), the winner of this race could ever be the 2nd or 3rd place overall if it raced against the 1st place horse in the first heat. But because only one of these 2nd place horses could have raved against the fastest horse overall, all others in this race could never be even 3rd place overall, since it would have lost its first heat to, at best, the 2nd place horse overall and then lost the second heat as well. I do apologize for not catching this in my first post. Again – the answer is 9. debarshi nailed it. 8 races. it also means that the general answer, where: n = number of horses r = maximum number in a race p = number of places needed is , in APL, p + ? n÷r 7 races is the correct answer I think 9 races will solve the problem... 1) 5 races to get locally top 5 horses 2) In race #6, I will race the 5 winners from 1st round. 3) In race #7, I'll race the 2nd place holders from round 1 with each other. 4) In race #8, I'll race the 3rd place holders from round 1 with each other. 5) Now, race the top 3 from race #6, with the best horse from race #7 and race #8 That's it ! The top 3 of this 9th race are your 3 fastest horses. Explanation: From first 6 races, you get the undisputed champion Assuming that you raced the actual 3 fastest horses together in one of the first 5 rounds, you give chance for the second fastest horse in race #7. Again, assuming the previous worst case scenario, you grant the third fastest horse race #8 And finally, you race the top 3 from race #6 with top 1 from race #7 and top 1 from race #8. If the ideal case turns out, where first 5 races gave you the actual fastest horses, they would naturally win the race #9 (since you kept the top 3 amongst them) So the answer is 0. No races are actually required to do as the question asks, which is to pick the 3 fastest horses. Had the question been asked to provide the minimum number of races to PROVE you have picked the 3 fastest horses then I believe the answer is what ever you overthinkers know the answer to be. Mehr Antworten anzeigen Travis took my answer. Good answer by the way Travis. It is designed to see your thought process. Do you have a tendency to over think or over analyze a problem? First we need some assumptions. Let's say the horses perform the same in different races, and we are looking for the minimum number of race to determine the fastest three. 1) If we got a timer, the answer is five, obviously. 2) I we did not have a timer and could only record the standing of horses, the number is 7. Firstly, 5 races will cover all 25 horses and give us the champion of each group. 6th race is between the 1st horses of 5 groups, and we name the groups A, B, C, D, E, according to the standing of this 6th race. The 2nd and 3rd horses of group A, and 1st and 2nd horses of group B, also with the 1st horse in group C will attend the 7th race. The top two of 7th race and 1st horse of group A give us the fastest 3. See http://math.stackexchange.com/a/746801/6876 The answer is: You need 7 races. 7 check career cup book for explanation 5 races. you just need a stopwatch!? Ans: 8 After 5 races you have 5 sorted lists. Now you have to merge them using a 5-way merge. First 5-way compare: race 6 Second 5-way compare: race 7 Third 5-way compare: race 8 5 races of 5 will yield 15 new candidates by picking the top three each time, 4 and 5 are eliminated 3 races of 5 will yield 9 new candidates by picking the top 3 each time, 4 and 5 are eliminated 2 more races, one of 5 and another with 4 will yield 6 new candidates by picking the top 3. 2 more races of 3 will yield 4 more candidate picking the top 2 one more race will yield the 3 top horses. 5 + 3 + 2 + 2 = 12 races will yield the absolute 3 best horses. Mehr Antworten anzeigen 25 horses 5 groups of 5 horses choose the first place horse from each group have have them race From this race we gain information ---The 1st place can win in the other group, but the same does not go for the other top two horses. ---2nd place can beat the horses in 3rd place's group and the other groups, but it's uncertain if 2nd place can beat horses in 1st place's group ---it is uncertain that 3rd place can beat horses in 1st and 2nd place's groups, but can beat horses in the other groups 2 place races the horse in 1st places groups. whichever horse wins is able to beat horse in all the other groups except the original winner of the top 5 horses 3 place races horses in 2 place's group, whichever horse wins is able to beat horses 3 place's group and 2nd places group. --That same horse faces 1st places group in 1st place's group, whichever horse wins is able to beat horses in 1,2,3 places group but not the original 1st place horse. 9 races in total and you have the top 3 horses. 5 Races It says fastest horses, NOT the ones that win the race. In 5 races, you will know ALL of the horses time around the track. 1: ABCDE : Keep fastest horse out of race, ex. A time x secs 2: FGHIJ : Keep fastest horse out of race, ex. F time x secs 3: KLMNO : Keep fastest horse out of race, ex. K time x secs 4: PQRST : Keep fastest horse out of race, ex. P time x secs 5: UVWXY : Keep fastest horse out of race, ex. U time x secs Out of the 5 fastest horses, one winner from each race, pick the top 3 fastest horses out of A F K P U: ex. A K U 5 Races Showing my work... 5 Races: 1) ABCDE : Keep top 3 fastest lap times from ABCDE ex. ABC 2) FGHIJ : Keep top 3 fastest lap times from ABC FGHIJ ex. ABF 3) KLMNO : Keep top 3 fastest lap times from ABF KLMNO ex. AFK 4) PQRST : Keep top 3 fastest lap times from AFK PQRST ex. APQ 5) UVWXY : Keep top 3 fastest lap times from APQ UVWXY ex. APU The top 3 fastest horses would be APU Einer oder mehrere Kommentare wurden entfernt. |
Suppose you had eight identical balls. One of them is slightly heavier and you are given a balance scale . What's the fewest number of times you have to use the scale to find the heavier ball? 60 Antworten3 times. (2^3 = 8) Two. Split into three groups of three, three, and two. weigh the two groups of three against each other. If equal, weigh the group of two to find the heavier. If one group of three is heavier pick two of the three and compare them to find the heaviest. Brian - this would be correct if you in fact were using a weighing scale, and not a balance scale. The ability to weigh one group against another with a balance scale allows Marty's answer to be a correct answer. Although - the question as worded provides a loophole. If it had been worded as "What's the fewest number of times you have to use the scale to CONSISTENTLY find the heavier ball", then Marty's answer would be the only correct answer. However, it is possible that you could get lucky and find the heavier ball in the first comparison. Therefore, the answer to the question as stated, is ONE. Mehr Antworten anzeigen This question is from the book "How to move Mt Fuji".... Marty has already got the right answer. Actually Bill, by your interpretation of the question the answer is zero, because you could just pick a ball at random. If you get lucky, then you've found the heaviest ball without using the scale at all, thus the least possible amount of times using the scale would be zero. The answer is 2, as @Marty mentioned. cuz its the worst case scenario which u have to consider, otherwise as @woctaog mentioned it can be zero, u just got lucky picking the first ball.... None- weigh them in your hands. Assuming that the balls cannot be discerned by physical touch, the answer is 3. You first divide the balls in two groups of 4, weigh, and discard the lighter pile. You do the same with the 4 remaining, dividing into two groups of 2, weighing, and discarding the lighter pile. Then you weigh the two remaining balls, and the heavier one is evident. 2 3a+3b+2 = 8 if wt(3a)==wt(3b) then compare the remaining 2 to find the heaviest if wt(3a) !== wt(3b) then ignore group of 2 discard lighter group of 3 divide the remaining group of 3 into 2+1 weigh those 2 If == the remaing 1 is the heaviest if !== the heaviest will be on the scale With the systematic approach, the answer is 3. But, if you randomly choose 2 balls and weigh them, and by coincidence one of these two is the heavier ball, then the fewest number of times you'd have to use the scale is 1. Although the real question is: are the balls truly identical if one is heavier than the rest? just once. Say you are lucky and pick the heavy ball. One use of the scale will reveal your lucky choice so once, or the creative answer zero if you allow for weighing by hand Without judging by hand: Put 4 balls on one side, and 4 on the other. Take the heavier group and divide again, put 2 balls on one side, and 2 on the other. Take the 2 that were heavier, and put one on each side. You've now found the heaviest ball. This is using the scale 3 times, and will always find the right ball. Mehr Antworten anzeigen None. They are identical. None is heavier. 2 weighings to find the slightly heavier ball. Step 1. compare 2 groups of three balls. Case 1. if they are both equal in weight, compare the last 2 balls - one will be heavier. case 2. If either group of 3 balls is heavier, take 2 balls from the heavier side. compare 1 ball against the 2nd from the heavy group result 1. if one ball is heavier than the other, you have found the slightly heavier ball. result 2. if both balls are equal weight, the 3rd ball is the slightly heavier ball. Easy Shmeezi Fewest - get lucky and pick the heaviest one. But wait! How would you know it is the heaviest one by just weighing one ball? Your logic is flawed. Two groups of four. Split heavier one, weigh. Split heavier one, weigh. 3 times. i think its 3. i would take it like this OOOO OOOO then OO OO then OO problem solved. i do this everyday. bye. praise be to allah. thats it. It's 2. Period. If you can't figure it out look it up online or in "How Would You Move Mount Fuji" (like somebody else said). This is one of the most basic brainteasers you could be asked in an interview. The answer is 2. 1) Divide the balls into 3 groups. 2 piles with 3 balls each, 1 pile with 2 balls. 2) Weigh the 2 piles of 3 balls. If both piles are the same weight, discard all 6 and weigh the last 2 to find the heavier one. 3) If 1 pile of 3 is heavier than the other, discard the lighter pile and the pile of 2 balls. Weigh 2 of the remaining 3 balls from the heavier pile. If both of the weighed balls are equal, the last ball is the heavier one. 2=if all the balls are identical and you pick up the first...weigh it and the second one is lighter or heavier then you've found the heavier ball in the least amount of attempts. 1=if all the balls are identical and you pick up the first...balance it and the second one is lighter or heavier then you've found the heavier ball in the least amount of attempts. Amy is 100% correct for the following reason: everyone (except Amy) is solving the theoretical problem. The practical side of the problem - notwithstanding jimwilliams57's brilliant observation that if one weighs more than the others IT IS NOT IDENTICAL (would have loved to see the interviewer's face on that one) - in order to 'weigh' them on a scale, one has to pick them up, therefore, you will immediately detect the heavier one without weighing: pick-up three and three ... no difference, no need to weight. Pick-up the remaining two to determine the heavier one. Steve First off, take yourself through the process visually and forget square roots, that doesnt apply here and here is why: The question is the Minimum, not the MAXIMUM. BTW, the max would be 7 ( 8-1); you are comparing 2 objects, so 1 ball is eliminated automatically in the first step. Anyway, you have a fulcrom of which you are placing 2 of 8 objects on each end. If by chance you pick the slightly heavier object as one of the two balls, you have in fact, found the slightly heavier one in the first round... btw dont be a smartass with your interviewer, he is looking for smarts not smarmy;) Mehr Antworten anzeigen Respectfully, the folks who are answering "3" are mathematically modeling the nature of the balance incorrectly. Performing a measurement on a balance scale is not binary. It is trinary. Each measurement gives you one of three responses: The left is heavier, the right is heavier, or they are equal. So while you do need three binary bits to specify a number from one to eight, you need only two TRINARY-DIGITS Formally, you want the smallest value of n such that 3^n >= 8. The answer is 2. Note that you could add a ninth ball, and still, you'd only need to make two measurements. Of course, the smarty pants answer would be one. Just pick two balls at random and be lucky to have chosen the heavy one. But you're not guaranteed to be able to do it in just one measurement. English isn't my mother tongue... What is a balance scale? If looking up on Google, I find some devices with two bowls on a bar bearing in the center. Hence, the answer is once (if I'm luck enough to select the heavier ball in teh first measurement) If a balance scale allows to measure only one ball at a time, then it would take two measurements, unless you'd have more information on the weight, which is not listed here, hence doesn't exist in the context of the question^. minimum is 1 (if lucky - 25% chance by picking 2 balls at random) & max is 2 (using most efficientl process to absolutely determine without luck - 3/3/2 scenario) While Symantec was busy weighing my balls I took a job with NetApp.... They need to focus on hiring good, capable security engineers, not weighing their balls. The point of these interview questions is to both check your logical brain function and to hear how you think. Most of you are just posting jerk off answers trying to be funny, or you are really dumb. These answer get you nowhere with me in an interview. Think out loud, go down the wrong path back track try another logic path, find the answer. None of this "0 if you use your hands". That is fine if you are interviewing for a job in advertising where creativity is desired, nobody wants you writing code like an 8 year old. You have 12 balls, equally big, equally heavy - except for one, which is a little heavier. How would you identify the heavier ball if you could use a pair of balance scales only twice? The problem is based on Binary Search. Split the balls into groups of 4 each. Choose the heavier group. Continue till you get the heavier ball. This can be done in log(8) (base 2) operations, that is, 3. Since there is only one scale available to weigh. You first divide the balls in half. Weigh each group, take the heaviest group. This is using the scale twice so far. Now, divide the previous heaviest group into half, weigh both groups. Take the heaviest. Divide this last group and take the heaviest. This is the heaviest ball. We have used the scale 5 times. Mehr Antworten anzeigen Would it be wrong to say for a sample size as small as 8, we might as well not waste time thinking about an optimal solution and just use the scale 7 times, as this will be more efficient than coming up with an ideal solution prior to using the scale? I stumbled across this while looking for something else on Google but I had to answer. It is 2, split balls into 2,3 and 3. weigh the 2 groups of 3 against each other. If equal weigh the group of 2 and the heaviest is obvious. If they are not equal keep heavy group of 3 and weigh 2 of the balls. if equal heaviest ball is one you didn't weigh. If not equal the heavy ball is obvious. 2 times. 8 balls. 1st step: [3] [3] [2] 2nd step: [[1] [1] [1]] [[1] [1] [1]] [[1] [1]] No idea The fewest number of times to use the scale to find the heavier would be Eight to One times ? It will actually be 1 because the question asks what's the fewest amount of times which is one because you could just get lucky you can use any method you want it would still be one because that is the fewest amount of turns you can have It's one. The fewest number of tries on using a balance scale would be one. If you put one ball on each side and one is heavier, you have the found the heavier ball. Use an equilateral triangular lamina which is of uniform mass throughout. It is balanced on a pole or a similar structure. Steps: Place 2 balls at each corner (total 6 balls) i. if the odd ball is one of those, one side will either go up or go down. Now repeat the process with one ball at each corner including the 2 unbalanced ones. ii. if balance is perfect, repeat the process with the remaining two balls and one of the already weighed balls. test answer 2016-01-12 00:34:07 +0000 Mehr Antworten anzeigen You would not be able to find a ball heavier than the others. All eight balls are identical; therefore, they must all be the same weight. Correct answer has already been posted. I just want to contribute some theoretical analysis. Given N balls, one of them is heavier. Finding out the ball requires log3(N) trit of information. (trit is the 3-base version of bit). Each weighing may give you one of the three outcomes: equal, left-heavier, right-heavier. So the amount of information given by each weighing is upper-bounded at 1 trit. Therefore, theoretical lower-bound for number of weighings in the worst case is log3(N), which is actually attainable. So 27 such balls need only 3 weighings and 243 balls need only 5 weighings, etc. 2 as many have indicated above. The 3 is the kneejerk reaction but 2 is the correct answer. Marty's answer is correct, but he does not explain why. The logic of the balance scale is three-valued: . Its most efficient use is the recursive application of the three-valued logic until there is only one item left. The integral ceiling of ln(x)/ln(3) thus gives the fewest number of times you have to use the balance scale to find the uniquely heaviest ball of x balls. Ceiling(ln(8)/ln(3)) = 2. TvRef Reviewing the answers from over the years has been fun! Some time I would like to be the interviewer to ask these kinds of questions. In first looking at the question, I thought, "probably eliminate as many as possible with the 4 and 4" but then why would it he a thought experiment, less one in an interview, if it was so 2 dimensional? Whether or not getting to the best answer is much of the point, being reductionist by ignoring details, like the context of who is asking, lead me to go my own way as of the question was just text on a screen. There's a lot of 3 dimensional information you could get from someone by this question -- how nervous they are, if they don't then you see how they handle that, or how much they think of their answers to anything. I wonder, were the semantic holes in the question also intentional? In the comments people have written about technicalities -- things about how it wasn't specified that they were only visually identical, and therefore the question is contradictory. Or, how it didn't explicitly specify how to consistently, by most likely repeated efficient scenario, find the heavier ball, so people started that the least possible would be 1 if lucky. Then, since it wasn't explicit that you have to know which one was heavier, people said you could go 0 and guess the right one without the scale, either by direct guessing or trusting your hands with an unspecified sized difference in weight. If the word choice is designed to allow for those, perhaps the question is even more fun than I thought. One could see where and if one goes or gets hung up, see if one would ask clarification if they got hung up, or claim steadfastly about their thoughts being the most important on it, or focus elsewhere -- then that would be another layer to the question that makes it more interesting than I originally thought. I like tea. Mehr Antworten anzeigen Einer oder mehrere Kommentare wurden entfernt. |
GIven 9 balls all of which weigh the same except for one, what is the minimum of weighings necessary to find the ball weighs more (or less). 29 AntwortenWhile the solution above is correct, more or less, you first should clarify the question and spell out any assumptions. The assumption here is that you know or are aware beforehand that only one ball is of different weight. Sometimes your ability to clarify and state assumptions is more valuable than getting the right answer. Sometimes you can arrive at the right answer with the wrong logic which helps you solve this problem, but may mess you up in the future. You could do this with two weighings assuming its a two pan balance - (1) place three balls on each side - if they balance out then its the remaining three that has abnormal ball (2) out of that group, place one ball on each side - if balances it out, the abnormal ball is the remaining one. If the weighing in step (1) does not balance out, grab the group of three balls that is light or heavy and repeat step (2) described above. Mehr Antworten anzeigen I began with the assumption you could do this with a minimum of three, but I now believe it's four. Perhaps I'm over thinking it though, so I'll explain my "solution". Step 1. Start with three balls on either side of the scale, with a third set waiting on the sidelines. If the scale is balanced, you can move onto the three waiting. 2. place one ball on either side, again with the last one waiting. Should the scales be balanced, it's the last one. 3. If they aren't, take the heavier side off, and place the waiting ball on, if they balance. It's the one you just removed. If they're off canter again, it's whichever side was inconsistent. The hitch with the fourth measurement comes due to the little trip up in the question "To find the ball that weighs more (or less)." If you don't know from the start if you're looking for a heavier or lighter ball, should the scales be off on the first measurement, you'll need to replace three of the balls with the reserves to determine which ones are the odd batch out. The comment about the assumptions is absolutely spot on. For example, I like the answer that says ONE step (weighing) but this assumes a balance scale is used not a device that weighs each ball. Based upon a weighing device that weighs each ball and remembering the question is the MINIMUM number of weighings then the answer is THREE - here is the logic. Each weighing weighs one ball. The minimum number of weighings to identify a difference is two, i.e the first two balls are different in weight. The third weighing will confirm which of the previous two is part of the set of eight balls with the other being the odd one out. Simple....8 of the balls are hollow.....1 is not. Maybe I'm slow but....if I put set A and set B on the scale while reserving set C, and if set A is heavier than set B, how do I know if set C is equal to set A or B without weighing it? Notice the question says "more (or less)". In other words, why wouldn't I have to weigh set C? (This is assuming each set is of 3 balls.) Suncoastgal has a point, and most of the answers above are simplifying this problem a bit. You are not told if the odd ball is heaver or lighter, which complicates things. The most efficient method is that described by 'questions like this...' as method 2. Split balls into 3 groups and weigh two. The worst outcome is if the groups do not weigh the same, so assume that happens. All you know now is that the odd ball is NOT in the reserved group of 3, so set those aside. You don't know which of the two weighed groups contains the odd ball, so now you have 6. Repeat the first step with groups of 2 balls. Again the worst outcome is that the scales don't balance, so you've eliminated 2 more balls and only know that the odd ball is one of 4. As near as I can tell, you still need 2 more steps now to guarantee finding the odd ball: Choose any two balls from the 4 and compare. If they are the same, the odd ball is in the reserved 2, if they differ the odd ball is one of the two you weighed. Now take one of the two balls that might be odd, and weigh against one of the balls you have been setting aside as 'normal'. By the way, although you now know which ball is odd, you may still not know if it's heavier or lighter. If the last weighing balances, you only know that the other ball is odd, and you would have to weigh it against one of the 'normal' balls to see how it is off. You can do this problem in only 2 weighings if you are told whether the odd ball is heavy or light before you begin. Suncoastgal has a point, and most of the answers above are simplifying this problem a bit. You are not told if the odd ball is heaver or lighter, which complicates things. The most efficient method is that described by 'questions like this...' as method 2. Split balls into 3 groups and weigh two. The worst outcome is if the groups do not weigh the same, so assume that happens. All you know now is that the odd ball is NOT in the reserved group of 3, so set those aside. You don't know which of the two weighed groups contains the odd ball, so now you have 6. Repeat the first step with groups of 2 balls. Again the worst outcome is that the scales don't balance, so you've eliminated 2 more balls and only know that the odd ball is one of 4. As near as I can tell, you still need 2 more steps now to guarantee finding the odd ball: Choose any two balls from the 4 and compare. If they are the same, the odd ball is in the reserved 2, if they differ the odd ball is one of the two you weighed. Now take one of the two balls that might be odd, and weigh against one of the balls you have been setting aside as 'normal'. By the way, although you now know which ball is odd, you may still not know if it's heavier or lighter. If the last weighing balances, you only know that the other ball is odd, and you would have to weigh it against one of the 'normal' balls to see how it is off. You can do this problem in only 2 weighings if you are told whether the odd ball is heavy or light before you begin. If the question to identify the odd ball (heavy or light) out of 9 balls is read literally, then the answer is 1 weighing (under the most luckiest of circumstances): weigh 2 sets of 4 balls against each other using a double-pan balance and if you're lucky it will weigh evenly, allowing identification of the not-weighed 9th ball as the odd ball. (The question doesn't say you need to identify whether it was heavy or light.) If the question is what is the least number of weighings it takes to identify the odd ball under the least lucky circumstances then the answer is 4, as best I can come up with. 1. Weigh 2 sets of 3 balls against each other, setting aside the 3rd set of 3 balls. The least lucky result ("LLR") is an imbalance. However, this does identify the 3rd unweighed set as all standard balls. 2. Here's where creative problem solving/out-of-box thinking comes into play. Take a red and black marker and mark one of the heavy balls red and one of the light balls black. Switch the marked balls. LLR --> still an imbalance, though imbalance must remain in the same direction since there is only 1 odd ball (yet to be identified). 3. Repeat step 2 (mark one of the unmarked heavy balls red and one of the unmarked light balls black, switch them and reweigh). LLR --> still an imbalance. 4. Take one of the 3 unweighed balls, previously set aside from the 1st weighing, and substitute it for the last remaining unmarked heavy ball. If this last weighing results in an imbalance then the odd ball is the last remaining light ball (and is light, obviously). If the weighing results in a balance, then the removed unmarked heavy ball was the (heavy) odd ball. These type of interview questions are so lame. They don't sniff out the lazy people, the coders who write crap no one can decipher, and can't or won't write maintainable code. Yes you want people who can problem solve and break down problems into manageable chunks, but how often do software projects fail? Answer = 70-90% and that's mostly due to poor management, not giving clients what they want, feature creep, poor quality, etc. So how is answering this question going to tell me that this new hire has integrity and can throw out his ego and write code for a real life product that people want to use? No wonder so much software is trash. (And yes I've been programming for 25 years and see the same errors happening over and over, it's pathetic and completely fixable.) I read the question as "determine if the odd ball weighs more or less", not "determine which ball is the odd one out". After re-reading the question, it seems like the word "IF" (i.e. "...to find [IF] the ball weighs more (or less)") or the word "THAT" (i.e. "...to find the ball [THAT] weighs more (or less)") is ommitted (purposefully?). I went about answering the my first interpretation and came up with 2 weighings as the MINIMUM required. I assumed we have a scale that can accurately measure the weight in grams (or whatever unit of measurement needed to accurately measure the ball). Step 1. Weigh 8 balls. Divide the total weight by eight. Step 2. Weigh the remaining ball. If you compare the result from each step you'll know if the ball is heavier or lighter than the others. Only 1 step required. Throw all of the balls in a sufficiently deep enough pool of water. The ball that sinks the fastest/slowest is the ball that doesn't weigh the same. If all of the balls float, then it is the ball that is lowest/highest in the water that doesn't weigh the same. Mehr Antworten anzeigen The answer should 1 as it asked "the minimum". When you weight 4 balls on each side of the scale and find it equally weight then the 9th ball is definitely the odd ball. You can always got lucky on the first attempt! I understand the Question to be what the minimum of weightings needed is to find out if the different ball weighs more or less than the other 8. The answer is three. 1. You way 1 ball and get its weight 2. Weigh a second and get its weight 3. If they do not weigh the same way a third to see if the different ball is the heavier or lighter one. Or If they weigh the same weigh all the balls and divide by 9 if it is less than one of the balls you weighed the different ball is lighter. If it is more than one of the balls you weighed the different ball is heavier. I agree with Anonymous in that these questions don't tell much about character. However, I can't beleive nobody here is analytical enough to come up with the correct answer. First off, the question is not stated correctly. The scale should be a simple balance, and the objective is to find the "odd" ball AND determine if it is heavy or light. The answer is three. First separate into three groups of three, G1, G2, and G3. In the first two weighings you can determine which group has the "odd" ball AND if the odd ball is heavy or light. Weighing 1 - weigh G1 against G2: Two outcomes 1) G1 == G2 --> Odd ball is in G3, in Weighnig 2, use either G1 or G2 against G3 to determine if Oddball is H or L 2) G1 != G2 -> Odd ball is NOT in G3 but you now know if G1 is heavier or lighter than G2, in Weghing 2, use either G1 or G2 against G3, for instance use G2 and G3, if same, then G1 has oddball and you know if its H or L, if G2 != G3, then G2 has odd ball and you know if it is H or L Now that you know which G it is in And the disposition of the Oddball (Heavy or Light), weigh any two of the Group containing the oddball, and based on your knowledge of wether the oddball is H or L, you know which one it is and its disposition. Any offers?? The question is perfect to define how the person takes directions - how many assumptions the person does before start the job - how many questions the person asks (if asks) to make clarifications before start the job. Also, I see there another result - all answers come finally to two groups of getting result : 1) to get faster the first result but more steps for guaranteed result - from 1 to 4 steps or 1 to 4 weightings for combination 4+4+1 2) to get faster guaranteed result - from 2 to 3 steps for starting combination 3+3+3, I would say that BMF scheme contains one additional step (comparison of weight lighter/heavier - definition what of them is consider to be "odd" ), which in solution structure should be equal to the additional step, so it comes to from 2 to 4 steps but still in 2 to 3 weightings. After all, I would say that you may get from this question: How the person understand the task How many assumptions the person does before start the job How many questions the person asks before start the job How many solutions and ideas the persons generates. How the person make a choice to present one solution from multiple (say fastest first result vs fastest guaranteed result). Etc. The candidate should clarify if they truly mean the minimum to find the odd-weighted once, or everytime. I agree that it only takes one weighing (and some luck) to find it. Actually, the person could randomly guess (not weigh any) and get the right ball. So you need to understand the balance of risk vs. cost. By the way, simple logic problems do trip up people that you don't want working for you (depending on the job). So I like the question. It is interesting to speculate if the question wording is being cute or tricky by saying "more (or less)". Is it just being general and saying find the odd ball, or is it being tricky and saying find the odd ball AND tell me if it is lighter or heavier. I think it is being over thought here and just means find the odd. In that case the answers saying 2 weighings is the best you can guarantee. None of this lucky crap. BMF had it if you had to determine if it was in fact heavier or lighter instead of being told. So if the question had the added clause that if you really tried it and didn't get it in the number of tries you answered (or fewer), then you would be killed, would you still say "just one if you get lucky"? Keep it simple. If it's 3-state balance you need log2(9) / log2(3) attempts since you can encode 9 states using 2 3-bit states. I don't understand why everyone is confused. The question clearly asks to not only find the odd ball out but to also determine if the odd ball is lighter or heavier. The only assumption is that it is a standard two pan balance. My solution is 4 weighings: 1. Divide 9 balls in three groups of 3. Let's name them A,B,C 2. Weigh any two groups of 3. Let's say A and C. (1st weigh) 3. If A and C are equal then the B group is the culprit. 4. Now lets label the B group as B1, B2, and B3 5. Take either two balls from either A or C and measure against two from B let's say B2 and B3. (2nd weighing). If both are equal then B1 is the odd ball. Now weigh B1+ one good ball against the same two good balls used in the previous weighing and compare to see if the ball is heavier or lighter. (3 weighings) If they are not equal then determine if the B group is currently heavier or lighter. Go to step 6. 6. Switch either B2 or B3 with B1. Let's say we replaced B2 with B1. If the weighing is now equal then B2 is the odd ball out. If the weighing is still unequal then B3 must be the ball. Thus we have used a total of only 3 weighings. Since we made note of the weighing in step 5 we know if the odd ball is heavier or lighter. 7. Now if the 1st weighing (between group A and C) was unequal then we need to determine which is the bad group. Thus we need to weigh one of them against group B (which we know is correct) and then proceed with the steps 2-6. So in this case it is one extra weighing which brings a worst case total of 4 weighings. I hope everything made sense. I don't think its possible to get it in 3 AND also find whether the odd ball is lighter or heavier. One thing is for sure: I would have never solved it during the interview since this took way more than 5 min to figure out. I believe the answer is 2. Step 1: Before weighing anything, you separate the balls into groups of three. Step 2: Put one group of three on one side of the scale, and the other group of three on the other side of the scale, leaving still one other group of three somewhere on the side. ---visualization ooo /\ ooo <--------1st weighing ooo <------side group Step 3: If the scale is balanced that means that the heavier ball is in the side group. At this point, you would weigh any two of the remaining three balls. Again, if the scale is balanced, then you know that the only ball left is the heaviest one. If the scale tips to any particular side, on the other hand, then you know that the heavier ball is on that side. Up to this point the number of weighings is 2. Step 4: if on your first weighing with three balls on each side, the scale tips, then your next weighing will be of any two of the three balls which were on the tipping side of the scale. Again.. if the scale is balanced, then the remaining ball must be the heaviest. And if the scale tips to a side, then you know that side has the heaviest ball. Up to this point the number of weighings is also 2. Therefore the minimum number of weighings is 2. You obviously can get away with 1 weighing, but only if you are lucky; weighing 4 against 4 and hoping that the other ball (not weighed) is the heavier one. Otherwise, starting out weighing 4 against 4 will lead to 3 weighings, therefore that solution is not the optimal one. Even starting out with a 2 against 2 scheme, you can have up to 3 weighings until you are absolutely sure of which ball is the heaviest. So, optimally, you will be weighing 3 balls against 3, and the least amount of times you would have to weigh the balls to know for sure which one is heaviest is 2. In lieu of the fact that we don't know whether the ball is heavier or lighter then the rest, you would have to do 3 weighings. 1: ooo/\ooo ooo Do the first weighing as pictured above to isolate the set of balls that you know for a fact weigh the same. Then, in the second weighing, use that set to isolate the set that contains the odd ball. The second weighing should also tell you whether the odd ball is heavier or lighter because of how the scale reacts when you replace the control set with the unknown set. If the scale stays tipped down to the side opposite the control set, then it's heavier. If it stays tipped up, then it's lighter. If the scale was balanced before the second weighing, then you know that the remaining set is the set that has the odd ball, and replacing it with a set that you know all weigh the same should still tell you whether the ball is heavier or lighter by watching how the scale behaves. Then you can proceed to the 3rd weighing to isolate the heavier/lighter ball. So my mistake everyone -- the correct answer is 3 weighings when you don't know if the ball is heavier or lighter. Mehr Antworten anzeigen I had this interview question this morning. Those of you who say it has no bearing on determining character are wrong. An arrogant person will present their answer, right or wrong, and say that they are done and it is perfect. It takes humility to consider that your first answer may be wrong, and the interviewer will want to see your process for checking that your answer is correct. Remember, it is the path you take to get to the answer that is more important than getting the answer right. Given 3 step, divide the balls into 3 groups A, B, C, Not knowing which has the heavier or the lighter ball, #1 Step: scale A vs B, If it balanced then we already know that C has the different weight.(but we still dont know if the ball is heavier or lighter. If it did not balance we will know that the OTHER ball is maybe in group A or B. (Note: e.g. A raises and B dropped) #2 Step: scale A vs C, If it balanced then we will know that the OTHER ball is in group B. If it did not balance e.g A raises and C dropped. we now conclude that C and B has the same weight and the OTHER ball is lighter #3 Step: Using the group A ball. scale the 2 balls, if they balance they we will know that the 3rd ball is the one that is different. if it did not balanced then the side where the ball raises is the OTHER ball because from step 2 we already notice that the ball is Lighter. Problem solved! Divide the 9 balls into groups of 3 3 - 3 -3 take first 2 groups on the scale. If they balance out: Take the last group of 3 Divide the last group into 1 - 2 Take the 2 (above) one each of the scale. If they balance out, then the '1' is the heavier one else u get the heavier one. Number of scale measurements required = 2 Balance 4 vs 4, - if balance the excess 1 is the lightest or the heaviest. Don't mind which is the heaviest nor the lightest since the question is OR - you can just have one answer. the minimum would be two. First ball and second ball either one would weight more... since they are asking the "minimum'... if they asked for the maximum then it will take 8 times. Einer oder mehrere Kommentare wurden entfernt. |
An array of 99 elements contains integers from 1 to 100 with one missing element. Find the missing element. 127 Antworten100 1. calculate the sum of elements in array say SUM 2. sum of numbers 1 to 100 is(n* (n+1))/2 = 5050 when n==100 3. missing element is (5050-SUM) 100 Mehr Antworten anzeigen The parameters of the question do not allow you to determine what element is missing. Either more information should be supplied, or all answers are equally correct. How could an array size of 99 elements contain 1 - 100? Should either be integers 1-99 or 2-100 , in either case there is no missing element. All indices are accounted for. Sum them and then subtract them from 5050. In general, if an array of size n - 1 elements has unique elements from 1 to n, then the missing element can be found by subtracting the sum of the elements in the array from sum(1 ... n) = n * (n + 1) / 2. Alternately, one could use a boolean array of length n with all values set to false and then for each value, set array[val - 1] to true. To find the missing value, scan through the array and find the index which is set to false. Return index + 1. This requires O(n) memory and two passes over an O(n) array (instead of constant memory and one pass), but has the advantage of actually allowing you to verify whether or not the input was well formed. Admittedly, this question is poorly posed; however, the answer they are looking for refers to the syntax/nomenclature of some (not all) programming languages to index arrays starting at “0.” As such the 1-100 stored values would be in entries 0-99 of the array. Read the question. Here are the steps to solve it: 1) find the sum of integers 1 to 100 2) subtract the sum of the 99 members of your set 3) the result is your missing element! Very satisfying! Sort array. While loop with an index variable with condition of next element being 1 greater than previous element. When loop breaks, return the value of the index. Doing the expected sum and subtracting the actual gives the run time of O(2n), however a bucket sort will almost always do it in less time (somewhere between O(n) and O(2n)): 1. create a 101-int (or boolean) array (to have a 100-index) 2. traverse original and for each int, assign value in bucket array to 1 or true. 3.After first traversal, traverse created array starting at one, and when value is false, print it. 100 100 coz in array it initial value starts frm 0 to 100. or else 4 further clarification u can study array chapter in c or c++ 100 Mehr Antworten anzeigen The question: "An array of 99 elements contains integers from 1 to 100 with one missing element. Find the missing element." The information states that the integer count is 1 to 100. I take this to be inclusive of all elements in the array so that the missing inters would be subjective to their arrangement or random. In other words, I do not have enough information to say which one. 1 I need more information. 1. Are the integers unique in this array? 2. Do I have enough information to find the sum of the integers in the array (or some aggregation)? If sum is available, then, the answer is 5050-sum{integers}. Bucket Sort works and summation works. I think both are good, practical and clever solutions. I think sorting the array then searching may be unnecessary computation. Another interesting method which may be faster. SIMD computers may do this particularly quickly: Do a bitwise operation on all the elements: Result = Array[0] xor Array[1] xor ... Array[98] xor 1 xor 2 xor ... xor 100 Result = Missing number. Explanation: When you xor 2 identical numbers your result = 0. For example, 5 xor 5 -> 101 xor 101 = 000. (5 in decimal is 101 in binary). Knowing that "xoring" 2 identical numbers results in zero is useful. Now we apply this useful info to the problem. Array is Identical to a list of 1,2,3,...,100 except for one number. In other words 1,2,3,...,100 duplicates all of array's elements and adds one extra element that is missing in Array. Therefore, we now have 2 instances of each element in the Array in addition to one extra element in 1,2,3,...,100. We can see when you xor two duplicate numbers you get zero. Because we have pairs for all numbers in Array and one extra number we are essentially "xoring" the missing number with zero. When we xor the missing number with zero we get the missing number. (For example, 6 xor 0 -> 110 xor 000 = 110) The question states that one (not two or three or n) element ("value") from 1 to 100 is missing. There are 99 elements ("values") in the array. The question implies that the data is well-formed because it states that only element is missing. It doesn't ask you to find the missing value(s), but the one (singular) missing element. With the problem constrained, the solution falls out. Subtracting from 5050 is an elegant solution, but not obvious as to why it works. The array of booleans is more obvious, but doesn't scale well. I agree with one of the answers in this thread...5050-sum(elements) = missing item. Other approach that crossed my mind is something similar to binary search. Check the index of 50th element: if A(50) == 50, the missing element > 50, else if A(50) > 50, missing element <50. Do this iteratively. The number of comparisons would be log 100 = 7. Add 1-100 to a hash of 100 elements. Then compare each element with the hash.. Answer in o(n) Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Mehr Antworten anzeigen Einer oder mehrere Kommentare wurden entfernt. |
1. Phone interview - Sort the characters in string by frequency and then by their alphabetical order. Example - bbaaccc -> cccaabb 2. The question that screwed me - given array is [0,1,1,0,1,1,1] ; output should be [0,1,1,0,1,2,3] ie., for every non-zero element in array, find its distance to the nearest zero in O(n) time. i would definitely encourage the candidates who read this post to share their solution for this question. 3. In order traversal of Binary search tree related (the solution is to start from right sub tree). 16 AntwortenSolution to the second problem (sequence processing, with O(N) time and O(N) space complexity): std::vector getZeroDistance(const std::vector &v) { if (v.size() result; uint64_t cnt = 0; bool flag = false; for (auto &i : v) { if (i == 0 && !flag) { flag = true; if (cnt) { while(cnt) result.push_back(cnt--); } result.push_back(0); continue; } if (i != 0) ++cnt; if (i == 0) { if (cnt == 1) { result.push_back(1); } else { uint64_t mid = cnt / 2; for (uint64_t t = 0; t 0; --mid) result.push_back(mid); } result.push_back(0); cnt = 0; } } // If no zeros in input string found, return input string; if (!flag) return v; if (cnt > 0) { if (cnt == 1) result.push_back(1); else { for (uint64_t t = 1; t v = { 0,1,1,0,1,1,1 }; // expected: [0,1,1,0,1,2,3] std::vector v = { 1,1,1,1,1,1,1 }; auto res = getZeroDistance(v); return 0; } std::vector getZeroDistance(const std::vector &v) { if (v.size() result; uint64_t cnt = 0; bool flag = false; for (auto &i : v) { if (i == 0 && !flag) { flag = true; if (cnt) { while(cnt) result.push_back(cnt--); } result.push_back(0); continue; } if (i != 0) ++cnt; if (i == 0) { if (cnt == 1) { result.push_back(1); } else { uint64_t mid = cnt / 2; for (uint64_t t = 0; t 0; --mid) result.push_back(mid); } result.push_back(0); cnt = 0; } } // If no zeros in input string found, return input string; if (!flag) return v; if (cnt > 0) { if (cnt == 1) result.push_back(1); else { for (uint64_t t = 1; t <= cnt; ++t) result.push_back(t); } } return result; } First solution has been posted with wrong format. In the second one, 2 lines should be corrected: instead of this if (v.size() result; should be: if (v.size() result; Mehr Antworten anzeigen First solution has been posted with wrong format. In the second one, 2 lines should be corrected: instead of this: if (v.size() result; should be: if (v. size() result; std::vector result; #include #include #include using namespace std; int main() { vector v = {0, 1, 1, 0, 1, 1, 1, 0}; vector dist(8, 0); vector zeros_pos; for(int i = 0; i < v.size(); i++) { if(!v[i]) { zeros_pos.push_back(i); } } int fz = zeros_pos[0]; int sz = zeros_pos[1]; int j = 2; for(int i = 0; i < 8; i++) { dist[i] = min(abs(i - fz), abs(i - sz)); if(i == sz) { fz = sz; if(j < zeros_pos.size()) { sz = zeros_pos[j]; j++; } } } for(auto& iter : dist) cout << iter << " " ; return 0; } std::vector dist(std::vector& value) { std::vector pin; std::vector output(value.size()); bool found = false; int last_zero = -1; for (size_t i = 0; i < value.size(); ++i) { if (value[i] == 0) { int rewind = (last_zero == -1)?i:((i - last_zero) / 2); for (int j = 1; j <= rewind ; ++j) { output[i-j] = j; } last_zero = i; } else { output[i] = (last_zero == -1)?-1:(i-last_zero); } } return output; } Missed the explanation. This is O(n) time complexity with O(1) space complexity. Basically this algorithm iterates through the input vector and records the incremental integers when 0 has been found. When you find 0, trace back to change the distance. If there's no 0 in the input vector, you will see -1 in the distance. This is sort of thing you need to discuss with the interviewer what to do when distance is unknown. std::vector dist(std::vector& value) { std::vector output(value.size()); int last_zero = -1; for (size_t i = 0; i < value.size(); ++i) { if (value[i] == 0) { int rewind = (last_zero == -1)?i:((i - last_zero) / 2); for (int j = 1; j <= rewind ; ++j) { output[i-j] = j; } last_zero = i; } else { output[i] = (last_zero == -1)?-1:(i-last_zero); } } return output; } {{{ vector getMinDistFromZeros(vector A) { int n = A.size(); vector zero_idx(A.size(), INT_MAX); bool atleast_one_zero = false; for (int i = 0; i < n; i++) { if (!A[i]) { zero_idx_map.push_back(i); atleast_one_zero = true; } } if (!atleast_one_zero) { return zero_idx; } for (int i = 0; i < zero_idx.size(); i++) { for (int j = 0; j < n; j++) { if (A[j] != 0) { A[i] = min ( abs ( j - zero_idx[i] ) ); } } return A; } }}} Space Complexity is O(m) where m is num zeros. Run Time: O(n * m) # vector distance calculator: def calc_dist_nearest_zero(vct): curr_zero = -1 curr = 0 dist = [float('inf')]*len(vct) while curr = 0: dist[curr] = abs(curr - curr_zero) curr -= 1 curr = curr_zero + 1 else: if curr_zero != -1: dist[curr] = abs(curr - curr_zero) curr += 1 return dist All of the slutions above are using O(n) space. I believe the correct solution would have 2 indices ( int i1 and int i2 example ) running from each end of the input array and using -1 ( think how ) and as soon as both cross each other ( in the middle , assuming both move one step towatds each other ) then the algorithms gets in action. They start correcting each other. Ofc you will need O(4) or something like that as space complecxity to hold the left and right zero indces and the most recent distance from each of them. O(1) space complexity if we do in-place. Time complexity is O(n) void inplace_dist(std::vector& value) { int last_zero = -1; for (size_t i = 0; i < value.size(); ++i) { if (value[i] == 0) { int rewind = (last_zero == -1)?i:((i - last_zero) / 2); for (int j = 1; j <= rewind ; ++j) { value[i-j] = j; } last_zero = i; } else { value[i] = (last_zero == -1)?-1:(i-last_zero); } } return value; } Here is a O(N) java solution. I use 3 pointers. One for the left zero, one for the right zero, and a main pointer: int leftZero = 0; int rightZero = leftZero; int[] newElements = new int[elements.length]; while(rightZero < elements.length){ if(elements[rightZero] == 0) break; rightZero++; } leftZero = rightZero; for(int i = 0; i < elements.length; i++){ if(rightZero == i){ leftZero = i; newElements[i] = 0; while(true){ if(rightZero == elements.length - 1){ rightZero = Integer.MAX_VALUE; break; } rightZero++; if(elements[rightZero] == 0) break; } } else { newElements[i] = Math.min(Math.abs(i - leftZero), Math.abs(i - rightZero)); } } return newElements; Mehr Antworten anzeigen -> traverse left to right and make a temp1 array -> traverse right to left and make a temp2 array -> pick lower number at every index from temp1 and temp2 array to make result array def findAndSetNearestDist(arr): n = len(arr) lastZeroIndex = -1 for index, a in enumerate(arr): if a == 0: if lastZeroIndex == -1: lastZeroIndex = index continue else: twoZeroDistance = index - lastZeroIndex for i in range(int((twoZeroDistance/2) + 1), index): arr[i] = abs(index -i) lastZeroIndex = index continue if a > 0 and lastZeroIndex != -1: dist = index - lastZeroIndex arr[index] = dist return arr def findAndSetNearestDist(arr): # sliding window approach # from left to right zeroIndex = -1 for index, value in enumerate(arr): if value == 0: zeroIndex = index continue if zeroIndex > -1: arr[index] = index - zeroIndex # from right to left zeroIndex = -1 for index in range(len(arr)-1,-1,-1): value = arr[index] if value == 0: zeroIndex = index continue if zeroIndex > -1: arr[index] = min(abs(index - zeroIndex), arr[index]) return arr |
Coding test: 1. Given a string, find out if there's repeat characters in it. 2. SQL. Given a Customer table and a Payment table (with Customer ID as primary and foreign key), write a query to output a list of customers who have not paid their bills in the last 3 months. 17 AntwortenDid well on the first Java coding test. Solution using Hashset. Not so well on the SQL query. Able to give a query, but a few errors in it I am sure. Also there was a second questions regarding the SQL query, which we didn't have time to get to. So that was another bad thing. I am pretty sure I did not pass. But good learning experience. import java.io.*; public class CountChar { public static void main(String[] args) throws IOException { String ch; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter the Statement:"); ch=br.readLine(); int count=0,len=0; do { try { char name[]=ch.toCharArray(); len=name.length; count=0; for(int j=0;j=65&&name[0]=97&&name[0]<=123))) count++; } if(count!=0) System.out.println(name[0]+" "+count+" Times"); ch=ch.replace(""+name[0],""); } catch(Exception ex){} } while(len!=1); } } package epam; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class RepeatedCharactersInString { public static void main(String[] args) { ArrayList arrli = new ArrayList(); Scanner sc = new Scanner(System.in); String s = sc.next(); String s1=""; for (int i = 0; i < s.length(); i++) { arrli.add(s.charAt(i)); } for (int i = 0; i < arrli.size(); i++) { for (int j = i + 1; j < arrli.size(); j++) { if (arrli.get(i) == arrli.get(j)) { arrli.remove(j); j--; } } } for (int i = 0; i < arrli.size(); i++) { // System.out.println(arrli.get(i)); s1=s1+arrli.get(i); } System.out.println(s1); sc.close(); } } Mehr Antworten anzeigen SQL> select customername from customers inner join Payment on customers.customer id=Payment.customerid where payment.due>=3 package epam; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class RepeatedCharactersInString { public static void main(String[] args) { ArrayList arrli = new ArrayList(); ArrayList arrli2 = new ArrayList(); Scanner sc = new Scanner(System.in); String s = sc.next(); String s1=""; for (int i = 0; i < s.length(); i++) { arrli.add(s.charAt(i)); } for(int i=0;i package epam; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class RepeatedCharactersInString { public static void main(String[] args) { ArrayList arrli = new ArrayList(); ArrayList arrli2 = new ArrayList(); Scanner sc = new Scanner(System.in); String s = sc.next(); String s1=""; for (int i = 0; i < s.length(); i++) { arrli.add(s.charAt(i)); } for(int i=0;i public class Test { public static void main(String args[]) { String test = "abcddeff"; ArrayList listStr = new ArrayList(); for (int i =0; i< test.length(); i++) { if (listStr.contains(test.charAt(i))) { System.out.println("Repeated Character Found:"+test.charAt(i)); } else { listStr.add(test.charAt(i)); } } } } ----To find out repeated characters in a given string import java.util.*; public class test { public static void main(String[] args) { String str = "abdc"; char[] arr = str.toCharArray(); HashSet set = new HashSet(); for (char i : arr ) { set.add(i); } if((set.size()) == (arr.length)) System.out.println("unique character"); else System.out.println("repetition"); } } Solution 1: String str="asaaatttmmppo"; HashMap map = new HashMap(); for(char c : str.toCharArray()) { if(map.containsKey(String.valueOf(c))) { map.put(String.valueOf(c), map.get(String.valueOf(c))+1); }else { map.put(String.valueOf(c),1); } } map.forEach((x,y)-> { if(y>1) { System.out.println(x); } }); Solution 2: String str="asdfghjkloiuyt"; HashSet c = new HashSet(); for(char ch:str.toCharArray()) { c.add(ch); } System.out.println(c.size() != str.length()); import java.util.*; public class FindDuplicates{ public static void main(String []args){ String test = "abccdefga"; char[] arr = test.toCharArray(); List list = new ArrayList(); for(int i=0; i SQL: select a.customer_name from Customer a left join Payments p on p.cid =a.cid where DATEDIFF(day,p.lastPaymentDate,getdate())>90; String res=""; for(int i=0;i No Mehr Antworten anzeigen No Coding test: 1. Given a string, find out if there's repeat characters in it. public static void findRepeatedCharacters(String input) { String normalized = (input.toLowerCase()).trim(); char[] inputCharArray = normalized.toCharArray(); int index = 1; String searchStr = ""; String repatedChars = ""; for (char c : inputCharArray) { searchStr = normalized.substring(index); if (searchStr.contains(Character.toString(c))) { if (!repatedChars.contains(Character.toString(c))) { repatedChars = repatedChars + Character.toString(c); } } index = index + 1; } if (repatedChars.length() > 0) { System.out.println("Repeated characters in the input string '" + normalized + "' are : " + repatedChars); } else { System.out.println("There are no repated characters in the input string '" + normalized); } } Given a Customer table and a Payment table (with Customer ID as primary and foreign key), write a query to output a list of customers who have not paid their bills in the last 3 months. Solution : Select * from customer where customer.customerid NOT IN (SELECT payment.customerid FROM payment where paymentdate >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH)); Einer oder mehrere Kommentare wurden entfernt. |
You have all of the prices for a given stock for the next year. You can buy once and sell once in that year. How do you determine when to buy and sell to maximize your profit? 14 AntwortenAssuming the prices are sorted on their dates 1. start from the last entry (i.e price on the last date) make it as selling price. 2. From last but one entry to first entry { if price > sell price sell price = that price else { diff = sell price - price; if diff > max then max = diff; } } gaurav your answer is not correct if you can only sell after buying. assume you have this prices 1 99 100 10 50 In this case, the optimal answer would be buy at 1 and sell at 50, but your algorithm cannot find that answer. This problem can be solved transforming the input and executing the so called maximum-subarray-algorithm Wont the optimal answer be buy at 1 and sell at 100? The profit in this case is 99, where as in ur case its 50(buy @ 1 and sell @ 50, the profit is 49). So I will choose to buy at 1 and sell at 100. Any way, 1. set sell price at last entry = 50(lets call sell price as sp), set profit = lowest possible value 2. then set i = last but one entry = 3 (ie index of 10) 3. array[i] profit so profit = diff = 40 i-- 4. i = 2 array[i] > sp, so sp = 100 i-- 5. i = 1 arrayi] diff, we dont change the profit value i --; 6. i = 0; array[i] profit(40) so set profit = diff END OF LOOP ans = profit = 99. Hope this helps u Mehr Antworten anzeigen current min , current max = first price keep track current min , current max, iterate when you find something smaller than current min record if diff is the best diff set current min current max to this price and iterate. Outside the box: just find the minimum/maximum. If the minimum is before the maximum, buy it and sell it as usual. If the minimum is after the maximum, short it and buy it back later. void printBuySell(int[] l) { int maxDiff = 0, maxStart = 0, maxEnd = 0; int start = 0, end = 0; for (int i = 1; i maxDiff) { maxStart = start; maxEnd = end; maxDiff = diff; } start = i; end = i; }else { if (l[i] > l[end]) end = i; } } System.out.println(l[maxStart] + " " + l[maxEnd]); } def buy_low_sell_high(prices): return max((prices[j]-prices[i], i, j) for i in range(len(prices)) for j in range(i+1, len(prices))) # go python! I agree with Jordan's answer... Find the (max,min) from the price list. If "min" occurs earlier than "max" => buy at instant "min" occurs and sell at "max" If "max" occurs earlier than "min" => sell at instant "max" and buy back at "min" The question is equivalent to the following problem: Find a sequence with max sum in an array of negative and positive real numbers s.t the numbers in this case are the delta between two consecutive prices. Its the maximum subsequence problem where the new array is the deltas of the stock prices every day. To add to what Jacob said above: 1. List out the stock prices at discrete intervals 2. Compute the cumulative sums 3. Start two pointers: an "explorer", and a "stabilizer" at node 0. 4. Find the largest "up tick" using the foll. algorithm: a) Move the explorer ahead of the stabilizer. Compute the delta; if the delta is larger than the stored delta, update your 'maximum delta'. b) move stabilizer to the right only if that takes it to a lower value. c) move explorer to the right till it reaches a higher value. d) when either b) or c) are true, compute a new delta and compare to your saved away maximum When stabilizer reaches the right most node, you're done. you can only sell and buy once. so find two price point that return a max profit. buy low and sell high. public int maxGain(int[] a) { int tmp = a[0], max = 0; for (int i = 0; i < a.length; i++) { tmp = Math.min(tmp, a[i]); max = Math.max(max, a[i] - tmp); } return max; } suppose we have array int Price[365] and it contains price on particular day....now lets create another array min [365] which has number /index so far which had minimum value. this will take O(n). now parse array second time and find max profit you can make on that day by price[i] -price[min[i]]. keep track of max you have found so far. Mehr Antworten anzeigen var abc = [1 ,99, 100, 10 ,50]; abc.sort( (a,b) => (a-b)) ; var maxProfit = abc[abc.length-1]-abc[0]; console.log(maxProfit); |
One independent survey showed that 70% on people asked like coffee. Another independent survey showed that 80% of people like tea. What is the upper and lower bound of peoples who likes both coffee and tea 14 AntwortenUpper: 70% Lower: 50% 20, 80 50, 70 Mehr Antworten anzeigen It is 70% Both High & Low. Any higher and people don't like Coffee, any lower and they don't like coffee. This is assuming 0% margin of error and a perfect survey. Take 100 people. 1-100. Assume, 1st 70 likes coffee (1-70) and 1st 80 likes tea(1-80). So, atmost 70 can like both tea and coffee. Now, take the same 100 people. Assumed, 1st 70 likes coffee and last 80 likes tea(21-100). So, that make atleast 50 people likes both coffee and tea. So, upper is 70 and lower is 50. Only 70% of people like coffee, so that would be the upper bound since they need to like both coffee and tea. 80% of people like tea, which leaves 20% that don't like tea. Once again, they need to like both coffee and tea, so you subtract the 20% that don't like tea from the upper bound which leaves 50% for the lower bound. This assumes the survey was 100% accurate and had 0% margin of error, which means they would have had to interview the same 100 people in both surveys and the results are only valid for the 100 people surveyed. Only 70% of people like coffee, so that would be the upper bound since they need to like both coffee and tea. 80% of people like tea, which leaves 20% that don't like tea. Once again, they need to like both coffee and tea, so you subtract the 20% that don't like tea from the upper bound which leaves 50% for the lower bound. This assumes the survey was 100% accurate and had 0% margin of error, which means they would have had to interview the same 100 people in both surveys and the results are only valid for the 100 people surveyed. The fact that these are two independent surveys suggests that they were not conducted on the same group of people. Therefore, if we were to extrapolate this survey data for people in general, you can only conclude that the upper limit is 70% but the lower limit can be zero since 100% of the set of people who like coffee may not like tea. Seventy percent of people like coffee so the upper bound is limited by that seventy. 80 percent of the people who like tea multiplied by 70 percent who may like coffee is 56 percent, so 56 lower 70 upper. This problem reminds me of a convolution operation. Convolve 1111111000 with 1111111100 and you sortof get your answer. Assuming the two independent surveys have been done on the same sample of people, following a consistent set of rules: n(AUB) = n(A)+ n(B) - n(A intersection B) Assuming a population of 10 people: 10 = 7 + 8 - x or, x= 5 or, 50% = lower limit And of course the max will the min(coffee lovers, tea lovers) = min(7,8)= 7 ~ 70% Rock has it right. The trick is that it is; two independent studies, not we asked the same group. 70% is the easy part but of those 70% that like coffee 80% like tea so that means at least 56% like both Given that they were the same set of people. Or assuming that the sample size was large and a representative of entire population, the lower bound is 50% and the upper bound is 70%. Here's how: Let the population be represented by 10 dashes: Worse Case: - - - - - - - - - - (total) - - - - - - - (70% coffee) - - - - - - - - (80 % tea) If you take the common of above two, you get 5 dashes. Meaning 50% atleast like both coffee and tea Best case: - - - - - - - - - - (total) - - - - - - - (70% coffee) - - - - - - - - (80 % tea) Which gives you 70% Mehr Antworten anzeigen Key is "two independent surveys". Also note that it is not mentioned anywhere that both surveys had options of coffee and tea or they were the only options. So, lets say there are 200 people of which 70 like coffee and 80 like tea. We don't anything about remaining 50. They could like liquor for all we know. Maximum liking both tea and coffee: 150 out of 200 i.e. in survey one who said they like coffee also like tea and similarly in survey two who said they like tea also like coffee. Hence, 3/4 or 75% is the upper limit. Lower bound: 0%. None of them liking coffee like tea and vice-versa. Remaining ones like coconut water :) |
I got a few C++ questions, then a question on sorting algorithms then a brainteaser. The brainteaser went as follows: Three people are given hats. Each hat is either red or blue, chosen at random. Each person can see the other 2 hats, but not their own. They each must simultaneously either guess their own hat's color, or pass. No communication is allowed, although they can agree on a strategy ahead of time. What strategy will give them the best chances of at least one person guessing right, and nobody guessing wrong? 13 AntwortenIf the 2 hats you see are the same, guess the opposite color, otherwise pass. If all 3 players use this rule, it works 75% of the time. It fails only when all the hats are the same color. You might want to start by listing all the possibilities. One person can assume there is an odd number of blue hats, another person can assume there is an even. By counting the number of blue hats amount the other two people each person arrives at a unique prediction for the color of there own hat. Sine the number of blue hats must be either even or odd, one of the guesses must be right. Yes, but the other one will be wrong. The question says that all the people who talk must give the correct color. The others can pass. However, if one answers wrong, they loose, so your strategy wouldn't work S. Mehr Antworten anzeigen Here's a strategy: each member passes to the left if they see the same color (assume they are standing in a triangle) and to the right if they see different colors. If the first person sees two blue hats, and the second sees a red and a blue, the first will know their hat is red. If all hats are the same color, after one pass to the left, the second person will know their hat is the same as the third person. At most this will require two passes. I'm confused by the answers. We know the following: State: 1. There are three people 2. Each person is given one - and only one - hat 3. The colour will be either red or blue - completely random 4. No communication is allowed. 5. Each person can see the other two hats - but not their own. Behaviour: Each must simultaneously either guess their color or pass. Proposed Strategy: I see no rule against each individual passing his/her hat in a uniform direction - either left or right. This way, no communication has taken place and you now know the colour of your hat. It can obviously be considered as a form of communication after the start of the game. Just assume that every person can do one and only one action and that is pass or say a color. Also, that single action has to be done at the same time as the action or the two others, that is, there is only one pass. The strategy can be simple: Each person can see the color of the other two hats, so the strategy before the game could be, in the second vote the person should mention the color of the third persons hat. Assuming he tells the truth. So the first person can just tell any color, now only two people are left, the 2nd person will the tell the color of third persons hat, and the third person would repeat it. This will ensure every time that at least one answer is correct. Your answers are all horrible. Yeah, they really all are. The answer I posted is the correct one. It's actually on the internet if you google that problem, and it's really well explained. I mean the question is stated in an understandable manner. I really don't get all the ridiculous answers that are posted. two colors and allow the number of players to be of the form 2k − 1, where k 2, then we can devise a strategy for winning that—perhaps surprisingly—results in increasing probability of a win as the parameter k get large. Even better, this probability of winning approaches unity as k ! 1 ! In fact, we’ll show how to devise a strategy whose probability of a win is Prob(win) = 1 − 2 ^ (2k−k−1)/ 2 ^ (2k−1) . Note that if k = 2 (three players), this sets the probability of winning at 1 − 2 8 = 3 4 . The reason for this somewhat forced constraint on the number of people is that it allows a strategy based on the so-called Hamming codes, which we now briefly describe. We let F be the binary field, i.e., the field with two elements (0 and 1). All vector spaces shall be over the field F. Let k be a fixed positive integer ( 2) and let W be a fixed vector space of dimension k over F. Therefore we see that W contains exactly 2k − 1 nonzero vectors; we label these vectors w1,w2, . . . ,w2k−1. Now set n = 2k − 1 and let V = Fn: 1 2 V = {(a1, a2, . . . , an) | all ai 2 F}. The tautological map is the surjective linear transformation : V ! W defined by (a1, a2, . . . , an) = Xn i=1 aiwi 2 W. Since this is surjective, the kernel H (null space) has dimension dimH = dim V − dimW = n−k = 2k−1−k. We call H the (2k − 1, 2k − k − 1)-Hamming code; note that if k = 3, then H has dimension 4; when k = 4, then H has dimension 11. The only result that we need concerning the Hamming codes is the following. We define the “unit vectors” e1, e2, . . . , en 2 V by setting ei = (0, 0, . . . , 0, 1, 0, . . . , 0), where there is a “1” in the i-th position and 0s elsewhere. For convenience, set e0 = 0 2 V . Lemma. Let H be the (2k − 1, 2k − k − 1)- Hamming code. Then V = [n i=0 (ei + H) (disjoint union), where we set e0 = 0. Proof. Note first that if i 6= j, 1 i, j n, then (ei + H) \ (ej + H) = ;. For otherwise, it would happen that ei+ej 2 H; since (ei+ej) = wi + wj 6= 0 (set w0 = 0 2 W), this assertion follows. Therefore, S (ei + H) has cardinality (n + 1) · |H| = 2k(22k−k−1) = 22k−1 = |V |, and the result follows. Now assume that k 2 is fixed and that we have n = 2k − 1 members on the team. Label these people 1, 2, . . . , n. In preparation for the “hat trial,” we shall agree on the following strategy. First of all, let us represent the colors “black” and “white” by the elements 0 and 1 of F, respectively. Therefore, the random placing of hats on the team members’ heads is tantamount to the specification of a random vector v = (a1, a2, . . . , an) 2 V where person i has been given a hat with color ai. Note that it may or may not be the case that v 2 H (in fact it usually won’t be—this is an easy calculation). Therefore, if the distribution vector describing the placement of hats is given by the vector v = (a1, a2, . . . , an) 2 V, then person i can only infer that the distribution vector is of the form v = (a1, a2, . . . , ai−1, 0, ai+1, . . . , an) + biei = vi + biei, for some bi 2 F, and where the vector vi is defined above by what person i sees. In terms of the above notation, here’s the strategy: (a) If vi + biei 62 H for either choice of bi 2 F, then player i shall pass; (b) If vi + biei 2 H, then player i shall guess that his hat color is 1 + bi. We proceed to prove that the above is a welldefined strategy and is, in fact, a winning strategy for all hat distributions v such that v 62 H. First of all, the well-definedness issue stems from (b), above; namely we must show that we cannot have vi +biei 2 H for both choices of bi 2 F. Indeed, were this to happen then we would have ei = vi + vi + ei 2 H. Since (ei) = wi 6= 0 we have a contradiction. Therefore the strategy is well-defined. Next we show that if v 62 H, then the above strategy result in a win, i.e., at least one person will guess his hat color correctly and no one will guess incorrectly. Thus, assuming that v 62 H, we have, by the above lemma that v+ej 2 H for some unique index j, 1 j n. Therefore, we see immediately that person j will necessarily correctly guess his hat color. We contend that everyone else must pass. To see this, fix i 6= j 3 and write v = vi + aiei. For person i to do anything but pass, it must happen that vi+biei 2 H for some bi 2 F. Were this the case, then since v = vi+aiei, and since vi+aiei+ej = v+ej 2 H, we infer that (ai+bi)ei+ej = (vi+biei)+(vi+aiei+ej) 2 H. Since ((ai + bi)ei + ej) = (ai + bi)wi + wj 6= 0 this contradiction proves the result. We could be content to stop here as we’ve already shown that the above strategy results in a win with probability at least 1 − |H| |V | = 1 − 2−k. However, this is the exact probability as it’s clear that when v 2 H, then everyone guesses wrong. What about just telling the colour of hat of next person in cycle. Like A will tell of b , b of c and c of a. It guarantees atleast one will be correct Come on, the most important rule is they must response together! You miss that lol |