49
Phil15
30 56 64 Leader of the month
23067/ 25141
Last seen 8 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
Simple and readable-malion
What would happen with `'[ord(s) for s in "GeneratorExp"]'`? More
First-Tanis1981
replace_all('o', 'o', 'oo') 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
Obfuscated milp-Phil15
This is an obfuscation of [my 3rd party solution](https://py.checkio.org/mission/blood-distribution-3/publications/Phil15/python-3/scipy-19-milp-mixed-integer-linear-programming/). Tricks here: - `integrality=0,` and `lb=0,` are actually default values so I didn't need to write those - 1-letter na More
max, with a key-Phil15
Note: Here, `max` would be enough by itself (because isoformat is sortable by design), but it would be easy to change this solution to consider other datetime formats, something like: get_latest = functools.partial(max, key=lambda s: datetime.datetime.strptime(s, '%H:%M %d/%m/%Y')) More
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
Dynamic programming-Phil15 2
Or a more "complex" unpacking instead of the whole try/except block: value, weight, limit, *_ = item + (total_weight,) # there is also this below but I don't like it. value, weight, limit = (item + (total_weight,))[:3] More
A derelict battery-veky 1 2
Nice treasure from the deprecated stdlib. Only looking at docs, I could not find this gem. Curious, I looked the source code (with "inspect.getsource") and saw a comment "_This will die of IndexError when counter is too big_". So after some calls, I found out that it fails for 4000 (and bigger numb More
str-Phil15
If you are reading this solution and asking yourself why this solution can even be publish (the function signature being clearly incorrect), it's because: 1. The mission (at the very beginning) did not have the second parameter which was latter added (to make it really different from another palind More
+8 is not enough for this task =)-Kolia951
As the mission author, I receive emails about new solutions and saw the title of your solution and I'm glad you liked my task. =) More
Clear-U.V 1
Don't you think you spam published solutions?! 6 (very very similar) published solutions. More
For changed mission - Explained-Selindian 3 1
Just so you know, instead of `num.insert(0, rem)`, you could have done `num.append(rem)`. The elements of `num` would be reversed, but it would not change the final result. That and `append` is contant time (`O(1)` complexity, it just add the element at the end) while `num.insert(0, ...)` does `len( More
always return to start-Sim0000 1 1
The first precondition > You can collect all gems in any possible order (otherwise it would be far more difficult). is there to ensure there is not multiple rooms (without suggesting strongly connected components too much). Or more precisely, gems are in a single strongly connected component acces More
[typed] Coroutine, filters, cached expressions-Phil15
I think the "checkio" function should receive only one “step info” each time and process it, instead of giving the entire history, and a coroutine is a good way to do just that. Plus, it's a rare occasion to use `typing.Generator` in a meaningful way. More
First-Nikolay86
You don't need "nonlocal" here. In a new example, define variable "s" inside "g" is okay, but we can't use the "s" outside for it. >>> def f(n): s = [] def g(i): s = s + [i**2] for i in range(n): g(i) return s >>> f(5) Traceback More
First-phongtt2
Compare with `>` already give a boolean, you can just return the (boolean) comparison: return items.count(True) > items.count(False) More
BFS resolution order and backtracking-Phil15
Coming back to it 19 months later, I still understand it clearly. It makes me happy. ✨ And the only thing I would really change is: No need of the variable "okay" in the "possible_words" function: the "else" clause would do the job. changes = [] for rc, letter in z More
binary search-Lemmi 1
A recursive "binary search" on such small list is quite overkill, but why not. However, it's already implemented in the standard library: from bisect import bisect def ryerson_letter_grade(pct: int) -> str: return MARKS[bisect(POINTS, pct) - 1] (Tested on all possible percentages: More
Explained-Selindian 1 1
Note that `if len(result) > 0:` and `if result:` are equivalent for a list. More
numpy for easy rotations, itertools.compress and zip (length-check py3.10+)-Phil15
**EDIT:** in the arguments are of the **same** lengths. More
1
2 3 4 5 6 7 8 9 10 11 12 13