57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 20 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.
Wasn't it easier to give additional parameter than have inc and dec as separate functions? :-)
Also, don't join([...for...]). Drop the brackets.
More
Please, state what you want to catch. Don't ever write empty except - unless you really want to catch everything, which you almost never do.
Look: imagine you accidentally reverse order of arguments and call index_power(2, (1, 2, 3, 4)). You'd like TypeError, right? But you get -1. :-/
More
In fact I meant something more [like this](http://www.checkio.org/mission/boolean-algebra/publications/veky/python-3/whats-up-__doc__/).
More
Don't single-exit your functions without good reason. Instead of "number = blah", just return blah.
More
elif in line 9 could just be "else", given the task.
It seems to me you wrote line 3 (instead of just "for word in words.split():") because you thought you were optimizing something. You weren't. :-P This isn't C, and words is split only once, no matter how you write it.
More
Line 11 is doubly pointless. :-D
One, either line 6 or line 8 will execute, so program will never get to line 11.
And two, None is exactly the default return value. So even if index_power without line 11 somehow mysteriously fell through the bottom, return value would be None.
More
First, you can chain comparisons: 65 <= ord(char) <= 90 (or ord(char) in range(65, 91)).
Second, you can compare strs: 'A' <= char <= 'Z'.
And third, you can just write char.isupper(), which is what you really wanted to do anyway. :-D
Unrelated: don't += strs in a loop. Much better is to append t
More
Again, inconsistent and really too long names.
Your create_dictionaries could really use the help of enumerate builtin. ;-)
extract_digits seems so complicated, I think map(int, str(number).zfill(3)) is much clearer about what's going on. You don't even need map(int... if you're willing to treat t
More
That's a really strange flow control. Wasn't it easier (e.g.)
if char.isupper():
upper = True
break
More
Why are lines after 16 in the loop?? Also, they can be combined with "or".
Also, you don't need () after if. And range(0, 3) is simply range(3).
More
Again, your branching looks weird. You _either_ check the conditions independently, _or_ you chain them:
if number < 10: ... | if number < 10: ...
if 10 <= number < 20: ... | elif number < 20: ...
if 20 <= number < 100: ... | elif number < 100: ...
if number >= 1
More
Don't use int for truncation, it's bad style (Guido tries to deprecate such usage). When floordividing, use the dedicated operator: `n // 2`.
Even better: since you need both // and %, why not acquire both at once:
half, odd = divmod(len(data), 2)
if odd:
return sum(data[half-1:hal
More
This is a 9 line solution. :-) It can be considered 2 line solution if you want. :-)
More
Your meat is smelly. :-P
Lambda mapped over zip, put into a list, and then that list converted to a tuple, to be added to another tuple and named a one-letter name, to be used in a simple tail-recursion.
I don't even know where to start.
Eta reduction:
lambda x: max(x) ~~~> max
lam
More
This solution is not good. Besides "special cases are not special enough",
and not using modern Python idioms like sorted(), it has a math error.
While c1d and b1d are calculated correctly, a1d _doesn't_ have to be 180 -
their sum. See http://goo.gl/UMrZNd and the resulting discussion.
More
Hm, a nice generalization of [my code](https://checkio.org/mission/comp_funcs/publications/veky/python-3/def-def-def/?ordering=most_voted). :-D
More
Discussion [here](https://checkio.org/mission/non-unique-elements/publications/veky/python-3/two-bins/#comment-44259).
More