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

    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