• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 09:32
CEST 15:32
KST 22:32
  • 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
[ASL19] Finals Recap: Standing Tall8HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Flash Announces Hiatus From ASL43Weekly Cups (June 23-29): Reynor in world title form?12FEL Cracov 2025 (July 27) - $8000 live event16Esports World Cup 2025 - Final Player Roster16Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
RELIABLE USDT RECOVERY SERVICE//TECHY FORCE CYBER The SCII GOAT: A statistical Evaluation Statistics for vetoed/disliked maps Esports World Cup 2025 - Final Player Roster How does the number of casters affect your enjoyment of esports?
Tourneys
RSL: Revival, a new crowdfunded tournament series [GSL 2025] Code S: Season 2 - Semi Finals & Finals $5,100+ SEL Season 2 Championship (SC: Evo) FEL Cracov 2025 (July 27) - $8000 live event HomeStory Cup 27 (June 27-29)
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
Flash Announces Hiatus From ASL BW General Discussion [ASL19] Finals Recap: Standing Tall BGH Auto Balance -> http://bghmmr.eu/ Help: rep cant save
Tourneys
[Megathread] Daily Proleagues [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET The Casual Games of the Week Thread [BSL20] ProLeague LB Final - Saturday 20:00 CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile What do you want from future RTS games? Beyond All Reason
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
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Trading/Investing Thread The Games Industry And ATVI
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2025 Football Thread NBA General Discussion Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
Game Sound vs. Music: The Im…
TrAiDoS
StarCraft improvement
iopq
Heero Yuy & the Tax…
KrillinFromwales
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 579 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 States24665 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
1 2 3 4 Next All
Please log in or register to reply.
Live Events Refresh
Next event in 2h 28m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Harstem 608
Lowko389
Rex 125
ProTech58
StarCraft: Brood War
Britney 48452
Rain 5233
Sea 3495
Jaedong 1828
EffOrt 986
BeSt 494
Larva 457
Stork 388
actioN 366
ZerO 343
[ Show more ]
ToSsGirL 270
Mini 251
Light 198
Snow 174
Killer 164
Last 136
Mong 124
Sharp 80
hero 74
Shinee 63
Pusan 56
Mind 44
Sea.KH 40
Rush 32
sSak 29
Nal_rA 27
ajuk12(nOOB) 21
Terrorterran 21
sorry 19
yabsab 16
Noble 16
JulyZerg 16
soO 15
PianO 14
Sacsri 13
Movie 11
GoRush 11
SilentControl 11
IntoTheRainbow 10
Dota 2
qojqva2834
420jenkins540
XcaliburYe348
Counter-Strike
x6flipin564
oskar222
byalli208
kRYSTAL_17
Super Smash Bros
Mew2King148
Other Games
hiko923
B2W.Neo840
DeMusliM705
crisheroes323
Happy192
ArmadaUGS77
QueenE35
ZerO(Twitch)25
KnowMe1
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• StrangeGG 49
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV570
League of Legends
• Nemesis6468
Upcoming Events
WardiTV European League
2h 28m
ByuN vs NightPhoenix
HeRoMaRinE vs HiGhDrA
Krystianer vs sebesdes
MaxPax vs Babymarine
SKillous vs Mixu
ShoWTimE vs MaNa
Replay Cast
10h 28m
RSL Revival
20h 28m
herO vs SHIN
Reynor vs Cure
OSC
23h 28m
WardiTV European League
1d 2h
Scarlett vs Percival
Jumy vs ArT
YoungYakov vs Shameless
uThermal vs Fjant
Nicoract vs goblin
Harstem vs Gerald
FEL
1d 2h
Korean StarCraft League
1d 13h
CranKy Ducklings
1d 20h
RSL Revival
1d 20h
FEL
2 days
[ Show More ]
Sparkling Tuna Cup
2 days
RSL Revival
2 days
FEL
2 days
BSL: ProLeague
3 days
Dewalt vs Bonyth
Replay Cast
4 days
Replay Cast
4 days
The PondCast
5 days
Replay Cast
6 days
RSL Revival
6 days
Liquipedia Results

Completed

Proleague 2025-06-28
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025
YaLLa Compass Qatar 2025

Upcoming

CSLPRO Last Chance 2025
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
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
IEM Cologne 2025
FISSURE Playground #1
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.