Ad
  • Custom User Avatar

    Be sure to only recurse until the number of items in signature become greater than n.

  • Default User Avatar

    it seems like if someone explained why the code terminates, a comment three years from now would be asking why the code doesn't terminate, and this would just go on forever...

  • Default User Avatar

    Can you explain me why and how does the recursion terminate ? I'm new to coding

  • Custom User Avatar

    You've responded with this multiple times but I don't understand what you mean by "don't mutate the input." Why would we be mutating the input?

  • Custom User Avatar

    Lol. Can't see my original post because I haven't solved the kata and it's marked as spoiler. Why doesn't codewars know I'm looking at my own comment? Sometimes this site is dumb. :)

  • Custom User Avatar

    Python tests reuse the same list for all test cases for some reasons, so don't mutate the input.

    Also, the python version is a pretty bad kata translation (it doesn't even have random tests), so blame the translator, not the poor creator who already has to take the flak of people who're unaware of algorithmic complexity :)

  • Default User Avatar

    I didn't get it at first either. The length of signature is getting larger and increasing by 1 each iteration. Once the length of signature grows to > n, the recursion terminates and returns all values in the now-large signature up to n-1. There's one extra calculation of the sum it's cool. Also handles the n<=3 cases nicely.

  • Default User Avatar

    I don't know, but I blame the creator of this kata.

  • Default User Avatar

    I've got the same message.

    If I write as first instruction:

    def whoIsNext(names, r):
    print(r, names)

    I get:

    2 ['Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny', 'Penny'.....

    Second drinker should be Penny, not Leonard...
    So what is wrong?

  • 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

    Execpt the instructions for the kata give the input restrictions as this:

    Input: The input data consist of an array which contains five names, and a single integer n where 1 ≤ n ≤ 1000000000.

    But then runs a test with 7230702951 - 6.2 billion places outside the scope.

  • Custom User Avatar

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

  • Custom User Avatar

    I'll leave this issue here just so folks can see it. The author has already acknowledged the issue (see the suggestions forum), but can't change it now that so many have already passed the kata.

  • Custom User Avatar

    Ah, should have viewed the questions before I submitted my issue (mine is simply a repeat of this).

  • Loading more items...