57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 22 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.
Line 10 is more clearly written as "huns = tens = ones = 0".
Line 21 is just: "if tens or ones:".
And so on.
More
Calculating sorted(data) multiple times is not nice. Cache it somewhere, or just data.sort() at the beginning.
BTW that lines 6~7 are weird. How could it be "else"? :-)
More
It seems you're trying to golf. In that case, you can look at my (or nickie's) solution. ;-)
More
You can remove duplication in line 18 with careful slicing of "MDCLXVI", see my solution.
Don't use / for int division (line 25), it will bite you when you last expect it.
int in line 23 is superfluous for the same reason. But you could do interesting things with zip(str(data).zfill(4), numera
More
You're going overboard with European Association of Fish Pathologists. Generalizing case n=2 is not really productive. And beating someone to death with a loaded uzi is really not fun. :-P Look, your lines 10~17 can be:
if "XXX" in candidates: return "X"
if "OOO" in candidates: return "O
More
Duuude. :-]
Just one nitpick: line 31, please learn about >2-arg form of map. It could come handy. ;-)
More
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
Why a list?? You never do anything with it except append 1, increment some element (pointless) and return len.
More
Aaargh. Don't ever loop over indices when you can loop over values.
for char in number:
More
You have some really weird ways of thinking. Why outer loop is nice, and inner one is ugly? :-P
for i in w:
for j in w:
More