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.
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
"<=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
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
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
ROTFL. :-) Clear, no doubt. :-P
Wouldn't str(tuple(evil)) be clearer? Then you don't need .pop, and you're not depending on the type of evil.
BTW, you can .replace(*',+') for added puzzlement. Replace multiplication prime with addition prime. ;-D
More
Line 9 surely shows some misunderstanding of how Python works. What did you think it does (as opposed to just "return data_new")?
And of course, you can just write a list comprehension.
return [x for x in data if cnt[x] > 1]
More
This is a perfect example of how deeply unpythonic regexes are. That line 6 seems like it has fallen from some wholly different planet (named Perl, incidentally:).
BTW,
sum(regex.match(element) and not re.search('\d+', element)
for element in re.split('\W+', text.lower()))
More
Does [this](http://www.checkio.org/mission/count-inversions/publications/veky/python-3/gallery/?ordering=most_voted) count? :-D
[Yes, pun intended.:]
More
LOL, wonderful. :-) Giving start index without end index to endswith is just beautifully weird. :-D
More
You can return it as soon as you have it.
if number%5 == number%3 == 0:
return 'Fizz Buzz'
More
I think [this one](http://www.checkio.org/mission/digits-multiplication/publications/blabaster/python-3/golf/?ordering=most_voted) will floor you. :-D
Also, // (and divmod) might be nice to learn.
while number:
number, digit = divmod(number, 10)
if digit: product *= digit
More
What you did in first two cases, you can do in others, too.
elif operation == 'implication': return not (x == 1 and y == 0)
elif operation == 'exclusive': return x + y == 1
elif operation == 'equivalence': return x == y
Those OPERATION_NAMES repeating are not giving you anything. Much
More
Best compared to what? :-) You can have just one expression,
','.join(phrases).replace('right', 'left')
And then you can just stick
left_join = lambda phrases:
at the beginning. :-)
More
This is beginning to look a lot like Python, to paraphrase that old Christmas song. :-D
The only jarring thing is that name in line 2. Just inline it, man.
for word in words.split():
More
Wow, what a cheat! :-D
Of course it doesn't always work, but still very nice.
Instead of (second) str, you can use id. It is false in rarer occasions. ;-]
More
def checkio(from_date, to_date):
"""Count Saturdays and Sundays between dates."""
weeks, days = divmod((to_date - from_date).days, 7)
nd = from_date.weekday() + days # next same weekday as to_date
return 2*weeks + (nd > 4) + (days and nd > 5)
Same algo, 4 times
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