49
Phil15
30 56 64 Leader of the month
23067/ 25141
Last seen 7 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_colin_the_weapons-colinmcnicholl 1 1
First, you have done it, bravo. But * I don't like you have to rewrite equip weapons for every subclass of warrior even if it works. * I recently like try/except[/else][/finally] (for example in scripts for rename files without check if I can) but here in straight fight IMO... readability takes a s More
sum bool-Phil15 1
if you don't like I call _word(door)_ for each bool in the sum of secret_room, just add from functools import lru_cache @lru_cache(4) # for word function remembering the last 4 calls. Then word(door) is in memory. def word(nb): ... More
Compass, Map and Spyglass-JimmyCarlos 1 1
It's original to use a class for that with __sub __ for define distance. More
First_olin_map_compass_spyglass-colinmcnicholl 1 1
math.hypot(x, y) == math.sqrt(x**2+y**2) def double_distance(point_1, point_2): dx = abs(point_2[1] - point_1[1]) dy = abs(point_2[0] - point_1[0]) return max(dx, dy) #your code simplify itself. #And this function is the only distance function you need. It will More
Fixed solution-mindaugas.dadurkevicius 1 1
(x_cr**2 + y_cr**2)**(1/2) # use math.hypot(x_cr, y_cr) I don't see the point of try/except here. It's more readable with only one assertion in the try (here we don't know what you try to pass), like try: i = string_input.index('best') except ValueError: i = None #'best' More
y=kx + b-quarkov 1 2
I will have used math.inf instead of 1e10 (or split into 2 cases), and 0 instead of 1e-6 (so r==int(r ) here). And you can unpack dots with x1, y1, x2, y2 = *dot1, *dot2 # it's more pleasant. More
Caution! Pure magic.-Merzix 1 2
You have the list of values the function take, I have the map of it (with matplotlib). We can see the part between 0 and 100 repeating multiple times on it. More
9-liner: finally clean (Phil15 thanks for pointing the mess)-przemyslaw.daniel 1 1
I would see pairs like constant here. I like it. And why set(sorted(...)) instead of set(...) ? :-D Maybe PAIRS = ((0, 3), (1, 2), (4, 5)) cube_rims = lambda cubes: {''.join(sorted(cubes[x]+cubes[y])) for x, y in PAIRS} More
comprehension-kurosawa4434 1 1
I like your use of the key argument 'reverse' but `reverse=r%2` is enough. More
Create deck, remove cards from deck-Merzix 1 1
you can do hand.sort() # and use it instead of s_hand. I like your set "unique" because for large deck and small hand, your set "unique" is small. More
9-liner: finally clean (Phil15 thanks for pointing the mess)-przemyslaw.daniel 1 1
And if you want it shorter and if you like next. from itertools import combinations tower = lambda cubes: next(size for size in range(len(cubes), -1, -1) for cur in combinations(cubes, size) if len(set.intersection(*map(cube More
Slow-quarkov 1 1
Why a while loop here? Instead of for amount in range(3, len(numbers)+1) The flag thing... flag = all(is_match(c[i], c[i + 1]) for i in range(amount - 1)) # short/clear code If the first thing is false, you don't continue. In your code, you look all i in range(amount - 1). Well, you can More
First-fed.kz 1
Typically why I don't like map with lambda functions. Comprehension thing is so more readable (and shorter), and good unpacking ^^. result |= {COL[c] + ROW[r] for c, r in new} I didn't thought of knight move as manhattan distance 3 (`abs(i)+abs(j)==3`), it's original! Like it! More
10-liner-Merzix 1
Two comments (I'm in the mood tonight): * First, range(len(...)) should be (nearly always) enumerate(...). Then no need of itertools.product. * is_valid is not clear to me. So new version def hypercube(grid, target='hypercube'): prev = None is_valid = lambda xA, yA, xB, yB: abs(x More
For me is clear, advise how to improve myself-Rafal_Bartko 1 1
You don't need cards.sort(), it's already sorted by construction. cards list can be improved with list comprehension cards = [(i, i+1) for i in range(deck)] # clearer right? The big for loop isn't really clear for me. * i,j are not very well named here I think. * Given a "i" in hand, you just More
1-line-Oleg_Skomorokhov 1
`sorted` take any iterable, no need of a list so `sorted(set(items))` is enough. More
Text Editor-JimmyCarlos 1 1
Don't like your show method. '[{1}]{0}[{1}]'.format(self.text, self.fontName) #or f'[{self.fontName}]{self.text}[{self.fontName}]' is more appropriate I think. Generally, I prefer f-strings but in this case, I prefer the first with 0-1. And you reinvent the wheel to copy. More
quarkov's-quarkov 1 1
**1** If you want to write range(len(thing)) you probably should use enumerate(thing). m_rotated = [[m[j][i] for j in range(len(m))] for i in range(len(m[0]))] sum_x, sum_y = min(sum(line) for line in m), min(sum(line) for line in m_rotated) y = min(i for i, row in enumerate(m_rotated) More
Counter-kurosawa4434 1
map is usefull for simple mapping. For complicated ones, list/generator comprehension is more readable IMO, and no need of _import chain from itertools_ here with generator comprehension: return max(Counter(normalize(pos) for cube in cubes for pos in possib More
Sorted Faces (6-liner)-BrianMcleod 1 1
return Counter(''.join(sorted(x)) for faces in cube_opposites for x in permutations(faces, 2)).most_common()[0][1]/2 # no // ? More
1
2
3 4 5 6 7 8 9 10 11 12 13