57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 1 day ago
Member for 11 years, 6 months, 7 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.
Cool. But don't you think there's an easier way to do what you do in lines 16~18?
Also, condition in line 12 is more usually written as "if not shortages".
More
Cool. But you really could have used what you imported from math, instead of that while. ;-P
More
I think this is the only usage of generator.send I have seen on checkio. :-D
More
ROTFL.
P.S. Even I'd never be so bold to import * from operator. :-D But you handle it excellently. :-)
More
You don't need nonlocal. buffer doesn't have to be nonlocal at all (since you don't rebind it), and ptr can be just an argument.
def BF(s):
buffer = ... # how about defaultdict(int)? Much cleaner.
def execute(s, ptr=0):
...
... ret += execute(s[i+1:],
More
You mean, checkio = lambda a, b: sum(map(int, bin(a^b)[2:])) ? :-)
That's nice, but reusing names like that is really weird. If you put it in Creative, you'll get another thumb. :-D
More
Those two if-elses are unnecessary. If you really wanted to handle the case of empty data (despite the precondition), you could have done it like this:
if length % 2: ... #handle the odd case
elif data: ... #handle the even case
elif is useful, empty list can be sorted trivially, and pytho
More
Lines 13~16 (and maybe others;) can be replaced with just one. Builtin max is your friend. ;-)
More
... and all(re.search(p.join("[]"), data) for p in ("0-9", "a-z", "A-Z"))
Eliminate duplication. ;-)
More
You can eliminate line 22 if you assign tail='' instead of None. str is a sequence, None is not really a good fit there.
More
... except when it [isn't](http://www.checkio.org/mission/i-love-python/publications/veky/python-3/magnum-opus/). ;-D
More
Trust me, your "normal" way is just the way of the programming language you learned before (most probably C). It's not normal in any absolute way, just more popular. :-]
More
"for years and years"... probably, if you switch to Py3. For Py2, I'm not so sure...
More
You don't need () after if. Simple rule for (): after blue no, after purple yes. ;-)
More
Nice, but when you learn about slices it will be much simpler:
for w0, w1, w2 in zip(pal, pal[1:], pal[2:]):
if w0.isalpha() and w1.isalpha() and w2.isalpha():
Or even, if you like pointfree writing:-),
for troika in zip(*(pal[i:] for i in range(3))):
if all(map(str.isalph
More
Again, min and max are purple. What does it tell you? ;-)
Also, line 4. "if args:".
More