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.
Be sure to only recurse until the number of items in signature become greater than n.
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...
Can you explain me why and how does the recursion terminate ? I'm new to coding
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?
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. :)
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 :)
I didn't get it at first either. The length of
signature
is getting larger and increasing by 1 each iteration. Once the length ofsignature
grows to > n, the recursion terminates and returns all values in the now-largesignature
up to n-1. There's one extra calculation of the sum it's cool. Also handles then<=3
cases nicely.I don't know, but I blame the creator of this kata.
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?
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
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.
This comment is hidden because it contains spoiler information about the solution
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.
Ah, should have viewed the questions before I submitted my issue (mine is simply a repeat of this).
Loading more items...