57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 12 hours ago
Member for 11 years, 6 months, 24 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.
This is just one example of how PEP 479 is bad for Python. Another one is at https://py.checkio.org/mission/merge-intervals/publications/veky/python-3/generator/#comment-54572.
More
It seems I'm not the only one getting strange compliments on CiO. Python gets them too. :-D
More
I'm not absolutely sure, but I think Py2 also gives you better way of calling replace:
','.join(phrases).replace("right", "left")
More
Lines 5 and 7:
if i in "([{":
if i in ")]}":
Line 15: You can just
return not stack and not error
Or even `not (stack and error)` :-) But really, why error at all? It's not that you can recover anyway. When you find an error, don't set error to True, just `return False`. At the end,
More
Lines 4~7: Again, don't know about Py2, but you probably have .partition. Use that instead of .split, it fits much better.
cmd, _, arg = i.partition(" ")
For the other try (lines 8, 11 and 12): Yes, EAFP is nice, but sometimes it pays to be practical:
if cmd == "POP" and stack: stack.pop(
More
Inspired by [bukebuer](http://www.checkio.org/mission/network-loops/publications/bukebuer/python-27/second/?ordering=most_voted) (and Guido;).
More
`a = max(a, incredibly_long_name, key=len)` is cool, but every time incredibly_long_name doesn't give something longer than a, Python "rebinds" a to itself. Maybe it would be better after all to use if?
b = incredibly_long_name
if len(b) > len(a): a = b
More
Well, you said everything about ghastliness... so I won't go there. I'll just say that number of cases being finite is not an excuse to go haphazardly enumerating them. :-)
But a more important lesson about how Python namespacing works: you `import` _names_, not objects. Conclusion: you don't need
More
Why wouldn't it be slow? You're testing all numbers up to 10**5 one by one. :-o
More
But you should use it fully FTW. :-P Check out unicodedata.category and unicodedata.combining. ;-)
More
I'd still like to register my general dislike of eval, but here it's overweighted by elegance of this solution. Congratulations, you win one of Veky's fives! :-)
And yes, I find it funny that you call it golf, and then use spaces as is proper. :-) As if you're saying, "this is _so_ short, I can spr
More
No lambda needed. And no list needed. And in fact no def needed at all. :-D
More
Yeah, you should. :-D For start, study for-else loop. Much better than this insane flag manipulation.
More
First we take Manhattan. Then we take whichever is smaller of East Berlin and West Berlin...
🤣🤣
More
Nice solution. Shows how [DRY](http://www.checkio.org/mission/count-neighbours/publications/veky/python-3/around/?ordering=most_voted) is not always the same as shortest code. And I really like DRY more, but I do enjoy a game of golf here and there. Especially if [I win](http://www.checkio.org/missi
More
Little Fermat is cool, but I'm more surprised by the fact that 0-something isn't always the same as -something. :-O
More
Feedback? Too much duplication and too much low-level code.
About that uglier-than-toad line 6... if you want to be a wizard, read http://code.activestate.com/recipes/204297-the-secret-name-of-list-comprehensions/. If you don't, just write the loop like normal people. It's not hard. :-)
More
Please use // instead of / when you actually want int division.
More