57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 21 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.
People write many languages in Python. But you're the first one I saw write XML in Python. :-O
More
The nice thing about Boolean operations is that they are total (defined everywhere on their relatively small domain) and very easy to compute. That together means you can just delete `lambda x,y:` and `(x, y)` parts, and it will still work, while being cleaner, shorter, and probably faster.
You can
More
Flat is better than nested, indeed. :-D The only thing you missed is that
you could write line 25 as
cube_volume = 3..__rpow__
:-D
More
You were very close with that "key". ;-)
return max(sorted(map), key=map.count)
Also, you don't need re. You can just use "abcdefghijklmnopqrstuvwxyz" (also known as string.ascii_lowercase) as first argument to max, and key=text.count as second. But then it's too easy. :-D
More
Using << and >> instead of // and ** (oh yeah, and & instead of %) would be even more obviouslier. :-]
More
Funny, this is exactly the same length:
safe_pawns=lambda p:sum(bool({chr(ord(c)+o)+chr(ord(r)-1)for o in(-1,1)}&p)for c,r in p)
More
Line 2 is unnecessary. You can have
for x in text
without problems. list is not the only iterable.
Also, line 7 is horrible. 'jim' is probably some joke name, but much better would be to evade the naming altogether. You don't do anything beside just return it.
return ''.join(uppercases)
More
Why list? This is also one of frequent newbies mistakes, many objects can be iterated. You don't have to listify everything. list offers a special interface: appending at end, and random access by index. If you don't need these, you don't need list.
---
And just for fun, you can look at [this](ht
More
You could have written just `class checkio` instead of Override. :-)
More
First, really too many cases.
Second, "if blah != 0" and "if blah > 0"... could really be just "if blah".
Third, use divmod. It will be _much_ simpler than what you're doing (lines 20~21, lines 48~49,...).
More
Slicing is better than indexing by range. And you don't need those mins then.
More
.71 is nice. Couldn't .8 work too? :-)
Also, 0<=y< len(m[x]) wouldn't cost you a char, yet would be more explicit. ;-)
And those int() calls would be more appropriate in []s at the end of first line. Lines length would be more balanced. ;-)
More
If you're writing a tribute to me, at least drop brackets inside parentheses.
sum(x for i, x in enumerate(array) if not i%2)
But in fact, slicing is much simpler. You can use itertools.islice if you worry about memory.
More
First, a defaultdict would _really_ help here. :-)
Second, you don't need () inside [] indexing. Just d[i, j].
Third, end of line 11 can be just `... else max((n1, s1), (n2, s2))`. Tuples compare sensibly. :-)
And fourth, you can get by without tracking lengths all the time, just calculate when n
More
OMG. The dreaded "else: pass" pattern. :-D
Also, why do you check for tuple at some point? (and for list at another!?) The code shouldn't depend on exact types passed into min/max.
More