Google And The Puzzle of Dropping Eggs ±¸±Û°ú ÆÛÁñÀÌ ¶³¾îÁö´Â °è¶õ
Google is also known for its interesting interview questions. ±¸±ÛÀº ¶ÇÇÑ Èï¹Ì·Î¿î ÀÎÅͺä Áú¹® À¯¸íÇÕ´Ï´Ù. Enjoy this one and my solution. Çϳª¿Í ³» ¼Ö·ç¼ÇÀ» Áñ±æ ¼öÀÖ½À´Ï´Ù. Suppose you have two eggs. °¡Á¤ °è¶õÀÌ µÎ °³ÀÖ½À´Ï´Ù. These are special eggs—they can take much more punishment than you average chicken egg. À̵éÀº ó¹úÀ» Ưº° °è¶õ - ±×µéÀº ´ç½Åº¸´Ù ÈξÀ ´õ °É¸± ¼öÀÖ½À´Ï´Ù Æò±Õ ´ß°í±â °è¶õÀ»ÇÕ´Ï´Ù. The question is exactly just how much punishment can they take? ¹®Á¦´Â Á¤È®ÇÏ°Ô ´ÜÁö ó¹úÀ» ÇÒ ¼ö ¾ó¸¶³ª °É¸±±î¿ä?
Using a 100 storey building and only the two eggs, how would you find out which is the highest floor of the building you can drop the eggs from, before they break? 100 Ãþ °Ç¹°°ú¸¸À» »ç¿ëÇÏ¿© µÎ °³ÀÇ ³ÀÚ°¡ ¾î¶»°Ô ¾Ë¾Æ ³Â Ãþ °Ç¹°ÀÌ ÃÖ°íÀÇ °è¶õÀ»ÇÏ½Ç ¼öÀÖ½À´Ï´Ù¿¡¼ µå·ÓÇϱâ Àü¿¡, ±×µéÀº ÈÞ½Ä ½Ã°£?It could be the 1st floor but it could also be the 99th floor—you don¡¯t know but to test, you need to try dropping the eggs from different floors and see what happens. ±×°Í ¼öÀÖ´Â 1 ÃþÇÏÁö¸¸ÀÌ 99¹øÂ° ¼öµµÀÖ½À´Ï´Ù Ãþ - ³Í ¸ð¸£Áö¸¸ »õ ¹öÀüÀ» Å×½ºÆ®ÇÏ·Á¸é ¶³¾îÁö´Â °è¶õÀ» ½ÃµµÇؾßÇÕ´Ï´Ù ¼·Î ´Ù¸¥Áö¸é, ¾î¶»°ÔµÇ´ÂÁöÇÕ´Ï´Ù.
via SitePoint ¸¦ ÅëÇØ Sitepoint -
Are you done yet? ¾ÆÁ÷µµ ¸Ö¾ú¼Ò? My solution is simple. ³» ÇØ°áÃ¥Àº °£´ÜÇÕ´Ï´Ù.
Use binary search with one egg till it breaks. ÀÌÁø °Ë»ö°ú Çϳª°¡ µÉ¶§±îÁö °è¶õ ³ª´©±â¸¦ »ç¿ëÇÕ´Ï´Ù. Use linear search with the second egg till it breaks. ¼±Çü °Ë»öÀ» »ç¿ëÇÒ ¶§±î ÁöÀÇ µÎ ¹øÂ° °è¶õ ³ª´©±âÇÕ´Ï´Ù. And you have the solution. ±×¸®°í ´ç½ÅÀºÀÌ ¼Ö·ç¼ÇÇÕ´Ï´Ù. If that's not clear enough allow me to explain. ¸¸¾à ±×°Ô Á¦°Ô ±âȸ¸¦ ÃæºÐÈ÷ ¼³¸íÇÒ ¸íÈ®ÇÏÁö ¾Ê´Ù.
First drop one egg from 50th (midway). ÇÑ °è¶õ¿¡¼ ù ¹øÂ° µå·Ó 50 (¹Ìµå¿þÀÌ).
- If it breaks (no more binary search) then drop the second egg from first floor. ¸¸¾à ºê·¹ÀÌÅ© (´õ ÀÌ»ó ÀÌÁø °Ë»ö)À» µå·Ó µÎ ¹øÂ° °è¶õÀ» 1 Ãþ¿¡ÀÖ½À´Ï´Ù. Move up one floor at a time till it breaks. ÇÑ ¹ø¿¡ ÇÑ Ãþ À§·Î À̵¿ÇÒ ¶§±î ÁöÀÇ ÈÞ½ÄÇÕ´Ï´Ù.
- If it doesn't break then drop it from 75th floor. ÈÞ½Ä ½Ã°£À» ¶³¾î¶ß¿¡¼ÇÏÁö ¾ÊÀ¸¸é 75 ÃþÇÕ´Ï´Ù.
- If it breaks then drop the second egg from 76th floor. ¸¸¾à ºê·¹ÀÌÅ©¸¦ µå·Ó 76¹øÂ° ¹Ù´Ú¿¡¼ µÎ ¹øÂ° °è¶õÀ»ÇÕ´Ï´Ù. Move up one floor at a time till it breaks. ÇÑ ¹ø¿¡ ÇÑ Ãþ À§·Î À̵¿ÇÒ ¶§±î ÁöÀÇ ÈÞ½ÄÇÕ´Ï´Ù.
- If it doesn't break then drop it from the 87th floor¡¦ ÈÞ½Ä ½Ã°£À» ¶³¾î¶ßÇÏÁö ¾ÊÀ¸¸é Á¦ 87 ȸ ¹Ù´Ú¿¡¼¡¦
I hope you get the picture by now. ³ª´Â Áö±Ý±îÁö ±×¸²ÀÌ ±×·ÁÁö ¹Ù¶ø´Ï´Ù. I would love to see anyone coming with a better optimized solution. ³ª´Â »ç¶ûÀ» º¸ÀÌ´Â »ç¶÷ÀÌ Àú¿Í ÇÔ²² ´õ ³ªÀº ÃÖÀûÀÇ ¼Ö·ç¼ÇÀ»ÇÕ´Ï´Ù.
Update: The optimization is to minimize the number of drops. ¾÷µ¥ÀÌÆ® :ÀÇ ÃÖÀûÈ´Â »óǰÀÇ °³¼ö¸¦ ÃÖ¼ÒÈÇÕ´Ï´Ù.
Filed under ¹Ø¿¡ Google ±¸±Û , Headline News Çìµå ¶óÀÎ ´º½º , How To ÇÏ´Â ¹æ¹ýÀ» , Web À¥ | |
| |
RSS 2.0 rss 2.0 | |
Trackback Æ®·¢¹é this Article | ÀÌ ¹®¼ |
Email this Article ÀüÀÚ ¿ìÆíÀÌ ¹®¼
You may also like to read °°Àº¸¦ ÀÐÀ» ¼öÀÖ½À´Ï´Ù |



June 10th, 2006 at 12:24 pm 2006³â 6¿ù 10ÀÏ¿¡¼ ¿ÀÈÄ 12½Ã 24ºÐ
wouldn¡¯t you drop it from the 51st instead of the 76th floor on the second round? ±×·¸Áö ¾Ê³ª¿ä¿¡¼ µå·Ó ½®ÇѹøÂ° ´ë½Å ¹Ù´Ú¿¡¼ Á¦ 76 ȸ Á¦ 2 Â÷? if the first broke on 75, then it¡¯s between 51 and 74 inclusive that you need to check now ù ¹øÂ° ÆÄ»êÀ» °æ¿ì¿¡´Â 75, ±×·¯¸é 51°ú 74 »çÀÌÀÇ ÇöÀ縦 È®ÀÎÇÏ´Â µ¥ ÇÊ¿äÇÑÀÌ Æ÷ÇÔµÈ
June 10th, 2006 at 5:41 pm 2006³â 6¿ù 10ÀÏ¿¡¼ ¿ÀÈÄ 5½Ã 41ºÐ
I spent a long time typing a detailed explanation of a solution but I lost it in a browser mishap. ¿À·£ ½Ã°£À» º¸³Â¾î¿äÀÇ ÇØ°á ¹æ¹ý¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ ¼³¸íÀ» ÀÔ·Â ±×·¯³ª »ç°íÀÇ ºê¶ó¿ìÀú¿¡¼ ÀÒ¾î ¹ö·È¾î¿ä. But, here is my solution, without the explanation: drop egg #1 at every 10th (0, 10, 30, 50¡¦) floor, and drop egg #2 at every 20th floor (20, 40, 60¡¦), until one breaks. ÇÏÁö¸¸, ¿©±â°¡ ³» ¼Ö·ç¼ÇÀ»ÇÏÁö ¾Ê°í¿¡ ´ëÇÑ ¼³¸í : µå·Ó °è¶õ # 1¸¶´Ù 10 ÀÏ (0, 10, 30, 50¡¦) ¹Ù´Ú, ¾Ø µå·Ó °è¶õ # 2¸¶´Ù 20 Ãþ (20, 40, 60¡¦),Çϱâ Àü±îÁö ÈÞ½ÄÇÕ´Ï´Ù. Then, drop one egg on every odd numbered floor and the other on every even numbered floor until one breaks. ±×¸®°í, µå·Ó ÇÑ °è¶õÀ»ÇÏ°í ´Ù¸¥ ¸ðµç Ȧ¼ö ¹øÈ£°¡ ¸Å°ÜÁø Ãþ ¹Ù´Ú±îÁö ¸ðµç ¹øÈ£°¡ ¸Å°ÜÁø ³ª´©±âµµÇÕ´Ï´Ù. Then, you will have the answer to the question of ¡°what is the lowest floor on which the egg will break?¡± ±× ´ÙÀ½ Áú¹®¿¡ ´ëÇÑ ´äº¯À»ÇϼžßÇÕ´Ï´Ù "³·Àº Ãþ¿¡ÀÖ´Â °è¶õÀº ¹«¾ùÀԴϱî ÈÞ½Ä ½Ã°£Àº?"
If you analyze the two solutions with respect to the number of drops, you will see that this alternative has the same best-case performance, and notably better worst-case performance, always wins when the answer is within (10,50) when, and often wins (but sometimes loses) when the answer is greather than 50. 2 °³ÀÇ ¼Ö·ç¼ÇÀ» ºÐ¼®ÇÏ´Â °æ¿ì¿Í °ü·ÃÇÏ¿© »óǰÀÇ °³¼ö°¡ ³ªÅ¸³³´Ï´Ù - »ç°ÇÀÌ ´ë¾ÈÀº µ¿ÀÏÇÑ ÃÖ°íÀÇ ¼º´ÉÀ», ±×¸®°í ƯÈ÷ ´õ ³ªÀº ÃÖ¾ÇÀÇ - »ç°ÇÀÇ ¼º´É, Ç×»ó ½Â ¶§ ´ë´äÀº '½Ã°£ (10,50) ¶§, ±×¸®°í ÀÚÁÖ ½Â (±×·¯³ª ¶§·Î´Â ¼Õ½Ç)À» greather¿¡ ´ëÇÑ ´äº¯Àº 50.
If you analyze the two solutions with respect to travel time/effort going up/down the building, then I believe that the alternative¡¯s advantage is even better. 2 °³ÀÇ ¼Ö·ç¼ÇÀ» Á¸ÁßÇÏ´Â °æ¿ì·Î ¿©ÇàÀ» ºÐ¼®ÇÏ´Â ½Ã°£ / ³ë·ÂÀ»°¡´Â ¾÷ / ´Ù¿î °Ç¹°, ±×¸®°í ³ª¼ ³»°¡ ±× ´ë¾ÈÀÇ ÀåÁ¡Àº ´õ¿í ¹ÏÀ»ÇÕ´Ï´Ù. Your solution ignores travel time, but I imagine you¡¯d do it the same way I did (travel up, drop one, travel up again, drop the other, then travel down to get both). ±ÍÇÏÀÇ ¼Ö·ç¼ÇÀ» ¹«½Ã ¼Ò¿ä ½Ã°£,ÇÏÁö¸¸ ³ ±×°ÍÀ»ÇÏ°í ½Í¾îÀÌ ¶È°°Àº ¹æ½ÄÀ¸·Î »ó»óÀÌ ³ (¿©ÇàÀ», ÃÑ Çϳª, ¿©ÇàÀ» ´Ù½Ã´Â µå·Ó ´Ù¸¥¸é ¾Æ·¡¸¦ ¿©Çà µÑ ´Ù).
I don¡¯t know if the alternative solution is optimal; I was just trying to show a better alternative. Àß ¸ð¸£°Ú ¼Ö·ç¼ÇÀº ÃÖÀûÀÇ ´ë¾È °æ¿ì¿¡´Â; Àü ±×Àú ´õ ³ªÀº ´ë¾ÈÀ» Ç¥½ÃÇÕ´Ï´Ù. I too am interested in a better solution. ³ª ¶ÇÇÑ ´õ ³ªÀº ¼Ö·ç¼Ç¿¡ °ü½ÉÀÌÀÖ½À´Ï´Ù.
June 11th, 2006 at 7:17 am 2006³â 6¿ù 11ÀÏ¿¡¼ ¿ÀÀü 7½Ã 17ºÐ
@a ´ÙÀ©
That depends on whether your floor numbering starts from 0 (ground floor) or 1 (first floor). ±ÍÇÏÀÇ ¹Ù´Ú ¿©ºÎ¿¡ µû¶ó ´Þ¶óÁý´Ï´Ù¿¡¼ ½ÃÀÛÇÏ´Â ¹øÈ£°¡ 0 (1 Ãþ) ¶Ç´Â 1 (1 Ãþ).
@Brian @ ºê¶óÀ̾ð
I am sorry to hear your explanation got lost. ±ÍÇÏÀÇ ¼³¸íÀ» µè´Â ³ª´Â ±æÀ» ÀÒ¾ú Á˼ÛÇÕ´Ï´Ù. I would love to hear it. ³ª´Â ±×°ÍÀ» µè´Â ³²ÆíÀ» »ç¶ûÇÕ´Ï´Ù.
> Then, drop one egg on every odd numbered floor and the other on every even numbered floor until one breaks. > ±×¸®°í, µå·Ó ÇÑ °è¶õÀ»ÇÏ°í ´Ù¸¥ ¸ðµç Ȧ¼ö ¹øÈ£°¡ ¸Å°ÜÁø Ãþ ¹Ù´Ú±îÁö ¸ðµç ¹øÈ£°¡ ¸Å°ÜÁø ³ª´©±âµµÇÕ´Ï´Ù.
At this point one has already broken. ÀÌ ½ÃÁ¡¿¡¼ Çϳª°¡ ÀÌ¹Ì ±úÁøÇÕ´Ï´Ù. If your second egg breaks too then you do not have any more eggs to find the exact floor. ¸¸¾à ´ç½ÅÀÇ µÎ ¹øÂ° °è¶õÀ» ³ª´©±âµµ¸¦ ´õ ÀÌ»óÇÏÁö ¾Ê¾ÆµµµË´Ï´Ù Ãþ ³ÀÚ¸¦ Á¤È®ÇÏ°Ô Ã£À» ¼öÀÖ½À´Ï´Ù.
Also why use two eggs at ood and even floors? ¶ÇÇÑ 2 °³ÀÇ ³ÀÚ¸¦ »ç¿ëÇÏ´Â ÀÌÀ¯µµ ¿ìµå Ç÷ξî? Why not simply use one egg? ¿Ö °è¶õÀ» ´Ü¼øÈ÷ Çϳª¸¦ »ç¿ë? We are limited by only two eggs. ¿ì¸®´Â ´Ü µÎ °è¶õ¿¡ ÀÇÇØ Á¦ÇÑÇÕ´Ï´Ù. So shouldn¡¯t we keep the second egg to pinpoint the exact floor? ±×·¡¼ µÎ ¹øÂ° °è¶õÀ» À¯Áö¸¦ Á¤È®ÇÏ°Ô ÁöÀûÇØ¾ßÇÏÁö ¾ÊÀ»±îÀÇ Á¤È®ÇÑ Ãþ?
June 12th, 2006 at 12:37 am 2006³â 6¿ù 12ÀÏ¿¡¼ ¿ÀÀü 12½Ã 37ºÐ
You are right; I copied my wording from the 10/20 part absent-mindedly. ´ç½ÅÀÌ ±Ç¸®, ³ ºÎºÐ¿¡ º¹»ç ºÎÀç - 20ºÐÀÇ 10¿¡¼ ³» ¸¶À½À» Ç¥ÇöÇÕ´Ï´Ù. Once the first egg breaks, you should drop the second one from every floor, increasing the floor number by one, just as in your case. ù ¹øÂ° °è¶õÀ» ÇÑ ¹ø ³ª´©±â, ´ç½ÅÀº µÎ ¹øÂ° µå·ÓÀÇ ¸ðµç Ãþ, È®´ë ¹Ù´Ú¿¡ ¹øÈ£¸¦ Çϳª, ±ÍÇÏÀÇ °æ¿ìó·³ ´ÜÁö.
However, my main point was that it is better to go every 10th floor then to try the ¡°binary search¡± you described. ÇÏÁö¸¸, ³» ÁÖ¿ä Æ÷ÀÎÆ®´Â ¸Å 10 Ãþ °¥ °ÍÀÌ ÁÁ½À´Ï´Ù ±× ´ÙÀ½¿¡ ½Ãµµ "ÀÌÁø °Ë»ö"À» ¼³¸íÇÕ´Ï´Ù. Your search is highly optimized for when the answer is a floor over 75 and it performs very poorly for high floors less than 50. ±ÍÇÏÀÇ °Ë»ö¿¡ ¸Â°Ô ÃÖÀûȵǾ ´ëÇÑ ´äº¯ÀÌ ¶§, ±×°ÍÀ» ¼öÇà ¸Å¿ì ÀúÁ¶ÇÑ Ãþ ÀÌ»ó 75 Ãþ ÀÌÇÏÀÇ ³ôÀÌ 50.
The reason for the ¡°every 10th floor / every 20th floor¡± logic is to minimize travel time. ±× ÀÌÀ¯´Â "¸ðµç 10 Ãþ / ¸ÅÁÖ 20 Ãþ"³í¸®´Â ¿©Çà ½Ã°£À» ÃÖ¼ÒÈÇϰíÀÚ ³ë·ÂÇϰíÀÖ½À´Ï´Ù. Let¡¯s say that the answer is ¡°22.¡± Then, I would drop egg #1 from floor 10, it would not break. ±× ´ë´äÀº 'À̶ó°íÇսô٠"22."±×¸®°í ³ª¼, ³ª´Â °è¶õÀ» # 1¿¡¼ ¹ØÀ¸·Î ¶³¾îÁú Ãþ 10, ±×·¸Áö ¾ÊÀ» ÈÞ½ÄÇÕ´Ï´Ù. Then, I can go up to floor 20 and drop egg #2 from floor 20, and it does not break. ±×¸®°í ³ª¼, ³ª´Â ¹Ù´Ú±îÁö °¥ ¼ö ¾Ø µå·Ó °è¶õ # 2¿¡¼ 20 Ãþ¿¡ 20, ±×¸®°í ±×°ÍÀº ±úÁöÁö ¾Ê½À´Ï´Ù. Then I need to go down and pick up both eggs, and take them both to floor 30. ±×·³ ³ µÑ Çʿ䰡 ³»·Á°¡¼ ÇȾ÷ °è¶õ, ±×¸®°í ¾çÂÊ¿¡ µ¥¸®°í Ãþ 30. At this point I have traveled 10+10+20+30=70 flights of stairs. ÀÌ ½ÃÁ¡¿¡¼ ³ª´Â 10 +10 +20 +30 = 70 Ç×°ø ¿©ÇàÀÇ °è´ÜÀ»ÇÕ´Ï´Ù.
If travel time is not an issue, then you could just go up to floor 10, drop egg #1, go down to pick it up, carry it up to floor 20, drop it again, go down to pick it up, go up to floor 30 etc. In this case you would just keep egg #2 in your pocket until egg #1 breaks. ¼Ò¿ä ½Ã°£Àº ¹®Á¦°¡µÇÁö ¾Ê½À´Ï´Ù °æ¿ì ´ÙÀ½¿¡ °¥ ¼öÀÖ½À´Ï´Ù Ãþ ´ÜÁö 10, µå·Ó °è¶õ # 1, °¡¼ ¼öȱ⸦ µé¸é, ¿î¹ÝÀ» À§ÇØ ±×°÷ Ãþ 20, µå·Ó ´Ù½Ã´Â Èļ¼¿¡ ¼öȱ⸦ µé¸é, °¥ ÀÌ ¹Ù´Ú 30 µîµîÀÌ °æ¿ì´Â ±×³É °è¼Ó °è¶õÀ» # 2 ÁÖ¸Ó´Ï¿¡ °è¶õÀ» # 1 ³ª´©±â±îÁöÇÕ´Ï´Ù. This method would require traveling 10+10+20+20+30=90 flights of stairs to get to floor 30. ÀÌ ¹æ¹ýÀÌ ÇÊ¿ä 10 +10 +20 +20 +30 = 90 Ç×°ø ¿©ÇàÀÇ 30 Ãþ °è´ÜÀ» °¡ºÁ¾ßÇÕ´Ï´Ù. This is the kind of detail that interviewers would probably be interested in at least hearing about-they¡¯d also probably like you to at least ask if the eggs will weaken structurally as you drop them. À̰ÍÀº ¾Æ¸¶ Á¾·ùÀÇ ¼¼ºÎ »çÇ×À» ¸éÁ¢ ¿ø - they'd¿¡ ´ëÇÑ Ã»¹®È¸¿¡ °ü½ÉÀÌ Àû¾îµµ ´ç½Åó·³, ±×¸®°í ¾Æ¸¶ ³ÀÚ¸¦ ¿ì¿ïÇϰÔÇÏ´Â °æ¿ì¿¡´Â ¿äûÀ» ÃÖ¼ÒÇÑ ±¸Á¶ÀûÀ¸·Î ±×µéÀ» µå·ÓÇÕ´Ï´Ù.
Note also that I chose ¡°10¡È arbitrarily: I was just trying a better solution, not the optimal one. Âü°í : ¿ª½Ã Á¦°¡ ¼±ÅÃÇÑ "10"ÀÓÀÇ : ³ª´Â ±×³É°¡ ´õ ³ªÀº ¼Ö·ç¼ÇÀÌ ¾Æ´Ï¶ó ÃÖÀûÀÇ Çϳª.
June 22nd, 2006 at 4:35 am 2006³â 6¿ù 22ÀÏ¿¡¼ ¿ÀÀü 4½Ã 35ºÐ
What about N floors? ¹«¾ù¿¡ ´ëÇØ n Ãþ?
Is 10 a good choice since it¡¯s the sqrt of 100? ±×°ÍÀº ÁÁÀº ¼±ÅÃÀÌ 10 sqrt ÀÌÈÄÀÇ 100?
What about using a binary search on floors i=1, 2, 4, 8, 16, 32, 64, ¡¦ and then a linear search for the floors inbetween? ÀÌÁø °Ë»öÀ» »ç¿ëÇÏ´Â ¹æ¹ýÀ» ³ª´Â ¹«¾ù Ãþ = 1, 2, 4, 8, 16, 32, 64,¡¦ ±× ´ÙÀ½ 1 Ãþ¿¡ ¼±ÇüÀ» °Ë»öÇÕ´Ï´Ù inbetween?
A solution for 36 floors is here: ¿¡ ´ëÇÑ ÇØ°áÃ¥À» 36 Ãþ´Â ¿©±â¿¡ÀÖ½À´Ï´Ù :
http://mathforum.org/wagon/past_solns/s921.html
Using the fact that 36 is the 8th triangular number, ie 36 = 1 + 2 + ¡¦ + 8 ¸¦ »ç¿ëÇÏ¿© »ï°¢ÇüÀÇ ¼ýÀÚ´Â »ç½ÇÀ» 36Àº 8 ÀÏ, Áï 36 = 1 + 2 +¡¦ + 8
June 22nd, 2006 at 8:04 am 2006³â 6¿ù 22ÀÏ¿¡¼ ¿ÀÀü 8½Ã 4ºÐ
If you know the height of the building then I think the jump search is optimum using sqrt(h) as your jump size, but if the height of the building is unknown then I¡¯m really not sure. ±× °Ç¹°ÀÇ ³ôÀ̸¦ ¾Ë°í ÀÖÀ¸¸é ±×¶§ »ý°¢ÇÏ°Ô »ç¿ëÇÏ¿© ÃÖÀûÀÇ Á¡ÇÁ °Ë»öÀº sqrt (¿øÁ¤)·Î ¿©·¯ºÐÀÇ Á¡ÇÁÀÇ Å©±â, ±×·¯³ª ¸¸¾àÀÇ ³ôÀ̸¦ ¾Ë ¼ö¾ø´Â °Ç¹°Àº ´ÙÀ½ ³ Á¤¸» ¸ð¸£°ÚÇÕ´Ï´Ù. Triangular numbers, fibonnaci, or binary. »ï°¢Çü ¼ýÀÚ, fibonnaci, ¶Ç´Â ¹ÙÀ̳ʸ®ÇÕ´Ï´Ù. Binary search on floors i=1, 2, 4, 8, 16, 32, 64, ¡¦ covers a lot of ground quickly with the first egg. ÀÌÁø °Ë»öÀ»Áö¸é ³ª´Â = 1, 2, 4, 8, 16, 32, 64,¡¦ Ä¿¹ö´Â ¸¹Àº ±×¶ó¿îµå ½Å¼ÓÇÏ°Ô Ã¹ ¹øÂ° °è¶õÀ»ÇÕ´Ï´Ù.
November 4th, 2006 at 4:02 am 2006³â 11¿ù 4ÀÏ¿¡¼ ¿ÀÀü 4½Ã 2ºÐ
hei¡¦just a simple math problem Çö´ë ÀüÀÚ ¼öÇÐ ¹®Á¦¸¦ °£´ÜÇϰԡ¦
suppose we jump every N floors, and use second egg in the one step increasing pinpoint. °¡Á¤ Á¡ÇÁ Á֯ļö¸¦ ¿ì¸®°¡Áö¸é, ÇÑ °ÉÀ½ ´õ È®´ëÇÏ°í »ç¿ëÇÏ´Â µÎ ¹øÂ° °è¶õÀ» Á¤È®ÇÏ°Ô ÁöÀûÇÕ´Ï´Ù.
MaxNumbers = 100/N + (N-1) maxnumbers = 100 / n + (n - 1)
To get the Max N we take a derivative: ¸¦ ÃÖ´ë n ¿ì¸®´Â ÆÄ»ý :
-100/N^2 + 1 = 0 => N = 10 -100 / n ^ 2 + 1 = 0 => n = 10
So we take 1st egg every 10 floors, then second egg one by one to pinpoint. ±×·¡¼ ¿ì¸®´Â 1 °è¶õÀ» ¸Å 10 Ãþ, ´ÙÀ½ °è¶õÀ» Çϳª¾¿ Â÷·Ê·Î µÎ ¹øÂ°¸¦ Á¤È®ÇÏ°Ô ÁöÀûÇÕ´Ï´Ù.
Worse case: 19 ÃÖ¾ÇÀÇ °æ¿ì : 19
Average case: 10. Æò±Õ »ç·Ê : 10.
November 30th, 2006 at 1:43 am 2006³â 11¿ù 30ÀÏ¿¡¼ ¿ÀÀü 1½Ã 43ºÐ
Say X is the number we are looking for. ¿ì¸®°¡ ¸»ÇÏ´Â ¿¢½º´Â ÀüÈ ¹øÈ£¸¦ ã°íÀÖ½À´Ï´Ù. Then, my choice will start with floor X first. ±× ´ÙÀ½¿¡ ³ªÀÇ ¼±ÅÃÀ»°¡ ½ÃÀ۵˴ϴ٠Ãþ x ¿ì¼±ÇÕ´Ï´Ù. This way, if the egg breaks, I start a linear search starting from 1 to X-1, guaranteeing a solution in Y attempts. ÀÌ·±½ÄÀ¸·Î, ¸¸¾à °è¶õ ³ª´©±â, Àü ¼±Çü °Ë»öÀ» ½ÃÀÛºÎÅÍ 1 ~ x - 1, ±×¸®°í ½Ãµµ¿¡ÀÖ´Â ¼Ö·ç¼ÇÀ» º¸ÀåÇÕ´Ï´Ù. Otherwise, I go to X + (X-1) floor¡¦. ±×·¸Áö ¾ÊÀ¸¸é, ³ª´Â °¥ x + (x - 1) ¹Ù´Ú¡¦. Continuing in this way, with X attempts, I can cover sum(X + X-1 + X-2¡¦ 2 + 1) floors. Áö¼ÓÀûÀ¸·Î ÀÌ·¯ÇÑ ¹æ¹ýÀ¸·Î x ½Ãµµ, ÇÒ ¼ö ÀÖ Ä¿¹ö (x 755 - 1 755 - 2¡¦ 2 + 1) ¹Ù´ÚÇÕ´Ï´Ù. Hence, we are looking for Min X such that X(X+1)/2 > 100. ±×·¯¹Ç·Î, ¿ì¸®´Â ã°í ºÐ x °°Àº ¡¿ (x +1) / 2> 100.
I can do it in 14 ³ ÇÒ ¼ö ÀÖ¾î¿ä 14
October 4th, 2007 at 3:57 pm 2007³â 10¿ù 4ÀÏ¿¡¼ ¿ÀÈÄ 3½Ã 57ºÐ
I ran into this problem recently and am looking for a solution¡¦ it seems there are many ³ª´ÂÀÌ ¹®Á¦´Â ÃÖ±Ù¿¡ ¿ì¿¬È÷ ÇØ°áÃ¥À» ã°í ±×¸®°íÀÌ ¸¹Àº °Í¡¦
I don¡¯t have a formal proof of this, but a gut feeling tells me my solution is good/pretty close to optimal (and it¡¯s nice to have Jason Southgate¡¯s agreement, I think he¡¯s describing the same solution?). °ø½ÄÀûÀÎ Áõ°Å°¡¾ø´Â ³ª´Â, ±×·¯³ª ³ªÀÇ ÇØ°á ¹æ¹ýÀº ÁÁÀº ¸»·Î Á÷°¨ / ¾ÆÁÖ °¡±îÀÌ ÃÖÀûÀÇ (±×¸®°í Á¦À̽¼ ³²´ë¹®ÀÇ µ¿ÀǸ¦ ¸¸³ª¼, ³ª °°Àº ÇØ°á ¹æ¹ýÀ» ¼³¸íÇÏ´Â °Í °°Àºµ¥? ).
Algorithm (assumes we know the number of floors): ¾Ë°í¸®Áò (Ç÷ξîÀÇ ¼ö¸¦ ¿ì¸®°¡ ¾Ë°í ÀÖ´Ù°í °¡Á¤) :
* Number of floors = N * Ãþ¼ö = n
* Drop the first egg at floor 1 * sqrt(N), 2 * sqrt(N), ¡¦ until you either reach N or it breaks. * µå·Ó¿¡ ´ëÇÑ Ã¹ ´Þ°¿À» ¹Ù´Ú 1 * sqrt (n), 2 * sqrt (n), nÇϰųª¡¦ µµ´ÞÇÒ ¶§±îÁö ÈÞ½Ä Áß Çϳª. If you drop it from the top floor without it breaking you have your answer. ¿¡¼ µå·ÓÇÏ´Â °æ¿ì ÃÖ»óÃþ¿¡ ´ëÇÑ ÀÀ´äÀÌ ¾øÀ¸¸é, ÆÄ±«ÇÕ´Ï´Ù.
* If it breaks when dropped from k * sqrt(N) floor then drop the second egg, starting at the (k - 1) * sqrt(N) floor and going up one floor at a time until it breaks. * ¸¸¾àÀÌ Âõ¾îÁ® ¶³¾îÁ³´Ù ¶§ k * sqrt (n) ¹Ù´ÚÀ» µå·Ó µÎ ¹øÂ° °è¶õ, ½ÃÀÛ¿¡ (ÄÉÀÌ - 1) * sqrt (n) ¹Ù´ÚÀ̳ª ¿Ã¶ó ³ª´©±â±îÁö ÇÑ ¹ø¿¡ ÇÑ ÃþÇÕ´Ï´Ù. By definition it must break sometime before k * sqrt(N) ¾ðÁ¨°¡Çϱâ Àü¿¡ ºê·¹ÀÌÅ©¸¦ Á¤ÀÇÇØ¾ßÇÕ´Ï´Ù k * sqrt (n)
I think this algorithm is O(N^0.5) - the maximum number of drops it can take is sqrt(N) + (sqrt(N) - 2). ³» »ý°¢ÀÌ ¾Ë°í¸®ÁòÀº ¿À (n ^ 0.5) - »óǰÀÇ ÃÖ´ë °³¼ö°¡ ¼Ò¿äµÉ ¼öÀÖ½À´Ï´Ù sqrt (n) + (sqrt (n) - 2). This would occur if it broke on the N-1¡Çth floor. À̰ÍÀº °íÀå¿¡¼ ¹ß»ýÇÏ´Â n - 1'th ¹Ù´Ú¸éÇÕ´Ï´Ù.
Two interesting extensions of it would be: what if the number of floors doesn¡¯t have an integer square root? ±×°ÍÀº µÎ °³ÀÇ Àç¹ÌÀÖ´Â È®Àå : ¸¸¾à¿¡Áö¸éÀÇ °³¼öÀÇ Á¤¼ö°¡µÇÁö ¾Ê½À´Ï´Ù Á¦°ö±Ù? Eg if N = 378? ¿¹¸¦ µé¾î ¸¸¾à n = 378? It seems there are three alternatives for the size of the increment of the first egg drops - the floor, ceiling or round of sqrt(N). ¼¼ °¡Áö ´ë¾ÈÀ»À§ÇÑ °Í ÁõºÐÀÇ Å©±â´Â ´Þ°¿ÀÇ Ã¹¹øÂ° »óǰ - ¹Ù´Ú, õÀå ¶Ç´Â Â÷ sqrt (n). I¡¯m not certain of my answer but I think using the round would be optimal? ³» ´äº¯ÀÌ È®½ÇÇÏÁö ¾Ê´ÙÇÏÁö¸¸ Á¦ »ý°¢À» »ç¿ëÇÏ¿© ÃÖÀûÀÇ ¶ó¿îµå°¡?
The second extension is what to do in the case of an unknown number of floors, where N is just some integer (1¡¦infinity). µÎ ¹øÂ° È®Àå ±â´ÉÀÌ ¹«¾ùÀ»ÇؾßÇÒÁö ¾Ë ¼ö¾ø´Â °³¼öÀÇ °æ¿ì¿¡´Â ¹Ù´Ú, ¿©±â¼ nÀº ¾î¶² Á¤¼ö (1¡¦ ¹«ÇÑ´ë). sqrt(infinity) just doesn¡¯t make sense, and it seems to me that if any integer is equiprobable (sp?) then you want to leap up towards infinity as fast as possible, so you get a known upper bound and then just have a linear search. sqrt (¹«ÇÑ´ë) ¸»ÀÌ ¾ÈµÇ´Â, ±×¸®°í ³ª¿¡°Ô ±×°ÍÀ» º¸Àδ٠Á¤¼ö°¡ÀÖ´Â °æ¿ì equiprobable (Ãâ¹ßÁ¡?) ±×·¸´Ù¸é ¹«ÇÑ´ëÂÊÀ¸·Î µµ¾àÀ» ÃÖ´ëÇÑ »¡¸®, Àß ¾Ë·ÁÁø ¾òÀ» ¼ö ÀÖµµ·Ï ±×¸®°í ±× ¹Ù·ÎÀÌ »óÇÑ ¼±Çü °Ë»öÇÕ´Ï´Ù. But I have no way of expressing this formally or in any convincing way, I¡¯m just pumping intuitions madly! ÇÏÁö¸¸ ³ Ç¥Çö ¹æ¹ýÀÌ ¾ø´Ù ¼³µæ·ÂÀÌ °ø½ÄÀûÀ¸·Î ¶Ç´Â ¾î¶°ÇÑ ¹æ½Ä, ³ ±×³É ÆßÇÁ Á÷°¨ ¹ÌÄ¡!
All this fancy reasoning said though I think the triangle number solution linked to above is actually better. °ø»ó Ãß·ÐÀÌ ¸ðµç »ï°¢Çü ¼ýÀÚ´Â ºñ·Ï ³» »ý°¢¿¡ ±× ÀÌ»óÀÌ ½ÇÁ¦·Î ´õ ³ªÀº ¼Ö·ç¼ÇÀ» ¿¬°áÇÕ´Ï´Ù. I¡¯m just not sure how you would generalise it to situations where N is not a triangular number. ³ª´Â ´ÜÁö generalise ¾ø´Ù¸é ±×°ÍÀ» È®ÀÎÇÏ´Â ¹æ¹ý »óȲ¿¡¼ nÀº »ï°¢ ¹øÈ£¸¦ÇÕ´Ï´Ù.
Binary search would be O(log N) though¡¦ hmmm, OK, now I¡¯m confused and lack all certainty, but what the heck, other things to do this morning, I¡¯ll post anyway ÀÌÁø °Ë»öÀº ¿À (·Î±× n) ºñ·Ï¡¦ Èì, ±×·¡, Áö±ÝÀº È¥¶õ°ú ºÎÀçÀÇ ¸ðµç È®½Ç¼º,ÇÏÁö¸¸ µµ´ëü, ´Ù¸¥ÇØ¾ß ÇÒ °ÍµéÀÌ ¿À´Ã ¾ÆÄ§, ³ ¾î·µç °Ô½Ã¹°
Christo christo
PS: A point I didn¡¯t consider till now: if you¡¯ve checked all but two possible floors and break the egg on the second to last possible floor then you still have your answer¡¦ Again, not sure and no time to see if this is important! ps : Áö±Ý±îÁö °í·ÁÇÒ Á¡ ¾È : ¸¸¾àÀÌ °Ë»ç¸¦ Á¦¿ÜÇÑ ¸ðµç °è¶õÀ» ±ý ¼öÀÖ´Â 2 °³ÀÇÁö¸é, µÎ ¹øÂ°¸¦ ¸¶Áö¸·À¸·Î¡¦ ¼öÀÖ½À´Ï´Ù Ãþ ´ÙÀ½¿¡ ´ëÇÑ ÀÀ´äÀ» ´Ù½Ã ´ç½ÅÀº ¿©ÀüÈ÷°¡ ¾Æ´Ï¶óµµ¾ø°í ½Ã°£ÀÌ ÀÖ´ÂÁö È®ÀÎ À̰ÍÀº Áß¿äÇÕ´Ï´Ù!
October 5th, 2007 at 5:13 pm 2007³â 10¿ù 5ÀÏ¿¡¼ ¿ÀÈÄ 5½Ã 13ºÐ
The original puzzle doesn¡¯t say what they¡¯re trying to optimize, so I assume the optimization variable is left to the solver. ÆÛÁñÀÇ ¿ø·¡ ±×µéÀÌ ¹«½¼ ³ë·ÂÀ» ÃÖÀûÈÇÏ´Â ¸»À»ÇÏÁö ¾Ê½À´Ï´Ù, ±×·¡¼ ¿ÞÂÊÀ¸·Î ÃßÃøÀÇ ÃÖÀûÈ º¯¼ö°¡ ÇØ°áÇÕ´Ï´Ù.
Personally, I would optimize for minimal egg breaks by starting on floor 1 and going up one floor at a time until it breaks. °³ÀÎÀûÀ¸·Î, Àü ÈÞ½ÄÀ» ÃÖÀûÈÇϱâÀ§ÇÑ ÃÖ¼ÒÇÑÀÇ °è¶õÀ» ½ÃÀÛÇÏ¿© 1 Ãþ¿¡±îÁö ¿Ã¶ó ÈÞ½ÄÀ» ÇÑ ¹ø¿¡ ÇÑ ÃþÇÕ´Ï´Ù. In the end you¡¯d be left with your answer and one unbroken egg. °á±¹ ´ç½ÅÀº ´ç½ÅÀÇ ´ë´äÀ» ÇÑ ²÷¾îÁöÁö ¿ÞÂʰú °è¶õÀ»ÇÕ´Ï´Ù. Any egg that can survive a drop from more than 1 story would be a very valuable egg indeed, and get you a lot of money on ebay! ¸ðµç °è¶õÀ» ÇÑ °³ À̻󿡼 ÇÑ ¹æ¿ïÀÌ »ýÁ¸ÇÒ ¼öÀÖ½À´Ï´Ù ½ºÅ丮´Â ¸Å¿ì ±ÍÁßÇÑ ³ÀÚ »ç½Ç, ±×¸®°í °æ¸Å »çÀÌÆ®¿¡ ¸¹Àº µ·À»¸¦ ±¸ÇØ!
October 6th, 2007 at 11:42 am 2007³â 10¿ù 6ÀÏ¿¡¼ ¿ÀÀü 11½Ã 42ºÐ
The optimization is for minimizing the number of drops. ÀÇ ÃÖÀûÈ´Â »óǰÀÇ ¼ö¸¦ ÃÖ¼ÒÈÇÕ´Ï´Ù.
October 16th, 2007 at 12:42 am 2007³â 10¿ù 16ÀÏ¿¡¼ ¿ÀÀü 12½Ã 42ºÐ
For goodness sake. ÀÌ·± ¼¼»ó¿¡ÇÕ´Ï´Ù. The egg will break when dropped from the first floor because, well, it¡¯s an egg. ÈÞ½Ä ½Ã°£Àº ¶³¾îÁ³´Ù ¶§, °è¶õÀº 1 Ãþ ¿Ö³ÄÇϸé, À½, ÀÌ°Ç ´Þ°¿ÇÕ´Ï´Ù.
I say cook the two eggs for breakfast and move onto the next question! ³»°¡ ¸»ÇÏ´Â ¿ä¸®»çÇϰí À̵¿Àº ¾ÆÄ§¿¡ °è¶õ µÎ ¹æ¸éÀÇ ´ÙÀ½ Áú¹®!
November 2nd, 2007 at 11:21 pm 2007³â 11¿ù 2ÀÏ¿¡¼ ¿ÀÈÄ 11½Ã 21ºÐ
@Christo Fogelberg execellent explanation and generalisation for optimizing the no of attempts. @ christo ¾Æ´Ï¿À fogelberg execellent ÃÖÀûÈÇϱâÀ§ÇÑ ¼³¸í°ú ÀϹÝȸ¦ ½ÃµµÇÕ´Ï´Ù.
but ofcourse you can match sqrt(n)(how did you find this?) from duduqin solution. ÇÏÁö¸¸ ´ç¿¬ÇÏÁö¸¦ ÀÏÄ¡½Ãų ¼öÀÖ½À´Ï´Ù sqrt (n) (ÇÏ´Â ¹æ¹ýÀÌ µÇ¼Ì½À´Ï±î?)¿¡¼ duduqin ¼Ö·ç¼ÇÀ»ÇÕ´Ï´Ù.
it is like : ÀÌ °°Àº :
no of steps = n Áö¿ªÀÇ ´Ü°è = n
let us assume x = no of steps between two attempts ¿ì¸® »çÀÌ¿¡ µÎ °³ÀÇ ½ÃµµÀÇ ´Ü°è ÃßÃø x = ¾Æ´Ï¿À
and y = total no of attempts with first egg (maximum) ±×·±µ¥µµ = ÃÑ ¾Æ¹« ¼Ò¸®¿Í ù ¹øÂ° °è¶õÀ» ½ÃµµÇÕ´Ï´Ù (ÃÖ´ë)
so we get ±×·³ ¿ì¸®¿¡°Õ
x*y = n x * ±×¸®°í = n
and now no of attempt = y + x -1 (or y + x not sure) ±×¸®°í ÀÌÁ¦ Áö¿ªÀÇ ½Ãµµ = ±×¸®°í 755 -1 (¶Ç´Â ±×¸®°í 755 ¸ð¸£°Ú)
so for min(y + x - 1) ±×·¸±â ¶§¹®¿¡ ºÐ (±×¸®°í 755 - 1)
derivative(y + x -1) = 0 ÆÄ»ý (±×¸®°í 755 -1) = 0
so you get x = y = sqrt(n) from here. ±×·¯´Ï x = ¹× = sqrt (n)¸¦ ¿©±â¿¡ÀÖ½À´Ï´Ù.
Now we can go with your solution. ÀÌÁ¦ ¿ì¸®°¡ °¥ ¼ö ±ÍÇÏÀÇ ¼Ö·ç¼ÇÀ»ÇÕ´Ï´Ù.
I dont know what to do when it is required to optimize not the no of attemps but the total no of steps travelled(going up to some floor and coming down to collect the egg(s) and in the same way). ³ª´Â ¹«¾ùÀ»ÇؾßÇÒÁö ¸ð¸£´Â °æ¿ì°¡ ¾Æ´ÏÀ» ÃÖÀûÈÇÏ´Â °ÍÀÌ ÇÊ¿äÇÕ´Ï´Ù attempsÇÏÁö¸¸ Áö¿ªÀÇ Àüü Áö¿ªÀÇ ´Ü°è¸¦ ¿©Çà (»ó½ÂÇϰí, ¹«³ÊÁö´Â¸¦ ¼öÁýÇÏ´Â ÀϺΠÃþ, °è¶õ (µé)¿Í °°Àº ¹æ½ÄÀ¸·Î).
Please put your views. ´ç½ÅÀÇ Àü¸Á¿¡ ³Ö¾îÁÖ¼¼¿ä.
December 4th, 2007 at 4:24 am 2007³â 12¿ù 4ÀÏ¿¡¼ ¿ÀÀü 4½Ã 24ºÐ
Well because the questions is based upin eggs (fragile), we need to include the non-algorithmic parameters as well. Áú¹®ÀÌ Àֱ⠶§¹®¿¡ Àß ±â¹Ý upin °è¶õ (¾àÇÑ), ¿ì¸®°¡ ¾Æ´Ñ - ¾Ë°í¸®Áò ¸Å°³ º¯¼ö¸¦ Æ÷ÇÔÇØ¾ßÇÕ´Ï´ÙµµÇÕ´Ï´Ù.
Looking at the question statement, nothing is mentioned about the material on which it is to be dropped & the place where it should be dropped. Áú¹®À» ¹®ÀåÀ»º¸°í, ¾Æ¹«°ÍµµµÇ´Â ¹°Áú¿¡ ´ëÇØ¼´Â ¾ð±ÞÀÌÀÖ´Â °÷¿¡ ±×°ÍÀ» »èÁ¦ ¹× »èÁ¦µÇ¾î¾ßÇÕ´Ï´Ù. In those cases the egg could also be dropped on to the same floor from any height. ÀÌ·¯ÇÑ °æ¿ì, °è¶õÀº µ¿ÀÏÇÑ ¹Ù´Ú¿¡ ¶³¾îÁø ¼öµµ ¸ðµç °íµµÇÕ´Ï´Ù.
December 4th, 2007 at 9:20 pm 2007³â 12¿ù 4ÀÏ¿¡¼ ¿ÀÈÄ 9½Ã 20ºÐ
Obviously it is being dropped to the ground otherwise the question becomes meaningless. ¸í¹éÈ÷ ±×°ÍÀº ´Ù¸¥ ¹®Á¦°¡ ¶¥¿¡ ¶³¾îÁ³´Ù´Â Àǹ̰¡µÈ´Ù. What non-algorithmic parameters are you talking about? - ¾Ë°í¸®Áò ¸Å°³ º¯¼ö´Â ¹«¾ù ¾Æ´Ñ ¸»¾¸À̼¼¿ä?
The task is to determine at which height (divisible by height of each floors which are of equal height) the egg breaks. ÀÌ ÀÛ¾÷Àº °áÁ¤¿¡ ¾î¶² ³ôÀÌ (ºÐÇÒÇÏ¿© °¢ Ç÷ξîÀÇ ³ôÀ̰¡ µ¿ÀÏÇÑ ³ôÀÌ), °è¶õ ³ª´©±âÇÕ´Ï´Ù. The material of egg is unknown but obviously it is made of stronger material than your regular poultry egg. ÇÏÁö¸¸ ºÐ¸íÈ÷ ¾Ë ¼ö¾ø´Â ¼ÒÀçÀÇ °è¶õÀÌ ¸¸µé¾îÁø °ÍÀº ±ÍÇÏÀÇ ÀÏ¹Ý ´ßº¸´Ù ´õ °ÇÑ ¼ÒÀç °è¶õÀ»ÇÕ´Ï´Ù.
December 14th, 2007 at 11:48 am 2007³â 12¿ù 14ÀÏ¿¡¼ ¿ÀÀü 11½Ã 48ºÐ
One idea is that you want to maintain a constant risk throughout the drops to guarantee an equal average- and worst-case. ÇϳªÀÇ ¾ÆÀ̵ð¾î´Â ÀÏÁ¤ÇÑ À§ÇèÀ» À¯ÁöÇϰíÀÚÇÏ´Â »óǰÀ» º¸ÀåÇÒ ³»³» ´ëµîÇÑ Æò±Õ -¿Í ÃÖ¾ÇÀÇ - »ç·ÊÇÕ´Ï´Ù.
With the strategy of skipping a constant number of floors \ ÀÏÁ¤ °³¼öÀÇ Àü·«À» °Ç³Ê¶Ù´Â Ç÷ξî \
January 18th, 2008 at 1:36 pm 2008³â 1¿ù 18ÀÏ¿¡¼ ¿ÀÈÄ 1½Ã 36ºÐ
I found this page again randomly while checking nothing too noxious was being attributed to me on Google, it sounds like the discussion has moved on so I figure I\¡¯ll add to it again º» ÆäÀÌÁö¸¦ ´Ù½Ã ã¾ÒÀ» È®ÀÎÇÏ´Â µ¿¾È ³ª´Â ¾Æ¹«°Íµµ ¹«ÀÛÀ§·Î ¹ß»ýÇÏ´Â À¯ÇØ´Â ÀÚ½ÅÀÇ Àü ³¯ ±¸±Û, µè±â¿¡ ´ëÇÑ Åä·ÐÀÌ À̻縦 ±×·¡¼ ³ ±×¸² ³ª´Â \ '°Ô¿ä Àå¹Ù±¸´Ï¿¡ ´Ù½Ã
@Dhananjay: @ dhananjay :
Yes, going back now and reading duduqin\¡¯s reasoning I see it is a specific example for n=100 of the general case. ¿¹, Áö±Ý µ¹¾Æ°¥ ¹× Àбâ duduqin \ 'ÀÇ ³í¸®´Â ±¸Ã¼ÀûÀÎ ¿¹Á¦¸¦ º¸¿© n = 100ÀÇ ÀϹÝÀûÀÎ »ç·Ê.
You are also right that I did not explain why sqrt(n) was optimal - and in fact, as I think I noted, I\¡¯m still not sure that it is! ¶ÇÇÑ ´ç½ÅÀÇ ±Ç¸®°¡ ³ª´Â ÀÌÀ¯¸¦ ¼³¸í ¾Ê¾Ò sqrt (n)Àº ÃÖÀûÀÇ - ±×¸®°í »ç½Ç Àû¾î °Í °°¾Æ¿ä, ³ª \ 'm ¾ÆÁ÷ È®½ÅÀÌÀÖ´Ù!
In any case, I don\¡¯t think derivatives factor into it. ¾î¶°ÇÑ °æ¿ì¶óµµ, ³ª µ· \ 't ÆÄ»ý »óǰ ¿äÀνÃÄÑ »ý°¢ÇÕ´Ï´Ù. Perhaps they do but I\¡¯m not sure what you\¡¯re deriving with respect to. ¾Æ¸¶µµ ±×µéÀº¾ø½À´Ï´ÙÇÏÁö¸¸ Àü \ '¸ð¸£°Ú ´ç½ÅÀÌ \'´Ù½Ã ÆÄ»ý°ú °ü·ÃÇÏ¿©ÇÕ´Ï´Ù. I agree x = y and that the maximum number of attempts will be n=xy and that you can get sqrt(n) from that but I\¡¯m still a little bit confused. µ¿ÀÇ x = ±×¸®°í ±× ½ÃµµÀÇ ÃÖ´ë °³¼ö´Â n = xyÀ» ¾òÀ» ¼öÀÖ½À´Ï´Ù sqrt (n)¿¡¼ÇÏÁö¸¸ Àü \ '¾ÆÁ÷ Á¶±Ý È¥¶õ½º·¯¿öÇÕ´Ï´Ù. Sorry! Á˼ÛÇÕ´Ï´Ù! Also, what does the min function in min(x + y - 1) refer to or mean? ¶ÇÇÑ, ¹«¾ùÀ» ÃÖ¼Ò ±â´ÉÀ» ºÐ (x + ±×¸®°í - 1)¸¦ ÂüÁ¶Çϰųª ÀǹÌÇմϱî?
###########
@dkaminski: @ dkaminski :
I haven\¡¯t thought about this much, but I think you\¡¯re right - it would be interesting to look at the expectation distribution. ³ª´ÂÀÖ´Ù \ 'tÀÌ Á¤µµ·Î »ý°¢Çß´Ù,ÇÏÁö¸¸ Á¦ »ý°¢¿¡ ´ç½Å \'´Ù½Ã ¿À¸¥ÂÊ -¸é Àç¹ÌÀÖÀ» ºÐÆ÷¿¡ ´ëÇÑ ±â´ë¸¦ º¸¸é¼ ÀÌ·± »ý°¢À»ÇÕ´Ï´Ù. Any further thoughts? ±× ÀÌ»óÀÇ »ý°¢ÇϽʴϱî? (I have none right now:) (Áö±ÝÀº ¾Æ¹«µµ ¾ø¾î :)
Actually, talking of expectation, a cute wee problem with plenty of off-by-1 and off-by-k chances that a friend and I ended up talking about over dinner recently goes something like this: »ç½Ç, À̾߱âÀÇ ±â´ë¸¦, ±Í¿©¿î ²¿¸¶ ¹®Á¦¸¦ ÃæºÐÈ÷ -ÇÏ¿© - 1°ú µû·Î µû·Î -¿¡ - k ±âȸ¸¦ ¸»Çϴ°¡ °á±¹Àº Àú³á ½Ä»ç ½Ã°£¿¡ Ä£±¸¿Í ³ª´Â ÃÖ±Ù¿¡ ½ÄÀÔ´Ï´ÙÀÌ :
You have a bag with 50 lengths of string inside it. ´ç½ÅÀºÀÌ 50 ±æÀÌÀÇ ¹®ÀÚ¿À» ºÀÅõ ¾È¿¡ ±×°ÍÇÕ´Ï´Ù.
You pull out one end of one piece of string, leaving the rest of that piece in the bag. ´ç½ÅÀÇ ÇÑÂÊ ³¡À» ö¼ö Çϳª ¹®ÀÚ¿, ºÀÅõ ¾È¿¡´Â ±× ºÎºÐÀÇ ³ª¸ÓÁö ºÎºÐ ¶°³´Ù. You pull out a second end of string, possibly the end of a different piece of string and possibly the other end of the piece of string you\¡¯re already holding. µÎ ¹øÂ° ¿£µåÀÇ ¹®ÀÚ¿À» ö¼ö, ¾Æ¸¶ ¿ù¸»¿¡ ´Ù¸¥ Á¶°¢ÀÌ ¹®ÀÚ¿°ú ¾Æ¸¶ Á¶°¢ÀÌ ¹®ÀÚ¿ÀÇ ³ª¸ÓÁö ³¡ºÎºÐÀ» \ '´Ù½ÃÀÌ ÀÌ¹Ì º¸À¯ÇÕ´Ï´Ù. You tie the two ends together before dropping them back in the bag. 2 ¿£µå¸¦ ÇÔ²² ¹¾î ºÀÅõ¿¡ µçÇϱâ Àü¿¡ ±×µéÀ» µ¹·Á Ç϶ôÇÕ´Ï´Ù.
After all the ends have been tied to some other end, what is the expected number of loops in the bag? ÀÌÈÄÀÇ ¸ðµç °øµ¿ÀÇ ³¡ºÎºÐ ÀϺΰ¡ ´Ù¸¥ ÂÊ ³¡À», ¾î¶² °æ¿ì¿¡ÀÌ ºÀÅõ ¾È¿¡´Â ·çÇÁ¸¦ ¿¹»ó °³¼ö?
OK, it\¡¯s Friday night, there\¡¯s jazz and cocktails on and if I\¡¯m not going to go to that I should really be doing something more productive. ±×·¡, ±×°Í \ 'ÀÇ ±Ý¿äÀÏ ¹ã, °Å±â \'ÀÇ ÀçÁî¿Í ĬÅ×ÀÏÀ» ±×¸®°í ¸¸¾à ³»°¡ \ '¾Æ´Õ´Ï´Ù¿¡ °¡¼ ÀÏÀ»ÇϰíÀÖÀ» °¡·Ô Á¤¸»·Î »ý»êÀûÇÕ´Ï´Ù. Cheerio all! ÀßÀÖ°Ô ½ºÅ¸¸¦ ¼Ò°³ÇÕ´Ï´Ù!
xto