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.
I tested it out. Version without set() is much much slower than any other solution pasted here.
This should not be best practices.
Time of execution for long text of this version: 0.27908778190612793
time of exection for long text where you iterate over set: 0.0005300045013427734
@noweare
yes, it is one of the greatest features of this site
CPU go brrrrrrrr
That's the thing, they aren't. It's a culture thing :D
People just upvote one-liners as best practice for the sole purpose that it compacts more code into a smaller space and is thus seen as minimalist or cool.
Of course, sometimes (such as for list comprehensions or for cases where it's easier to use a built-in function) one-liners are actually best practice, but half the time, it's more likely to be someone using some esoteric, relatively niche and/or inefficient code in a one-liner.
But it's been 11 months so you probably know by now.
i had the same answer, but split into two lines 'cause of the indent. It's a great habit to get used to, especially for larger and more complex projects, so it's easier to read.
great job.
one liners can be clever, but not best practice most of the time (I agree with you)
This solution is very inefficient, being O(n^2), when it easily could have been made O(n)
Not every one-liner is clever or best practice.
@sztssp
Maybe perhaps it won't be for a larger data! (like an entire paragraph)!!! Would be a good experiment to test it!
Nice, but parenthesses are unneccesary here :>
I fully agree with you. It should not be. This is not so clear especially for the beginners like me.
Why are these one liners considered better practice than splitting it into a second indented line?
Thought I would be the first)
Could anyone explain why this is O(n2) instead of O(n) please?
Now that is a one-liner!
Loading more items...