27
Федор Кудинов
Last seen 12 days ago
Member for 4 years, 9 months, 22 days
Difficulty Normal
I think this solution should be in top ))
No need to invent a wheel if it is in common library
More
nice one, clever usage of locals!
never saw format_map
simple format also can be used:
"Hi. My name is {name} and I'm {age} years old".format(**locals())
More
coords - I would suggest set usage, since position is not necessary, but remove iterates heavily through this object
More
i like this solution more than just using math.gcd function )
oh ok, this is how math.gcd actually works under the hood
More
Wow, interesting solution,
But it is expensive to use recursion here, and you have limitation in 2k elements
More
expectation is that you yield items 1 by 1
in your case you first process all items, but only then start yielding them
More
count_neighbours = lambda grid, row, col: \
looks the same as
def count_neighbours(grid, row, col):
funny, never noticed )
More
pattern = re.sub('\[\]', '[^.]', pattern)
good catch, in my solution if I find [] I return False at once, and tests still never fail
More
Nice recursive solution, I didn't manage to solve it with recursion
max_total=-1000 you could use float("-inf") instead,
this task can be solved with single loop iteration, as calling recursive function twice in body does not look very effective (I am just jealous :))
More
Nice solution as does not affect init method, given by task,
For better readability, you could move nested class from body of Capital class
More
Nice usage of strip
You can write just as
```
sum(bool(i.strip()) for i in text.split('\n'))
```
sum handles unpacking of generator comprehension,
and it is more memory wise approach
More
if you invert condition you can get rid of cumbersome if else block
return end_pointX >= s2[0] and end_pointY >= s2[1]
More
line 14 can be removed
I would suggest more descriptive names and spaces around = and > as per PEP8
More
you could make it more readable and friendly not trying to fit into minimal amount of code lines
'Readability counts.'
More
good idea with str.maketrans('AEIOUY', '000000')
you could remove symbols by re lib:
import re
re.split("\W", text)
More