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.
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).
damn, that runs fast
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