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