49
Phil15
30 56 64 Leader of the month
23067/ 25141
Last seen 20 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-mihail.ponomaryov
I didn't know `partition`, like to finally know it, so `+2`. More
Strange solution with OOP. Thanks user @Phil15 for help-fed.kz
I suggested you OOP thanks to veky's solution. You can look it, it also defines a `__lt__` method, but it's more readable/simpler. More
@join(',') on generator with Counter-Phil15
"Take the least taken detais" (with counter stock most_common) is a good strategy with really readable code IMO (if we know Counter of course). join decorator was copied from another of my scripts making what remains pretty IMO. More
Simple and readable-malion
What would happen with `'[ord(s) for s in "GeneratorExp"]'`? More
First-kurosuke 1
You could use `float('inf')` or `from math import inf` for min_cost. And global variable are tricky to use. You can define a function into another. Then you won't have to use a global variable. def cheapest_flights(): min_cost = float('inf') def cost_calc(): # cost_ More
numpy-rodka81
Great use of numpy and scipy! I like the simplicity that these modules offer to your code, except lines 24-31, I would like a function similar to `pad` to reduce the matrix. :-) Or apply pad function only if it's necessary. More
aligned-quarkov 1
`trees[1:]` is enough, why not `len(trees)`? More
85 chars and still probably fastest code-Ylliw
with `sum([...])` instead of `sum(...)`, you store an entire list before doing the sum. `for p in list_of_one_element` to not write the expression twice is a good idea but here, `float_expression.is_integer()` can do the job. yours: sum([p==int(p)for a in range(int((2*n)**.5))for p in[(2*n- More
Neighboring neighboring... area of obstacles and border-Phil15
Lines 30-33 could be a single line with future python 3.8: while next_cells := neighboring_area(cells) - obstacles: ... See more in the description of [PEP 572](https://www.python.org/dev/peps/pep-0572/). More
[actually inefficient] Maximize lit area with a priority queue-Phil15 1
For my solution, I finally compared the use of a priority queue with a stack (so a list, like a DFS implementation) and a queue (like a BFS implementation). To do minimal changes, here my changes: ```python # Instead of from heapq import heappop, heappush # For use a list instead of the priority qu More
Clean OOP Solution with full inheritance-bsquare 1
### Timings Well first, I executed your code on all check tests. It is (with debug lines commented, because create strings for these lines took time) **2.4 times** slower than mine. Thanks to `import cProfile; cProfile.run('''tests block''', sort='tottime')`, I know it's because of `next_living_war More
How do I optimise my code? Write your opion in the comments-Frazer-dl
write a function to avoid to write the "same thing" three times: def some_function_name(a, b, c): return round(m.degrees(m.acos((a ** 2 + b ** 2 - c ** 2) / (2 * a * b)))) `while` should be `if` `return [0, 0, 0]` is enough, no need to write `list(some_list)`. More
Pearls in the Box-IRONKAGE
More creative than clear IMO. No need of parenthesis around `float` or around no rounded result: `round((...), 2)` -> `round(..., 2)`. More
First-JingMeng 2
L[0 if (20 > age or 40 < age) else 1] # or just L[20 <= age <= 40] Why does it work? `20 <= age <= 40` is a boolean True/False, which are integers: `True == 1 and False == 0`. More
First-mortonfox
Personaly I don't like too much "append", I prefer to yield things. Less code can be more readable. It still not readable enough for me (too much indexes) but it's a start. def rectdiff(r1, r2): if r1[0] < r2[0]: yield r1[0], r1[1], min(r2[0], r1[2]), r1[3] if r1[2] More
First-alexandrov.net
`for x1, y1, x2, y2 in recs` is simplier More
First-bourbaka
area = area.union(one_rec(rec)) # or just area |= one_rec(rec) More
First-colinmcnicholl
Ahah, we wrote the same code. They are minor changes obviously but it is the same. More
First-Jonethan
* Use else when needed, we exit the function when we `return` something. * `not ... == ...` is the same as `... != ...`. * A number that does not finish with a zero does not seem to be a special case to me, but 0 does. * You do not really use the index, but you want to iterate on the string in a rev More
First-meta77fora
Do not overuse parentheses, while, return and ... are not functions: def beginning_zeros(number: str) -> int: i = 0 while number[i] == "0": i += 1 if len(number) <= i: break return i # It can even be def beginning_z More
1 2 3 4 5 6 7 8 9 10
11
12 13