57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 3 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.
Doesn't all this duplication bother you? :-)
Also, I think you're taking EAFP a bit too far with line 4. :-D
More
Instead of passing indices, it would be much better to pass slices. ;-)
Also,
(some expression with i and data[i] for i in range(len(data))) ~~~>
(some expression with index and item for index, item in enumerate(data))
More
How exactly do you propose to insert newlines and indentation into a tweet? :-P
More
About half of that length stems from keeping to the Pascal foolishness of a single return at the end of the function. Look:
def checkio(words):
words = words.split()
for i in range(0, len(words) - 2):
if words[i].isalpha() and words[i+1].isalpha() and words[i+2].isal
More
Aaargh. Semantically empty names (`newList`, seriously??), the code is _drowned_ in the sea of comments (those things are connected: if you chose more semantical names, you wouldn't need comments!), and most importantly, you're doing iteration wrong.
for index in range(0, len(sequence)): ~~~
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
First, your list obsession shows again. str is a sequence too. All sequences have .count method.
Second, why not just %2 ? Or even better, &1 ?
More
Meh. In this case, simple is not better than [complex](https://py.checkio.org/mission/humpty-dumpty/publications/veky/python-3/complex-battery-staple/?ordering=most_voted&filtering=all). :-P
More
defaultdict(float) would be a nice thing to use for jars.
But really, there is a closed formula. Go smoke a peace pipe with algebra. :-D
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
A bit more Pythonic than the previous one, but still not very Pythonic.
Line 2 is unnecessary. How many same arguments you'll have? And each of them will clear that inner loop in 2 steps.
Line 3 is simply wrong. gcd(2, -4) is 4. And gcd(0, 5) is 5. "greatest" is by divisibility, not by standard or
More
Why do you keep thinking your solutions are Pythonic when they _obviously_ aren't? Superfluous comments, duplicated code, and that mortal sin of Python programming, "except: pass".
More