57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 1 day 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.
It's not easy when you're not using the tools you have. :-] Look:
You intend to go through str1 and str2 simultaneously. That's what `zip` is for.
m = {}
for x, y in zip(str1, str2, strict=True):
if x in m and y != m[x]: return False
m[x] = y
return True
Now, you check
More
Thanks @pakicetus for the [idea](https://py.checkio.org/mission/isometric-strings/publications/pakicetus/python-3/hmmm-not-easy/?ordering=most_voted&filtering=all#comment-114512)!
More
Of course, the len checking can be done in the same way, at the expense of blowing up the code by a factor of at least 2. But that's even more wrong than this. :-D
More
OK. Lines 8~9 could have been nested under line 5, but this is good.
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
Nice hack with %180. :-D Bare excepts are usually frowned upon, but this is obivously a quick&dirty solution.
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
h, m = map(int, time.split(":"))
Also, wouldn't it be nicer to name the subexpression abs(long(e?) - short)?
More
LOL. You manage to complicate everything. :-)
Line 13: just return i, no need to break first.
"if fib[0] == i: fib = [sum(fib), i]" is really funny. :-)
More
That numpy cannot be used doesn't mean you should go medieval on ranges of lens. :-/
map(sum, matrix)
map(sum, zip(*matrix))
Also, lines 22 and 23: nice usage of enumerate, decorate-max-undecorate, key and itemgetter, but you could have just
sums.index(min(sums))
BTW [see second para
More
This becomes ridiculous. You solve everything with re? :-D
b = "".join(x for x in expression if x in "()[]{}")
Also, not everything is a list. ;-) And you should decide _what_ name you want, instead of giving three names to the same object. :-D
Lines 13~16: just return not b.
More
Line 3: mapList doesn't have to be a list. "abcdefgh" will do just fine.
Lines 5~7: just write "for k, l in pawns:". Don't range(len(. Ever. :-)
Also, not everything is a list. If you removed line 2 and made difence (defense?) a set (just put {} instead of [] around comprehension), you could just
More
iElement is a very strange name. Do you come from the Kingdom of Nouns (also known to its denizens as Java)? :-)
More
Your complicated protocol has a name: **and**. ;-)
return digit and upper and lower and len(data) < 10
And a nitpick: you don't need + in your regexen. ;-)
More