6 kyu
Micro-World
69 of 202sazzadshopno
Loading description...
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
There is
using namespace std;
in C++ Preloaded section which should be removed. See: https://github.com/codewars/content-issues/wiki/List-of-Cpp-Kata-to-UpdateFixed
JavaScript translation. Please, review and approve.
Added code-blocks for all languages. Slightly restructured the description, and removed a couple typos.
Thanks, Approved.
Ruby translation. Please, review and approve.
Note: will add code-blocks later.
Approved.
Python translation. Please, review and approve.
Note: will add code-blocks later.
Approved.
You should add fixed tests where multiple bacterias with the same highest number survive, e.g.
{1, 2, 3, 4, 5, 5}, k = 1
(2 bacterias survived) or{1, 3, 5, 5}, k = 1
(4 bacterias survived).Added some fixed cases..
Are you sure your reference solutions for the random tests are correct? e.g:
This comment has been hidden.
41 cannot eat 41 because
41 >n't 41
, so they both survive;-)
Sorry, but amount of last bacteries who cannot eat each other depend of sequence of eating. That is not good. As example: [ 1, 2, 3 ], k = 1. If at first bacteria #3 will eat bacteria #2 that later it cannot will eat bacteria #1 and amount of bacteria is 2. But if at first bacteria #2 will eat bacteria #1 that later bacteria #3 can will eat bacteria #2 and amount of bacteria is 1. We can get different answers...
It doesn't matter because kata asks us to
We're only interested in the minimal possible number.
Cool name, but it doesn't explain what's the idea behind this
K
.What is this supposed to mean?
a <= a + b
is always true forb >= 0
and always false forb < 0
.IMO, right now the description is terrible, and explains pretty much nothing.
Sorry, It was a typo.. It should be a[i] > a[j] and a[i] ≤ a[j] + K if this condition satisfies then only a a[i] can destroy a[j].
Okay, now the borders are correct, but this still doesn't explain what's happening. How do we choose
i
andj
(i.e. who eats and who gets eaten)? As I see it, in({20, 15, 10, 15, 20, 25} , 5)
bacteria with number25
can eat everything else, because all other bacterias satisfy the rulea[j] < 25 <= a[j] + 5
- the answer is1
. Same thing happens with({101, 53, 42, 102, 101, 55, 54} , 1)
- bacteria with number102
eats everyhting becausea[j] < 102 <= a[j] + 1
- somehow the answer is3
???The one of possible sequences of swallows is: {101,53,42,102,
101,55,54} → {101,53,42,102,55,54} → {101,42,102,55,54} → {42,102,55,54} → {42,102,55}. In total there are 3 bacteria remained in the Petri dish.Why do
42
and55
survive?102
can eat those 2 bacterias as well...102
is greater than42
but42 + 1
is less than or not equal102
so102
can not eat42
, also same thing happens for55
. So these3
bacterias only survives.Okay, now I see it, thanks.
Also, you should remove
"The bacteria can perform multiple swallows. On each swallow operation any bacteria i can swallow any bacteria j if bacteriai > bacteriaj and bacteriai ≤ bacteriaj + K. The swallow operations go one after another."
from the description - you're duplicating one of the previous sentences.Removed. :)