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.
For Python the Note is meaningless. Make sure not to modify the input of your function in-place, it is a bad practice.
All the strings are inmutable objects, nothing you can do can change the string.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I miss the oportunity to use operator.eq and finish doing an ugly double comprension. I should reread the docs of that library.
"premature optimization is the root of all evil"
So, yes, this is good enough, but is nice came to an O(0) solution, it's there at the hand of 5 years old Gauss.
I had the same tought than you, but I did a crude test with %timeit and strangely enoug this solution is faster than mine with mod and rigth shift.
Beside that, premature optimization is the root of all evil ( or something like that, I'm translating from the translation to my native lenguaje ).
I think it's really clever solution, but all the join and split can be push away from the recursion.
It's trivial in python....
2y later, but if you have the time read about topological sorting. https://en.wikipedia.org/wiki/Topological_sorting
I tried to calc the 2n term directly from the cloused form formula but the numbers are too big for the standar float, and
are too big too for a reasonable precision of the decimal module. I tested some numbers and the calculation get too long
before getting the needed precision.
So the best way is using int. I did a raw for for it. The interesting of this solution is the use of a generator that improve the readability a lot.
Excelent answer. I only did a minor change.
Strings an specialized sequence type, so you can enumerate them without converting to list.