57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 1 hour 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.
Please don't use "concatenating digits in a large base" as a method for selecting by multiple keys. Unicode has more than 1e5 code points (if not now, then soon:)). Tuples comparison is exactly meant for this. Key should be (count, -ord).
Also, this algorithm has quadratic complexity, while the t
More
Nice and complicated. :-P Wouldn't dict be more appropriate data structure for z?
More
First, if you _used_ regex here, that would be remarkable. Not using Python re here is like not using a bicycle for swimming. :-D
Second, argh. Please don't do
if c: return True
else: return False
if c binds something bool. Do
return c
Token count just went from 7 to 2. A
More
Yep, a lot more code than needed. BTW you get a Special Confusion Award for using " ".join on a str. :-D (And then .split() right after that.:)
More
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
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
Lines 12-14 can be simply written as
f = kwargs.get('key', lambda x: x)
Also, None can be aliased. :-)
val = fval = None
More
"return None" is the same as "don't return anything". You don't need lines 5 and 12.
More
aargh. My eyes hurt. What good can you _possibly_ think will come out of a line as
if b != int and b != str and b != list and b != float and b !=bool:
And lines 5-11 are really mind-bending. Is this some kind of bet? How to convert iterable to list in the most complicated way imaginabl
More
Lines 2-4: you can set
a = b = c = 0
And in line 15, you can just say
return a and b and c and len(data) >= 10
More
c.extend([x]) is much clearer as c.append(x). And whole business is just a list comprehension, but you don't need to know about that yet. :-)
More
First, why a special case that is not special at all (lines 2-4)??
Second, why are you str-ifying i and j?
More
sequences are boolable. You can just write "if not args" in line 2 (or even "if args" if you switch lines 3 and 5).
More
That "sum" being red wasn't enough of a hint for you? :-)
Yes, there is a sum builtin. It might come handy. ;-)
Also, you might learn about slices and negative indices.
More
Again, you might see (and exploit) a pattern in the above code. At least in lines 10-17. :-)
More