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
sorted frequency dictionary-rbrian 1
1. You don't need to sort and extract just to find maximum. See max with key argument. 2. Lines 4~6 can just be "for letter in text.lower():". This is not C, text will be lowered only once in any case. 3. Line 8 is pretty ugly. You can use defaultdict(int), but even better, the name of a varia More
create possibilities list-rbrian 1
You don't need copying in line 9. Unpacking is much better when you use it consistently with your structure: line 6 is row_zero, row_one, row_two = game_result range(0,3) is range(3). Or even better, use zip(row_zero, row_one, row_two). That "str"s everywhere are probably worse than More
First-rbrian 1
Whenever you import copy, a python dies somewhere. ;-P More
First-smilicic
I guess now you see why I strive to write Artifex completely in English. That language mix (nw_bio:) is really jarring. :-] dict with bool values that are by default False, is really just a set. But it's nice you showed you knew about .fromkeys. ;-D About that ugly "if it is there, append, els More
First-smilicic
Keyword arguments don't _have_ to be lumped together with **. "def min(*args, key=lambda x:x, **kw):" would free you of writing line 2 (and 18). And you don't really need rest of **kw anyway. Lines 4~7 could be replaced with: if len(args) == 1: args = list(args[0]) and then jus More
Tail-smilicic
* You should write m == n == 0 here. * int is completely superfluous here. bool is a subclass of int. * n%2 != m%2 (parentheses not needed!) is easier written as (m - n)%2 (m is not congruent to n mod 2). * You might want to learn about ^ operator. ;-) * This is not tail recursion either More
First-smilicic
"for i, j, (di, dj)". Unpack what you need. BTW dirs is really a set, order is obviously not important. Do you _really_ consider product easier than nested loops? (for i,j,d. For coords, you can just use "ti not in rr or tj not in rc") Of course, you don't really use nr and nc: things like rr=ran More
Readable-smilicic
You bet it's readable. After you read it twice, it better be. :-D More
First-smilicic
You don't really need line 7. If data is less than ar, then N is 0, so you ''.join the empty list, and out stays the same. Here it doesn't matter since len(romans) is small, but a rule of thumb: *don't* use Schlemiel the Painter's algorithm for joining strings. Better leave the lists in place (se More
First-smilicic
Read the hints. ;-) return out.strip() is much easier than all those conditional adding of spaces. Also, a list that is ' '.joined at the end might be a better choice. Lines 25~28 are just out += (FIRST\_TEN + SECOND\_TEN)[number], right? :-) Also, "if number//100>0" normal people usually writ More
Nested is faster than flat.-veky 1
Of course, the len checking can be done in the same way, at the expense of blowing up the code by a factor of at least 2. But that's even more wrong than this. :-D 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
Recursion-drejcek 1
Noone said list won't be empty. :-P More
xor-drejcek 1
A lot of people know about .format _method_, but they don't know about format _function_. It's really much nicer when you just want to format a single value. format(m ^ n, "b") More
sorted-drejcek 1
First, don't test "len(args) == 0". Just test "args" (or "not args", if you want to have that order of returns). PEP8: "For sequences, (strings, lists, tuples), use the fact that empty sequences are false." Second, why sort? min and max are linear. More
First-sodium
Lines 12-14 can be simply written as f = kwargs.get('key', lambda x: x) Also, None can be aliased. :-) val = fval = None More
First-MatthiasWiesmann
"return None" is the same as "don't return anything". You don't need lines 5 and 12. More
Mycroft's-Mycroft0121
You really don't need that much code duplication. :-) More
Fraction-free GE-DiZ 1
I'm not quite sure what you _get_ by eliminating fractions (since you still do the same operations, just above the big common denominator), but for bragging rights, it's ok. :-) More
xus-ShuaiXu
Nice overflow avoidance. :-) Of course, it would be better to let Python decide. More