57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 22 hours ago
Member for 11 years, 6 months, 6 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.
Yeah, that's the way to do it. A tip: max can receive a slice. (See mine.)
More
If you're trying to see how it works: just print(r) between lines 5 and 6. I'm sure you'll see what r is, and then the rest is pretty obvious. (Of course, if there are any questions, just ask.)
More
Doesn't work on empty list.
checkio=f=lambda x:x.pop()+f(x)if x else 0
would be better. ;-)
More
Last line is just
return s*(n == 1)
And yes, you could have get rid of that special case (given your hate for special cases) in line 2. For example,
return (s + (not s))*(n == 1)
Here you do need parentheses around not, since it is special in grammar. But "not" being special enab
More
Again, no parentheses around "not s" are needed. You never need them when you use it as a logical condition, only as an arithmetical expression.
BTW sentinel really could have helped here (to reduce number of cases:). See mine. ;-)
More
Line 3: nice optimization, but it's not like we have millions of elements. list.index would work perfectly fine. :-)
Line 5: str is also just a (kindof) list of characters. "qria" is probably more readable than ["q", "r", "i", "a"].
Lines 37~40: you _should_ feel bad. Not because of hardcoding
More
So, you see the problem? How can using str.endswith (which is intended for exactly this kind of check) not be clear, and at the same time using
c.split(d)[-1]==""
is somehow "clear"?
Everybody considers their code clear. That's why this whole category thing is nonsense.
More
We have a very similar solution. :-)
BTW, I ROTFLed at 'Aaaaaaarrrrgghhhhh!'. :-D Wasn't it better to raise some appropriate exception? (PermissionError sounds very appropriate.:))
More
As Express Delivery was just A* in 3D (n x n x 2), this is just A* in 4D (4 x 4 x 4 x 4). Precise formulation of analogy is left as an excercise to the reader. ;-D
More
Nice use of default arguments. ;-) BTW why a commented checkio above?
A nitpick: wouldn't
c if b else a
be nicer than
a if not b else c
?
More
ROTFL. I admit I was staring at that 1/ for a few minutes. :-D
For translated, maybe it would be nicer to first starmap(complex, data)?
More
Awww, iter, finditer, and even _itertools.chain.from\_iterable_. Awww. :-D
Haven't you buried the idea of your solution a bit too deep? :-]
More
Hm. This doesn't _really_ work, it's just that the tester stops as soon as you reach the goal. It can be fixed (and your solution removed) later.
That being said, it's trivial to fix: just use another connective instead of +. Can you see what it is? :-)
More
Aargh. I think I taw a puddy tat... I mean, a semicolon. :-P
Please don't write C in Python. It's not just semicolons... comparisons, loops, the whole thing is so unpythonic it hurts. :-(
More