21
Artyom Koval
Last seen 1 year ago
Member for 11 years, 7 months, 3 days
Difficulty Normal
Check for iterator stRange
class strange:
s = 0
i = 0
def __init__(self, n):
self.n = n
def __iter__(self):
self.s += 10
return self
def __next__(self):
if self.i < self.n:
i = self.i
More
If this problem was in "Easy go" area, then this solution is most "unusual" of all.
More
Wow. Pretty cool solution.
Btw, `lru_cache` default maxsize is 128, if you just increase it a little bit it should work even faster.
More
Math solution works well for examples in task and short sequences. It uses long arithmetic with numbers about 10^number_of_brackets, so it has only theoretical concern.
More
Hi, slicing is more "pythonic" than indexing.
Instead of
sum(a[i] for i in range(max(0, x-1), min(len(a), x+2))
Try:
sum(a[max(0, x-1):x+2])
More
It doesn't work with `assert sort_by_ext(['...cad', '1.bat', '..cad']) == ['...cad', '..cad', '1.bat']`
More
A little explanation for future myself.
* Dfs is not required for tests on this website. When dfs starts here, the problem is already solved. However, it's not guaranteed for all possible tasks.
* Some parts of code could be deleted here and it would even make algorithm faster on the provided test
More
Instead of ```len(lst) > 0``` and ```not len(lst)``` pep8 recommends to use ```lst``` and ```not lst```
More