Ad
  • Custom User Avatar

    To my knowledge, the only time math.sqrt would be faster would be when you're doing a large number of square roots. Probably more than you'll see in a kata (but don't quote me on that one).

    Generally I don't worry about it unless I'm doing something that is centered around a lot of square roots and I'm having issues with optimization. If I do worry about it, I have to test it anyway.

  • Custom User Avatar

    Thanks a lot for the clarification and explanation, would there be any cases where it would be more efficient to use math.sqrt over **?

  • Custom User Avatar

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

  • Custom User Avatar

    Never fails to suprise me with how they always upvote the worse solution

  • Custom User Avatar

    Yeah, that does make sense. I try to solve these in the least amount of effort though. I can't be bothered to import a module.

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    Is math.sqrt() not faster than **0.5?

  • Custom User Avatar

    thanks for this comment made it easy to understand

  • Custom User Avatar

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

  • Custom User Avatar

    Approved

  • Custom User Avatar

    Friends
    Andrzej was given a task:

    There are n jars containing an infinite number of pills, each jar containing a different type of pill. Of all the pill types, one makes the person glow about 30 minutes after taking that pill. None of the other pill types have any effect.

    His job: determain which jar contains the pills that make the person glow.
    But there is one catch: he only has 35 minutes to figure out which jar it is.(So he cannot take a pill, wait for the results and then take another one, because he will not be able to see the results). Fortunetely, he can take any number of friends he needs with him.
    On completing the task, Andrzej will receive $1,000,000. Being the honest man he is, he will split the winnings with his friends.

    Your job is to write an algorithm that will help Andrzej complete his job.

    Example:
    For n = 2, he will not need any friends, answer is 0, since he can just take a pill from the first jar, and wait for the effects.

    For n = 4, he will only need one friend, answer is 1, since with the four jars, being A B C D, he can take pills from jars A B, and his friend from jars B C
    (If neither of them glow, D is the right pill. If Andrzej glows, it is A, or if his friend glows, it is C. If they both glow, it is B)

    Note: Andrzej is not able to accurately measure time during the task.


    This might be better. I am not so sure about the need of his prize and his honesty, but for the story's sake, it seems fine. As for thinking about the whole thing, I came to a confused thought about why I am solving this for Andrzej, unless I am Andrzej. Could change it around so that the person doing the kata is the one partaking in the competition, or have it that we are working along with Andrzej (the latter could change how the problem is approached, since if we are working with him, n=4 should be 0 since there will be two people already, so no need to bring in a friend.)
    But then, I am probably just rambling on now...

    Was a great Kata none-the-less. I enjoyed it. Had no issue with the current translation (for python)

  • Custom User Avatar

    It only requires basic math knowledge, so seemed pretty concise to me.
    If you have a more intuitive one, you can add it here.

  • Custom User Avatar

    but no

  • Custom User Avatar

    n - 16 test - 3 How? Java

  • Loading more items...