6 kyu

Micro-World

69 of 202sazzadshopno
Description
Loading description...
Fundamentals
  • Please sign in or sign up to leave a comment.
  • Voile Avatar

    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-Update

  • FArekkusu Avatar

    JavaScript translation. Please, review and approve.

    Added code-blocks for all languages. Slightly restructured the description, and removed a couple typos.

  • FArekkusu Avatar

    Ruby translation. Please, review and approve.

    Note: will add code-blocks later.

  • FArekkusu Avatar

    Python translation. Please, review and approve.

    Note: will add code-blocks later.

  • FArekkusu Avatar

    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).

  • Voile Avatar

    Are you sure your reference solutions for the random tests are correct? e.g:

    bacteria = {31, 36, 18, 2, 58, 11, 41, 9, 13, 29, 15, 41, 16, 34, 58, 11, 20, 55, 49, 4, 31, 51, 32, 59, 7, 57, 15, 13, 17}, k = 2
    
    Expected: equal to 7
    Actual: 6
    
    • Voile Avatar

      This comment has been hidden.

    • ZED.CWT Avatar

      41 cannot eat 41 because 41 >n't 41, so they both survive

    • Voile Avatar

      ;-)

      Issue marked resolved by Voile 7 years ago
    • Ratibor Redoran Avatar

      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...

    • Voile Avatar

      It doesn't matter because kata asks us to

      you can only guess the minimal possible number of bacteria that will remain in your Petri dish when you finally find a microscope.

      We're only interested in the minimal possible number.

  • FArekkusu Avatar

    you know intergalactic positive integer constant K

    Cool name, but it doesn't explain what's the idea behind this K.

    if a[i] ≤ a[i] + K

    What is this supposed to mean? a <= a + b is always true for b >= 0 and always false for b < 0.

    IMO, right now the description is terrible, and explains pretty much nothing.

    • sazzadshopno Avatar

      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].

    • FArekkusu Avatar

      Okay, now the borders are correct, but this still doesn't explain what's happening. How do we choose i and j (i.e. who eats and who gets eaten)? As I see it, in ({20, 15, 10, 15, 20, 25} , 5) bacteria with number 25 can eat everything else, because all other bacterias satisfy the rule a[j] < 25 <= a[j] + 5 - the answer is 1. Same thing happens with ({101, 53, 42, 102, 101, 55, 54} , 1) - bacteria with number 102 eats everyhting because a[j] < 102 <= a[j] + 1 - somehow the answer is 3???

    • sazzadshopno Avatar
      bacteria = {101, 53, 42, 102, 101, 55, 54} and K = 1.
      

      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.

    • FArekkusu Avatar

      Why do 42 and 55 survive? 102 can eat those 2 bacterias as well...

    • sazzadshopno Avatar

      102 is greater than 42 but 42 + 1 is less than or not equal 102 so 102 can not eat 42, also same thing happens for 55. So these 3 bacterias only survives.

    • FArekkusu Avatar

      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.

      Issue marked resolved by FArekkusu 7 years ago
    • sazzadshopno Avatar

      Removed. :)