57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 12 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.
You might love Python, but you obviously hate me. I see what you're doing, but I don't see what you're trying to accomplish. It's probably so obvious to you that you didn't even consider the possibility your motive wouldn't be understood.
Can you articulate your message? Even terrorists make some k
More
That "print( c )" wasn't very helpful, right? :-)
In fact, your steps can be much more pythonic.
b = words.split()
c = ("10"[x.isnumeric()] for x in b)
d = "".join(c)
return "1"*3 in d
Whenever you're mapping lambda, you should use a generator.
map(lambda arg: expr, seq) ~~>
More
[since CiO will probably never get back links to commenter's solutions :-(, [here is the link to mine](http://www.checkio.org/mission/mind-switcher/publications/veky/python-3/zendoh/?ordering=most_voted), for comparison. This is a reply to ignalion's comment on my code.]
While you might think our s
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
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
Aargh. I think I taw a puddy tat... I mean, a semicolon. :-P
Please don't write C in Python. It's not just semicolons... comparisons, loops, the whole thing is so unpythonic it hurts. :-(
More
"<=1" is a cute and completely unnecessary "optimization", that's really hard to grasp at first. You could just say "if not args" in line 2 (or "if args" and reverse returns). In newer Pythons, you can also put default kwarg in min and max, eliminating the need for if totally.
BTW you don't need *
More
Of course, the len checking can be done in the same way, at the expense of blowing up the code by a factor of at least 2. But that's even more wrong than this. :-D
More
abs is already a function. Saying lambda x: abs(x) is a bit like saying str("Pointless"). :-)
(Smartsounding name is ["Eta reduction"](http://www.lambda-bound.com/book/lambdacalc/node21.html). But this only shows that many things have smartsounding names.:)
More
Not bad, but could be clearer.
Since you're not using a list as a list, but sorting it anyway at the end, a better structure might be a set (it might also give you the idea to use set.intersection, but let's not go too deep:). You could say you care about performance (and set.add _is_ a bit handi
More
Lines 12-14 can be simply written as
f = kwargs.get('key', lambda x: x)
Also, None can be aliased. :-)
val = fval = None
More
"return None" is the same as "don't return anything". You don't need lines 5 and 12.
More
You don't need parens around lambda: lambda is it's own left paren. :-)
opt is a weird name (I think you're again calling it by implementation, not by meaning;). `cmp` would probably be better (in Py2 a very similar argument was really called `cmp`).
In fact, name `inner` has the same problem. "ex
More