57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 14 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.
I think this is the only usage of generator.send I have seen on checkio. :-D
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
Please, state what you want to catch. Don't ever write empty except - unless you really want to catch everything, which you almost never do.
Look: imagine you accidentally reverse order of arguments and call index_power(2, (1, 2, 3, 4)). You'd like TypeError, right? But you get -1. :-/
More
In fact I meant something more [like this](http://www.checkio.org/mission/boolean-algebra/publications/veky/python-3/whats-up-__doc__/).
More
Don't single-exit your functions without good reason. Instead of "number = blah", just return blah.
More
elif in line 9 could just be "else", given the task.
It seems to me you wrote line 3 (instead of just "for word in words.split():") because you thought you were optimizing something. You weren't. :-P This isn't C, and words is split only once, no matter how you write it.
More
Line 11 is doubly pointless. :-D
One, either line 6 or line 8 will execute, so program will never get to line 11.
And two, None is exactly the default return value. So even if index_power without line 11 somehow mysteriously fell through the bottom, return value would be None.
More
First, you can chain comparisons: 65 <= ord(char) <= 90 (or ord(char) in range(65, 91)).
Second, you can compare strs: 'A' <= char <= 'Z'.
And third, you can just write char.isupper(), which is what you really wanted to do anyway. :-D
Unrelated: don't += strs in a loop. Much better is to append t
More
Again, inconsistent and really too long names.
Your create_dictionaries could really use the help of enumerate builtin. ;-)
extract_digits seems so complicated, I think map(int, str(number).zfill(3)) is much clearer about what's going on. You don't even need map(int... if you're willing to treat t
More
That's a really strange flow control. Wasn't it easier (e.g.)
if char.isupper():
upper = True
break
More
Why are lines after 16 in the loop?? Also, they can be combined with "or".
Also, you don't need () after if. And range(0, 3) is simply range(3).
More
Clear? Hm. :-D
That while loop is really unfortunate. You could have used for for what you need, and if you really like the potential infinity, since you've already imported itertools, count would be nice. ;-)
BTW, "chain(*starmap(chain" is really Rambo-like construct. :-DD
More
Very clear. :-P
_0 would be nice addition. :-D
BTW, sum([[a for b] for c], []), isn't it just [a for c for b]?
[a[cipher[0]][cipher[1]] for cipher in m], use unpacking: [a[i][j] for i,j in m].
More
Have you ever heard of list comprehensions? They could reduce your code by a factor of three, without hurting readability. :-)
More
"word in text.lower()" is much nicer than that regex monstrosity. :-]
More
If this was an attempt to write the most complicated solution, you've nearly done it. :-O
May I just ask what those [0:] slices you thought were doing? Because the answer is: nothing.
all(mark == 'X' for mark in game_result[0]) is simply game_result[0] == 'XXX'.
And == can be chained (lines 32, 3
More
Since you've already broken the 80col boundary...
if cond1:
if cond2:
return True
return False
is simply "return cond1 and cond2". ;-)
Also, any(char.isdigit() for char in data) can be said any(map(str.isdigit, data)).
Then cond2 can be said all(any(map(f, data)) for
More
You have a weird definition of clear. ;-) Iterating over a genexp with for is really strange (when you can transform your item in the loop itself). At least write it as map(str.isalpha, words.split()).
Also, in line 4 you can just multiply count + 1 by is_word. ;-)
More