13
grutte_pier
11 24
743/ 845
Jakob van Bethlehem
Last seen 5 years ago
Member for 10 years, 4 months
Difficulty Normal
Best reviews / Newest reviews
First-AbnerZheng24 1
If you have that much code in common, you should probably think about refactoring the common parts into a function of its own. Also you should probably have a look at the _next_ function - that one would have saved you from using a flag, which again would have simplified the core part of the algori More
Product-spoty
Nice one - not sure whether it would the speediest out there though; you're still comparing every word with every other word. More
First-RomanZhyvitski
Last four lines could be more clearly written as: return alphabet == "" More
First-Federigo 1
The last four lines could be written much consizer as: return len(lst) == 26 More
First-kamikaze 1
You're comparing every word with every other word - that's not speedy! More
Can it be done shorter?-grutte_pier
I guess the answer to my own question is 'yes' - at the very least I could have saved some spaces ;) More
First-vishal.02jan
_abs_ is already a function, so no need to create a separate _lambda_ for it: sorted(numbers_array, key=abs) is enough! More
First-konrad.gadzina
If you intentionally didn't want to use the _key_ parameter to _sort_ and _sorted_ that's fine - otherwise I'd suggest you to learn it, see https://docs.python.org/2/library/functions.html#sorted More
First-xiongbiao
Hm, using _%_ to format is really old fashioned nowadays - I'd urge you to start using the _format()_ function, see https://docs.python.org/2/library/string.html#formatspec More
First-cizeko
Python programmers typically wouldn't write very long lines (PEP8 for instance even suggests a limit of 79 characters) - better divide the _corners_ and _repr_ functions over multiple lines More
First-RomanZhyvitski 1
Variable names _i_ and _j_ are not very descriptive .... Better use something like _word1_ and _word2_ or something alike. You could also simplify by replacing lines 6, 7 and 8 by: if j in second: common.append(j) instead of writing a nested loop. This is a slightly better description o More
First-GreggLeventhal
After a construct like this: if test: return result there really is no need to write the _else_ - if the _test_ succeeds, the _return_ will immediately exit the function/method, so the code after it will not be executed More
First-agdk26
You could simplify the nested _if-elif-else_ construct by simply writing three _if_ s, because you _return_ anyway! That actually better fits your intentention as well (as the three scenarios are mutually exclusive to each other) More
Iterative-CRoig
Instead of storing a _cowString_ in your first _if_-branch, you could also immediately just return that string, saving you having to write the _else_-branch, and saving a full indentation level, which keeps the code slightly better readable. Unless of course you happen to be one of these 'one-exit'- More
First-jcg
Never implement features that are not requested! More
THY-_THY_
You really should have a look at other solutions and learn from it. A view things that are just really wrong in Python: * Never do _tmp == False_ - just say _not tmp_ - this is true for any programming language in the world, actually * Never do _for i in range(len(text))_: you should loop over the c More
First-brenninc
Better use _enumerate_ in the for-loops: for row_idx, row in enumerate(matrix): for col_idx, number in enumerate(row): # etc ... Also this solution counts every region as many times as it is big: so every connected region of size _x_ is also counted _x_ times - that could b More
First-PAY
Pass the _matrix_ as argument to _count_ - making it a global is really, really, ugly More
Simple approach-easternHeretic
It seems your 'simple' approach is what most other authors have done as well. What you could improve upon is to prevent to count each cell of size _x_ also _x_ times - in other words: skip locations you already visited And don't do _for i in range(len(l))_ - it's really non-Pythonic; instead do: More
Second-jpc
It is not quite clear to me why you need the _sorted_ if you're already looping over _string.ascii_lowercase_, which is already sorted. It should be possible to write in such a way that a final sort is not necessary. More
1 2
3
4 5