49
Phil15
30 56 64 Leader of the month
23067/ 25141
Last seen 6 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
Simple-petr.synek.phd
Hi! Found that weird marked = marked|set().union(*newly_marked) # Instead I suggest marked = marked.union(*newly_marked) # or if update the set "marked" IN-PLACE is okay (I think it is) : marked.update(*newly_marked) and indexed_circles = [(index, circle) for index, circ More
One liner-petr.synek.phd 1
Well if `i != 0` then `i - 1 >= 0` "1" if val == line[max(0, i - 1)] and i != 0 else "0" str(int(i != 0 and val == line[i - 1])) More
First-mazeua
Great use of maketrans/translate, but no need of the space in the table. alphabet = string.ascii_lowercase delta_alphabet = alphabet[delta:] + alphabet[:delta] table = str.maketrans(alphabet, delta_alphabet) More
4 clear lines: next(possible points generator)-Phil15
We can do it in three lines without import math.hypot, but with complex numbers: a little less clear IMO. grid = lambda N: ([i,j] for i in range(N) for j in range(N)) test = lambda i, j, probes: all(round(abs(i-x+(j-y)*1j)) == d for x,y,d in probes) checkio = lambda previous: next(c for More
date.datetime-Anton_Prokopovich
abs(d1-d2).days #work so this too return abs(date(*date1) - date(*date2)).days # then eventually days_diff = lambda date1, date2: abs(date(*date1) - date(*date2)).days More
Same as to_encrypt; rotate ascii_lowercase by delta to build cipher map-kkkkk 1
`cipher_map` could be more easily done that way. from string import ascii_lowercase as alphabet cipher_map = str.maketrans(alphabet, alphabet[delta:] + alphabet[:delta]) # cipher_map is now of type Dict[int, int] instead of Dict[str, str]. # and no need to consider spaces, commas o More
[numpy] 9-liner: Math magic with Markov chain-Phil15 1
**Few explanations...** (I won't write a mathematical article for it) _Mathematically:_ P is the transition matrix of the markov chain involved here. _In english:_ P[i,j] is the probability to go to j from i with one dice roll. M is the same thing as P with a ban on going through target. **1/(I- More
First-colinmcnicholl 1
By keeping what is not in `special_txt`, you could keep special chars you do not want (if the text had such things), so I think it is better to keep what is in `set(string.ascii_letters) | {' '}`. More
First-vladislav.bezugliy
Even if you reinvent the wheel (it's not recommended like Veky said)... Lines 6-8 can be one simple line: ints[i], ints[i+1] = ints[i+1], ints[i] And while loop should be a for loop here. More
Find the 1st father then all easy-rockwellshabani 1
- Sets are great, fully use them. - `sorted(list(x))` and `sorted(x)` are both good, sorted function accept any iterable, sets included. - I prefer used named variables to indexes and only use `_` for variable I do not use. - I made a few changes and comments. ```python from collections import Coun More
Neighboring coordinates?-Phil15
Same thing, shorter! Without test of enough letters, and a shorter last part. Not enough readable IMO, that's why I kept my code like it is. from itertools import product def hypercube(array, word='hypercube'): coord_letters = {letter: [] for letter in word} for i, row in en More
First-Chazlar
* I prefer `for a, b in ...` at `for x in ...: x[0], x[1]`. * tuples: please `(a, b)` not `tuple([a, b])` * list/set/... comprehension is good. * `abs` is optional but kind of appropriate here. * I'm pretty sure sets are not useful for you here, lists should be enough. Sets could be good with a More
First-Chazlar
Great use of Counter [elem for elem, count in counter.most_common() for _ in range(count)] More
First-panama555
N = len(matrix) # == len(matrix[0]) for y in range(N - 3): for x in range(N - 3): ... then `if` are much easier!! More
First-lunskra
import re # ? Consider use the maximum built-in function with the key parameter. max(data.keys(), key = lambda x: data[x]) # this is doing the exact same thing as your code. Or just max(data, key = lambda x: data[x]) because it only look keys when read through a dict. More
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-mortonfox
No need of sum lists: Counter(ring for cube in cubes for ring in sides(cube)) I did a sum at first too. 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
[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
DFS-drpepper1412
List/Dict comprehension is good def convert(grid, points): return {grid[i][j].lower(): (i,j) for i,j in points} path = [(i, j) for i, row in enumerate(grid) for j, cell in enumerate(row) if cell.lower() == check[0]] Your count variable is a li More
1 2 3 4 5 6 7 8
9
10 11 12 13