Ad
  • Custom User Avatar
  • Custom User Avatar

    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) is 1 <= target_floor <= max_floor, and we are to find max_floor, then (n, m) = (0, 0) implies that max_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 subtracting 1 from the resulting max_floor. Indeed, if you consider the algorithm for finding the target_floor, and if from the start it is assumed that k <= target_floor for some k, then it is useless for the algorithm to check any floors at or below k. This effectively shifts the algorithm's search by k - 1 places and thus shifts the resulting max_floor by the same amount.

  • Custom User Avatar

    Respectable approach for sure, but I still feel that being able to prove the answer is what you suspect it to be is also a pretty important skill (not sure if that's what you meant or not).

  • Custom User Avatar

    Realy good Kata! Thanks to author!

  • Custom User Avatar
  • Default User Avatar

    Extremely poorly explained.
    Misses the point of programming exercises entirely,
    as programming knowledge is completely secondary
    to the task at hand.

    If you're interested in Katas that involve programming, skip this one.

  • Default User Avatar

    Exactly - if it does not break at 3, you know it will break at 4 since you tested it.
    If you alter the decision tree, you'd have no idea whether floor 4 breaks eggs, you only know that floor 5 breaks eggs and floor 3 does not.

    If it helps, extend your tree with the result - if you have more tries then eggs, you'll reach a result once the last egg breaks, eg. down from 1 you get the result 0, down from 2 you get the result 1,... and to the very right, next to the 10-throw you omitted if no break occurs at 9, the results are 9 or 10.

  • Custom User Avatar

    assume we have 2 eggs and 4 try

    from what i understand, the decision tree behind the answer is that

    down is break, rigth is survive
    4 ----- 7 --- 9
    |       |     |
    1-2-3   5-6   8
    

    the answer is 9

    but if it did not break at 3 or 6 or 8, we know its 1 above it since we already tested 2 above it
    so the decision tree should be

    5 ----- 9 --- 12
    |       |     |
    1-2-3   6-7   10
    

    the answer should be 12

    im not sure if i misunderstand it or i should put it into issue

  • Custom User Avatar

    Am I doing something wrong or are we restricted to using only BigInteger?

  • Custom User Avatar

    suggestion closed

  • Custom User Avatar

    That is really silly then. This should be on mathwars.com, not codewars.com.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Took me a minute to understand the question, but the test values helped. The values are:

    • n - number of eggs available
    • m - number of drops possible (any more would cause his heart to break)

    So for example if the values were n = 1, m = 100, the answer would be 100. Just start dropping
    your one egg at floor 1 and continue up until it either breaks or you run out of tries. So you can
    give the exact number for any floor up to 100. The actual floor might be 2000, but you can only verify up
    to 100 with one egg. If you start on any other number, for example floor 2, the egg might break. Then
    you know that floor 2 isn't safe, but you aren't sure if floor 1 is safe or not, so you can't
    give a correct answer.

  • Custom User Avatar

    Whether there is an issue or not, this isn't the way to describe it.

    Which language? Which random test? What's the issue with it?

    Oh right, none of that is provided, so... closing.

  • Default User Avatar

    so you're saying there's no issue?

  • Loading more items...