49
Phil15
30 56 64 Leader of the month
23067/ 25141
Last seen 21 minutes ago
Member for 6 years, 2 months, 27 days
Difficulty Advanced
I was a math teacher in France for two years. I'm currently reconverting to IT, I'm here to improve my Python skills, and practice English.

Best reviews / Newest reviews
First-kazuki.h 1 1
You can write `int` instead of `lambda: int()`. A simple dict with "(int, int)" keys would be enough. And the returned value is surely equal to `dp[i][weight]`. I prefered using a list but defaultdict is also nice. More
1-liner-Stensen 1 1
After I deobfuscated it, I would change `[...].pop()` for `next(...)` since it has a single element. And since we are in creative section, I would even add it is shorter by 2 chars. Or even shorter `[...][0]`, but I prefer next. _Next_ deobfuscated version: from calendar import Calendar fr More
4-liner: aim for the accuracy dawg-Stensen 1 1
I did not know about this log determinant, thanks. But I have to say that `_` is usually used for variables we don't use, such as for _ in range(5): print('Hi!') time.sleep(1) Here I had to see the doc to know it was the sign of the det. I could have guessed but I did not, the More
Standard library:itertools-takewhile-PatrickFeiYu 1 1
Great use of takewhile function. Not the most obvious choice here. More
1-liner works just as much as I can hope-Stensen 1 1
I was just curious about "pure code" in the title. But so much to tell about this creative code. "not len(l)==0" is equivalent to "l" "1%len(l) == (1 if len(l) > 1 else 0)" since len(l) > 0 but "1" is enough after that it becomes "l[1:]+l[:1] if l else l" but "l[1:]+l[:1]" is enough More
9-liner: Feed Pigeons the right way!-Stensen 1 1
while sum(answer) < N: # sum(answer if answer else [0]) len(list(filter(None, answer))) # It count the number of true elements so equivalent to sum(map(bool, answer)) More
13-liner: check every single words permutations-Stensen 1 1
`[crossword[i] for i in (0, 2, 4)] == crossword[::2]` More
Lateral thinking-Samuele_Baracani 1 1
Great, I think I did not thought of `title` method. But to make it a bit simplier: def to_camel_case(name): names = name.replace('_', ' ') return names.title().replace(' ', '') # delete spaces `join` is not the only useful method 😉 More
As simple as I can-Samuele_Baracani 1 1
You do not need to make a list, args is a tuple (which is "like" an immutable list). # example: checkio(1, 2, 3) # args = (1, 2, 3) (type tuple) # your list: [1, 2, 3] (type list) # there are not the same but they behave the same in this situation. def checkio(*args): More
search and destroy-Adrian_Goh 1 1
while ...: for pair in '()', '[]', '{}': sstr = sstr.replace(pair, '') return not sstr More
perimeters-ogoro 1 2
Well it is clearly nicely short. After looking tests, which seem to be strong enough, I must admit it has to be right. Then I thought about it... And while I easily admit than every line has to be in a "perimeter" in one way or the other, I have hard time understanding why it is sufficient to have More
indexes-ogoro 1 1
First, it is great to not run so algorithm on the tree for each pair. It's nearly perfect. The only thing I don't like here is about `index_prefix`. We can for example have `str(10)==str(1)+str(0)` hence have the same `index_prefix` without being on the same path. The easiest fix would be to have More
Diff-pandektis 1 1
`sorted(list(map(lambda x: (abs(x-one), x), values)))[0][1]` is equivalent to... # You don't need to sort the entire thing to only get the minimal element: # sorted(...)[0] == min(...) min(list(map(lambda x: (abs(x-one), x), values)))[1] # No need to give a list to sorted/min/max s More
First-Lemur21 1 1
The `+[1]` is because `structure` can be empty sometimes, but note that `max` function has an argument for such cases: "default". max([1 + how_deep(el) for el in structure], default=1) Or without "for loop". 1 + max(map(how_deep, structure), default=0) More
scanner with code dictionary-ogoro 1 1
You asked me why no-one seems to use `re.Scanner` for this. Well personally I did not know it, I probably looked at it someday and forgot about it (or not after writing this message). I just went to the documentation and type `help(re.Scanner)` and I still don't know what it does exactly. Looking a More
First-sanjieyu 1 1
Do you know about `map`? I like the key argument and list comprehensions but sometimes, `map` can be quite useful: len(max(rows, key = len)) # or max(map(len, rows)) ["".join(item) for item in zip(*rows)] # or map("".join, zip(*rows)) # could be list(map...) to be reall More
Sudo make me a curry-veky 1 1
Great curry and good comment-explanations, as always. I particularly like `blah.__get__(4)` replacing `partial(blah, 4)`, it's a neat trick. More
16-liner: rapid fire-przemyslaw.daniel 1
_, size, split = distance[0] # smallest item without popping it split += 1 heapreplace(distance, (split/size, size, split)) # faster than heapop followed by heappush It's still `O(log n)` but the factor is a bit lower. After testing this change on all tests 10000 More
First-bravebug 1 1
The sequencer part is a bit weird, you don't need it. `triangular_numbers` can be a generator function itself. That's why I wrote this, what comes next is more optional. Second, insert an element at the beginning of the list suggest you instead need a queue (or we could append to a list, and rever More
First - but Shorter-blacksnblack 1
`True if boolean_expr else False` is simply equivalent to `boolean_expr`. `False not in [boolean_expr for ... in ...]` is simply equivalent to `all(boolean_expr for ... in ...)` More
1
2
3 4 5 6 7 8 9 10 11 12 13