57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 16 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.
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
Python is not Lisp. Don't map lambdas.
sum(x+max(0,x-100) for x in fold.values())
More
Not particularly clear. BTW why not `keys[0] = ''`? And str.zfill method could be handy. :-9
More
Your matrices obviously aren't. The good question is, why? :-) And more importantly, why do you think this is clear? :-P
More
It would be much better to use SymPy directly here, not only its results. :-)
And people really should import hypot from math instead of sqrt. :-P
More
Next time try stackoverflow sort. :-P
More
There is really no reason for a separate function. Lines 10~22 should just be up there, instead of line 4.
Also, instead of naming the result (with those unfortunate parentheses), it would be better to return it immediately.
if f_result is g_result is None: return None, 'both_error'
More
You have obviously seen that the origin is irrelevant - after all, you start from 0 for ranks, and from 1 for files. It is much easier if you put origin on (97, 48) - do you know why? ;-)
And why lines 9~10? Special cases are not special enough. ;-)
More