11
Last seen 3 years ago
Member for 9 years, 1 month, 28 days
Difficulty Normal
This doesn't work with exceptions as stated in the mission text. ;)
Also, you are using the same **for** expression three times!
More
I knew it must be possible to use an arbitrary number of arguments. I just couldn't figure it put. Thanks for showing me. ;)
More
Could have saved yourself all that sorting. That's what **sets** are for. ;)
More
Could have used a **set** for self.connections. No need for doing deduplication yourself.
More
Nice. I have to keep product() in mind. This is the second time, I didn't see its usefulness. ;)
But line 7 seems a bit, for lack of a better word, 'manual' to me. Those are also two lists, that don't need to exist IMHO. And line 8 is just too long. Why not break it into multiple lines. That would
More
Oh my! ;) This is supposed to be speedy? For starters, set() and list() are unnecessary. And I believe, you lose more time sorting and RE-matching, than you gain. And a simle
'abcdefghijklmnopqrstuvwxyz' in ''.join(sorted(text.lower()))
would have been enough, no need for RE-matching at all.
More
Line 2 is crying for a generator expression, if you ask me. ;)
Also, line 5 smells. :P Hard to follow, whats going on and waaaayyy too long.
More
What is it with throwing REs at everything that a string? And two of them no less. ;) Now I am not a RE expert, but I assert one would have done it.
Anyway it is so not necessary to strip the string to search in:
from string import ascii_lowercase as letters
there. :P
And then simply count let
More
Oh, I totally overlooked that you do **text.lower()** on line 9 and _then_, immediately _after_ that, you get rid of everything that's not a character. Come on. ;) There are no lowercase _non-characters_. So, if anything, do the filtering first and _then_ the lowercasing.
Oh, and for that regex? Ye
More
Why [-1] on line 3? Gets overwritten without doing anything with it on line 8. **str.count()** is at least 0, and if you get that far in your loop, then you at least didn't get an empty string to begin with. And the precondition says: 0 < len(text) ≤ 10**5. ;)
Also, why must **let** be a list? Oh,
More
Why populate the **frequencies** dictionary on lines 4 and 5? It only needs to hold items with characters and their respective count. If count is 0, then it doesn't deserve to occupy memory in a dict. ;) Line 9 takes care of the rest.
Line 11, while the **key** function is a neat idea:
sorted(
More
Oh, let me add: Line 16, an endless loop, really? Could have used:
for pos in range(26):
# or at least
while pos < 26:
More
Not very readable, sorry. Single character varibles aren't very nice.
Anyway, in lines 3 and 5 why not iterate over a range there too? You count the x and y indices up from 0 to 3 both time. And there are built-in functions and constructs, so one does not have to type all that stuff. Line 8, the sa
More
Nice. But the last line I don't like all that much. There is a variable in there, the player. The two **ifs** are basically the same only different players.
More
Sorry, I don't understand the language of your comments and variables. English would have been nice. And at least the first 6 lines of your **lsligne** could have been autogenerated, I am sure of that. ;) Maybe not in one step, but in two. I don't like seeing such a long list being hardcoded. Genera
More
Finally I see someone with the same idea of zipping the list. ;)
I just found out that reversed(zip(*game_result)) is a 90 degree left rotation of the matrix. That makes the check of the diagonals a breeze. Have a look:
http://www.checkio.org/mission/x-o-referee/publications/Peter.White/python-27/
More
I like the nested list comprehension. Also nice use of enumeration. Lines 4 and 5 are repetitious, though, but pragmatic I guess.
More