Code Challenge #17: August 2, 2017
Every week, we feature the type of brainteasing question that might be asked in a fullstack developerās job interview at places such as Google and Facebook.
This weekās challenge was reported to have been asked in interviews at Microsoft:
Basic Difficulty
Suppose that you had 100 eggs in a 100floor skyscraper, and you wanted to conduct an experiment to find out the highest floor (
criticalFloor
) from which you could drop an egg without breaking itā¦ but youāre also really hungry so you donāt want to waste any eggs.Write a function,
minEggDropper100
, that will determine the minimum number of egg drops (minDrops100
) youād need to find thecriticalFloor
.

Function Name:
minEggDropper100

Output:
minDrops100
ā an integer representing the minimum number of drops needed to find thecriticalFloor
 An egg that survives a fall can be used again.
 A broken egg must be discarded.
 The eggs are all incredibly similar ā the effect of a fall from a particular floor is the same for all eggs.
 If an egg survives a fall from floor
n
, then it would also survive a fall from the floors below it: floorn1
, floorn2
, etc.  If an egg does not survive a fall from floor
n
, then it would also not survive a fall from the floors above it: floorn+1
, floorn+2
, etc.  You should not presume that an egg would survive a fall from the first floor, nor should you presume that it would not survive a fall from the 100th floor!
 Much of the challenge in this problem is in formulating your strategy for egg dropping ā interviewers want to see how you think in breaking down and solving this problem. Perhaps consider first how you would solve this problem with only one egg. Then think how youād solve this problem with infinite eggs without any code. After that, think how you can use coding to find
criticalFloor
more efficiently. Remember: the challenge is not to find
criticalFloor
itself! Your function should return the minimum number of egg drops you need to findcriticalFloor
.
 Remember: the challenge is not to find
 Try not to Google for help or check other responses online for solutions or help ā see how you can solve this problem yourself!
Donāt forget: you must explain your thought processes and solution!
Find out more about basic challenges.
Intermediate difficulty
Youāre at another 100floor skyscraper and want to perform another experiment but this time you have only two eggs.
Write a function,
minEggDropper2
, that will determine the minimum number of egg drops (minDrops2
) youād need to find the highest floor (criticalFloor2
) from which you could drop an egg without breaking it.

Function Name:
minEggDropper2

Output:
minDrops2
ā an integer representing the minimum number of drops needed to findcriticalFloor2
 Donāt forget to explain your work!
Find out more about intermediate challenges.
Hard Difficulty
Write
minEggDropperX
that will test forx
many eggs andy
many floors. Please write this as efficiently as possible!
 Donāt forget to explain your work!
Find out more about hard challenges and Big O
Reply
to this thread with a link to your code on repl.it and paste your properly formatted code to participate! Donāt just submit your code, remember to explain
your solution, too! If you want to be considered as the winner, it is vital that you walk us through your thought processes, including how you made your strategy for testing egg dropping. As always, please abide by our other simple rules.
As is the case in interview settings, solutions using imports to do all the heavy lifting such as itertools
will not be considered for the winner.
When including your repl.it link, please just give us the link and not the code preview! Just put a space before your URL so that the preview box doesnāt show ā too many preview boxes can make the thread hard to read.
The fine print:
Click the links to find out more about:
 the rules & how to participate in challenges
 how challenges are used as job interview questions
 why Codecademy runs challenges (and why they are formatted this way)
 more details about the challenges and why we think they are useful.
 find previous challenges (and see the past winners) in our Challenge Index