• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 00:21
CEST 06:21
KST 13:21
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Serral wins EWC 202532Tournament Spotlight: FEL Cracow 20259Power Rank - Esports World Cup 202580RSL Season 1 - Final Week9[ASL19] Finals Recap: Standing Tall15
Community News
[BSL 2025] H2 - Team Wars, Weeklies & SB Ladder8EWC 2025 - Replay Pack4Google Play ASL (Season 20) Announced38BSL Team Wars - Bonyth, Dewalt, Hawk & Sziky teams10Weekly Cups (July 14-20): Final Check-up0
StarCraft 2
General
Classic: "It's a thick wall to break through to become world champ" Serral wins EWC 2025 The GOAT ranking of GOAT rankings Firefly given lifetime ban by ESIC following match-fixing investigation EWC 2025 - Replay Pack
Tourneys
Sea Duckling Open (Global, Bronze-Diamond) TaeJa vs Creator Bo7 SC Evo Showmatch Sparkling Tuna Cup - Weekly Open Tournament FEL Cracov 2025 (July 27) - $10,000 live event Esports World Cup 2025
Strategy
How did i lose this ZvP, whats the proper response
Custom Maps
External Content
Mutation # 484 Magnetic Pull Mutation #239 Bad Weather Mutation # 483 Kill Bot Wars Mutation # 482 Wheel of Misfortune
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ Flash Announces (and Retracts) Hiatus From ASL BW General Discussion [BSL 2025] H2 - Team Wars, Weeklies & SB Ladder Brood War web app to calculate unit interactions
Tourneys
Small VOD Thread 2.0 [Megathread] Daily Proleagues [BSL] Non-Korean Championship - Final weekend [BSL20] Non-Korean Championship 4x BSL + 4x China
Strategy
Does 1 second matter in StarCraft? Simple Questions, Simple Answers Muta micro map competition [G] Mineral Boosting
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Beyond All Reason Total Annihilation Server - TAForever [MMORPG] Tree of Savior (Successor of Ragnarok)
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia TL Mafia Community Thread
Community
General
Things Aren’t Peaceful in Palestine US Politics Mega-thread Canadian Politics Mega-thread Stop Killing Games - European Citizens Initiative UK Politics Mega-thread
Fan Clubs
INnoVation Fan Club SKT1 Classic Fan Club!
Media & Entertainment
Anime Discussion Thread [\m/] Heavy Metal Thread Movie Discussion! [Manga] One Piece Korean Music Discussion
Sports
2024 - 2025 Football Thread Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023 NBA General Discussion
World Cup 2022
Tech Support
Gtx660 graphics card replacement Installation of Windows 10 suck at "just a moment" Computer Build, Upgrade & Buying Resource Thread
TL Community
TeamLiquid Team Shirt On Sale The Automated Ban List
Blogs
The Link Between Fitness and…
TrAiDoS
momentary artworks from des…
tankgirl
from making sc maps to makin…
Husyelt
StarCraft improvement
iopq
Socialism Anyone?
GreenHorizons
Eight Anniversary as a TL…
Mizenhauer
Customize Sidebar...

Website Feedback

Closed Threads



Active: 548 users

brain teaser

Blogs > Shady Sands
Post a Reply
Normal
Shady Sands
Profile Blog Joined June 2012
United States4021 Posts
November 20 2012 21:40 GMT
#1
Imagine you have, at most, two identical rocks and a 100-floor building.

Using only the method of dropping a rock from a certain floor and seeing whether it will crack open or not, what is the least number of drop attempts you need to use to figure out the highest floor from which a rock, dropped, will not break?

1) Breaking is ordinal--a rock that breaks from a 60 floor etc. can be safely assumed to break from a 70 floor drop, etc.

Once you have calculated this for the 100-floor building, what is the answer for an n-floor building?

**
Что?
AnachronisticAnarchy
Profile Blog Joined July 2011
United States2957 Posts
November 20 2012 21:46 GMT
#2
Is this a trick question? It seems impossible to do it with only 2 rocks.
"How are you?" "I am fine, because it is not normal to scream in pain."
TOCHMY
Profile Blog Joined June 2010
Sweden1692 Posts
Last Edited: 2012-11-20 22:11:55
November 20 2012 21:53 GMT
#3
+ Show Spoiler +
least number of drop attempts: 2, cuz you only have, at most, 2 rocks?


Dont mind the spoiler, I misunderstood the question...
Yoona <3 ¯\_(ツ)_/¯ Look! It's Totoro! ☉.☉☂
Warmonger
Profile Blog Joined June 2010
United States69 Posts
November 20 2012 21:53 GMT
#4
On November 21 2012 06:46 AnachronisticAnarchy wrote:
Is this a trick question? It seems impossible to do it with only 2 rocks.


Not impossible, it would just take a while without further assumptions/knowledge.

+ Show Spoiler +

1.)Drop the first rock from halfway up the building, N/2
2a.)If it breaks start on the 1st floor and keep going up a floor until it breaks
2b.)If it doesn't break start on the 51st floor (N/2 +1) and keep going up a floor until it breaks
AiurZ
Profile Blog Joined May 2004
United States429 Posts
November 20 2012 21:55 GMT
#5
fastest way to find out is to drop from 10th floor, then 20th floor, then 30th floor, etc. until it breaks and then you drop the 2nd rock ascending each floor 1 by 1.

for an n-floor building u just find the minimum of (n/x)+x=y and that is the amount of floors u skip each try (for a 100 floor building it is 10).
picture of dogs.jpg
micronesia
Profile Blog Joined July 2006
United States24680 Posts
November 20 2012 21:59 GMT
#6
http://www.teamliquid.net/blogs/viewblog.php?topic_id=285063

Except they used eggs.
ModeratorThere are animal crackers for people and there are people crackers for animals.
L3gendary
Profile Joined October 2010
Canada1470 Posts
Last Edited: 2012-11-20 22:34:27
November 20 2012 22:06 GMT
#7
logN/log2 ? rounded of course.
nvm i skipped over the u can only break it twice part, the egg one made it more clear to me. The steps of 10 seems right. For N case it'd be 2*root(N)-1.
Watching Jaedong play purifies my eyes. -Coach Ju Hoon
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
November 20 2012 22:12 GMT
#8
On November 21 2012 06:53 Warmonger wrote:
Show nested quote +
On November 21 2012 06:46 AnachronisticAnarchy wrote:
Is this a trick question? It seems impossible to do it with only 2 rocks.


Not impossible, it would just take a while without further assumptions/knowledge.

+ Show Spoiler +

1.)Drop the first rock from halfway up the building, N/2
2a.)If it breaks start on the 1st floor and keep going up a floor until it breaks
2b.)If it doesn't break start on the 51st floor (N/2 +1) and keep going up a floor until it breaks


It sounds like it works, but is it the fastest way?
AnachronisticAnarchy
Profile Blog Joined July 2011
United States2957 Posts
Last Edited: 2012-11-20 22:14:24
November 20 2012 22:12 GMT
#9
On November 21 2012 06:53 Warmonger wrote:
Show nested quote +
On November 21 2012 06:46 AnachronisticAnarchy wrote:
Is this a trick question? It seems impossible to do it with only 2 rocks.


Not impossible, it would just take a while without further assumptions/knowledge.

+ Show Spoiler +

1.)Drop the first rock from halfway up the building, N/2
2a.)If it breaks start on the 1st floor and keep going up a floor until it breaks
2b.)If it doesn't break start on the 51st floor (N/2 +1) and keep going up a floor until it breaks


You only have 2 rocks, though.
I guess if you want to discard that limit, you could do this:
1. drop a rock from the 50th floor
2a. if it breaks, go to floor 25
2b. if it doesn't break, go to floor 75
3a,a: if it breaks, go to floor 13
3a,b: if it doesn't break, go to floor 37
3b, a: if it does break, go to floor 63
3b, b: if it doesn't break, go to floor 87
and so on and so on
By doing this, you maximize the amount of floors each drop covers, until you find the floor you're looking for.
I'm not fond of the question though. Even without the 2-rock limit, there's the fact that the appropriate floor is random, so odds are you would stumble upon the answer before you finish the process you are doing and rule out everything but the answer.
"How are you?" "I am fine, because it is not normal to scream in pain."
stenole
Profile Blog Joined April 2004
Norway868 Posts
November 20 2012 22:16 GMT
#10
I liked this puzzle. Not enough to do the actual math, but it was a nice brain teaser.
Melliflue
Profile Joined October 2012
United Kingdom1389 Posts
Last Edited: 2012-11-20 22:22:54
November 20 2012 22:16 GMT
#11
On November 21 2012 06:53 Warmonger wrote:
Show nested quote +
On November 21 2012 06:46 AnachronisticAnarchy wrote:
Is this a trick question? It seems impossible to do it with only 2 rocks.


Not impossible, it would just take a while without further assumptions/knowledge.

+ Show Spoiler +

1.)Drop the first rock from halfway up the building, N/2
2a.)If it breaks start on the 1st floor and keep going up a floor until it breaks
2b.)If it doesn't break start on the 51st floor (N/2 +1) and keep going up a floor until it breaks

You can do better than this.
+ Show Spoiler +
If the rock doesn't break (case 2b) then you can drop a rock from the 75th floor using the same argument. If it breaks then start on 51st floor, if it doesn't then try higher.

I doubt that is optimal though.

Edit:
On November 21 2012 07:12 AnachronisticAnarchy wrote:
Show nested quote +
On November 21 2012 06:53 Warmonger wrote:
On November 21 2012 06:46 AnachronisticAnarchy wrote:
Is this a trick question? It seems impossible to do it with only 2 rocks.


Not impossible, it would just take a while without further assumptions/knowledge.

+ Show Spoiler +

1.)Drop the first rock from halfway up the building, N/2
2a.)If it breaks start on the 1st floor and keep going up a floor until it breaks
2b.)If it doesn't break start on the 51st floor (N/2 +1) and keep going up a floor until it breaks


You only have 2 rocks, though.
I guess if you want to discard that limit, you could do this:
1. drop a rock from the 50th floor
2a. if it breaks, go to floor 25
2b. if it doesn't break, go to floor 75
3a,a: if it breaks, go to floor 13
3a,b: if it doesn't break, go to floor 37
3b, a: if it does break, go to floor 63
3b, b: if it doesn't break, go to floor 87
and so on and so on
By doing this, you maximize the amount of floors each drop covers, until you find the floor you're looking for.
I'm not fond of the question though. Even without the 2-rock limit, there's the fact that the appropriate floor is random, so odds are you would stumble upon the answer before you finish the process you are doing and rule out everything but the answer.

That's a standard binary search or bisection search. I can't remember the technical term for it. It is the most efficient way with enough rocks.

I am not sure I follow your argument for why you don't like the question. The floor is random, but the question is what is the least number of drops needed to be certain that you know which floor it is.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2012-11-20 22:26:08
November 20 2012 22:20 GMT
#12
Logarithmic approaches don't work. If you start with half the total height, you end up with a worst case around n/2 (first rock breaks at n/2), which is much worse. If you start with 1, then do 3, 7, 15 and so on, you end up with at least 30 drops (first stone cracks at 63, you have to do 31 more drops if the correct floor is 62).

Heh, guess I was wrong about the 10 20 30 solution being right.
If you have a good reason to disagree with the above, please tell me. Thank you.
Cyber_Cheese
Profile Blog Joined July 2010
Australia3615 Posts
Last Edited: 2012-11-20 22:27:44
November 20 2012 22:21 GMT
#13
if it breaks on 50, and the answer is 49, you'd have to go through 1-49 because you cant afford to break the other rock
I think the working the way up in multiples of 10 thing was best
for 2 stones only, sqrt(floors)
I'm not about to sit down and calculate every scenario though..
The moment you lose confidence in yourself, is the moment the world loses it's confidence in you.
Phael
Profile Joined May 2010
United States281 Posts
Last Edited: 2012-11-20 22:24:34
November 20 2012 22:22 GMT
#14
Solution for 100 floors:

+ Show Spoiler +

A straightforward solution would be to drop the first rock every 10 floors until it breaks, then drop the second rock from the last floor that didn't break up in increments of 1. Ex: drop at 10, 20, 30, 40, 50 .. break. Ok, second rock: 41, 42, 43, 44 ... break. Highest floor: 43.

This would give us a solution of 19, which isn't optimal, because you're "wasting" potential drops if the rock cracks on floor 9, for example, vs floor 99.

So instead, drop the first rock at floor 14, then floor 27 (14+13), then floor 39 (14+13+12), etc. This way, the "worst case scenario" of a rock breaking at 14 means you drop 13 more times, the WCS of a rock breaking at 27 would be dropping 12 more times, etc. so in total, you should only need 14 drops no matter which floor the rocks crack on.

How did I get 14? I recognized that you need 1 + 2 + 3 + 4 + 5 + ... + d >= number of floors, and for 100, d = 14.



General solution

+ Show Spoiler +

General solution for d drops on a building with n floors:

Following from previous, 1 + 2 + 3 + 4 + 5 + ... + d >= n.

d*(d+1)/2 >=n

d^2 + d - 2n >= 0

By the quadratic equation, the positive solutions:

d >= (root(8n+1)-1)/2

so minimum number of drops needed = ceiling((root(8n+1)-1)/2)
Warmonger
Profile Blog Joined June 2010
United States69 Posts
November 20 2012 22:28 GMT
#15
On November 21 2012 07:12 darkness wrote:
Show nested quote +
On November 21 2012 06:53 Warmonger wrote:
On November 21 2012 06:46 AnachronisticAnarchy wrote:
Is this a trick question? It seems impossible to do it with only 2 rocks.


Not impossible, it would just take a while without further assumptions/knowledge.

+ Show Spoiler +

1.)Drop the first rock from halfway up the building, N/2
2a.)If it breaks start on the 1st floor and keep going up a floor until it breaks
2b.)If it doesn't break start on the 51st floor (N/2 +1) and keep going up a floor until it breaks


It sounds like it works, but is it the fastest way?


You are right, I overlooked being able to re-use the first rock if it didn't break. In which case the "best" method may be defined differently for different needs. Are we looking for fastest average solution for a building with N stories? The solution with least attempts on worst-case? I don't have the knowledge to do either off the top of my head, but I'm sure some CS major can do it fairly easily.
CoughingHydra
Profile Blog Joined May 2012
177 Posts
Last Edited: 2012-11-20 22:34:08
November 20 2012 22:30 GMT
#16
On November 21 2012 07:06 L3gendary wrote:
logN/log2 ? rounded of course.

This is the first thing that came to my mind too ( binary search algorithm ).
http://en.wikipedia.org/wiki/Binary_search_algorithm

EDIT: Nevermind
Blazinghand *
Profile Blog Joined December 2010
United States25551 Posts
November 20 2012 22:35 GMT
#17
this is a pretty standard CS interview question
When you stare into the iCCup, the iCCup stares back.
TL+ Member
opisska
Profile Blog Joined February 2011
Poland8852 Posts
November 20 2012 22:38 GMT
#18
I am always so lazy when I know that there probably is a solution for me to read. So I will never know if I would do it, but I highly doubt it. Very cool, that such a simple problem has a nontrivial solution.
"Jeez, that's far from ideal." - Serral, the king of mild trashtalk
TL+ Member
AnachronisticAnarchy
Profile Blog Joined July 2011
United States2957 Posts
Last Edited: 2012-11-20 22:48:05
November 20 2012 22:47 GMT
#19
"How are you?" "I am fine, because it is not normal to scream in pain."
Varanice
Profile Blog Joined June 2011
United States1517 Posts
November 20 2012 23:01 GMT
#20
On November 21 2012 07:22 Phael wrote:
Solution for 100 floors:

+ Show Spoiler +

A straightforward solution would be to drop the first rock every 10 floors until it breaks, then drop the second rock from the last floor that didn't break up in increments of 1. Ex: drop at 10, 20, 30, 40, 50 .. break. Ok, second rock: 41, 42, 43, 44 ... break. Highest floor: 43.

This would give us a solution of 19, which isn't optimal, because you're "wasting" potential drops if the rock cracks on floor 9, for example, vs floor 99.

So instead, drop the first rock at floor 14, then floor 27 (14+13), then floor 39 (14+13+12), etc. This way, the "worst case scenario" of a rock breaking at 14 means you drop 13 more times, the WCS of a rock breaking at 27 would be dropping 12 more times, etc. so in total, you should only need 14 drops no matter which floor the rocks crack on.

How did I get 14? I recognized that you need 1 + 2 + 3 + 4 + 5 + ... + d >= number of floors, and for 100, d = 14.



General solution

+ Show Spoiler +

General solution for d drops on a building with n floors:

Following from previous, 1 + 2 + 3 + 4 + 5 + ... + d >= n.

d*(d+1)/2 >=n

d^2 + d - 2n >= 0

By the quadratic equation, the positive solutions:

d >= (root(8n+1)-1)/2

so minimum number of drops needed = ceiling((root(8n+1)-1)/2)

I was getting close to this for the 100 floor version, but you sir are a genius.
www.twitch.tv/varanice
synapse
Profile Blog Joined January 2009
China13814 Posts
November 20 2012 23:17 GMT
#21
With the 2-rock limit I don't think the binary search works... you would have a worst-case of both rocks instantly breaking if the floor was <25
:)
KaRnaGe[cF]
Profile Joined September 2007
United States355 Posts
November 20 2012 23:38 GMT
#22
If you drop any one rock more than once, it will damage the integrity of the rock making it useless to use in the test again.
"We must remember that one man is much the same as another, and that he is best who is trained in the severest school." - Athenian General Thucydides Quantum Gaming
Aerisky
Profile Blog Joined May 2012
United States12129 Posts
November 21 2012 00:35 GMT
#23
Yeah I think this is a standard CS interview question to see how you are with logic/creativity and what have you.

I am sooo bad at logic puzzles/brain teasers though lol ;__;. Maybe I shouldn't go through with a technical field and/or EECS after all. And karnage the assumption is that the rock sustains no damage until it hits the breaking point, whereupon the rock immediately and completely breaks. Otherwise you can't actually do the puzzle lol.
Jim while Johnny had had had had had had had; had had had had the better effect on the teacher.
farvacola
Profile Blog Joined January 2011
United States18826 Posts
Last Edited: 2012-11-21 00:41:55
November 21 2012 00:41 GMT
#24
I like this problem more if it includes an acknowledgement of the damage each rock receives per drop, which is then itself contingent on the distance of the fall. With that in mind, find the shortest total distance needed for both rocks to break.
"when the Dead Kennedys found out they had skinhead fans, they literally wrote a song titled 'Nazi Punks Fuck Off'"
Complete
Profile Joined October 2009
United States1864 Posts
November 21 2012 02:05 GMT
#25
On November 13 2011 13:34 Complete wrote:
14,27,39,50,60,69,77,84,90,95,99,100
worst case 14


My answer from another thread with this question.
ClysmiC
Profile Blog Joined December 2010
United States2192 Posts
November 21 2012 02:49 GMT
#26
Binary selection doesn't work. Assume you have a 100 story building and it breaks on the 20th story.

You drop the first one at 50, it breaks. You drop the second one at 25, it breaks. Both your rocks are now broken and you can't continue testing. If you had unlimited number of rocks, then yes, binary selection is the fastest way. That being said, I'm not sure what the fastest way is ^_^
snively
Profile Blog Joined August 2011
United States1159 Posts
November 21 2012 03:01 GMT
#27
I just realized... it says "brian teaser" and not "brain teaser"
xD
My religion is Starcraft
brian
Profile Blog Joined August 2004
United States9619 Posts
November 21 2012 03:24 GMT
#28
seriously. As a Brian, I can confirm this is #1 most annoying thing in the world.
Shady Sands
Profile Blog Joined June 2012
United States4021 Posts
Last Edited: 2012-11-21 04:39:51
November 21 2012 03:36 GMT
#29
On November 21 2012 12:24 Gene wrote:
seriously. As a Brian, I can confirm this is #1 most annoying thing in the world.


=/ bah

edit: ty mystery mod
Что?
DarkPlasmaBall
Profile Blog Joined March 2010
United States44324 Posts
November 21 2012 06:21 GMT
#30
I agree with the "10 steps of 10" starting point. It seems in general you want your second rock to be responsible for the same number of steps as your first rock, assuming the worst case scenario- that your first rock breaks on the first try. From there, the answer is trivial.
"There is nothing more satisfying than looking at a crowd of people and helping them get what I love." ~Day[9] Daily #100
peidongyang
Profile Joined January 2009
Canada2084 Posts
Last Edited: 2012-11-21 06:39:01
November 21 2012 06:29 GMT
#31
Base case: For 0 rocks we are able to determine whether or not 1 floor is passable (we assume it is)
Recursive Relation: a(n)=2*a(n-1), where n is the number of rocks
Proof
For 1 rock, we are able to drop it from floor 1 and if it breaks, and it won't break from floor 0
For 2 rocks, we are able to drop it from floor 2. If it breaks, we drop it from floor 1. If not, we will drop it from floor 3. Therefore we are able to determine breaking from floors 1-4.

Without going into rigorous mathematical proof, it is very easy to see that 2^n floors can be determined with n rocks, or the reserve, the binary search tree with log(2)n time.

Therefore the solution for 100 floors is ceil(log(2)100).

The general solution is ceil(log(2)n)

edit2: nvm again I think my solution holds. Guaranteed to produce result in 7 searches
the throws never bothered me anyway
Blazinghand *
Profile Blog Joined December 2010
United States25551 Posts
November 21 2012 06:31 GMT
#32
On November 21 2012 15:21 DarkPlasmaBall wrote:
I agree with the "10 steps of 10" starting point. It seems in general you want your second rock to be responsible for the same number of steps as your first rock, assuming the worst case scenario- that your first rock breaks on the first try. From there, the answer is trivial.


Yeah the thing is, if you do 10 steps of 10 as a starting point you quickly realize it's not optimal. Let's say you drop at 10, 20, 30, etc all the way up to 80. Where do you drop now? Well, you could drop at 90, but then your first rock is responsible for 1 step and your second rock could be responsible for 10. So basically your initial increment should be bigger than 10, and by the time you get to 100 it should be pretty small. This ends up being increment of 14, 13, 12, 11, and so on, so that each time, even later on, both rocks are responsible for the same amount of chance.
When you stare into the iCCup, the iCCup stares back.
TL+ Member
DarkPlasmaBall
Profile Blog Joined March 2010
United States44324 Posts
Last Edited: 2012-11-21 06:49:23
November 21 2012 06:43 GMT
#33
On November 21 2012 15:31 Blazinghand wrote:
Show nested quote +
On November 21 2012 15:21 DarkPlasmaBall wrote:
I agree with the "10 steps of 10" starting point. It seems in general you want your second rock to be responsible for the same number of steps as your first rock, assuming the worst case scenario- that your first rock breaks on the first try. From there, the answer is trivial.


Yeah the thing is, if you do 10 steps of 10 as a starting point you quickly realize it's not optimal. Let's say you drop at 10, 20, 30, etc all the way up to 80. Where do you drop now? Well, you could drop at 90, but then your first rock is responsible for 1 step and your second rock could be responsible for 10. So basically your initial increment should be bigger than 10, and by the time you get to 100 it should be pretty small. This ends up being increment of 14, 13, 12, 11, and so on, so that each time, even later on, both rocks are responsible for the same amount of chance.


Well can't you adjust after each drop, so that every step would hypothetically cause your second rock to require the same amount of floor responsibility as the first one, if the first rock broke at any given step? I'm just concerned about the starting point for starters.

If you start at floor 10 and the first rock does break, the the second rock will then be responsible for 10 floors (1-9). If the first rock didn't break, then you need to account for the other 90 floors. I'm not suggesting that you always go up in increments in 10 (although looking back at my post, I totally could have chosen better words- I just meant the starting point though), as I do agree with your reasoning that then the first rock would be doing less work (so to speak) in accounting for fewer relative groups, whereas the second rock would always need to do increments of 10. But then we would just keep rounding (perhaps via square roots? I don't know; I'm tired) such that the first and second rocks are always hypothetically responsible for the same amount of work (the first rock being the larger division and then the second rock having an equal sub-division in case the first rock breaks at any time) at any given step.

EDIT: So I guess for the second step, assuming the first rock doesn't break and there are 90 floors left... drop the first rock at ~sqrt(90), or 9 or 10 floors, up, so that the second rock can also cover that many floors in case the rock breaks? If the first rock attempted to cover more to make your job easier, you'd fall behind on your counting if it breaks. If you cover fewer floors in an attempt to ensure the rock doesn't break, then you still have potentially many more floors to go in the long run.

Or is it the case that with all of these cumulatively smaller increments, it ends up being slightly larger overall than if you happened to just plain start off with a bigger number for the first rock drop than floor 10? Is there a justification for this other than working out all the calculations?
"There is nothing more satisfying than looking at a crowd of people and helping them get what I love." ~Day[9] Daily #100
GhandiEAGLE
Profile Blog Joined March 2011
United States20754 Posts
Last Edited: 2012-11-21 07:08:15
November 21 2012 07:07 GMT
#34
=============Ignore==============
Oh, my achin' hands, from rakin' in grands, and breakin' in mic stands
Cyber_Cheese
Profile Blog Joined July 2010
Australia3615 Posts
Last Edited: 2012-11-21 09:28:36
November 21 2012 09:27 GMT
#35
On November 21 2012 15:31 Blazinghand wrote:
Show nested quote +
On November 21 2012 15:21 DarkPlasmaBall wrote:
I agree with the "10 steps of 10" starting point. It seems in general you want your second rock to be responsible for the same number of steps as your first rock, assuming the worst case scenario- that your first rock breaks on the first try. From there, the answer is trivial.


Yeah the thing is, if you do 10 steps of 10 as a starting point you quickly realize it's not optimal. Let's say you drop at 10, 20, 30, etc all the way up to 80. Where do you drop now? Well, you could drop at 90, but then your first rock is responsible for 1 step and your second rock could be responsible for 10. So basically your initial increment should be bigger than 10, and by the time you get to 100 it should be pretty small. This ends up being increment of 14, 13, 12, 11, and so on, so that each time, even later on, both rocks are responsible for the same amount of chance.

I think this changes the average to be better too
The 10 example works out to ~ 11 average (if I'm not mistaken.) The average number of guesses the first rock will take is the average of the sum of 1->10 which is 5.5, then the second rocks the same for 11 total.
As a worst case scenario, it goes to 19 (10,20,30...100 =10), when it breaks on 99 or 100 (Because it has to break somewhere right?) You have to test 91,92,93....99.
with 14+13... it's a little more complicated to find an average, the first rock has 12 possibilites, but it's an average of (x?), because the early ones are more likely to show up, and then the second one has 11 possibilites, but an average of (y?) because the ones the cooincide with a large number of rock 1 drops will require less rock 2 drops
If I did x+y, it'd be manually tallying, I suspect someone knows a better way?
The moment you lose confidence in yourself, is the moment the world loses it's confidence in you.
Rannasha
Profile Blog Joined August 2010
Netherlands2398 Posts
November 21 2012 09:51 GMT
#36
On November 21 2012 18:27 Cyber_Cheese wrote:
Show nested quote +
On November 21 2012 15:31 Blazinghand wrote:
On November 21 2012 15:21 DarkPlasmaBall wrote:
I agree with the "10 steps of 10" starting point. It seems in general you want your second rock to be responsible for the same number of steps as your first rock, assuming the worst case scenario- that your first rock breaks on the first try. From there, the answer is trivial.


Yeah the thing is, if you do 10 steps of 10 as a starting point you quickly realize it's not optimal. Let's say you drop at 10, 20, 30, etc all the way up to 80. Where do you drop now? Well, you could drop at 90, but then your first rock is responsible for 1 step and your second rock could be responsible for 10. So basically your initial increment should be bigger than 10, and by the time you get to 100 it should be pretty small. This ends up being increment of 14, 13, 12, 11, and so on, so that each time, even later on, both rocks are responsible for the same amount of chance.

I think this changes the average to be better too
The 10 example works out to ~ 11 average (if I'm not mistaken.) The average number of guesses the first rock will take is the average of the sum of 1->10 which is 5.5, then the second rocks the same for 11 total.
As a worst case scenario, it goes to 19 (10,20,30...100 =10), when it breaks on 99 or 100 (Because it has to break somewhere right?) You have to test 91,92,93....99.
with 14+13... it's a little more complicated to find an average, the first rock has 12 possibilites, but it's an average of (x?), because the early ones are more likely to show up, and then the second one has 11 possibilites, but an average of (y?) because the ones the cooincide with a large number of rock 1 drops will require less rock 2 drops
If I did x+y, it'd be manually tallying, I suspect someone knows a better way?


The second option (14,13,12...) averages at 10.36 drops. Determined by just averaging the number of drops from all possible heights.
Such flammable little insects!
Cyber_Cheese
Profile Blog Joined July 2010
Australia3615 Posts
Last Edited: 2012-11-21 10:27:20
November 21 2012 10:26 GMT
#37
On November 21 2012 18:51 Rannasha wrote:
Show nested quote +
On November 21 2012 18:27 Cyber_Cheese wrote:
On November 21 2012 15:31 Blazinghand wrote:
On November 21 2012 15:21 DarkPlasmaBall wrote:
I agree with the "10 steps of 10" starting point. It seems in general you want your second rock to be responsible for the same number of steps as your first rock, assuming the worst case scenario- that your first rock breaks on the first try. From there, the answer is trivial.


Yeah the thing is, if you do 10 steps of 10 as a starting point you quickly realize it's not optimal. Let's say you drop at 10, 20, 30, etc all the way up to 80. Where do you drop now? Well, you could drop at 90, but then your first rock is responsible for 1 step and your second rock could be responsible for 10. So basically your initial increment should be bigger than 10, and by the time you get to 100 it should be pretty small. This ends up being increment of 14, 13, 12, 11, and so on, so that each time, even later on, both rocks are responsible for the same amount of chance.

I think this changes the average to be better too
The 10 example works out to ~ 11 average (if I'm not mistaken.) The average number of guesses the first rock will take is the average of the sum of 1->10 which is 5.5, then the second rocks the same for 11 total.
As a worst case scenario, it goes to 19 (10,20,30...100 =10), when it breaks on 99 or 100 (Because it has to break somewhere right?) You have to test 91,92,93....99.
with 14+13... it's a little more complicated to find an average, the first rock has 12 possibilites, but it's an average of (x?), because the early ones are more likely to show up, and then the second one has 11 possibilites, but an average of (y?) because the ones the cooincide with a large number of rock 1 drops will require less rock 2 drops
If I did x+y, it'd be manually tallying, I suspect someone knows a better way?


The second option (14,13,12...) averages at 10.36 drops. Determined by just averaging the number of drops from all possible heights.

Did you include that '14' would be 14 drops, because you don't know if the rock broke at 13 or not? Same with 27,39,50,60,69,77,84,90,95,99
The moment you lose confidence in yourself, is the moment the world loses it's confidence in you.
Flonomenalz
Profile Joined May 2011
Nigeria3519 Posts
Last Edited: 2012-11-21 10:30:38
November 21 2012 10:30 GMT
#38
wrong thread
I love crazymoving
AcrossFiveJulys
Profile Blog Joined September 2005
United States3612 Posts
Last Edited: 2012-11-21 11:02:00
November 21 2012 10:35 GMT
#39
On November 21 2012 06:40 Shady Sands wrote:
+ Show Spoiler +

Imagine you have, at most, two identical rocks and a 100-floor building.

Using only the method of dropping a rock from a certain floor and seeing whether it will crack open or not, what is the least number of drop attempts you need to use to figure out the highest floor from which a rock, dropped, will not break?

1) Breaking is ordinal--a rock that breaks from a 60 floor etc. can be safely assumed to break from a 70 floor drop, etc.

Once you have calculated this for the 100-floor building, what is the answer for an n-floor building?



The "at most 2 identical rocks" condition is confusingly worded. One interpretation would be that you start with either 1 rock or 2 identical rocks, and if a rock breaks, you can't drop it anymore. So the challenge is that if you break all rocks you start with without finding a floor in which a rock doesn't break you can't say with certainty any floor in which a rock does not break.


So under that interpretation, if you start with 1, the only strategy that is guaranteed to give you an answer is to start at floor 1 and continue upwards until the rock breaks; the floor before the one in which it breaks is the answer. If you start with 2, the best strategy that is guaranteed to give you an answer would be one in which you ascend 2 floors at a time and drop one rock at each floor until it breaks. Then you try the other rock on the floor below. If it breaks at floor X, the answer is floor X-1; if it doesn't break, the floor X is the answer.


Another interpretation of the "at most 2 identical rocks" condition would be that you start with a (known finite? infinite?) number of rocks in which at most 2 are identical, and you are trying to find the highest floor that some rock breaks. In this scenario, the optimal strategy depends on how many rocks you start with which you didn't tell us.

Yet another (loose) interpretation is that we start with an infinite number of identical rocks. In this case the optimal strategy is a binary search: try floor ceil(N/2), if a rock breaks, try floor ceil(N/4), and if not try floor ceil(3*N/4), and so on. The maximum number of drops will be ceil(log_2(N)).
Cyber_Cheese
Profile Blog Joined July 2010
Australia3615 Posts
November 21 2012 10:45 GMT
#40
On November 21 2012 19:35 AcrossFiveJulys wrote:
The "at most 2 identical rocks" condition is confusingly worded. One interpretation would be that you start with either 1 rock or 2 identical rocks, and if a rock breaks, you can't drop it anymore. So the challenge is that if you break all rocks you start with without finding a floor in which a rock doesn't break you can't say with certainty any floor in which a rock does not break.

So under that interpretation, if you start with 1, the only strategy that is guaranteed to give you an answer is to start at floor 1 and continue upwards until the rock breaks; the floor before the one in which it breaks is the answer. If you start with 2, the best strategy that is guaranteed to give you an answer would be one in which you ascend 2 floors at a time and drop one rock at each floor until it breaks. Then you try the other rock on the floor below. If it breaks, the answer is the floor below; if it doesn't break, the current floor is the answer.


.... What? The first rock exsists to narrow down the range such that the second could act as your only rock example. What if the answer was 99? Are you seriously calling 51 potential drops optimal?
The moment you lose confidence in yourself, is the moment the world loses it's confidence in you.
Ota Solgryn
Profile Blog Joined January 2008
Denmark2011 Posts
Last Edited: 2012-11-21 10:50:26
November 21 2012 10:48 GMT
#41
On November 21 2012 06:40 Shady Sands wrote:
Imagine you have, at most, two identical rocks and a 100-floor building.

Using only the method of dropping a rock from a certain floor and seeing whether it will crack open or not, what is the least number of drop attempts you need to use to figure out the highest floor from which a rock, dropped, will not break?

1) Breaking is ordinal--a rock that breaks from a 60 floor etc. can be safely assumed to break from a 70 floor drop, etc.

Once you have calculated this for the 100-floor building, what is the answer for an n-floor building?


The least number of drops you need to use is 2. You drop the first rock from n+1 floor -> it breaks. You drop the next rock from n floor -> it doesn't break. So now you know the highest floor from which is doesn't break is the n floor.

The answer cannot be 1 (the rock breaks at 1st floor) because then there would be no floor from which the rock would be intact. This is unless you are allowed to use the exclusion principle and just drop one rock from the 2nd floor and you then know the rock would be intact on the 1st floor (then it would be only 1 drop).

I did it this way becuase the question is the least number of drops.
Most people here seem to calculate what is the maximum number of drops you would need to use in the case you have the most optimal way of generally finding the highest floor of which the rock would be intact.
ihasaKAROT: "Wish people would stop wasting their lives on finding flaws in others"
AcrossFiveJulys
Profile Blog Joined September 2005
United States3612 Posts
November 21 2012 10:59 GMT
#42
On November 21 2012 19:45 Cyber_Cheese wrote:
Show nested quote +
On November 21 2012 19:35 AcrossFiveJulys wrote:
The "at most 2 identical rocks" condition is confusingly worded. One interpretation would be that you start with either 1 rock or 2 identical rocks, and if a rock breaks, you can't drop it anymore. So the challenge is that if you break all rocks you start with without finding a floor in which a rock doesn't break you can't say with certainty any floor in which a rock does not break.

So under that interpretation, if you start with 1, the only strategy that is guaranteed to give you an answer is to start at floor 1 and continue upwards until the rock breaks; the floor before the one in which it breaks is the answer. If you start with 2, the best strategy that is guaranteed to give you an answer would be one in which you ascend 2 floors at a time and drop one rock at each floor until it breaks. Then you try the other rock on the floor below. If it breaks, the answer is the floor below; if it doesn't break, the current floor is the answer.


.... What? The first rock exsists to narrow down the range such that the second could act as your only rock example. What if the answer was 99? Are you seriously calling 51 potential drops optimal?


Mmmm you're right. It's 6am here ><
Clazziquai10
Profile Blog Joined August 2011
Singapore1949 Posts
November 21 2012 11:39 GMT
#43
I think the question needs to be rephrased into something like this:

How do you drop the rocks in such a way that yields the best worst-case scenario? i.e. the worst case scenario for a particular way to drop the rocks would require the lowest number of drops compared to other ways to do so
Rannasha
Profile Blog Joined August 2010
Netherlands2398 Posts
November 21 2012 12:47 GMT
#44
On November 21 2012 19:48 Ota Solgryn wrote:
Show nested quote +
On November 21 2012 06:40 Shady Sands wrote:
Imagine you have, at most, two identical rocks and a 100-floor building.

Using only the method of dropping a rock from a certain floor and seeing whether it will crack open or not, what is the least number of drop attempts you need to use to figure out the highest floor from which a rock, dropped, will not break?

1) Breaking is ordinal--a rock that breaks from a 60 floor etc. can be safely assumed to break from a 70 floor drop, etc.

Once you have calculated this for the 100-floor building, what is the answer for an n-floor building?


The least number of drops you need to use is 2. You drop the first rock from n+1 floor -> it breaks. You drop the next rock from n floor -> it doesn't break. So now you know the highest floor from which is doesn't break is the n floor.

Except you don't know what n is.

I did it this way becuase the question is the least number of drops.
Most people here seem to calculate what is the maximum number of drops you would need to use in the case you have the most optimal way of generally finding the highest floor of which the rock would be intact.


What you answered is the least number of drops you need to verify that the highest non-breaking-floor is n, when n is provided a priori. If n is not known, you need to the "best worst-case-scenario", which is what people have been calculating.
Such flammable little insects!
Rannasha
Profile Blog Joined August 2010
Netherlands2398 Posts
November 21 2012 12:52 GMT
#45
On November 21 2012 15:29 peidongyang wrote:
Base case: For 0 rocks we are able to determine whether or not 1 floor is passable (we assume it is)
Recursive Relation: a(n)=2*a(n-1), where n is the number of rocks
Proof
For 1 rock, we are able to drop it from floor 1 and if it breaks, and it won't break from floor 0
For 2 rocks, we are able to drop it from floor 2. If it breaks, we drop it from floor 1. If not, we will drop it from floor 3. Therefore we are able to determine breaking from floors 1-4.

Without going into rigorous mathematical proof, it is very easy to see that 2^n floors can be determined with n rocks, or the reserve, the binary search tree with log(2)n time.

Therefore the solution for 100 floors is ceil(log(2)100).

The general solution is ceil(log(2)n)

edit2: nvm again I think my solution holds. Guaranteed to produce result in 7 searches


The problem only allows you 2 rocks, your solution requires more. Specifically, if the rock already breaks on the first floor, your binary search tree requires you to break 7 rocks. This is why binary search trees are not a correct way of approaching the problem. (The problem would be rather dull otherwise, since binary search trees are such a common technique.)
Such flammable little insects!
Incze
Profile Blog Joined December 2011
Romania2058 Posts
November 21 2012 13:17 GMT
#46
But if a rock would normally break when thrown from, say, the 50th floor, then if it's already been dropped from all the previous floors, it won't be able to reach 50, it would break much sooner because each fall, no matter how small affects its structural integrity.
Religion: Buckethead
Rannasha
Profile Blog Joined August 2010
Netherlands2398 Posts
November 21 2012 13:31 GMT
#47
On November 21 2012 22:17 Incze wrote:
But if a rock would normally break when thrown from, say, the 50th floor, then if it's already been dropped from all the previous floors, it won't be able to reach 50, it would break much sooner because each fall, no matter how small affects its structural integrity.


It's an abstract problem. The only reason it's described with physical concepts such as rocks and floors is to make it accessible. In this case, you must assume that the rocks is completely unaffected by a drop that doesn't outright break it. If you can't do that, I can give you a purely mathematical description of the problem.
Such flammable little insects!
Ota Solgryn
Profile Blog Joined January 2008
Denmark2011 Posts
Last Edited: 2012-11-21 13:47:09
November 21 2012 13:46 GMT
#48
On November 21 2012 21:47 Rannasha wrote:
Show nested quote +
On November 21 2012 19:48 Ota Solgryn wrote:
On November 21 2012 06:40 Shady Sands wrote:
Imagine you have, at most, two identical rocks and a 100-floor building.

Using only the method of dropping a rock from a certain floor and seeing whether it will crack open or not, what is the least number of drop attempts you need to use to figure out the highest floor from which a rock, dropped, will not break?

1) Breaking is ordinal--a rock that breaks from a 60 floor etc. can be safely assumed to break from a 70 floor drop, etc.

Once you have calculated this for the 100-floor building, what is the answer for an n-floor building?


The least number of drops you need to use is 2. You drop the first rock from n+1 floor -> it breaks. You drop the next rock from n floor -> it doesn't break. So now you know the highest floor from which is doesn't break is the n floor.

Except you don't know what n is.

Show nested quote +
I did it this way becuase the question is the least number of drops.
Most people here seem to calculate what is the maximum number of drops you would need to use in the case you have the most optimal way of generally finding the highest floor of which the rock would be intact.


What you answered is the least number of drops you need to verify that the highest non-breaking-floor is n, when n is provided a priori. If n is not known, you need to the "best worst-case-scenario", which is what people have been calculating.


No, I provided the least number of drops you need if you make a lucky guess, I do not need to know n, nowhere does the question state that you could not make guess, and be lucky with that guess. Anyhow, I just answered it as was it a trick question, which to me it is, because of a vague formulation.
ihasaKAROT: "Wish people would stop wasting their lives on finding flaws in others"
DarkPlasmaBall
Profile Blog Joined March 2010
United States44324 Posts
Last Edited: 2012-11-21 14:32:01
November 21 2012 14:25 GMT
#49
On November 21 2012 22:46 Ota Solgryn wrote:
Show nested quote +
On November 21 2012 21:47 Rannasha wrote:
On November 21 2012 19:48 Ota Solgryn wrote:
On November 21 2012 06:40 Shady Sands wrote:
Imagine you have, at most, two identical rocks and a 100-floor building.

Using only the method of dropping a rock from a certain floor and seeing whether it will crack open or not, what is the least number of drop attempts you need to use to figure out the highest floor from which a rock, dropped, will not break?

1) Breaking is ordinal--a rock that breaks from a 60 floor etc. can be safely assumed to break from a 70 floor drop, etc.

Once you have calculated this for the 100-floor building, what is the answer for an n-floor building?


The least number of drops you need to use is 2. You drop the first rock from n+1 floor -> it breaks. You drop the next rock from n floor -> it doesn't break. So now you know the highest floor from which is doesn't break is the n floor.

Except you don't know what n is.

I did it this way becuase the question is the least number of drops.
Most people here seem to calculate what is the maximum number of drops you would need to use in the case you have the most optimal way of generally finding the highest floor of which the rock would be intact.


What you answered is the least number of drops you need to verify that the highest non-breaking-floor is n, when n is provided a priori. If n is not known, you need to the "best worst-case-scenario", which is what people have been calculating.


No, I provided the least number of drops you need if you make a lucky guess, I do not need to know n, nowhere does the question state that you could not make guess, and be lucky with that guess. Anyhow, I just answered it as was it a trick question, which to me it is, because of a vague formulation.


While I understand that possible ambiguity/ need to be clever, I'm also pretty sure that based on the context, you really understood that it wasn't a trick question. It means for any given floor, the fact that you're always looking to optimize your answer (not just "get lucky"), and the understanding that you can't risk both rocks breaking without knowing for a fact what the correct floor is. You can't just arbitrarily say, "I choose to pick the two perfect floors to give me the correct answer, meaning the answer's two", because you're incapable of knowing for sure that you'd pick those two ideal floors. You'd need to already know the answers, and then drop the rocks to reconfirm them. However, as the person dropping the rocks, you don't actually know yet what those ideal floors are.

I mean, after all, if you really want to be a dick about it, why not just say, "Well I was super lucky in my individual trial because the answer was "the rock breaks at the first floor" and I dropped my first rock on the first floor and it broke, and therefore I didn't even need the second rock. Answer's one." It's really missing the point of the brain teaser, because if it hadn't broken, I would have only eliminated one floor in one step, and I'd still have ninety-nine to go... and you simply can't work under the assumption that it will be the first floor, so it's silly to pick floor one to drop the first rock. It will be better for you (probability-wise) to drop the first rock at floor two at step one than at floor one.
"There is nothing more satisfying than looking at a crowd of people and helping them get what I love." ~Day[9] Daily #100
Scorch
Profile Blog Joined March 2008
Austria3371 Posts
November 21 2012 14:50 GMT
#50
I'd throw the first rock in increases of sqrt(n) (floors 10, 20, 30... in our example), and of course the second rock in single steps from the last known safe position. That yields a worst case of 2*sqrt(n). Probably not optimal, but should be decent enough for starters.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
November 21 2012 15:05 GMT
#51
In case you missed it, Phael posted the right answer on page 1. There's no way to improve on it because all the worst case scenarios for rock 2 yield the same result, and it deals with the worst case scenario for rock 1, floor 99/100, as well with the same upper limit. Well ok, that wasn't a real proof. But since we're dealing with minima and integer values, proving it might be ugly...
If you have a good reason to disagree with the above, please tell me. Thank you.
Warillions
Profile Joined November 2010
United States215 Posts
November 21 2012 15:53 GMT
#52
half split method
green.at
Profile Blog Joined January 2010
Austria1459 Posts
November 21 2012 19:18 GMT
#53
+ Show Spoiler +
my initial thought is n/2 if i start on floor 2 and go up 2 each time it does not break, gonna think about it some more
Inputting special characters into chat should no longer cause the game to crash.
vaL4r
Profile Joined May 2010
Germany240 Posts
Last Edited: 2012-11-21 23:16:20
November 21 2012 23:01 GMT
#54
On November 21 2012 06:40 Shady Sands wrote:
what is the least number of drop attempts you need to use to figure out the highest floor from which a rock, dropped, will not break?


+ Show Spoiler +
Two. I drop my first rock from floor X which just so happens to be the floor above the one from which it won't break, of course at this time I don't know this.. not until I drop the rock from the floor X-1 and discover it is intact!

In case I am missunderstanding I could be wrong but it seems to me as thought this was a silly trick question and not a puzzle with a clever mathematical answer.

I would appreciate if you told me which one is


EDIT: oh nvm I get it.. so the idea is that if the rock doesn't break I can pick it up and use it again so the question is which is the most effective method for finding the floor without breaking more than 2 rocks.

Meh I don't see it! Seems like too much of a shot in the dark - I would start by throwing it from the [ highest floor - 1 ],
if it doesn't break you can go test the highest floor, if it does I would just go back to floor 0 and go one up every throw...

every other method I can come up with on the fly seems flawed in that it could be really bad depending on what the right floor number actually is.
You need to play starcraft with a light heart. If you play with a heavy heart, you can't win. -NaDa
Z-BosoN
Profile Blog Joined May 2007
Brazil2590 Posts
November 22 2012 00:38 GMT
#55
Well, if you have a large wooden plank that you can pin outside the windows and you are very precise in throwing the rocks, you need but one rock =p
AcrossFiveJulys
Profile Blog Joined September 2005
United States3612 Posts
Last Edited: 2012-11-22 01:24:32
November 22 2012 01:05 GMT
#56
This is actually a nice problem looking at it in a non-zombie state today. It's a sequential decision making problem but the objective is to minimize the worst-case number of steps needed subject to the condition that you cannot break both rocks.

Here's my solution which ends up more rigorously deriving Phael's solution. So you drop the first rock on some floor x_1. If it breaks, you are forced to start from floor 1 and increase to x_1-1 until the rock breaks, at which point you know the answer in x_1 steps. If it doesn't break, you get to choose another floor x2 to drop the first rock, where if it breaks you have to ascend from floor x_1+1 to x_2-1, which makes you take x_2-x_1+1 steps. Extending this reasoning to general x_k, the worst case becomes x_k - x_{k-1} + k-1.

So the problem can be formulated as choosing x1, x2, ..., xN to minimize max_k {x_k-x_{k-1}+k-1},

Let the number of steps that strategy G takes given the answer is F be G(F). Now consider the space of strategies that contains those that are valid (always outputs a solution) and never perform useless drops (ones that give no additional information); call that space S. Obviously this space of strategies contains the optimal strategy. Then for all G in S, G(F) summed over F=1 to N is the same. I think this is a safe assertion that could be easily proved via a proof by contradiction.

Then, we conclude that in order to minimize the maximum number of steps, the number of steps required for each possible F in the optimal strategy should be the same. So we need to find x_1, ..., x_M such that x_k-x_{k-1}+k-1 for all k from 1 to M, and where M <= N. The unique solution to that recurrence relation is Phael's solution.
Shady Sands
Profile Blog Joined June 2012
United States4021 Posts
November 22 2012 01:49 GMT
#57
FYI, I heard this in a Google interview. I guess this is somehow related to indexing and searching webpages?
Что?
zlefin
Profile Blog Joined October 2012
United States7689 Posts
November 22 2012 01:53 GMT
#58
1.
since question is poorly formulated; i get to interpret it to my convenience.
drop it from the top floor, if it doesn't break, it won't break at any floor; hence
it is the highest floor from which a rock dropped will not break (since tehre is no higher floor).
question doesnt' say whether to look for best or worst case scenarios; so i choose best case
Great read: http://shorensteincenter.org/news-coverage-2016-general-election/ great book on democracy: http://press.princeton.edu/titles/10671.html zlefin is grumpier due to long term illness. Ignoring some users.
LockeTazeline
Profile Blog Joined June 2012
2390 Posts
November 22 2012 02:18 GMT
#59
I think:

+ Show Spoiler +
Drop it from the midway point of the available floors, rounded up.

Longest solve (answer 1st floor):
-50 (break)
-25 (break)
-13 (break)
-7 (break)
-4 (break)
-2 (break)
-1 (break)

=7

Overall: Log 2 of n. (rounded up)
targ
Profile Blog Joined December 2010
Malaysia445 Posts
November 22 2012 03:50 GMT
#60
On November 21 2012 06:55 AiurZ wrote:
fastest way to find out is to drop from 10th floor, then 20th floor, then 30th floor, etc. until it breaks and then you drop the 2nd rock ascending each floor 1 by 1.

for an n-floor building u just find the minimum of (n/x)+x=y and that is the amount of floors u skip each try (for a 100 floor building it is 10).


This was my original idea too, just get the minimum of (n/x)+x-1=y, I think you missed out the -1, because say you drop and break on the tenth floor then you only need to drop the second rock nine times. However this only yields the optimal solution in the case that x is fixed, so it is less optimal that the 14 + 13 + 12... solution.

Binary search would be fastest if we had more rocks, but since we only have two its not workable.
http://billyfoong.blogspot.com/ my other opinions are here
Ota Solgryn
Profile Blog Joined January 2008
Denmark2011 Posts
November 22 2012 08:37 GMT
#61
On November 21 2012 23:25 DarkPlasmaBall wrote:
Show nested quote +
On November 21 2012 22:46 Ota Solgryn wrote:
On November 21 2012 21:47 Rannasha wrote:
On November 21 2012 19:48 Ota Solgryn wrote:
On November 21 2012 06:40 Shady Sands wrote:
Imagine you have, at most, two identical rocks and a 100-floor building.

Using only the method of dropping a rock from a certain floor and seeing whether it will crack open or not, what is the least number of drop attempts you need to use to figure out the highest floor from which a rock, dropped, will not break?

1) Breaking is ordinal--a rock that breaks from a 60 floor etc. can be safely assumed to break from a 70 floor drop, etc.

Once you have calculated this for the 100-floor building, what is the answer for an n-floor building?


The least number of drops you need to use is 2. You drop the first rock from n+1 floor -> it breaks. You drop the next rock from n floor -> it doesn't break. So now you know the highest floor from which is doesn't break is the n floor.

Except you don't know what n is.

I did it this way becuase the question is the least number of drops.
Most people here seem to calculate what is the maximum number of drops you would need to use in the case you have the most optimal way of generally finding the highest floor of which the rock would be intact.


What you answered is the least number of drops you need to verify that the highest non-breaking-floor is n, when n is provided a priori. If n is not known, you need to the "best worst-case-scenario", which is what people have been calculating.


No, I provided the least number of drops you need if you make a lucky guess, I do not need to know n, nowhere does the question state that you could not make guess, and be lucky with that guess. Anyhow, I just answered it as was it a trick question, which to me it is, because of a vague formulation.


While I understand that possible ambiguity/ need to be clever, I'm also pretty sure that based on the context, you really understood that it wasn't a trick question. It means for any given floor, the fact that you're always looking to optimize your answer (not just "get lucky"), and the understanding that you can't risk both rocks breaking without knowing for a fact what the correct floor is. You can't just arbitrarily say, "I choose to pick the two perfect floors to give me the correct answer, meaning the answer's two", because you're incapable of knowing for sure that you'd pick those two ideal floors. You'd need to already know the answers, and then drop the rocks to reconfirm them. However, as the person dropping the rocks, you don't actually know yet what those ideal floors are.

I mean, after all, if you really want to be a dick about it, why not just say, "Well I was super lucky in my individual trial because the answer was "the rock breaks at the first floor" and I dropped my first rock on the first floor and it broke, and therefore I didn't even need the second rock. Answer's one." It's really missing the point of the brain teaser, because if it hadn't broken, I would have only eliminated one floor in one step, and I'd still have ninety-nine to go... and you simply can't work under the assumption that it will be the first floor, so it's silly to pick floor one to drop the first rock. It will be better for you (probability-wise) to drop the first rock at floor two at step one than at floor one.


Yeah, you're right, I was trying to be clever ;o) but my point still stands.
The least number of drops you would need to show the highest floor from which the rock will not drop is still 2, and here I do not assume that I know the floor, I assume the specific case in which a lucky guess was made. And this specific case would yield the result of least dropped rocks: 2.

Your last paragraph I also commented on, but I excluded this as the answer becuase if the rock breaks at the first floor then there is no floor from which the rock survives a drop and the answer is not 1 but null.
ihasaKAROT: "Wish people would stop wasting their lives on finding flaws in others"
Rannasha
Profile Blog Joined August 2010
Netherlands2398 Posts
November 22 2012 09:30 GMT
#62
On November 22 2012 11:18 LockeTazeline wrote:
I think:

+ Show Spoiler +
Drop it from the midway point of the available floors, rounded up.

Longest solve (answer 1st floor):
-50 (break)
-25 (break)
-13 (break)
-7 (break)
-4 (break)
-2 (break)
-1 (break)

=7

Overall: Log 2 of n. (rounded up)


You only have 2 rocks you can break, not 7.
Such flammable little insects!
Normal
Please log in or register to reply.
Live Events Refresh
Next event in 11h 39m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nina 299
NeuroSwarm 125
StarCraft: Brood War
Nal_rA 218
MaD[AoV]101
Sexy 52
JulyZerg 30
Icarus 9
ivOry 5
ggaemo 1
Dota 2
monkeys_forever402
Counter-Strike
Coldzera 179
Other Games
summit1g9576
shahzam796
JimRising 493
C9.Mang0220
ViBE185
Livibee145
Organizations
Other Games
BasetradeTV24
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• Berry_CruncH235
• Hupsaiya 62
• davetesta50
• practicex 29
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Lourlo924
• Stunt379
Upcoming Events
WardiTV European League
11h 39m
MaNa vs NightPhoenix
ByuN vs YoungYakov
ShoWTimE vs Nicoract
Harstem vs ArT
Korean StarCraft League
22h 39m
CranKy Ducklings
1d 5h
BSL20 Non-Korean Champi…
1d 7h
Mihu vs QiaoGege
Zhanhun vs Dewalt
Fengzi vs TBD
WardiTV European League
1d 11h
Online Event
1d 13h
Sparkling Tuna Cup
2 days
BSL20 Non-Korean Champi…
2 days
Bonyth vs TBD
WardiTV European League
2 days
Wardi Open
3 days
[ Show More ]
OSC
3 days
uThermal 2v2 Circuit
5 days
The PondCast
6 days
Liquipedia Results

Completed

BSL 20 Non-Korean Championship
FEL Cracow 2025
Underdog Cup #2

Ongoing

Copa Latinoamericana 4
Jiahua Invitational
BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Qualifiers
CC Div. A S7
IEM Cologne 2025
FISSURE Playground #1
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025

Upcoming

ASL Season 20: Qualifier #1
ASL Season 20: Qualifier #2
ASL Season 20
CSLPRO Chat StarLAN 3
BSL Season 21
RSL Revival: Season 2
Maestros of the Game
SEL Season 2 Championship
WardiTV Summer 2025
uThermal 2v2 Main Event
HCC Europe
CAC 2025
Roobet Cup 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.