tag:blogger.com,1999:blog-26909122.post114608988488290691..comments2013-07-16T09:10:31.961-07:00Comments on Puzzles, puzzles and puzzles: Bulb droppingUnknownnoreply@blogger.comBlogger25125tag:blogger.com,1999:blog-26909122.post-1146922502070069592006-05-06T06:35:00.000-07:002006-05-06T06:35:00.000-07:00Ok, this has been open for a week now and thought ...Ok, this has been open for a week now and thought I would resolve it by posting the solution:<BR/><BR/>Many people got to the stage of telling that you need 2 bulbs to perform this test and you need to test about 63/64 floors. Well at the first crack to the problem yes, you need 2 bulbs and you need to test 63 floors in the worst case. How did we get that?<BR/><BR/>Take the square root of 1000 ~ 32<BR/>So start from 32nd floor and proceed upwards every 32 floors beyond that until you find an upper limit on the breaking floor. So that way you would need to test 32 floors until you reach the 1000th floor in the worst case. Now you know the limits are 968 and 1000. Start from 969 and proceed till 999. That is about 31 more floors. So a total of 63 floors.<BR/><BR/>So a generic answer for a 's' story building will be is to take the square root of s and that will give you the starting floor. So # of drops = sqrt(s) + sqrt(s) - 1 = 2*sqrt(s) - 1. Now this is the case when you will ever need only 2 bulbs to perform this test. Lets say you can use b bulbs tp perform the test. Then take the bth root of s to get the starting floor and then proceed further upwards.<BR/><BR/>Now, comes the jolt: Is 63 really needed? I thought so until I bumped across another reasoning that proved me wrong and this showed another methodology that can be used to get lesser # of floors to be tried out.<BR/><BR/>The idea in this methodology is to use a differential scheme to determine the next floor to try so as to minimize the # of floors to try as we go upwards. For simplicity lets take 100 floors. According to our previous logic we would get 2 * 10 - 1 = 19 floors need to be tested for the worst case scenario. Now in the new methodology start writing the floor numbers from 100 and keep subtracting series of 0, 1, 2, 3, ...to get lower floor numbers and stop when you can subtract anymore. This is how it will be:<BR/><BR/>100 - 0 = 100<BR/>100 - 1 = 99<BR/>99 - 2 = 97<BR/>97 - 3 = 94<BR/>94 - 4 = 90<BR/>90 - 5 = 85<BR/>85 - 6 = 79<BR/>79 - 7 = 72<BR/>72 - 8 = 64<BR/>64 - 9 = 55<BR/>55 - 10 = 45<BR/>45 - 11 = 34<BR/>34 - 12 = 22<BR/>22 - 13 = 9 -> Stop because 9 - 14 = -5, not correct!<BR/><BR/>So now we got the floor numbers to try. Observe it carefully, as we proceed upwards, the # of in between floors to test reduces.<BR/><BR/>So this way, the # of floors that need to be tested are in the worst case (if it is floor 8, floor 21, ...) is 14 and not 19.<BR/><BR/>Apply similar strategy for the 1000 floor case. Now, one might ask, how to generate this for sequence for higher numbered stories: Simple - write a simple computer program, that will spit out this sequence for you. I have one here in C/C++.<BR/><BR/>void printFloorsToTest(int s)<BR/>{<BR/>int step = 0;<BR/>printf("Floors to test:\n");<BR/>while (s - step > 0)<BR/>{<BR/>printf("%d\n", s-step);<BR/>s = s - step;<BR/>step++;<BR/>}<BR/>}<BR/><BR/>So, this will apply to any generic 's' story case. In any case you will only need 2 bulbs even out of the 'b' bulbs. To use all the b bulbs, then you would need to reconfigure the solution to suit the b bulb scheme and yet maintaining the optimal # of floors that need to be tested.<BR/><BR/>This puzzle is now SOLVED!Karthik Nagarajhttps://www.blogger.com/profile/02641166958828638787noreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146664627083564742006-05-03T06:57:00.000-07:002006-05-03T06:57:00.000-07:00Mohit,I agree that the binary distribution way of ...Mohit,<BR/>I agree that the binary distribution way of choosing the floors is fine BUT how many bulbs do you need? Lets say that the bulb breaks at 500th floor, then another one will break at the 250th floor, then anither one will break at the 375th floor, another one will break at the 438th floor, another one at the 469th, another one at the 485th floor, another one at the 492nd floor, another one at the 496th floor, another one at the 498th floor,<BR/>another one at the 499th floor. So That gives it a total of 10 bulbs.<BR/><BR/>Using this way you tend to use a lot of bulbs to lower the margin of checking the floors. So, I'm afraid the answer is not correct. Vikram has already told the same answer and I had already commented that it is not correct.<BR/><BR/>Again, somebody here has already said that the # of bulbs that need to be used is 2. So we know that the optimal solution is possible with 2. We also know that the starting point is 63 drops (Tejasvi already solved it to be 64 and I commented that it is 63, not 64, I showed how also). The only thing now is, can we do better than 63? Do we have to test 63 floors?Karthik Nagarajhttps://www.blogger.com/profile/02641166958828638787noreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146664590995809902006-05-03T06:56:00.000-07:002006-05-03T06:56:00.000-07:00Anonymous,Sorry I didn't quite understand your log...Anonymous,<BR/>Sorry I didn't quite understand your logic. In all respects, ignore the made assumptions as no information on how the bulb breaks and where the glass peices go by is not available to us. All we know if the bulb breaks or not when we drop it from a floor. We can only go up or down the floor and not to the ground and inspect the actual broken bulb.Karthik Nagarajhttps://www.blogger.com/profile/02641166958828638787noreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146653980217700032006-05-03T03:59:00.000-07:002006-05-03T03:59:00.000-07:00I Think only one bulb is enough,using the assumpti...I Think only one bulb is enough,<BR/>using the assumption that when a bulb breaks atleast the bulb peices will fall for one meter.<BR/>using this asumption.<BR/>one bulb drop it from the 100th floor and come checking down for the glass pieces, where u get the first would be the answer.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146638572017035232006-05-02T23:42:00.000-07:002006-05-02T23:42:00.000-07:00Drop from 500th floor.If it doesn’t break go to fl...Drop from 500th floor.<BR/><BR/>If it doesn’t break go to floor 750. i.e. (1000+500)/2<BR/><BR/>If it breaks, go to floor 250. i.e (500+0)/2<BR/><BR/>Continue this process of narrowing down.<BR/><BR/>This seems to be an optimal strategy. What are your views?<BR/><BR/>- MohitAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146613357777063992006-05-02T16:42:00.000-07:002006-05-02T16:42:00.000-07:00Tejasvi,Again I'm inclined to say yes, but there i...Tejasvi,<BR/><BR/>Again I'm inclined to say yes, but there is still a better way. Ok, lets look at it this way - Why did you divide 1000 by 25 to 40 floor blocks? How do you know that something else might now result in a better way. Say if you start at the 32nd floor. Then in the worst case you will drop the bulbs on 32nd, 64th, 96th, ... until the 1000th floor, which gives you about 32 attempts. Now if the bulb breaks on the 1000th floor you have to test the last set - which will give you about 31 attempts. So a total of 63 drops. Not 64! <BR/><BR/>So what is the methodology to decide which floor to begin at? Its not just some random number. How did we get 32 to begin with? Think about it and you would have cracked a portion of the problem. BUT now if I were to tell you that even 63 is not optimal, then what is the optimal number of throws you need to try? One thing is for sure - it is definitely lesser than 63.<BR/><BR/>Think about itKarthik Nagarajhttps://www.blogger.com/profile/02641166958828638787noreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146566353216598802006-05-02T03:39:00.000-07:002006-05-02T03:39:00.000-07:00so it takes 64 iterations. divide 1000 floors by 2...so it takes 64 iterations. divide 1000 floors by 25 u get 40 units each of 25 floors.now u go to the 25th floor and drop a bulb if it breaks u go to the 1st floor and if it doesnt go to 2nd floor and so on till it breaks.If it doesnt break at 25th floor u go to the 50th floor and drop if it breaks u come back to 26th floor and start throwing the bulb and so on till 1000 floors.TEJESVI.Rnoreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146551336243588572006-05-01T23:28:00.000-07:002006-05-01T23:28:00.000-07:00Tejasvi,Nice to have you on board to solve the puz...Tejasvi,<BR/><BR/>Nice to have you on board to solve the puzzle. Welcome! Your answer is logically correct. For all you know you could divide it into how many units you want and proceed in your methodology, BUT it is not optimal. Can we do better than testing 109 floors in the worst case? I'm sure you can. But whatever you have written is a good starting point. Start to minimze the floors needed and arrive at a pattern!Karthik Nagarajhttps://www.blogger.com/profile/02641166958828638787noreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146549877884468062006-05-01T23:04:00.000-07:002006-05-01T23:04:00.000-07:00hai karthik this is tejesvi from bit 6th sem m.c.a...hai karthik this is tejesvi from bit 6th sem m.c.a<BR/><BR/>U need a total of 109 iterations in worst case to solve this problem or to decide from which floor the bulb breaks.<BR/>first divide the 1000 floor into a unit of 100 floors each so that u have 10 units each with 100 floors<BR/>each.go to the 100th floor drop the 1st bulb if it breaks then start from the 1st floor,if doesnt then go to 2nd and repeat till the bulb breaks.TEJESVI.Rnoreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146332858630006232006-04-29T10:47:00.000-07:002006-04-29T10:47:00.000-07:00Vikram,I understand your lines of thinking, BUT I ...Vikram,<BR/>I understand your lines of thinking, BUT I doubt if a similar solution to the king's problem can be applied here. The reason being that if a floor 'm' is the breakage floor, then all floors below it also will result in the breaking of the bulb. So in that case you can never achieve an optimal strategy to minimize the # of bulbs needed and the # of floors that need to be tested. You could arrive at a solution, although it will not be optimal.<BR/><BR/>Let me give you all a clue in getting to it. Vishwanath got the # of bulbs needed correct. Yes, we need 2 bulbs. Now how will you use the 2 bulbs to determine how many floors need to be tested. All you need is an upper limit in finding which floor the bulb broke and a lower limit at which the bulb did not break with the first bulb. Now use the other bulb to determine between these bounds the correct break floor. Here is what I mean - If you find that the bulb did not break at x and you found that it broke at floor y (y > x) then minimize y-x to get an optimal solution. Hope this can put you onto the right track.Karthik Nagarajhttps://www.blogger.com/profile/02641166958828638787noreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146300222469901932006-04-29T01:43:00.000-07:002006-04-29T01:43:00.000-07:00this problem is a little like the bad king's wine...this problem is a little like the bad king's wine problem. there has to be a trade off between number of bulbs broken and the number of floors tested. <BR/>1 bulb - 1000 drops<BR/>2 bulbs - 110 drops<BR/>3 bulbs - 30 drops<BR/>4 bulbs - 26 drops<BR/>5 bulbs - 22 drops<BR/>...<BR/>8 bulbs - 12 drops<BR/>9 bulbs - 11 drops<BR/>10 bulbs - 10 drops<BR/><BR/>"For a 's' story building and 'b' # of bulbs, find the optimal strategy that will minimize (worst case scenario) the number of drops required to determine the floor on which the bulb will break."<BR/><BR/>for a given number of bulbs 'b' we can find the least number of floors 'c' that need to be tested. <BR/><BR/>we can fix the optimal strategy to be to minimize the product b*c or a more complex function with b and c. :)Vikramnoreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146250082935154052006-04-28T11:48:00.000-07:002006-04-28T11:48:00.000-07:00Victoria,This site is open for ALL. Add all you wa...Victoria,<BR/><BR/>This site is open for ALL. Add all you want, comment all you want for all open puzzles. It will be fun if you spread the word around and we have more people interacting and pouring in their viewpoints. Try adding the RSS feeds to your feeder and you will get updates everyday! The RSS feed is available on the top right corner of the home page of the puzzle. <BR/><BR/>Add a link to your own blog: http://puzzleguru.blogspot.com<BR/><BR/>Thanks for visiting and dropping by.Karthik Nagarajhttps://www.blogger.com/profile/02641166958828638787noreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146249084349815482006-04-28T11:31:00.000-07:002006-04-28T11:31:00.000-07:00Hello. This site looks like fun. If it's OK, I'm...Hello. This site looks like fun. If it's OK, I'm going to add this site to my favorites and keep coming back here. I don't know if you are a private club or not, but I just wanted to say hello and I'll come back and read your puzzles. I want to learn something!Donnie Davishttps://www.blogger.com/profile/10799321179017899508noreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146243770316034032006-04-28T10:02:00.000-07:002006-04-28T10:02:00.000-07:00Vikram,But then the # of bulbs are not optimized. ...Vikram,<BR/>But then the # of bulbs are not optimized. Then idea is to use minimal set of bulbs and test minimum # of floors. Take another crack at it.Karthik Nagarajhttps://www.blogger.com/profile/02641166958828638787noreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146234265573156072006-04-28T07:24:00.000-07:002006-04-28T07:24:00.000-07:00or u can use 3 bulbs and test a maximum of 30 time...or u can use 3 bulbs and test a maximum of 30 times instead of 110Vikramnoreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146232481362482382006-04-28T06:54:00.000-07:002006-04-28T06:54:00.000-07:00Vishwanath,Welcome! So you need only 2 bulbs, wow ...Vishwanath,<BR/>Welcome! So you need only 2 bulbs, wow - thats correct. But the # of floors to be tested is not right. It is not 100. I didn't quite understand your solution. When you say go to the first 10th floor and drop the bulb, and it breaks, then you say go to the blow floor and keep trying until it breaks. Right? Shouldn;t you try to go upwards once you break the bulb. If you go downwards again then with bulbs, if some 'mth' floor the second bulb breaks, then you will never get to know if from the (m-1)th floor also, the bulb would have broken. Correct me if I'm wrong.<BR/><BR/>So simplify what you have said - simply divide the 1000 into 100 floors section and keep trying each of the set of the 100. Try every 100th floor starting from the 100th floor itself until you reach some 100th floor section where the first bulb breaks and then start from the previous 100th section + 1th floor until you really find the floor that the second bulb breaks. Then in that case your worst case # of drops will be 10 (100th, 200th, 300th, ...) and then from 901st floor until 999th floor, we need 99 drops with the second bulb -> total of 109 drops. How did you get 100 drops? Can you please explain? Good thinking, the lines of thinking is correct, keep them flowing in...Let me know if what you are thinking is what I have tried to explain. I may have wrongly understood.Karthik Nagarajhttps://www.blogger.com/profile/02641166958828638787noreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146227328303260042006-04-28T05:28:00.000-07:002006-04-28T05:28:00.000-07:00I think we need 2 bulbs and in max of 100 iteratio...I think we need 2 bulbs and in max of 100 iteration. devide the number of floors into 100*10 sections and and again devide each esction by 10*10 sections.first go fore 10th flower dropp the bulb ,if the bulb is broken go for next below folwer ,continue the procedure till the bottom of 10th flower.if bulb is not broken in top 10th flower then go for the next 20th flower continue the above mentioned procedure you will get the exact solution tothe problem.<BR/><BR/><BR/> vishwanath (mca 6th sem bit)vishwanath_1312@yahoo.co.innoreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146163637376922422006-04-27T11:47:00.000-07:002006-04-27T11:47:00.000-07:00Can you please explain how you arrived at the figu...Can you please explain how you arrived at the figures. Well, there are a couple of solutions to this problem but obviously only one is optimal. Let me put it this way - 63 looks about right for one method of solution. But for that 32 bulbs is not required. Look again. Explain how you got the 63 and you will see for yourself why 32 bulbs is not required.Karthik Nagarajhttps://www.blogger.com/profile/02641166958828638787noreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146162724823834522006-04-27T11:32:00.000-07:002006-04-27T11:32:00.000-07:00I think you need 32 bulbs and 63 trys. I'm using t...I think you need 32 bulbs and 63 trys. I'm using the convergence series. Am I on the right track?ajitnoreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146147240922729232006-04-27T07:14:00.000-07:002006-04-27T07:14:00.000-07:00Vikram,If you use binary search then calculate how...Vikram,<BR/>If you use binary search then calculate how many floors you will really need to test before you can draw the conclusion that the floor is a break floor. Remember we are optimizing the # of bulbs needed and the # of floors that need to be experimented. I'm sorry, but 10 bulbs is not the correct answer. No doubt you can use any # of bulbs to test it in whatever fashion you think is right, BUT we need an optimal solution.Karthik Nagarajhttps://www.blogger.com/profile/02641166958828638787noreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146117934472832272006-04-26T23:05:00.000-07:002006-04-26T23:05:00.000-07:00i guess using a binary search would be the fastest...i guess using a binary search would be the fastest way to find the floor. 2^10 = 1024 > 1000, so 10 bulbs need to be dropped.Vikramnoreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146092153907499122006-04-26T15:55:00.001-07:002006-04-26T15:55:00.001-07:00Kala,At least you can comment on what others write...Kala,<BR/>At least you can comment on what others write. Pour in your suggestions. Keep participating. Don't lay off for a long time. :) <BR/><BR/>P.S: The bad king's puzzle is still UNSOLVED !!!Karthik Nagarajhttps://www.blogger.com/profile/02641166958828638787noreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146091970320278082006-04-26T15:52:00.001-07:002006-04-26T15:52:00.001-07:00Ajit,The catch is you need to minimize the number ...Ajit,<BR/>The catch is you need to minimize the number of throws as it states in the problem. In your case the # of throws will be 1000. Thats not an optimal solution. So minimize the # of throws and also find out how many bulbs you will need to perform such an optimal solution.Karthik Nagarajhttps://www.blogger.com/profile/02641166958828638787noreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146090651166444702006-04-26T15:30:00.000-07:002006-04-26T15:30:00.000-07:00whats the catch? You only need 1 bulb. Drop it fro...whats the catch? You only need 1 bulb. Drop it from floor 1. If it doesnt break pick it up and drop it from floor 2 & so on...until it breaks from a praticular floorajitnoreply@blogger.comtag:blogger.com,1999:blog-26909122.post-1146090461179777652006-04-26T15:27:00.000-07:002006-04-26T15:27:00.000-07:00Karthik, I'm going to stay off for some time ..o...Karthik,<BR/><BR/> I'm going to stay off for some time ..on public demand :) I have already gotten a couple of threats in advance to give others an opportunity to atleast look at the puzzle .. <BR/><BR/> Happy Puzzling people ! It gives you quite a kick ...atleast tickles those brain cells that have been lazying around since 10th grade.. <BR/><BR/>Cheerz,<BR/>-KalaKalahttps://www.blogger.com/profile/10919137635481656617noreply@blogger.com