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.
What's this epidemic separation of return with two empty lines from the rest of the function?? Where do you get this idea, people? :-/
More
You're writing docstrings on the wrong side. :-P
Also, that action at a distance via changing retlist is much more naturally written using a generator.
More
You were very close with that "key". ;-)
return max(sorted(map), key=map.count)
Also, you don't need re. You can just use "abcdefghijklmnopqrstuvwxyz" (also known as string.ascii_lowercase) as first argument to max, and key=text.count as second. But then it's too easy. :-D
More
Line 18 is wrong. rounded gamma is _not_ necessarily equal to 180 - rounded alpha - rounded beta.
BTW why do you reinvent the wheel (in this case, builtin round function)?
More
Aargh. Don't write C# in Python. And _please_ don't use pseudoHungarian notation. It completely misses the point of Python.
Also, learn Python idioms. Many of your lines can be written in a clearer, sometimes even point-free way. In some cases you don't even need to learn new idioms, just use them
More
You could have written just `class checkio` instead of Override. :-)
More
Yes, I know I have trained people to use enumerate instead of range(len,
but when you say i, _ in enumerate then something's wrong. :-) In this
case, you can simply use an even better tool, which is zip.
More
Why didn't you just put s=0 in line 1, then you don't need line 2 at all?
Also, len() is unnecessary. Sequences are boolable.
More
Hm... you know that those superscript digits also have .isdigit property? It still works because upper 2 < upper 6, but if there was 7d, it would sort before 7s. :-/
More
At least you could do
... for r in [range(len(matrix))] for i in r for j in r
It is shorter _and_ more readable. :-)
More
result = 0 \
for item in blah: >~~> result = sum(blah)
result += item /
Builtins are cool, use them. ;-)
if len(blah) == 0: ~~~> if not blah:
Or even better, `if blah` and reverse branches. First you want to say what function does i
More
Yup, that's what you get when you apply principles from some other OO languages. "Inheritance is horrible, use composition!" Whatever. In Python, inheritance is not for building ontologies, but for reusing code. Whether "A is_a B" is completely irrelevant. What matters is how much code A can use tra
More
Line 1 is unnecessary in principle, but even if this were Python2, it would still be unnecessary, since it specifies the coding of _source text_, and there you don't have any funny characters. :-)
BTW that three-char indent really stabs the eye. ;-P
More
Not every function is a lambda. :-) There is a `str.isupper` unbound method.
And not every callable is a function, either. ;-)
find_message = partial(filter, str.isupper)
More
Cool, but third lambda is really grafted on. :-P
blah if l else 0 can be written as len(l) and blah. ;-)
Instead of add_commas, wasn't it easier to map eval over .split()?
More
Nice and clear. However, it's O(n) only if you assume that sets are O(1) to add. Generally, complexity in Python is not so clear cut in many cases.
You could have at least removed that hint about .count, if you hate it so much. :-D
BTW, a curiosity: lines 11 and 12 could have been written as a
More