57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 55 minutes 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.
Nice and obvious. :-) You could have said
for w2 in words_set - {w1}:
in line 3, it would make your condition simpler.
But check `itertools.permutations`... it is a nice tool made for tasks like this. ;-)
A nitpick: why do you check `w2.endswith(w1)` instead of other way? Of course it's equi
More
:-) If you're going to use `len() and`, you can use it in at least two other missions. Try to find them. ;-]
More
[] is probably nicer way to write list(). But this is ok if you really want to be explicit. :-) And if you wrote [], you'd probably be more inclined to write it as a list comprehension, though explicit loop is also fine.
More
`set(blah.split(","))` could have been a separate function, though duplication isn't huge here.
But making something a list just so you could sort it and use the result once is an antipattern. That's what sorted is for.
",".join(sorted(a & b))
More
You could have made even better:
checkio = {'0'*6, '707409', '100478', ...}.__contains__
;-)
More
Aargh. Don't write C# in Python. And _please_ don't use pseudoHungarian notation. It completely misses the point of Python.
Also, learn Python idioms. Many of your lines can be written in a clearer, sometimes even point-free way. In some cases you don't even need to learn new idioms, just use them
More
Why didn't you just put s=0 in line 1, then you don't need line 2 at all?
Also, len() is unnecessary. Sequences are boolable.
More
Of course you can just delegate to int and inband its ValueError as -1. But let's ignore that. :-)
`abc` is a lousy name. `digits` would be much more appropriate, considering what they represent.
Using `enumerate` is laudable, but you're doing it wrong. Manual tweaking of index makes it pointless.
More
ROTFL.
But it would be way more cool if you mapped OPERATION_NAMES to symbols from "∧∨→⊕≡" instead of relying on indexes. This is not maintainable. ;-P
More
... except if array is empty, then it cannot. ;-D
More
Instead of lambda with \*, you can use `operator.mul`. Or if you don't want to import one module more, you can use `int.__mul__`.
int(z) is duplicated, since this is the reverse of usual listcomp paradigm: you need map first, then filter over that. So you can use the building blocks directly.
More
ROT13 effect in line 5 is really nice artefact. ;-D
But I'm confused... of five lines, you spend one just to introduce a semantically redundant name for the next line (without it, it still wouldn't be longer than line 5, so you weren't concerned of the right margin). Probably the real reason was so
More
Yeah, at first I thought inheriting from Counter would be a nice idea. However, it's insistance on reducing negative counts to 0 is painful to fight against.
Instead of that ugly polynomialize, you could have written something much more elegant: eval accepts a locals() dict as a second argument. So
More
`from datetime import date` might be more appropriate, since you only need that one, and you need it twice.
More important: learn about `*` argument splicing.
d1, d2 = date(*date1), date(*date2)
And a curiosity: `timedelta` knows how to `__abs__`. So you can drop the outer parens.
return
More
`", ".join` could really help you in line 21. ;-) And corners might benefit from calculating east and north separately.
More