27
karlian
11 30 46 Leader of the month
4059/ 4195
Eduardo Tsen
Last seen 1 year ago
Member for 2 years, 13 days
Difficulty Normal
Best reviews / Newest reviews
reduce-Sim0000 5 1
For the record, math.gcd(*integers) changed in version 3.9: > Added support for an arbitrary number of arguments. Formerly, only two arguments were supported. More
1-liner : not bool (x%2)-ainem 2 1
It seems that the _bool()_ call is not necessary. More
First-lechrudik 1 1
Please note, that _combinations(x,1)_ just wraps the elements of x in one-tuples. Instead, why not use the elements directly? for i in x: s = [i * x for x in segment2] Hint: _math_ module implements function [dist(p,q)](https://docs.python.org/3/library/math.html#math.dist) More
First-dx2-66 1
You can use _a.splitlines()_ instead of _a.split('\n')_. And I would use an _if_ clause insteand of _try/expect_ here. More
Detailed steps (replace and strip)-gamer995 1 1
Instead of strptime(), fromisotime() could have been used. To get rid of the leading zero, use "%-I". Wasn't aware of the capital "%P" as I only found the locale dependent lowercased "%p". More
First-lechrudik 1 1
if text.lower().count(i.lower()) can be replaced by (note that i already is lower() by precondition): if i in text.lower() Leaving out the brackets as _sum_ can work with the generator directly, moving the condition to the front, as _sum_ works fine with bools, this will lead to what seems More
First-hkgok1 1 1
I would try to avoid calling a (possibly expensive - depending on input) operation two times per iteration here: pos = 0 loc = 0 while x.find('X',pos) != -1: loc = x.find('X',pos) res1 += s[loc] pos = loc+1 You could rearrange your loop: More
OOP-hbczmxy 1 1
I think the key point of this mission is to use [property/@property](https://docs.python.org/3/library/functions.html#property) to handle _is_alive_ implicitly and not as explicit state. More
Just "sorted" (no "lambda")-gamer995 1 1
Hm, using search funcions as key, doesn't this lead to O(n**2)? Here twice? More
one liner - sum / zip-CDG.Axel 1
I like the zip(els[::2], els[1::2])]) in comparison to my zip(*(iter(els),)*2) More
First-Oleg_Salomatin 1 1
Instead of set([... for ... in ...]) use set comprehension directly {... for ... in ...} More
I think it is nice =)-Kolia951 1 1
Instead of list-comprehension and then transformation to set, use set-comprehension directly: final_result = {i for i in text.lower() if i in alphabet} More
First-lechrudik 1
In your implementation, all operations are calculated for each function call. You could enhance it, by using lamda expressions in your map (and possibly move the map definition outside of the function). More
Third-rybld2 1 1
Isn't this redundant? ma = [x for x in m] More
Detailed steps (replace and strip)-gamer995 1 1
Ah, you could have replaced "m" => ".m." to save one call. More
First-lechrudik 1
Refering to your _equip_weapon_ method, instead of: no_minus if no_minus > 0 else 0 you always can use: max(0, no_minus) That said, you could save some typing, by using hasattr/getattr/setattr (change your _weapon.power_heal_ to _weapon.heal_power_ first): for key in ("health","a More
Simple set condition-luipenox 1 1
Should this: return ''.join(set(trio)) not be: return check as the variable is already defined? More
First-tokiojapan55 1
Very clean implementation of the abstract factory pattern, following the textbook, even though I'm always tempted to push functunality up the hierarchy, like implementing _introduce()_ only once and passing up the format string in the super constructor call. More
Oneliner IF-luipenox 1
_for ch in text.lower()_ would avoid to call _ch.lower()_ twice. More
Conversion-frankiser 1
IMHO adding extra variable doesn't make code clearer More
1
2 3 4 5