57
veky
22 48 64 Leader of the month
44587/ 53887
Last seen 1 day ago
Member for 11 years, 6 months, 7 days
Difficulty Advanced
We shall not cease from exploration, and the end of all our exploring will be to arrive where we started and know the place for the first time.

Best reviews / Newest reviews
First-igor.isay2
data.sort() could be better than sortedData... but it depends on what exactly the caller is expecting, and the task isn't really clear on this. That -1 offset in line 4 is ugly, and you can do without it (just look to the left in case of even length). And since you use both //2 and %2, divmod More
First-igor.isay2
There is absolutely no reason to rebind data here. Just return [item for ... More
First-igor.isay2
LOL... that's a very roundabout way of doing it. :-) Whitelisting is much simpler than blacklisting. collections.Counter(filter(str.isalpha, text.lower())) And why sort before, instead of after? And more puzzlingly, why count from start for each _instance_ of each letter?? More
First-igor.isay2
You can assign multiple targets: uppercase_letters = lowercase_letters = digits = 0 You can add bools directly: digits += letter.isdigit() Or even count directly without writing loops: digits = sum(map(str.isdigit, data)) (But of course, considering the task, it's better to use `an More
flood fill-gyahun_dash
Nice idea, but few things are ugly. First, that `400` limit is really jarring. There is no reason not to implement proper floodfill. It's really not much harder than what you wrote. Line 9: If you made dirs a set (just put {} around), you could write explore |= dirs & area - set(flow) Line 2 More
Actual chase, not cheating like everyone else!-StefanPochmann 1
Sorry, but _you_'re the cheater here. Read the task carefully. And the 10**4 is just bad. :-P More
Simple and Short-StefanPochmann 1
Aargh - appending while iterating. Aargh! :-D More
Short-StefanPochmann 1
Line 4: see dict.setdefault. ;-) More
First-nsmirnoff
First, many things know how to bool: if not array: return 0 (or even better, if array: do your computation // else: return 0) And then you don't need else. Whatever part returns what it computed, other will not execute. Second, for a in [b for blah if cond]: stuff(a) is much cl More
First-nsmirnoff 1
Huh. You've employed some very powerful techniques for making your code longer than necessary. :-P First, not every condition must have a relation operator. Specifically, bools remain bools after comparison. And they remain themselves after comparison to True. So if cond isinstance of bool, then al More
First-nsmirnoff
You can use *=. And I always find it funny when someone uses continue when the "rest of the loop suite" is just one statement. Wouldn't it be easier to reverse the logic and guard the statement itself? for x in str(number): if x != "0": prod *= int(x) [BTW maybe the condit More
Python has some magic skills-borisuvarov 1
I'm not quite sure what magic skills you're referring to, but you might be amused by another one: sum(array[::2]) * array[-1] if array else 0 More
First-nsmirnoff
Again, args can bool without taking their len and comparing it to 0. "if args:". Or just max(args)-min(args) if args else 0 More
First-nsmirnoff
You don't need parens in line 6. and binds less tightly than ==. Even better, all are equal. You don't need and at all. if number % 5 == number % 3 == 0: if...else expression can also be used here, but it's probably overkill in this task. More
First-nsmirnoff
"if" is unneeded. Nothing horrible will happen if you replace something that isn't there. More
First-nsmirnoff
Hm. Do you _really_ think of this task as classifying result _first_ by x and y, and _then_ by operation? People usually read that truth table by columns, not by rows, though your interpretation is of course possible. :-) (Maybe I shouldn't be so surprised, since I wrote a solution that reads it by More
Second-nsmirnoff
Nice. Of course, that threefold repetition of "x" invites one to write it pointlessly, but this is also perfectly fine. More
First-terryyin
If you cannot code it, document it. Of course. :-DD A really nice solution. More
First-nsmirnoff 1
You can use +=. But better is to use "".join. Just like sum when initial value is 0, use "".join when initial value is "". And there is really no need for nested loops. Just for y in text: More
First-nsmirnoff 1
Cool. Here you can also use if...else expression, of course. array[n]**n if nMore