57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 20 hours ago
Member for 11 years, 6 months, 6 days
Difficulty Advanced
We shall not cease from exploration, and the end of all our exploring will be to arrive where we started and know the place for the first time.
"return None" is the same as "don't return anything". You don't need lines 5 and 12.
More
It can be even clearer [without them](https://py.checkio.org/mission/boolean-algebra/publications/veky/python-3/an-operator-by-any-other-name/). :-]
More
This is a beautiful algorithm. Too bad it's written in Java, not Python. :-P :-D
More
Kinda ok, but _readable_? No. :-P
First, CheckiO is not really a version control. And it shows. The previous attempts have nothing to do in the published solution.
And more importantly, you're using code comments wrong. (You're not the only one.) First, you "comment out" code and leave that in whe
More
LOL... that's a very roundabout way of doing it. :-) Whitelisting is much simpler than blacklisting.
collections.Counter(filter(str.isalpha, text.lower()))
And why sort before, instead of after?
And more puzzlingly, why count from start for each _instance_ of each letter??
More
I'm not quite sure what you _get_ by eliminating fractions (since you still do the same operations, just above the big common denominator), but for bragging rights, it's ok. :-)
More
Using list.append when you want a bound method is _really_ confusing. I advise you reconsider your name choices. ;-]
Don't iterate through indices if you need elements.
for x in data:
if data.count(x) != 1:
result.append(x)
And what do you think line 15 does?? Hint
More
There is much easier way to implement UnionFind. Objects don't need to be listed, associative mappings are much more intuitive. ;-)
More
If you're using i from enumerate just to index another sequence (as you do), then instead of enumerate, use zip.
for si, r in zip(s, p[1:]):
... use si instead of s[i] ...
More
First we take Manhattan. Then we take whichever is smaller of East Berlin and West Berlin...
🤣🤣
More
int(a/b) is a//b. Also, you don't have to round the result: "four digits precision" here means "(at least) four correct digits", which you can see from "±0.0001".
More
You could append fresh [] to result between lines 4 and 5. (Then it would be obvious that it's just a list comprehension.:) But this way is also ok.
range(0,bla) is just range(bla).
loop in line 5 can be more pythonic:
for row in data:
result[i].append(row[i])
More
It's not easy when you're not using the tools you have. :-] Look:
You intend to go through str1 and str2 simultaneously. That's what `zip` is for.
m = {}
for x, y in zip(str1, str2, strict=True):
if x in m and y != m[x]: return False
m[x] = y
return True
Now, you check
More
Lines 2-5: do you know what "precondition" means? :-/
Line 6: data.sort() is more readable and faster.
Line 11: I don't get why you float m. Of course you don't need to.
Lines 15-19: This is really head-scratching. Why do you do such contortions??
More
That inner while loop, with explicit x management, is unnecessary.
for letter, lnext in zip(word, word[1:]):
(you might want to end the zip earlier if your snake is too young:).
More