57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 2 hours ago
Member for 11 years, 6 months, 7 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.
"lambda c: c.isalpha()" has a much shorter name: str.isalpha. Eta-reduction. ;-)
More
When you see that pink colored identifiers, Python is trying to tell you something. Use a builtin, don't invent wheel all over again.
Also, nitpick: line 3 should be mn = mx = args[0].
More
res: don't do this. It's much slower with no reason. Use for-else.
for x, y, r in previous:
if round(math.hypot(i-x, j-y)) != r: break
else: return [i, j]
(Or even better, use all with generator.)
More
Cool, but can be done [better](http://www.checkio.org/mission/i-love-python/publications/veky/python-3/magnum-opus/). ;-)
(In my defence, I _didn't_ misunderstand the task.;)
A minor detail: it was probably easier to use .title, and then convert just L to l with (e.g.) .replace.
More
Those two if-elses are unnecessary. If you really wanted to handle the case of empty data (despite the precondition), you could have done it like this:
if length % 2: ... #handle the odd case
elif data: ... #handle the even case
elif is useful, empty list can be sorted trivially, and pytho
More
Lines 13~16 (and maybe others;) can be replaced with just one. Builtin max is your friend. ;-)
More
... and all(re.search(p.join("[]"), data) for p in ("0-9", "a-z", "A-Z"))
Eliminate duplication. ;-)
More
You can eliminate line 22 if you assign tail='' instead of None. str is a sequence, None is not really a good fit there.
More
... except when it [isn't](http://www.checkio.org/mission/i-love-python/publications/veky/python-3/magnum-opus/). ;-D
More
Trust me, your "normal" way is just the way of the programming language you learned before (most probably C). It's not normal in any absolute way, just more popular. :-]
More
"for years and years"... probably, if you switch to Py3. For Py2, I'm not so sure...
More
You don't need () after if. Simple rule for (): after blue no, after purple yes. ;-)
More
Nice, but when you learn about slices it will be much simpler:
for w0, w1, w2 in zip(pal, pal[1:], pal[2:]):
if w0.isalpha() and w1.isalpha() and w2.isalpha():
Or even, if you like pointfree writing:-),
for troika in zip(*(pal[i:] for i in range(3))):
if all(map(str.isalph
More
Again, min and max are purple. What does it tell you? ;-)
Also, line 4. "if args:".
More