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.
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)
This comment is hidden because it contains spoiler information about the solution