• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 05:26
CEST 11:26
KST 18:26
  • 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
[ASL20] Ro24 Preview Pt1: Runway132v2 & SC: Evo Complete: Weekend Double Feature4Team Liquid Map Contest #21 - Presented by Monster Energy9uThermal's 2v2 Tour: $15,000 Main Event18Serral wins EWC 202549
Community News
Maestros of The Game—$20k event w/ live finals in Paris20Weekly Cups (Aug 11-17): MaxPax triples again!13Weekly Cups (Aug 4-10): MaxPax wins a triple6SC2's Safe House 2 - October 18 & 195Weekly Cups (Jul 28-Aug 3): herO doubles up6
StarCraft 2
General
What mix of new and old maps do you want in the next 1v1 ladder pool? (SC2) : 2v2 & SC: Evo Complete: Weekend Double Feature Geoff 'iNcontroL' Robinson has passed away The GOAT ranking of GOAT rankings RSL Revival patreon money discussion thread
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament RSL: Revival, a new crowdfunded tournament series Maestros of The Game—$20k event w/ live finals in Paris Monday Nights Weeklies Master Swan Open (Global Bronze-Master 2)
Strategy
Custom Maps
External Content
Mutation # 487 Think Fast Mutation # 486 Watch the Skies Mutation # 485 Death from Below Mutation # 484 Magnetic Pull
Brood War
General
Flash On His 2010 "God" Form, Mind Games, vs JD Joined effort New season has just come in ladder BW General Discussion Flash Announces (and Retracts) Hiatus From ASL
Tourneys
[ASL20] Ro24 Group B [ASL20] Ro24 Group C BWCL Season 63 Announcement [CSLPRO] It's CSLAN Season! - Last Chance
Strategy
Simple Questions, Simple Answers Fighting Spirit mining rates [G] Mineral Boosting Muta micro map competition
Other Games
General Games
Nintendo Switch Thread General RTS Discussion Thread Dawn of War IV Path of Exile Stormgate/Frost Giant Megathread
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
Russo-Ukrainian War Thread US Politics Mega-thread The year 2050 Things Aren’t Peaceful in Palestine European Politico-economics QA Mega-thread
Fan Clubs
INnoVation Fan Club SKT1 Classic Fan Club!
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2026 Football Thread TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion
World Cup 2022
Tech Support
High temperatures on bridge(s) Gtx660 graphics card replacement Installation of Windows 10 suck at "just a moment"
TL Community
The Automated Ban List TeamLiquid Team Shirt On Sale
Blogs
Evil Gacha Games and the…
ffswowsucks
Breaking the Meta: Non-Stand…
TrAiDoS
INDEPENDIENTE LA CTM
XenOsky
[Girl blog} My fema…
artosisisthebest
Sharpening the Filtration…
frozenclaw
ASL S20 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2268 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 States24692 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 States25552 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 34m
[ Submit Event ]
Live Streams
Refresh
StarCraft: Brood War
Sea 7468
Shuttle 1931
Killer 743
PianO 583
Larva 449
Pusan 366
ggaemo 363
Hyun 300
Soma 152
firebathero 128
[ Show more ]
Rush 127
NotJumperer 26
Free 22
Noble 19
Sacsri 15
HiyA 14
NaDa 12
Dota 2
XcaliburYe501
febbydoto4
League of Legends
JimRising 407
Dendi407
Counter-Strike
Stewie2K1521
olofmeister706
Super Smash Bros
Mew2King30
Heroes of the Storm
Khaldor193
Other Games
summit1g7774
singsing1770
Happy246
SortOf111
Nina109
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• Berry_CruncH454
• Reevou 6
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos927
Upcoming Events
Sparkling Tuna Cup
34m
SC Evo League
2h 34m
Chat StarLeague
6h 34m
Razz vs Julia
StRyKeR vs ZZZero
Semih vs TBD
Replay Cast
14h 34m
Afreeca Starleague
1d
Queen vs HyuN
EffOrt vs Calm
Wardi Open
1d 1h
RotterdaM Event
1d 5h
Replay Cast
1d 14h
Afreeca Starleague
2 days
Rush vs TBD
Jaedong vs Mong
Afreeca Starleague
3 days
herO vs TBD
Royal vs Barracks
[ Show More ]
Replay Cast
3 days
The PondCast
4 days
Replay Cast
4 days
LiuLi Cup
5 days
Cosmonarchy
5 days
OyAji vs Sziky
Sziky vs WolFix
WolFix vs OyAji
BSL Team Wars
5 days
Team Hawk vs Team Dewalt
BSL Team Wars
5 days
Team Hawk vs Team Bonyth
SC Evo League
6 days
[BSL 2025] Weekly
6 days
Liquipedia Results

Completed

Jiahua Invitational
uThermal 2v2 Main Event
HCC Europe

Ongoing

Copa Latinoamericana 4
BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Qualifiers
ASL Season 20
CSL Season 18: Qualifier 1
Acropolis #4 - TS1
CSLAN 3
SEL Season 2 Championship
WardiTV Summer 2025
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
BLAST.tv Austin Major 2025

Upcoming

CSL Season 18: Qualifier 2
CSL 2025 AUTUMN (S18)
LASL Season 20
BSL Season 21
BSL 21 Team A
Chzzk MurlocKing SC1 vs SC2 Cup #2
RSL Revival: Season 2
Maestros of the Game
EC S1
Sisters' Call Cup
IEM Chengdu 2025
PGL Masters Bucharest 2025
MESA Nomadic Masters Fall
Thunderpick World Champ.
CS Asia Championships 2025
Roobet Cup 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open 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.