Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
I agree 100% that this is an off-by-one error. If, as the description suggests, the
target_floor
(highest floor before the egg breaks) is1 <= target_floor <= max_floor
, and we are to findmax_floor
, then(n, m) = (0, 0)
implies thatmax_floor = 1
.If you instead use the definition that
0 <= target_floor <= max_floor
then this is equivalent to solving the problem from the other perspective and then subtracting1
from the resultingmax_floor
. Indeed, if you consider the algorithm for finding thetarget_floor
, and if from the start it is assumed thatk <= target_floor
for somek
, then it is useless for the algorithm to check any floors at or belowk
. This effectively shifts the algorithm's search byk - 1
places and thus shifts the resultingmax_floor
by the same amount.The 0 answers do make sense, but that the target floor can't be 0 is weird: what if the egg breaks even if dropped from floor 1? then there is no maximum floor from which the egg won't crack and the logical answer (to the actual floor determination problem) would be 0.
And all of this is sort of a problem because it can lead to some off-by-one errors due to this 'floor zero' thing. I think this has to be clarified somehow in the description.
With 0 eggs and 1 floor you don't know if the egg would break while dropping from floor #1 or not, as you have 0 eggs to test. So it's proper to return zero here as if a house would have 0 floors, we can say that throwing eggs from that height won't break them even having no eggs.