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.
Funny usage of bisect. :-)
Again you with "if len(blah) == 0: continue"... just say "if blah:" (and indent lines 8~10).
blahset |= {item}... I really find blahset.add(item) easier to read. And Python does, too. ;-)
Of course, the best solution would be "yield" - that is, neighbours is natur
More
Yeah, annoying. :-P Too many irregularities and convolutions.
It's time to learn about str.maketrans. ;-)
''.join([...]) - drop the brackets. Your code will be nicer, more readable, and faster.
for i, z in ... and then using z[0], z[1]: you can unpack directly. for i, (d, j) in ...
Also,
More
Wasn't it easier to give additional parameter than have inc and dec as separate functions? :-)
Also, don't join([...for...]). Drop the brackets.
More
Cool. But you really could have used what you imported from math, instead of that while. ;-P
More
res: don't do this. It's much slower with no reason. Use for-else.
for x, y, r in previous:
if round(math.hypot(i-x, j-y)) != r: break
else: return [i, j]
(Or even better, use all with generator.)
More
Cool, but can be done [better](http://www.checkio.org/mission/i-love-python/publications/veky/python-3/magnum-opus/). ;-)
(In my defence, I _didn't_ misunderstand the task.;)
A minor detail: it was probably easier to use .title, and then convert just L to l with (e.g.) .replace.
More
Those two if-elses are unnecessary. If you really wanted to handle the case of empty data (despite the precondition), you could have done it like this:
if length % 2: ... #handle the odd case
elif data: ... #handle the even case
elif is useful, empty list can be sorted trivially, and pytho
More
Lines 13~16 (and maybe others;) can be replaced with just one. Builtin max is your friend. ;-)
More
... and all(re.search(p.join("[]"), data) for p in ("0-9", "a-z", "A-Z"))
Eliminate duplication. ;-)
More
You can eliminate line 22 if you assign tail='' instead of None. str is a sequence, None is not really a good fit there.
More
Again, inconsistent and really too long names.
Your create_dictionaries could really use the help of enumerate builtin. ;-)
extract_digits seems so complicated, I think map(int, str(number).zfill(3)) is much clearer about what's going on. You don't even need map(int... if you're willing to treat t
More
That's a really strange flow control. Wasn't it easier (e.g.)
if char.isupper():
upper = True
break
More
Why are lines after 16 in the loop?? Also, they can be combined with "or".
Also, you don't need () after if. And range(0, 3) is simply range(3).
More
Also, drop the [] inside "".join. Here it doesn't matter much, but it's better to get the right instinct.
There is no need to iterate through list(text)... "for c in text" is completely fine. Not everything is a list (and why do you call it array??:).
More
Why the alias? Pythonic way is calling the constructor same as the type. You don't say to_int("34"), right? ;-P
More