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.
Super easy to read!
that's a very good question...
._.
What is being repeated that shouldn't be in this solution?
have you used
timeit
to compare the performance of yourCounter()
solution with this one? I personally believe that your solution could be 10X slower.Repeating code doesnt automatically ruin a solution. In this case it is actually very readable and writing this in another way would make it unclear for no reason
How could this be "best practices"? 0_o
Time complexity is O(n^2), would not consider it as 'best practices' while there are more optimal solutions (e.g. see Counter).
But useless
=~)
ok i'm not the only one, I thought of this first and was like nope thats O(n)...
this is the way
Best practices doesn't mean the absolute most efficient code possible, especially at the expense of readability. This solution is bog-standard, 101 level programming. It's impossible for this to be a bad practice besides the lack of brackets on the if-statement which people have mixed opinions about.
Now you can use:
from math import gcd
but I guess this solution was created before Python 3.5.Simply beautiful.
Yes, there is solution in O(1) time, but this solution is O(n)
This can't be best practice no matter how you look at it.
Loading more items...