57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 11 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.
You're reinventing the wheel. See Counter in collections module (standard library).
More
Nice usage of pop, but the variable s is used in a really weird way here. (With "nonlocal" it would be funnier.:) Those "+=" are in fact just "=", and "initialization" to 0 isn't needed. Also, pop could be used in both branches (or better, before "if"), so condition could be simplified.
Also, I h
More
This is just to show various methods your system can be cheated. Fix these, and I'll find new ones. :-P
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
Nice usage of Zeckendorf's theorem. ;-)
BTW it would be more scary without that friendly looking boo-ghost. ;-D
More
I think this is the first time I've seen an unconditional break at the end of the loop. :-)
BTW you don't need line 28, Python is smart enough to return None if there is nothing to return. ;-)
More
Better, but still not universal. Where previous worked for under 2\*\*32, this one works under 2\*\*100. :-] Python's recursion is not a way to code iteration.
http://neopythonic.blogspot.com.au/2009/04/final-words-on-tail-calls.html
More
Someone has added precondition. So all of your previous codes also work. Sorry.
Yes, this one works for all nonnegative m and n.
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
Sorry, *= max( , 1) is very unclear to me.
But this is obviously ridiculous. Everybody considers their own code clear.
More
Cool. Mine is also floatless, but in a much more boring way. :-D
BTW, all these
expr if decimals else 0
are just
expr*bool(decimals)
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