17
Awesome Team
Sergey Panfilov
Last seen 5 months ago
Member for 10 years, 10 months, 9 days
Difficulty Normal
Clean and readable. It's better to keep imports outside of the functions though, unless it is to break up some import loops.
More
You don't need to keep the old code ;) You can publish different versions independently.
It would be better instead
```
for i in grid[row-change_r:row+2]:
```
write
```
for row in grid[max(0, row_num-1):row+2]:
```
More
There's no need to provide `Counter` a list built with list comprehension.
It perfectly operates on generator expression, which is more memory and compute efficient:
```
c=Counter(x.lower() for x in text if x.isalpha())
```
`sorted` also has `reverse` argument and lambda function could be simplifi
More
Remember https://en.wikipedia.org/wiki/Big_O_notation and learn https://wiki.python.org/moin/TimeComplexity
What is O(?) complexity of your solution?
Think how to improve performance of your solution in `data.count(x)` and `nonunique_list.insert(i, x)` lines.
More
`data.sort` modifies `data` list in place. What if it is required to keep the original data unchanged?
Do you remember complexity of sort? ;)
Please separate operations such as `/`, `%` and operands with spaces for readability.
You could also write `2.` instead of `float(2)`
More
Nice that you used generator expression and `"".join` for filtering out, but that also means it may double memory usage in the worst case.
I like that you used `Counter`, but what if there were no implementation of `Counter`?
One character variables and list comprehension with `sorted` call look a
More
Readability counts. Please see https://www.python.org/dev/peps/pep-0008/
I like that implementation is generic in terms of the grid size.
Could you rewrite it with index slicing and sum as an exercise?
More
I'll be pushing code style to solutions ;) Unnecessary empty lines, missing spaces between operands and operations :(
`(array[n])` could be written without parenthesis
More
Obviously this is not a clear solution. Mangling with indexes makes it hard to read.
It is not a Pythonic solution as well, because overwrites builtins such as max, next. map is also a builtin in Python 2.
More
Clean readable and educational solution conforming to the Python code style.
The only downside is 3 loops over the same string.
More
There's no need to comment in provided function, solution can be put in-place.
Let's put the [PEP8](https://www.python.org/dev/peps/pep-0008/) code style aside with spacing between operators and lines ([pylint](https://www.pylint.org/) can be used for automated code style checks).
`str` is a built
More
Nice to see, that the length check can be and is implemented with regex as well.
More
Short and concise. Worth overriding the build-in `sum` function with variable having the same name in such a small scope, but better to be aware of possible side-effects in larger programs.
More
Multiplication of `sum` by `2` puzzled me for a moment, but overall it's a clear solution.
More
This is overcomplicated without the need and very inefficient.
Using `text.count(c)` in the `for c in text` loop doubles iterations over `text`.
It is better to name `unsorted_dict` as `char_counts` and add char count every time it is met:
```
char_counts = {}
for c in text.lower():
char_counts
More