• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 20:55
CEST 02:55
KST 09:55
  • 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
TL.net Map Contest #21: Voting9[ASL20] Ro4 Preview: Descent11Team TLMC #5: Winners Announced!3[ASL20] Ro8 Preview Pt2: Holding On9Maestros of the Game: Live Finals Preview (RO4)5
Community News
BSL Team A vs Koreans - Sat-Sun 16:00 CET5Weekly Cups (Oct 6-12): Four star herO85.0.15 Patch Balance Hotfix (2025-10-8)80Weekly Cups (Sept 29-Oct 5): MaxPax triples up3PartinG joins SteamerZone, returns to SC2 competition32
StarCraft 2
General
Revisiting the game after10 years and wow it's bad Stellar Fest: StarCraft II returns to Canada The New Patch Killed Mech! herO Talks: Poor Performance at EWC and more... TL.net Map Contest #21: Voting
Tourneys
SC2's Safe House 2 - October 18 & 19 $1,200 WardiTV October (Oct 21st-31st) WardiTV Mondays RSL Offline Finals Dates + Ticket Sales! SC4ALL $6,000 Open LAN in Philadelphia
Strategy
Custom Maps
External Content
Mutation # 495 Rest In Peace Mutation # 494 Unstable Environment Mutation # 493 Quick Killers Mutation # 492 Get Out More
Brood War
General
BW General Discussion BSL Team A vs Koreans - Sat-Sun 16:00 CET Question regarding recent ASL Bisu vs Larva game [Interview] Grrrr... 2024 Pros React To: BarrackS + FlaSh Coaching vs SnOw
Tourneys
[ASL20] Semifinal B SC4ALL $1,500 Open Bracket LAN [Megathread] Daily Proleagues [ASL20] Semifinal A
Strategy
BW - ajfirecracker Strategy & Training Relatively freeroll strategies Current Meta Siegecraft - a new perspective
Other Games
General Games
Stormgate/Frost Giant Megathread Dawn of War IV Path of Exile Nintendo Switch Thread ZeroSpace Megathread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
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
SPIRED by.ASL Mafia {211640} TL Mafia Community Thread
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine Men's Fashion Thread Sex and weight loss
Fan Clubs
The herO Fan Club! The Happy Fan Club!
Media & Entertainment
Anime Discussion Thread [Manga] One Piece Series you have seen recently... Movie Discussion!
Sports
Formula 1 Discussion 2024 - 2026 Football Thread MLB/Baseball 2023 NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
The Heroism of Pepe the Fro…
Peanutsc
Rocket League: Traits, Abili…
TrAiDoS
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1559 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 States24717 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 States25553 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 9h 5m
[ Submit Event ]
Live Streams
Refresh
StarCraft: Brood War
Britney 32937
Dota 2
monkeys_forever642
LuMiX1
League of Legends
JimRising 407
Super Smash Bros
AZ_Axe223
Heroes of the Storm
Khaldor191
Other Games
summit1g12509
ZombieGrub400
ViBE116
Trikslyr54
Organizations
Other Games
gamesdonequick3155
BasetradeTV52
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• davetesta49
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• HerbMon 78
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• Ler47
Other Games
• Scarra723
• WagamamaTV363
Upcoming Events
Sparkling Tuna Cup
9h 5m
Safe House 2
16h 5m
IPSL
18h 5m
Sziky vs Havi
Artosis vs Klauso
Monday Night Weeklies
1d 15h
WardiTV Invitational
2 days
WardiTV Invitational
2 days
Tenacious Turtle Tussle
3 days
The PondCast
4 days
WardiTV Invitational
5 days
Online Event
5 days
[ Show More ]
RSL Revival
6 days
RSL Revival
6 days
WardiTV Invitational
6 days
Liquipedia Results

Completed

Acropolis #4 - TS2
WardiTV TLMC #15
HCC Europe

Ongoing

BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
C-Race Season 1
IPSL Winter 2025-26
EC S1
Thunderpick World Champ.
CS Asia Championships 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

Upcoming

SC4ALL: Brood War
BSL Season 21
BSL 21 Team A
BSL 21 Non-Korean Championship
RSL Offline Finals
RSL Revival: Season 3
Stellar Fest
SC4ALL: StarCraft II
CranK Gathers Season 2: SC II Pro Teams
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 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.