57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 2 hours 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.
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
"a.count(b) > 0" is just a very convoluted way to say "b in a".
Also, please drop the semicolon. Your C is showing. ;-P If you want to somehow group lines 2 and 3, it's
txt, cnt = text.lower(), 0
And be a bit more careful with names. First, you don't have to name everything, and second, names
More
Waitaminute. Not even a C programmer would use _that_ many parentheses. Do you maybe come from The Tower of PHP? :-O
More
Here it doesn't matter much, but be aware of [Schlemiel problem](http://en.wikipedia.org/wiki/Joel_Spolsky#Example). ;-)
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
Please use // instead of int(/). Or better yet, see divmod builtin.
Also, tail recursion is not really Pythonic... looping is better. This would fail for number with more than 100 digits.
More
Again, your branching looks weird. You _either_ check the conditions independently, _or_ you chain them:
if number < 10: ... | if number < 10: ...
if 10 <= number < 20: ... | elif number < 20: ...
if 20 <= number < 100: ... | elif number < 100: ...
if number >= 1
More
Aaargh. My eyes hurt. :-P
First, this is a classic example of how to go overboard with names. It would be _more readable_ if game_result was named just `r`. :-P
And those comments should really be names.
m_diag = r[0][0] + r[1][1] + r[2][2]
Or even
m_diag = ''.join(row[i] for i, row in
More
Sorry, but doesn't. mapping lambdas doesn't make sense when you have genexps:
all(map(lambda x: cond, seq)) ~~~> all(cond for x in seq)
Simpler, shorter, more elegant, and faster.
Also,
from string import ascii_lowercase as alp
But you already know that probably. :-)
More
You have a very convoluted way of expressing yourself. :-)
First, line 5:
if not array:
(or just reverse the logic and say `if array:`)
Second, why sum `[i for i in blah]` when you can sum `blah` directly?
Third, you obviously know that `array[:...]` has a default 0 for start. In the same w
More
"64" is a precondition, not a condition. :-] `{10,}` quantifier would be better.
And if something: return True \\ else: return False is simply `return bool(something)`.
More