57
veky
22 48 64 Leader of the month
44583/ 53887
Last seen 17 hours ago
Member for 11 years, 6 months, 6 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-gflegar
roundoff = lambda x: '{:.{}f}'.format(x, decimals) if decimals else str(int(x)) return roundoff(number / base**i) + p + suffix Same length, clearer IMO. More
First-ChampagneCurves
That empty line 5 is not really needed, or at least it should be less than empty space in line 14 (which would have to be 2 empty lines in that case:), and of course the context of lines 1, 2 and 15 is also not needed. But line 5 could be filled with a docstring. ;-) Also, Python's `not` operator i More
First-oglop
Of course, you can just return [x for x in ...] But in this CiO context, giving a return value a semantic name is even justified. Though of course, not in the real code - then the _function name_ should be used for that purpose. More
First-s_o_va
Too many indices! :-o But this is minor. Real problem is using 10 and 100 as magic numbers. Besides being maintainability hell (network expands, and in some random moment in the future, your code gives wrong results silently), documentation is lacking. Comments do help at the moment of assignm More
First-MrPablozOne
First, precondition says that all elements of numbers_array are ints. So `int(` in line 4 is unnecessary. Second, you then have for your key lambda x: abs(x) What's that function? Takes x and gives abs(x). I know a much simpler function that does exactly the same. Of course, key=abs Als More
First-aminami1127 1
This is a great example of OOP vs ADT dichotomy (see http://www.cs.utexas.edu/users/wcook/papers/OOPvsADT/CookOOPvsADT90.pdf). If you put everything in an object, it looks like above. But if you use smart data types, you see that reached and infected are just sets, index is id of node, security_leve More
First-martin.beseda.3
Was it really easier to build that str for eval, than to build the product itself? *= is as complicated as +=. :-) More
Second-aminami1127 1
Nice. However: len([y for y in blah if cond]) ~~~> any(cond for y in blah) is much clearer and it shortcircuits, while len-version doesn't. But even better IMO would be if connected were a _function_ taking an index and returning a set. (It could be local to `capture`, so it could access More
First-martin.beseda.3
Nice and explicit, but you might want to learn about "set" type, and & operator on them. More
First-martin.beseda.3
You do realize that you don't need max_count at all? As soon as count reaches 3, you can return True. More
offset-akoshodi
You're repeating len(data) // 2 too much. half, odd = divmod(len(data), 2) if odd: ... data[half] else: ... (data[half] + data[half-1]) / 2 Also, `...` should be direct returns. This is not Pascal, you don't have to single-exit your functions. As soon as you find the re More
First-akoshodi
Usage of Counter is cool, but still you're naming your return value what function should have been named. Just return [x for x in data if count[x] > 1] Also, a controversial point: recently, Python style seems to be moving towards precise imports (with namespace packages, blurring the line bet More
First-kostya241
Nice, but wasn't adding +"!" simpler than replacing "n"? Also, drop the [] inside join(). More
StringFromSlice-geruz
Nice idea, but there are many stab-in-the-eye problems with it. It can be polished much further. For example: reusing builtin names like len and iter. Not incorporating arg (and that's a horrible name!) into iter. Writing trivial genexps such as "a for a in blah" instead of just blah. Not using some More
First-masaki
Line 5 is just "if not array:" (or reverse the condition). Otherwise, nice command of slices and negative indices. ;-) More
Shorter than veky's-htamas 1
OK, you win. :-) I thought int would refuse to take string starting with "00" since Guido shunned old octal notation, but no, it works fine. BTW it's really sad that len(bin(b)), even with that //4 afterwards, is not longer than b.bit_length(). :-/ More
Power-theholy7
You can use if...else expression. return -1 if len(array) <= n else array[n]**n. Also, (binary) pow can be written as an operator **. Otherwise, fine. More
All combinations-LukeSolo 1
Wow, look, LukeSolo wrote a for loop! Of course, you wouldn't be you if you didn't squeeze a generator inside. :-P for a in (b for c in d): smth is more clearly expressed as: for c in d: a = b smth One additional assignment is worth it. :-) Also, for upper limit More
First-reviewboy
Ok, not only does single-exiting make your code convoluted, but you have to invent new names, even if you really are not inspired. :-P (Pascal at least helps you by naming the return value same as your function.:) Just return it when you get it, no need to name it. And especially no need to name it More
First-reviewboy
a > b - 1 should probably be a >= b. Easier to understand what you're comparing. Or you could rely on list's own way to check index and just catch IndexError. :-) More