57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 14 hours ago
Member for 11 years, 6 months, 24 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 don't like CamelCase. Luckily Python has a style guide. :-P
A much more important question: why does a new programmer use Python 2?
More
Ok, let's say you didn't know how to generate sets in less than 15 lines. But should I seriously believe that you thought it's better to compare sets with [XNOR](https://en.wikipedia.org/wiki/XNOR_gate) than with simple `==`? :-P
More
Ok, this looks better. But can be improved a lot.
First, you don't need so many parentheses. Last line, return doesn't need them:
return tally(first_word) == tally(secod_word)
Second, not only lists can be comprehended: sets can, too.
return {(letter, word.count(letter)) for letter in wo
More
It's funny that without parentheses around if/else expression it would be more natural and more readable. :-)
Also, 0 before : and len() around array can be dropped.
More
That 999 is so ugly and error-prone. Why not
from math import inf
? :-)
More
Nothing bad would happen if you popped it (after making sure stack is nonempty, BTW `if not stack` is much easier) before returning False:
if open[c] != stack.pop():
return False
Also, whenever you have `.index` inside `[]`, you should probably use a dictionary instead of parallel sequ
More
Having a separate function means you should name your things, not index them.
def convert_point(point):
''' Converts points into 4 turns '''
i, j = point
return [(i, j), (i, ~j), (~i, ~j), (~i, j)]
For looping too:
for i, j in points_ordered:
yield ciphered_pas
More
Why check for `__iter__` and do something different? It's not what builtin does:
> min(3)
TypeError: 'int' object is not iterable
More
It's weird that `is_fib` always starts from the beginning... writing it with a generator would be much nicer. :-)
More
Argh, triplicate! :-o
word = r'[a-z]+'
three_words = ' '.join([word] * 3)
found = re.search(three_words, input, re.I)
return bool(found)
More
When you're bad, be truly bad. :-]
filter('0'.__ne__, str(number))
Of course, much better is
filter(int, str(number))
\- not bad at all. ;-)
More
Line 2 is totally pointless. Lines 15-18 are also pointless. Line 12 is just `fhands |= it`. Lines 10 and 11 can be written in the same way. Lines 6, 13 and 14 can be written using `else` loops.
More
Again, obsession with lists. `merged` is the true solution, line 13 is just bureaucracy. :-)
More