• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 07:23
CET 13:23
KST 21:23
  • 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
RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15[BSL21] Ro.16 Group Stage (C->B->A->D)4Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win3RSL Season 3: RO16 results & RO8 bracket13
StarCraft 2
General
Chinese SC2 server to reopen; live all-star event in Hangzhou Maestros of the Game: Live Finals Preview (RO4) BGE Stara Zagora 2026 announced Weekly Cups (Nov 24-30): MaxPax, Clem, herO win SC2 Proleague Discontinued; SKT, KT, SGK, CJ disband
Tourneys
RSL Offline Finals Info - Dec 13 and 14! StarCraft Evolution League (SC Evo Biweekly) RSL Offline FInals Sea Duckling Open (Global, Bronze-Diamond) $5,000+ WardiTV 2025 Championship
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress Mutation # 500 Fright night Mutation # 499 Chilling Adaptation
Brood War
General
BW General Discussion Which season is the best in ASL? Data analysis on 70 million replays BGH Auto Balance -> http://bghmmr.eu/ [ASL20] Ask the mapmakers — Drop your questions
Tourneys
[Megathread] Daily Proleagues [BSL21] RO16 Group D - Sunday 21:00 CET [BSL21] RO16 Group A - Saturday 21:00 CET [BSL21] RO16 Group B - Sunday 21:00 CET
Strategy
Current Meta Game Theory for Starcraft How to stay on top of macro? PvZ map balance
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread ZeroSpace Megathread The Perfect Game Path of Exile
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
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas TL Mafia Community Thread
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread Things Aren’t Peaceful in Palestine The Big Programming Thread Artificial Intelligence Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Where to ask questions and add stream? The Automated Ban List
Blogs
Physical Exertion During Gam…
TrAiDoS
James Bond movies ranking - pa…
Topin
Thanks for the RSL
Hildegard
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1516 users

brain teaser

Blogs > Shady Sands
Post a Reply
1 2 3 4 Next All
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 States24744 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
Norway869 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 States25556 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
1 2 3 4 Next All
Please log in or register to reply.
Live Events Refresh
Next event in 3h 38m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 197
ProTech115
Lowko108
StarCraft: Brood War
Britney 25994
Calm 4408
Hyuk 1839
Shuttle 1591
Horang2 1504
GuemChi 1343
Jaedong 813
actioN 531
Larva 439
Light 389
[ Show more ]
EffOrt 352
firebathero 316
BeSt 291
Mini 268
Zeus 205
Rush 204
Last 203
Snow 140
Soma 135
Backho 131
Hyun 114
Pusan 99
ZerO 80
Soulkey 74
hero 70
sorry 68
ggaemo 64
Barracks 58
Sharp 48
yabsab 46
ToSsGirL 44
Sea.KH 39
Sacsri 38
Killer 37
Mong 32
Shine 26
Shinee 25
Icarus 21
soO 19
Bale 16
Noble 14
scan(afreeca) 12
ajuk12(nOOB) 12
JulyZerg 10
SilentControl 7
Hm[arnc] 6
Terrorterran 4
Dota 2
singsing1545
XcaliburYe191
Counter-Strike
zeus10681
fl0m1787
olofmeister1125
x6flipin544
shoxiejesuss538
Other Games
B2W.Neo789
crisheroes474
Hui .191
KnowMe75
Mew2King62
MindelVK15
ZerO(Twitch)14
Organizations
StarCraft: Brood War
Kim Chul Min (afreeca) 453
StarCraft 2
WardiTV246
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 12 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• lizZardDota270
League of Legends
• Jankos2537
Upcoming Events
OSC
3h 38m
Demi vs Mixu
Nicoract vs TBD
Babymarine vs MindelVK
ForJumy vs TBD
Shameless vs Percival
Replay Cast
11h 38m
Korean StarCraft League
1d 14h
CranKy Ducklings
1d 21h
WardiTV 2025
1d 23h
SC Evo League
2 days
BSL 21
2 days
Sziky vs OyAji
Gypsy vs eOnzErG
OSC
2 days
Solar vs Creator
ByuN vs Gerald
Percival vs Babymarine
Moja vs Krystianer
EnDerr vs ForJumy
sebesdes vs Nicoract
Sparkling Tuna Cup
2 days
WardiTV 2025
2 days
[ Show More ]
OSC
3 days
BSL 21
3 days
Bonyth vs StRyKeR
Tarson vs Dandy
Replay Cast
3 days
Wardi Open
3 days
StarCraft2.fi
4 days
Monday Night Weeklies
4 days
Replay Cast
4 days
WardiTV 2025
4 days
StarCraft2.fi
5 days
PiGosaur Monday
5 days
StarCraft2.fi
6 days
Tenacious Turtle Tussle
6 days
The PondCast
6 days
WardiTV 2025
6 days
Liquipedia Results

Completed

Proleague 2025-11-30
RSL Revival: Season 3
Light HT

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
CSCL: Masked Kings S3
Slon Tour Season 2
Acropolis #4 - TS3
META Madness #9
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
Kuram Kup
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
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.