57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 17 hours ago
Member for 11 years, 6 months, 23 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.
`while bool(blah)` is exactly the same as `while blah`, only slower. You can also write `while bool(bool(bool(blah)))`. :-D
And that `next(..., False)` pattern is much better expressed using EAFP in line 6, and simple `any` in line 11.
More
I see double! :-P
And `True if (True if f == s else False) else False` is not really helping. Just return `f == s`.
More
Why don't you sprinkle a few more float()s around your code? :-D
Or simply use a normal Python.
More
Yes, there is: Don't use regexen. :-D
More
Don't you think your code could use some refactoring? :-)
Also, everytime you write
if condition: return True
else: return False
a little python dies. :-P
More
A kinda classical Dijkstra with sentinels. Few points:
k loop should be constrained better: r*c is just a horrible upper bound.
Instead of that cute "min", you can have a full if statement, remembering
if you changed anything, and if you didn't, you break the outer loop to
return.
That indentation
More
... not. :-P
list(map(blah.__getitem__, days))
[blah[day] for day in days]
compare.
---
BTW do you write (2 * 5) + 3 ? Then don't do the same with Boolean multiplication and addition. :-P
More
Every time you map a lambda, a python dies. :-P
map(lambda variable: whatever, sequence) ~~~> [whatever for variable in sequence]
More
Ah, a butchering of a nice algorithm. :-P
def checkio(data):
arabic = dict(I=1, V=5, X=10, L=50, C=100, D=500, M=1000)
roman = dict(zip(arabic.values(), arabic))
def fragments():
for exponent, digit in enumerate(map(int, reversed(str(data)))):
More
This is not "as efficient as possible", but you already know that. :-)
It is also not as concise as it could be. Look at [this beauty](https://py.checkio.org/mission/the-longest-palindromic/publications/veky/python-3/although-straightforwardness-beats-speed/). :-)
And yes, comments are not really
More
OMG. filtering a lambda, then listing it, only to iterate through it. Hard to believe this wasn't intentionally ugly. :-P
How about
for b, w, n in states:
if n == n0:
(Indenting 2 spaces is acceptable in such situations, if you're stingy with line lengths.)
---
states[(b, w, n)]
More
LOL. Yes, sort might be unnecessary, but doing it twice... :-o And it even isn't one line. :-P
More
It's much better to use
if command.startswith('POP'):
since when you change POP to something else, you'll likely forget to change the 3.
Also, line 5:
if queue:
More
You could have written it even longer. Though I don't really know how. :-P
More