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.
This is small enough that it can be encoded in a moderate-sized Life grid. ;-)
More
Nice. While you're writing in Python3, you could have used .format for greater readability. :-)
More
delta is ok, but names d0 and d1 are semantically empty. Much better would be not to use them at all.
delta = date(*date1) - date(*date2)
More
Lines 6~9... wat? :-]
return [minr, minc]
Also, code duplication is horrible. Factor it out?
More
Condition in line 7 is really strange. What is it doing there??
Also, int(round(blah, 0)) is just round(blah).
And if you really use Py3, those / are truedivs. Don't write -2.0, write just -2. (Or better yet, cancel -1 and use 2.:)
More
Clear?? Hm... classifying commands according to len? And checking "if letters != []" instead of just "if letters"? No, sorry. Not clear. ;-P
More
That's one horrible code duplication. But more importantly, it doesn't work, does it?
verify_anagrams("a", "ab")
More
Lines 1 and 2: LOL. :-) Sometimes it is easier to just bite the bullet and write what you really mean.
parens = {"(":")", "[":"]", "{":"}"}
You could have simplified line 12 by putting one lion in Cairo first (see my solution and respective comments for explanation;).
More
If you really wanted to be _clear_, you'd probably use .count('1') as before. ;-] n &= n - 1 is a nice trick, but not really "clear" IMO.
More
letter.isupper() is what you're looking for. ;-)
Also, don't use Schlemiel the Painter's algorithm without understanding. :-]
More
Yes, you should have used a dict. (Rule of thumb: if it would be an ordinary switch (with breaks after every case) in C, it is not if/elsif/elsif/else in Python. It is (probably) a dict. If it is too complicated for a dict (code differs, not only data), then it is a class. But it's almost never a bu
More
Title can be written as col-bool(col). ;-)
Lines 8~10: second = sum(...) - grid[row][col]
BTW, pattern as in your lines 3~6 and 12~15 can be written as
first = row != 0 and sum(...)
third = row != len(grid) - 1 and sum(...)
More
Assigning something to a name just to return it afterwards, _especially_ when that name is the name of surrounding function, is really unnecessary. It would be much better to write
def area(self):
return self.width_WE * self.width_NS
and so on.
More
You used list() seven times. _None_ of them was necessary. This must be some kind of a record. ;-P
bin(n)[2:] is nicer written as format(n, "b").
Padding with zeros is common operation. See str.zfill. (And max is also nice.;)
In any case you don't need _three_ cases. Just two. [0]*(a-a)+l is l.
More
Argh, too complicated. Have you thought about a nicer data structure than the sequence of strings? :-o
And what do you think line 4 is doing? :-/
You don't need () after while.
else in line 18 doesn't do what you probably think it does.
Line 10: if not route:
More
It's nice you learned to use "in", but you can do better.
if i.startswith("POP"): ...
More