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.
This is cool, but it's not easy to read. Code should be as simple and easy for readability and maintainability.
true this is a good case of bad pratices the code should be/try to be easy to read to any person new to the code
Difficult to read
Mine is similar :)
So many votes for this being best practice. This is not best practice. Readability > Complexity.
Do only I have to my_eyes.split() to read that code?
If you want
ridiculous
, check mine out, lolAnd we all seek ridiculous one-liners in solutions section - that's a lot of fun.
In my opinon, his solution is easier to read thatn yours, and you have used too many unneccesary lambda functions further increasing the complexity. The other solution did the same thing without the use of multiple or no lambda functions :)
also the short versions will usually pop up as the first - meaning those that dont plan on looking through lots of different solutions will just drop their vote on the first clever-looking solution they see, and move on.
I'm pretty sure this one-liner will get you failed in a google interview. More than one "for" clauses in a list comprehension is not permitted per Google style guide 2.7.4. When things get complicated they'd rather see for loops, even though list comprehension has an internal overhead optimization (about 2x faster).
creating a list is an overkill in this case
Ok, thank you. I'll keep that in mind looking through solutions here.
There's no "right" answer to your question. In Python, generally speaking, readability is valued above terseness (it's a driving aspect of the languages design and syntax).
That said, you shouldn't look to kata solutions to find "good coding practice", unfortunately. Few people actually care, most just want to solve and move on. Shorter code is faster to write, obviously.
As for "clever" and "best practices", those are ironically completely misleading, since short, confusing and "clever looking" usually attracts many votes from users who simply don't know better, even when the code, in practice, is terribly inefficient.
This comment is hidden because it contains spoiler information about the solution
Loading more items...