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
Minimum changes from Vampires-BrianMcleod
if you don't need init method in Battle class, don't write it. len(army1.units) != 0 #or bool(army_units) line 102 #you can consider Army like a list with class Army(list): ... I like your management of behind units. 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
First-Nep
You can consider Army like a list with class Army(list): ... I would prefer kick like method of the warrior class and unit.kick(enemy_1, enemy_2) Maybe a second_warrior method in Army class for simplify battle fight. More
First-michalmikulasi 1
You don't need to iterate on the text. You're almost lucky it even works. def correct_sentence(text: str) -> str: text = text[0].upper()+text[1:] if text[-1] != ".": text += "." return text More
[creative] Scientific imports + 1-liner: Markov chain-Phil15
Note that when I published this I could not put it in **creative** category where it clearly belongs. 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
Unique neighbors and small paths search-Phil15
All tests in a quarter of a second on my computer. Fast enough for me. More
numpy-rodka81
Great use of numpy and scipy! I like the simplicity that these modules offer to your code, except lines 24-31, I would like a function similar to `pad` to reduce the matrix. :-) Or apply pad function only if it's necessary. More
short, recursive, max with default argument-Phil15
If the iterable is not necessarily a "list of lists of ... of ints/floats", but an "iterable of iterables of ... of not iterables". def how_deep(iterable) -> int: try: return 1 + max(map(how_deep, iterable), default=0) except TypeError: # not an iterable anymore, re More
Heuristic search for most contentious light-JamesArruda 3
I really like the fact you use **corners** (so +2). I thought about it too, but my solution worked without this kind of deduction. Line 54: `for v in range(1, 100):` or `for v in count(1):` itertools count, it's great. I like to see exceptions raised, but you should create your own exception to be More
First-kurosuke 1
You could use `float('inf')` or `from math import inf` for min_cost. And global variable are tricky to use. You can define a function into another. Then you won't have to use a global variable. def cheapest_flights(): min_cost = float('inf') def cost_calc(): # cost_ More
aligned-quarkov 1
`trees[1:]` is enough, why not `len(trees)`? More
[typed] Apply the rule and a simple reasoning-Phil15 1
@FromSnakeToPython Glad you liked the task. I enjoyed solving the task algorithmically more than manually. More
4-liner: don't complicate-przemyslaw.daniel 1
I failed trying to import `label` in a simple short line some time ago, so I'm glad to see it. _But I don't understand why `'object'` in `fromlist` make it work._ More
My first real yield generator: recursively generates partitions/dices until we have solution (if it exists).-Phil15
### I am particularly proud of my partition generator. _I think it is really beautiful thing!_ I noticed with other codes that "test(i,j)" can be replaced by "(i>j)-(iMore
85 chars and still probably fastest code-Ylliw
with `sum([...])` instead of `sum(...)`, you store an entire list before doing the sum. `for p in list_of_one_element` to not write the expression twice is a good idea but here, `float_expression.is_integer()` can do the job. yours: sum([p==int(p)for a in range(int((2*n)**.5))for p in[(2*n- More
Neighboring neighboring... area of obstacles and border-Phil15
Lines 30-33 could be a single line with future python 3.8: while next_cells := neighboring_area(cells) - obstacles: ... See more in the description of [PEP 572](https://www.python.org/dev/peps/pep-0572/). More
[actually inefficient] Maximize lit area with a priority queue-Phil15 1
For my solution, I finally compared the use of a priority queue with a stack (so a list, like a DFS implementation) and a queue (like a BFS implementation). To do minimal changes, here my changes: ```python # Instead of from heapq import heappop, heappush # For use a list instead of the priority qu More
Clean OOP Solution with full inheritance-bsquare 1
### Timings Well first, I executed your code on all check tests. It is (with debug lines commented, because create strings for these lines took time) **2.4 times** slower than mine. Thanks to `import cProfile; cProfile.run('''tests block''', sort='tottime')`, I know it's because of `next_living_war 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
1 2 3 4 5 6
7
8 9 10 11 12 13