49
Phil15
30 56 64 Leader of the month
23067/ 25141
Last seen 29 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-shan.u2008
`[x for x in y]` is equivalent to `list(y)` but here you don't even need a list. A string is a good enough iterable: `int(max(str(number)))` More
First-pupo
No need of making a list. a string is an iterable that max can very well handle. More
Simple and readable-malion
What would happen with `'[ord(s) for s in "GeneratorExp"]'`? More
First-mefka5757
If you think Army like a list, consider class Army(list): #Army is now a list with all methods from list and your mind. #So no need of init, getitem, len, remove. More
[v2] count odd divisors with math formula-Phil15
The sieve requires too much memory. More
First(using DFS)-tigerhu3180 1
In a more pythonic way... x,y = max(dict1.keys(),key= lambda x:dict1[x]) # keys method is not really useful, I don't remember any situation where it is. x, y = max(dict1, key = dict1.get) # your lambda function already exists for dicts. if len(dict1) == 0: # or if not dict1 More
First-fed.kz
I don't see the point of the `~1` instead of `-2` except to make the code a bit weird. Miss I something here? More
Stuck in the middle with you-HeNeArKr
if `len(els) < 3` then `range(2, len(els))` is empty so lines 7-8 are not required. More
Three solutions + 1 in comments-Phil15
As I did for "replace first", I add this fourth solution: ```python # numpy.roll generalize our function. import functools as fn import numpy as np replace_last = fn.partial(np.roll, shift=1) ``` More
First-Rounin
Intervals are already sorted (see description), so `sorted(set(...))` is a bit useless. More
Second-fed.kz
First, line 10 can be written `return f'({self.x}, {self.y})'`. Second, I don't really see the point of OOP here, you just need `range(...)`. It's probably because you thought about `chain(*map(...))`. List comprehension is enough here. Like this (if you want `chain`): chain.from_iterable(ran More
First-liuq901 1
I would use "for/else" instead of "flag". What do you think? for i in range(1, 101): for j in range(4): if i % prime[j] != attempts[j + 1][0]: break else: return [2, i] More
numpy for easy rotations, itertools.compress and zip (length-check py3.10+)-Phil15
**EDIT:** in the arguments are of the **same** lengths. More
First-Elemenope
def navigation(seaside): for i, row in enumerate(seaside): # n/s coordinate for j, item in enumerate(row): # w/e coordinate if item == 'Y': cY = i, j # now it's a tuple. elif item == 'C': cC = i, j More
25 lines: dot product with cube coords-Phil15
Possible improvement (decrease the number of possibilities). Between line 27 and 28, put that: # Only keep keys when the value is useful (not empty sets) # But put useless cannons (can't shoot any enemy) at North... reach = [({k: v for k, v in dirs.items() if v} if any(dirs.values()) More
First-Adrian_Goh 1
Use global variables is usually a bad idea, like here. Honestly it should NOT have pass tests. You only pass them because of "check" part work, and little tests did not warn you about it. assert isometric_strings('add', 'egg') == True dict == {'a': 'e', 'd': 'g'} assert isometric_strin More
First-Elemenope
width = len(w1[0]) # at begining, can be good for readability. And I use it later. `range(len(...))` should be forbidden ^^ `enumerate` is good enough. for row in wl: for j, ch in enumerate(row): if ch == '#': layers[j] += 1 Your way to find weakest spot More
Clear-U.V 1
Don't you think you spam published solutions?! 6 (very very similar) published solutions. More
First-tigerhu3180 1
**First** f2 = lambda x, y: any(True if (x + i, y + j) in X else False ... # please write it... f2 = lambda x, y: any((x + i, y + j) in X ... **Second**, right now for me on checkio, I can't see after 107 characters width without pain ^^ For readability, PEP8 insist on width, width no More
First-MarcAureleCoste
First, you use numpy, I like it but '3rd party' is there for such solutions. Your `... == 0` is already a boolean, so you can just write return np.count_nonzero(np_matrix + np_matrix.T) == 0 # True when it's True, False when... # or return not np.count_nonzero(np_matrix + np_matrix.T) More
1 2 3 4 5 6 7 8 9 10 11
12
13