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
Strings of rings-HeNeArKr 1 1
No need of itertools.chain counts = Counter(ring for cube in cubes for ring in rings(cube)) you can do rings without while loop: i = ring.index(first) ring = ring[i:] + ring[:i] I did this rotation like you at first. Ah and you can change rings in generator: More
recursive flood fill-fokusd 1
A little improvement on the end: return any(fill(row, col, '') for row in range(len(grid)) for col in range(len(grid[0]))) # Not really useful here but you should considerate use enumerate(...) instead of range(len(...)) map is good if it's a simple one. List c More
Simple-Chocolater 1
Dict comprehension is good too... Every single time you want to use range(len(...)), you probably should use enumerate(...) instead. Here, for example, it can be this. Enumerate rows, enumerate cells of the i-th row, put (i,j) when cell is the letter. all_letters = {letter: [(i, j) for i, row More
Compact solution with numpy and scipy.ndimage-rodka81 1 1
I didn't understand your solution at first, because of my ignorance of scipy (and then scipy.ndimage). But now I really like it, you inspired me a solution for Bacteria Colonies (challenging task) on Incinerator Island. Not a compact solution but a natural solution I think. A bit more complicated b More
With numpy and scipy.ndimage (again)-rodka81 1 1
Just a little improvment I can suggest. your while loop should be a for loop. Then this can simply be return any(... for ...) No need of key in max if you exchange center and np.sum(c). I would write it with generator comprehension. return max(((np.sum(c), center) for center, c in coloni More
Third-ndj_ys 1 1
all() is really good No need of brackets here: generator comprehension is good too. len(m**[i]**) useless here because m is a square matrix. all(m[i][j] == -m[j][i] for i in range(len(m)) for j in range(len(m)) ) More
First_the_buttons_with_graph_connected_components-colinmcnicholl 1 1
You seem to like OOP now. I don't understand all of the code, it seems complicated. Well I was looking for connected components too (with DFS, you it's BFS) but I didn't store many things like you (grid, graph, new graph, ...). **_Now some improvements I suggest:_** You can change connected_compon More
First-colinmcnicholl 1 1
Lines 15-20 in a else and 'return nothing' can disappear :) I never used collections.defaultdict yet, I don't really see the goal of it. Dict comprehension seem to be enough for me to create a graph. graph = {(r, c): adjac(r, c) for r, row in enumerate(grid) fo More
Сomplicated, but very fast-Merzix 1 1
I like your idea to search speeds from both sides (well if I understand it enough ^^). Slicing make a copy so: I would use `reversed` instead of slicing `[::-1]` and use `islice` instead of `[i:i+n]` because you imported it. speed_braking = reversed(speed_change(reversed(sections))) #and simpl More
x>max?-BrianMcleod 1
from typing import Iterable def is_ascending(items: Iterable[int]) -> bool: return all(x>max(items[:i+1]) for i,x in enumerate(items[1:])) should be enough because `all(empty iterable) == True`. You do many slicing (so a copy of items with every slice), don't like it. More
First-Vasily__Chibilyaev 1 1
`map` is good if it's a simple one. Comprehension thing is more readable, shorter for more complicated mapping. I only do `map` if the function I want apply have a name (and if I don't need to change the result into list, set... I don't do `list(map(function, iterable))`, I prefer `[function(a) for More
My first Generator!-BrianMcleod 1 1
First, **congratulations on making your first generator!** I think you understand how this works now. If you don't want `i` but `i+1`, `range(1, len(operations)+1)` or in my version `enumerate(operations, 1)` (for a start at 1). I did a generator at first too (probably influenced by you telling me More
stack-fokusd 1 1
Like it!! Probably because it's nearly mine and I already like it. Three comments * Good name `stack`. I don't remember how I named mine. * You write `stack.append(el)` in both if/else. * `yield from reversed(stack)` is more clear it's reversed than with `pop()` IMO. But then `stack = []` is requir More
First-colinmcnicholl 1 1
I started to think I would not see `list.extend(range(...))`. But you can unpack tuples from items by changing the line 5 into for start, stop in items: # and delete the line 6. More
Second-fed.kz 1 1
Like it but an iterable is enough. :D def checkio(array): for number in array: try: array.index(number, array.index(number) + 1) yield number except ValueError: pass More
I know it's awful-Merzix 1 1
I agree it's awful ^^. I tried some improvements. Happy new coding year! from math import ceil def available_coins(price, denominations): for i in sorted(denominations): if i <= price: for _ in range(price // i): yield i def chec More
First-vit.aborigen 1
line 32: folders = folders[:-1] # you do an entire copy of the list # or folders.pop() # just pop last element, usual for lists. line 20: `char in '-._~'` line 9: `first_rule = url.lower()`. No need of line 6, it's already clear it's converting to lowercase. line 21-22: I like your w More
Short solution using numpy-swagg010164 1
Well numpy is good but it's more for "3rd party" category. def checkio(matrix): a = np.array(matrix) b = - np.array(a.transpose()) return (a == b).all() # it's already a boolean, so just return it. It's great More
First-johan4622 1 1
You can write `if matrix[i][i]:` instead of `if matrix[i][i] != 0:`. It's a python thing. Don't see the point of `* (-1)`, just put a `-` before like `- matrix[i][j] == matrix[j][i]`. `matrix[i][j] * (-1) == matrix[j][i]` and `matrix[i][j] == matrix[j][i] * (-1)` are the exactly the same. Final More
First-Sillte 1 1
First, I'm glad you liked it. You probably spent a lot of time on it. There is ROCK, GEMS, MINES, ICE and ROUGH places in same proportion I think. You go only on GEMS, ICE and ROUGH places so 60% of the map (80% if you go on mines) if this can help you decrease the naive upper bound. Then, thanks t More
1 2
3
4 5 6 7 8 9 10 11 12 13