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.
generic, works for lists and for strings (and probably iterables in general)
This is 0.4ms shorter on average.
such a cool solution
@TielaRose - In Python you can use the
timeit
module to test the time taken to run anything you are interested in.Here is a good StackOverflow post where the topic is introduced (with some explanation of what the module actually does):
https://stackoverflow.com/questions/17579357/time-time-vs-timeit-timeit
and then this is the Python Docs page https://docs.python.org/3/library/timeit.html
Then you can just google stuff like "examples with Python timeit" and see how people build their tests (and make nice graphs if you want to be fancy).
Newbie question: how do you know or find out what is faster?
Indeed I used it too
This comment is hidden because it contains spoiler information about the solution
Don't do micro-optimizations on places where it doesn't matter!
Lol.......
String concatenation is bad when you use it in long recursive functions or loops because, string being immutables, at each step of the concatenation you create 2 strings objects in the heap space (memory). But here, adding just 2 strings together, this is bullshit to say that this is not best practice...
Other ways to do the concatenation:
''.join(list of strings elements)
for unknown or long lists of strings"{}{}{}".format(a,b,c)
for short and known number of strings elementsCould you explain why is that?
String concatenation with + is never best practice in Python.
I hope the authors of this code realize that an in-place sorting takes place, i.e. xs changes.