49
Phil15
30 56 64 Leader of the month
23067/ 25141
Last seen 1 hour 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
def four_more(i, j, d_1, d_2): for t in range(1, 4): if matrix[i][j] != matrix[i + d_1 * t][j + d_2 * t]: return False return True # or def four_more(i, j, d_1, d_2): return all( matrix[i][j] == matrix[i + d_1 * t][j + d_2 * More
First-koyana222 1
`([0-9])\1{3,}` is a simpler pattern. I would want to simplify what's next too, such as: for row in matrix: row = "".join(map(str, row)) if regex.search(row): print("a") return True 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
max_digit-Bondr
You can annotate with nearly whatever you want, but here `int` annotation is not useful, and `list` annotation is (useless and) just wrong in the sense that "map" returns an object that is not a list at all. "max" returns an integer (because "lnumber" is an iterable of integers), hence no need to c 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
Xs and Os Referee-iskenderunbtr
I just propose a clarification of your code. I did not test it but it should work. ```python from typing import List def checkio(game_result: List[str]) -> str: for xo in 'XO': # check rows for row in game_result: if row == 3 * xo: return xo 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
Second_thanks_Phil_15_and_a_hayashi-colinmcnicholl
Following... I understand why you use self.defense=0 on units without this attribute, but it's different to have the attribute = 0, and don't have the attribute. For 8th mission (it's not for today), this wouldn't be a great idea at all. hasattr function is useful on that point. Anyway, fight funct 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
Simple and readable-malion
What would happen with `'[ord(s) for s in "GeneratorExp"]'`? 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-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
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-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