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.
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.
Thanks a lot for the clarification and explanation, would there be any cases where it would be more efficient to use math.sqrt over **?
This comment is hidden because it contains spoiler information about the solution
Never fails to suprise me with how they always upvote the worse solution
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.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Is math.sqrt() not faster than **0.5?
thanks for this comment made it easy to understand
This comment is hidden because it contains spoiler information about the solution
Approved
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 is0
, 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 is1
, since with the four jars, beingA B C D
, he can take pills from jarsA B
, and his friend from jarsB C
(If neither of them glow,
D
is the right pill. If Andrzej glows, it isA
, or if his friend glows, it isC
. If they both glow, it isB
)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 be0
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)
It only requires basic math knowledge, so seemed pretty concise to me.
If you have a more intuitive one, you can add it here.
but no
n - 16 test - 3 How? Java
Loading more items...