57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 11 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.
There are some weird things going on here. For example, I thought Python doesn't have a character type (different from str). I bet you thought so too. Yet look at line 20.
Calling ord('aa') raises TypeError, calling ord('a') doesn't, but they are of the same type. It seems Guido didn't really mean
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
Nice regex formation. :-D But seriously, some other things might be
improved a lot. String methods, especially .isupper and .endswith, should
be considered.
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
Wouldn't
[x] * f for x, f in items
be nicer than that horrible indexing? :]
More
Best compared to what? :-) You can have just one expression,
','.join(phrases).replace('right', 'left')
And then you can just stick
left_join = lambda phrases:
at the beginning. :-)
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
What you did in first two cases, you can do in others, too.
elif operation == 'implication': return not (x == 1 and y == 0)
elif operation == 'exclusive': return x + y == 1
elif operation == 'equivalence': return x == y
Those OPERATION_NAMES repeating are not giving you anything. Much
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