57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 12 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.
OMG. Why a list of one element? Why not just
len({x for x in words if x in text.lower()})
? (Even nicer would be sum of bools, but this is also perfectly fine. Just remove that "result" that serves no purpose at all.)
More
What do you _think_ that flags did? Because I have a feeling you thought the wrong thing. `re.U & re.I` is 0.
And again, naming it just to return it is not really profitable. Just
return ''.join(...)
More
Again, don't name, return. (And especially don't name 0.:)
But a more important thing here: what do you think lines 5 and 6 do? Hint: they don't make your program faster. ;-]
From Zen:
> Special cases are not special enough.
More
You see how naming instead of just returning makes your task more difficult? If you just returned, "and countW < 3" wouldn't be needed.
And other namings are also unneeded. "elements" is practically semantically empty name, and you only use it once. Just:
for w in words.split():
More
For people who like computation: a [special treat](http://www.checkio.org/mission/ghosts-age/publications/veky/python-3/incredible/?ordering=most_voted). ;-)
More
Let me guess, 65 in the title has different meaning than 65 in the code? :-D
BTW, nice usage of upper to avoid threedigit numbers. :-)
More
Sets are cool, but you're doing it wrong. :-)
There are more set operators than `-`. Try `<=`, for example. ;-)
And independently, there is a bool protocol. `not` is so underused a keyword. ;-]
False if blah else True ~~~> not blah
More
Nice, but why rebinding in line 5? Just
all(map(text.lower().__contains__, string.ascii_lowercase))
More
Kernighan says "flatten your if/else chains". Judge for yourself whether this makes clearer code. :-)
More
Now please try to explain to me: what is creative here? I have the same solution, and I consider it a _direct_ translation of the task text: you check whether _all_ letters _from_ blah are _in_ nyeh. That's a mathematical definition of a subset, literally. I'd really like to know what made you publi
More
May the electromotor force be with you! Why fabs instead of ordinary abs??
More
All those len tests are unnecessary and unpythonic.
if len(stack) > 0: ~~~> if stack:
if len(stack) == 0: ~~~> if not stack:
Not to mention
if len(stack) == 1 and stack[0] == '': ~~~> if stack == ['']:
More
Kinda ok, but _readable_? No. :-P
First, CheckiO is not really a version control. And it shows. The previous attempts have nothing to do in the published solution.
And more importantly, you're using code comments wrong. (You're not the only one.) First, you "comment out" code and leave that in whe
More
Line 10 is a really nice example of what are the proportion of brain damage that CheckiO "every argument is a list" paradigm does to you. :-P
Even if you had more of them in a list, for loop is senseless: `return` would just return the first output.
More
You don't need "!= 0". And if double `int(x)` bothers you, you can map int over str(number) first. Otherwise, fine.
More
Waitaminute. One sort is acceptable (even though it _can_ be avoided, see nickie's solution;), but two?? I wouldn't be so horrified if you didn't call this "Mathy", which in my vocabulary means _calculating_ something in a closed formula, instead of doing physical work such as sorting. Twice. :-(
More
Simple, maybe. Clean? There is a builtin that does exactly what you do in lines 6 to 8. Nice name, three letters. Surely cleaner than three lines. ;-P
Also, giving one-letter names to things used only once does _not_ make your code more readable. Though it is a popular myth. ;-]
More