49
Phil15
30 56 64 Leader of the month
23067/ 25141
Last seen 9 hours 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
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
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
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
Clear, 5 lines of code-EdinsonUwU 1
`divmod(a, b)[1]` instead of just `a % b`. Okay why not! More
How do I optimise my code? Write your opion in the comments-Frazer-dl
write a function to avoid to write the "same thing" three times: def some_function_name(a, b, c): return round(m.degrees(m.acos((a ** 2 + b ** 2 - c ** 2) / (2 * a * b)))) `while` should be `if` `return [0, 0, 0]` is enough, no need to write `list(some_list)`. More
Pearls in the Box-IRONKAGE
More creative than clear IMO. No need of parenthesis around `float` or around no rounded result: `round((...), 2)` -> `round(..., 2)`. More
First-JingMeng 2
L[0 if (20 > age or 40 < age) else 1] # or just L[20 <= age <= 40] Why does it work? `20 <= age <= 40` is a boolean True/False, which are integers: `True == 1 and False == 0`. More
First-derrickding95 3
`range(len(...))` is useless is most cases, `enumerate` is great: for i, (A, B) in enumerate(pairs): ... I don't understand why you use `deepcopy` since there is no change in tree variable. And the final `return` (in `search` function) is useless too. 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
Simple and readable-malion
What would happen with `'[ord(s) for s in "GeneratorExp"]'`? More
strip and split with \n, zip(*rows)-Phil15
For critical readers: strip('\n') can be replaced by strip(). More
First-PythonWithPI
WOW, it's totally unexpected! From what I understand, `V[S[2:14]][S[4506:4512]](x,10)[0]` is equivalent to `vars()['__builtins__']['divmod'](x,10)[0]` so `divmod(x, 10)[0]` which is `x//10`. I tested it first on a shell on my machine before the checkio editor, it did not work on my machine. `__buil More
data.get-Fermax
I really like the use of **data.get** but sorting the all dict just for read the first element, it's not pretty at all! The built-in function **max** is much more efficient here. best_stock = lambda data: max(data, key=data.get) More
First-XiaoyeXie 1
You can use max function instead of sorting the all dict for just look the first element. def best_stock(data): fenge = data.items() res = max(fenge,key = lambda jieguo:jieguo[1]) stock = res[0] return stock or in a lambda function best_stock = lambda data: More
[wrong code] unions of sets and resolve all conflicts-Phil15
The part 2 has the wrong interpretation of the lexicographic order. See [my new code](https://py.checkio.org/mission/determine-the-order/publications/Phil15/python-3/compare-deduce-choose-with-lexicographic-order/) to see the right one. With `words = ['word', 'spread']`, the answer is `'spworead'`. 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
with items coordinates dictionary (so seaside traveled once)-Phil15
Shorter version distance = lambda xA, yA, xB, yB: max(abs(xB - xA), abs(yB - yA)) def navigation(seaside): coords = {elem: (i, j) for i, row in enumerate(seaside) for j, elem in enumerate(row) if elem} return sum(distance(*coords['Y'], *coords[ More
20 random searches-Phil15
If you want print the path we take without a single change of **YOUR code**, you can use this decorator I did for fun. Just put @print_maze_path before the definition of YOUR function. (Your function can have more than one argument.) def print_maze_path(f): CHARACTERS = EMPTY, WALL More
recurse-ojisan 1
No need to put parenthesis around the thing to return, just `return result`, it's not a function. if ...: return ... # else: # no need of else since return stop the function. return ... No need to make a list to sum elements sum([next(n,depth+1,weight*m) for n,m in branch More
numpy attempt-HeNeArKr
There are other ways but I like the use of numpy, especially `reshape` and array of booleans. It's original. More
1 2 3 4 5 6 7
8
9 10 11 12 13