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.
...looks pretty though
Went into comments just to say that, thanks dude for doing the work for me.
This comment is hidden because it contains spoiler information about the solution
that's normal initialisation of variables, the data type doesn't matter
makes the code more compact
modulo operation correct?
If what you mean is how it works, in here it prevents Index out of range by taking the leftover of a division.
So by having the length of the original list when the number goes higher it instead loops arround to 0 every multiple of it.
Sorry for being dumb. can someone please explain how is the modulo operation correct?
Thanks
is it best practice to assign variables like this, when i and ys are different data types? I guess I can get used to it but it was confusing to look at at first.
I did the same, but with two caveats:
You could also just use
while xs:
instead ofwhile len(xs) > 0
.I think it's because negative values can be divided by -1 as well as one and themselves? Don't quote me on that though :)
Recursive solutions aren't more "elegant" than iterative solutions. IMO this is misleading. In JavaScript it is very common to write iterative solutions in replacement of recursive solutions, for various reasons such as performance.
Why is it that (-7) is not considered a prime?