49
Phil15
30 56 64 Leader of the month
23067/ 25141
Last seen 7 hours 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
First-Divya_Amin 1
You do not really use `i` but `number_str[i]` so for digit in number_str: list_num.append(int(digit)) Second, list comprehension is great list_num = [int(digit) for digit in number_str] Third, or just return max(int(digit) for digit in str(number)) More
First-Chazlar 1
* the second return is useless. * you could list words on the sentence, then join them with spaces def morse_decoder(code): word_list = code.split(' ') words = [] for x in word_list: chars = [MORSE.get(z) for z in x.split(' ')] # or MORSE[z 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
search and destroy-Adrian_Goh 1 1
while ...: for pair in '()', '[]', '{}': sstr = sstr.replace(pair, '') return not sstr 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
Markov chain, numpy, scipy.sparse.spdiags-Phil15 1
@ogoro Just after looking your recent publication for this mission, I've dug up my [old solution](https://py.checkio.org/mission/box-probability/publications/Phil15/python-3/markov-chains/) and improved it. It's still "good" math but I found "spdiags" that handles matrix diagonals the right way. I More
New battle.fight method, and a different management of attributes/method.-Phil15 1
With _lancers_ who can attack _two units_, I felt the need to _start over_, looking at future missions, to have a more global view of these missions. 1) Battle.fight method and management of the dead warriors (Army properties) are completely reviewed to allow lancers to hit a second unit. 2) Differ 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
Re.sub solution-Nocturne13 1 1
`replace_all('qwerty', '.', '')` would return `''` because `.` as a regex match any character. There is sadly no test about this. To avoid that (do we want to avoid that?), `re.escape` would be useful (but then why use "re" at all?). def replace_all(mainText: str, target: str, repl: str) -> s 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
all lines found twice-juestr 1 1
To answer your comment on my solution, I agree. Liked solutions are not necessarily the best ones. But I give you a boost. Just for fun, I considered making it shorter with this, not necessarily better: from collections import Counter from itertools import combinations, starmap line_c 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 - 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
Explained-Selindian 1 1
Note that `if len(result) > 0:` and `if result:` are equivalent for a list. More
1 2 3 4
5
6 7 8 9 10 11 12 13