57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 16 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.
Using not with 2 branches is usually frowned upon. It's better to reverse branches and eliminate not:
if array:
return sum ...
return 0
Even better is to use try. But you're probably too young for that. :-)
More
"if int(digit)" is enough.
Or better, to remove duplications of int(...):
for digit in map(int, str(number)):
if digit:
mal *= digit
(You can even use filter(None,...) but let's not go there.:)
BTW what's "mal" (as a name)?
More
Same as before:
if args:
return max ...
return 0
In new Pythons, you can use default=0 in min and max.
More
Nice "oneliner". :-P But why all those list(...)s? [] are enough.
And sum([a,b,a]) is really nicer written as 2*a+b.
More
> The shorter your code, the more remarkable you are.
Then I am https://remarkable.com/ :-D
More
Sorry, *= max( , 1) is very unclear to me.
But this is obviously ridiculous. Everybody considers their own code clear.
More
Your idea of "functional programming" is very strange. Hint: lambdas and foldrs are not everything. :-D
See math.hypot, operator.and_, itertools.product, and itertools.starmap. And sorted returns a list already - what did you think, it will return an iterator? :-]
More
Yes, that's the way (a-ha, a-ha,) I like it (a-ha, a-ha). :-D
As a nitpick, I think that manual for-loop could be automatized (written as a real for loop), with while inside to repeat a single pass until d<0. But this is probably ok too.
More
A nice variant of my "Ordered" solution. :-) Is there _any_ reason to use d << 1 instead of d*2 (or even nicer, d+d :)? You just need parentheses for it.
BTW, in Py3.4, max finally got a "default" argument (despite Raymond's cries:), so you don't need that ugly line 4. :-]
More
Nice complex key. :-D But you don't have to search through the whole text, just through a..z. :-)
More
Please don't use "concatenating digits in a large base" as a method for selecting by multiple keys. Unicode has more than 1e5 code points (if not now, then soon:)). Tuples comparison is exactly meant for this. Key should be (count, -ord).
Also, this algorithm has quadratic complexity, while the t
More
Nice and complicated. :-P Wouldn't dict be more appropriate data structure for z?
More
First, if you _used_ regex here, that would be remarkable. Not using Python re here is like not using a bicycle for swimming. :-D
Second, argh. Please don't do
if c: return True
else: return False
if c binds something bool. Do
return c
Token count just went from 7 to 2. A
More