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.
LOL @ line 2. :-) And line 8 is a nice trick, but probably
ints[0] & ~0 << rembit
would be easier to grok.
But seriously... _noone_ but me solved this with Python's library batteries for working with IP? Really sad. :-/
More
Very repetitive and not very Pythonic - .join should be preffered to += for str: see also http://en.wikipedia.org/wiki/Schlemiel_the_Painter's_algorithm
More
(int(x) for x in bla) is just map(int,bla). "Dozen" is not really a good name for ten, you agree? Numbers inside {} (and 0 before :) are not necessary. And that code could really use one function to be called three times.
More
Whenever you write
if bla:
return True
else:
return False
please replace it by
return bla
Also, ints are true whenever they aren't 0, so you can use capital, lower_case and digit as bools (remove >=1).
And finally, you didn't have to type those letters a
More
Nice but a bit convoluted. Why that map at the end? Wouldn't it be simpler to just return sum(items)-2*max(onehandweights(items))?
More
Yeah, that's the way to do it. A tip: max can receive a slice. (See mine.)
More
LOL. This is the reason why I don't comment my code. :-] There would be more comments than code. :-)
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